I've had a bit of a search around, but couldn't find anything similar to what I was looking for. I'm interested in knowing how to display differing contents on secondary/tertiary monitors or projectors using C#. Basically, what I'm wanting to achieve is to have some form of presenter view (a lá Powerpoint) on one particular screen (the primary display), and the output on a secondary screen or projector. I've never really attempted to develop something with multiple display outputs, so any guidance will probably have to be at a fairly obvious level.
If someone could point me in the right direction as to how to handle this sort of thing in C#, that would be greatly appreciated!
Just to expand on Keven's answer (I +1'd it), The Screen.AllScreens array gives you have an array of Screen objects. The Screen object has a property called IsPrimary, which you can use to determine which is the primary screen, and which is the secondary (duh) and it also has a property called WorkingArea, which is a rectangle that gives you back all the coordinates of the second screen. The cool thing about this is, that even if let's say the secondary screen is configured to be on the left of the primary, the WorkingArea.X will be a negative number, and you can place forms there or whatever.
You can use the System.Windows.Forms.Screen.AllScreens property to access a list of all the monitors Windows knows about. If you're looking to utilize a display that hasn't been configured by the user, it gets more difficult - you'd probably need to initialize and access the display adapter using DirectX.
One of the main classes you will need to interact with is Screen (this is in the WinForms namespace). In general all the screens are treated as a set of working areas that you can use the screen class to get properties for each one.
You can get all the screens like this...
Screen [] screens = Screen.AllScreens;
Here is a short article about doing multi-monitor programming in C#.
Also remember to set the property 'StartPosition' to 'Manual' on your the window you want to display on the secondary screen otherwise it will always display on the primary screen.
Related
I am trying to get the CurrentMonitor property of NativeWindowSettings to change which monitor it creates the window on. I'm trying to display on my secondary monitor, here is what I have:
var nativeWindowSettings = new NativeWindowSettings()
{
Size = new OpenTK.Mathematics.Vector2i(800, 600),
Title = "My Window",
Flags = OpenTK.Windowing.Common.ContextFlags.ForwardCompatible,
CurrentMonitor = new Monitors.GetMonitors()[1].Handle, //problem
};
using (var window = new Game(GameWindowSettings.Default, nativeWindowSettings))
{
window.Run();
}
I've tried creating a new Monitor Handle and assigning it to that, and I've tried creating a new MonitorHandle using the pointer from the second monitor in the array of monitors.
CurrentMonitor = new MonitorHandle(Monitors.GetMonitors()[1].Handle.Pointer),
It depends on your OS. Not all window systems give you the ability to specify which screen a newly-created window will appear on, and not all of them are going to pay attention to that parameter either. Your mileage may vary, as they say. You didn’t specify which OS you’re on, so I’m going to assume for the rest of this that it’s some flavor of Microsoft Windows.
On MS Windows, you don’t get to specify which screen your new window appears on without also specifying exactly where on that screen the window should appear: If you let Windows pick the coordinates, it’s going to put the window on the primary screen every time, exactly as you’ve seen it doing.
So the right way to go about it, at least on MS Windows, is to first find out the virtual coordinates of the screen (the MonitorInfo) that you want to create the window on. You can choose from its ClientArea (the virtual coordinates of the entire screen) or its WorkArea (the virtual coordinates of the usable part of that screen, minus things like the taskbar). In either case, each MonitorInfo’s rectangle will be a unique chunk of virtual screen space that doesn’t overlap that of any of the others.
Once you’ve found the rectangle of the screen you want to create the window on, you just specify a Location in the NativeWindowSettings that’s on that screen, inside the coordinates of its ClientArea or WorkArea: Possibly in the top corner, or, if you want to be a bit more clever, you can do some math and center the window in that virtual rectangle. The only thing you can’t easily do is the OS’s “cascading” behavior, where your window will be given a new position that’s sort-of distinct from the others on the screen but not really centered and not really in the top corner either; that behavior is built-in inside the window system, and there’s no way to directly access it or influence it.
But that’s otherwise it: You don’t specify the monitor: You specify a Location that’s on the monitor, and then the window will appear there. That’s not really an OpenTK thing, either: That’s just how Microsoft Windows does a multi-monitor setup.
i'm trying to mirror my Richtextbox to another screen in Pictuerbox. actually i did that but my issue is (Lets to make my question clear say that we have 2 screens (Screen A and Screen B).
I want to show the Richtextbox in Screen B. As when i open a start menu in screen A it mustn't be shown in screen B. All i want in my program is to mirror the richtextbox as a control not the whole screen.
is that possible?
I dont know if it works and i dont have time to try it but i think you need to create 2 controls. By the 1st one you check the .textChanged() and when it is triggered you update the second textbox.
Example (pseudo code):
TextboxA;
TextboxB;
If TextboxA.TextChanged()
{
TextboxB.Text() = TextboxA.Text();
}
Maybe there is an better way, but this is the way i should try when i make it for my self. Hope it helps you.
What you describe sound like two over network connected applications. I would suggest to look for a chat network app. There are lots of examples in the net. On one side you will have a server and on the other side a client. Then you transfer your text char by char or word by word over the network.
I am trying to create a WPF application using C# to run on Pixelsense that is basic version of the tangram puzzle. I am able to draw my 7 shapes and translate and rotate them all around the screen.
Could anyone give me advise regarding how I should go about saving the pattern (with shapes in specific positions and orientations) so that when a user creates the pattern next time, the application can match it to the saved one and tell the user if it's correct.
It's a pattern matching and recognition problem that I am trying to solve.
I have been stuck on this for a while now :(
Define the solution as a collection of objects with shapeType, position, and orientation properties. Have the solution include one shape at position 0, 0 and an orientation of 0. Now loop over all the shapes the user has actually placed to find the ones with a shapeType that matches the shape your solution has at 0,0,0. Calculate the position and orientation of every other shape relative to where the user put this one. Compare those values to the rest of your solution. You'll need to experiment with how much tolerance to allow because this stuff is not precise - to make the game fun, err on the side of having high tolerances. If needed, you can follow this up with some performance optimizations to only re-evaluate pieces that moved.
Hopefully you are using physical shape prices with tags on them instead of this purely a virtual game. I always wanted to build this when I was on the Surface team but it never happened. One challenge you will run into is defining how the tag's position/orientation relates to the actual shape. If you'll be putting tag stickers on multiple tangram sets, you almost certainly won't get the on precisely the same each time so you may need to add a "calibration" mode to your app (have the user place each piece in a specific spot and then push a button so you can record where the tag is relative to those spots). The TagVisualizer WPF control should help a lot for building your UI - definitely look into using it (this scenario was top of mind when we designed that API). The default behavior of that control (if you tell it the ID of a tag to look for but not how to visualize it) is a "crosshair" that can help you find tune your offset values.
Good luck! If you wouldn't mind recording a YouTube video when you are done and posting a comment here linking to it, I'd really appreciate that
You can use ObservableCollection or List of a custom class. That class can consist of various values such as position, orientation etc as properties.
When a new pattern is drawn or when the pattern change its position you can update that particular object stored in the collection. As you have all the details of the pattern(positions and orientation) you can iterate the for loop and check the position of the new pattern when added.
I am writing a geoscience visualization application that uses wpf 3d. The user needs to be able to zoom deep into detail and out quick with minimum resources taken. I've decided to divide my slice (ModelVisual3D) into subrectangles (GeometryModel3D), so that each has it's own texture that changes when the camera zooms in (similar to Google maps).
The problem is that "cracks" are appearing between subrectangles, even though they actually have no empty space between them.
How to hide these? or is there any other way to assign multiple materials with different sizes to one ModelVisual3D?
PS I've tried making the background gray, light-gray, silver and white-smoke. It helps a little, but it's not acceptable. I've also tried overlapping the subrectangles, with no result.
Instead of your current setup you might want to make several textures at different resolutions and switch between these depending on the zoom level. (Mipmaps)
When getting really close you might replace the entire object and switch it for a much smaller one) and use a highly detailed texture.
It will require a bit more pre-processing but you will be able to use a single geometry.
Seems like changing ImageBrush's stretch to Stretch.None and using textures larger than the subsquare helps. Although now I need more precise control over texture coordinates for the surface.
I'd like to design a UI-Element, which gives the User the possibility to switch between different options. Therefore I want to use a Tangible which acts as control dial... I have already designed a Pointer and a Menu. The problem:
When the User rotates the Tangible, the Menu should stand still and the pointer should follow the rotation-movement. But when the User just moves the Tangible (without a rotation), the whole UI-Element should move.
Here a example for a non-Tangible control dial:
http://msdn.microsoft.com/en-us/library/ee804832%28v=surface.10%29.aspx
Does anyone know how to deal this with a TagVisualization?
Thanks in advance,
Chris
EDIT:
I've written a small tutorial, which can be viewed on: http://project-premium.org/
Set UsesTagOrientation=false on the TagVisualization or TagVisualizationDefinition
Inside the TagVisualization, monitor TrackedContact.Orientation to update your dial UI