示例#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;
            }
        }
示例#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);
        }
示例#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);
        }
示例#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;
    }
示例#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);
        }
示例#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;
            }
        }
示例#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;
 }