private void SetWindowPosition(Window w, WindowPositionType winPos) { var s = WpfScreen.GetScreenFrom(w).WorkingArea; switch (winPos) { case WindowPositionType.BottomRight: w.Top = s.Height - w.Height; w.Left = s.Width - w.Width; break; case WindowPositionType.TopLeft: w.Top = 0; w.Left = 0; break; case WindowPositionType.BottomLeft: w.Top = s.Height - w.Height; w.Left = 0; break; case WindowPositionType.TopRight: w.Top = 0; w.Left = s.Width - w.Width; break; } }
private WindowPositionType GetWindowPosition(Window w) { var s = WpfScreen.GetScreenFrom(w).WorkingArea; if ((w.Left + w.Width) == s.Width) { if (w.Top == 0) { return(WindowPositionType.TopRight); } else if (w.Top + w.Height == s.Height) { return(WindowPositionType.BottomRight); } } else if (w.Left == 0) { if (w.Top == 0) { return(WindowPositionType.TopLeft); } else if (w.Top + w.Height == s.Height) { return(WindowPositionType.BottomLeft); } } return(WindowPositionType.Custom); }
public static WpfScreen GetScreenFrom(Window window) { WindowInteropHelper windowInteropHelper = new WindowInteropHelper(window); Screen screen = System.Windows.Forms.Screen.FromHandle(windowInteropHelper.Handle); WpfScreen wpfScreen = new WpfScreen(screen); return(wpfScreen); }
public static WpfScreen GetScreenFrom(System.Windows.Point point) { int x = (int)Math.Round(point.X); int y = (int)Math.Round(point.Y); // are x,y device-independent-pixels ?? System.Drawing.Point drawingPoint = new System.Drawing.Point(x, y); Screen screen = System.Windows.Forms.Screen.FromPoint(drawingPoint); WpfScreen wpfScreen = new WpfScreen(screen); return wpfScreen; }
public static WpfScreen GetScreenFrom(System.Windows.Point point) { int x = (int)Math.Round(point.X); int y = (int)Math.Round(point.Y); // are x,y device-independent-pixels ?? System.Drawing.Point drawingPoint = new System.Drawing.Point(x, y); Screen screen = System.Windows.Forms.Screen.FromPoint(drawingPoint); WpfScreen wpfScreen = new WpfScreen(screen); return(wpfScreen); }
private void MakeSureVisibility(Window w) { var s = WpfScreen.GetScreenFrom(w).WorkingArea; if (w.Left + w.Width > s.Width) { w.Left = s.Width - w.Width; } if (w.Top + w.Height > s.Height) { w.Top = s.Height - w.Height; } }
public static WpfScreen GetScreenFrom(Window window) { WindowInteropHelper windowInteropHelper = new WindowInteropHelper(window); Screen screen = System.Windows.Forms.Screen.FromHandle(windowInteropHelper.Handle); WpfScreen wpfScreen = new WpfScreen(screen); return wpfScreen; }