Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dual/multi monitor with touchscreen

Pretend I have 2 monitors. Primary display is just a normal PC desktop monitor, the other other one is a touchscreen. When I load a program (WinForm, WPF, ...), it will load on the primary monitor.

Question: if I replace the program to the touchscreen, how can I know if the current screen/display/monitor is a touchscreen or has touch enabled?

In other words, how can I detect the current screen/display/monitor and its settings?

So far i worked with the Screen class (Windows.Forms), Tablet Class (Windows.Input) and with DLLImport of User32.dll (GetSystemMetrics()). None of them or a combination of them works.

I want something to find like: Monitor.Current.IsTouch or Display.CurrentDisplay.TouchEnabled

like image 592
Matthias Avatar asked Sep 17 '12 09:09

Matthias


1 Answers

I don't have a touch screen to test this on, but you can probably use System.Windows.Input.Tablet to enumerate through the static TabletDevices property. The ActiveSource property can be compared against PresentationSource.FromVisual to see if your UIElement is on the TabletDevice. This may not be perfect, I'm not used to using these classes, but that should get you on the right track. TabletDevices also have a Name property which you may be able to compare against System.Windows.Forms.Screen.DeviceName.

like image 82
TheXenocide Avatar answered Oct 11 '22 01:10

TheXenocide