Exemplo n.º 1
0
        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;
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
    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;
    }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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;
            }
        }
Exemplo n.º 7
0
 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;
 }