public static WpfScreen GetScreenFrom(Window window) { WindowInteropHelper windowInteropHelper = new WindowInteropHelper(window); Screen screen = Screen.FromHandle(windowInteropHelper.Handle); WpfScreen wpfScreen = new WpfScreen(screen); return(wpfScreen); }
public static WpfScreen GetScreenFrom(System.Drawing.Point point) { int x = (int)Math.Round((double)point.X); int y = (int)Math.Round((double)point.Y); // are x,y device-independent-pixels ?? System.Drawing.Point drawingPoint = new System.Drawing.Point(x, y); Screen screen = Screen.FromPoint(drawingPoint); WpfScreen wpfScreen = new WpfScreen(screen); return(wpfScreen); }
public MainWindow() { InitializeComponent(); OnTimer = new DispatcherTimer(); OffTimer = new DispatcherTimer(); OnTimer.Interval = TimeSpan.FromMilliseconds(20); OffTimer.Interval = TimeSpan.FromMilliseconds(500); OnTimer.Tick += OnTimer_Tick; OffTimer.Tick += OffTimer_Tick; OnTimer.Start(); Microsoft.Win32.SystemEvents.DisplaySettingsChanged += (s, e) => { Screens = WpfScreen.AllScreens().ToArray(); }; }