Пример #1
0
        public static WpfScreen GetScreenFrom(Window window)
        {
            WindowInteropHelper windowInteropHelper = new WindowInteropHelper(window);
            var       screen    = System.Windows.Forms.Screen.FromHandle(windowInteropHelper.Handle);
            WpfScreen wpfScreen = new WpfScreen(screen);

            return(wpfScreen);
        }
Пример #2
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);
            var       screen    = System.Windows.Forms.Screen.FromPoint(drawingPoint);
            WpfScreen wpfScreen = new WpfScreen(screen);

            return(wpfScreen);
        }
Пример #3
0
 private void maximizeButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (WindowState == WindowState.Normal)
         {
             var screen = WpfScreen.GetScreenFrom(this);
             MaxHeight   = screen.WorkingArea.Height;
             MaxWidth    = screen.WorkingArea.Width;
             WindowState = WindowState.Maximized;
             return;
         }
         WindowState = WindowState.Normal;
     }
     catch { }
 }
Пример #4
0
 private void maximizePanel_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     try
     {
         if (_canMaximize)
         {
             _canMaximize = false;
             if (WindowState == WindowState.Normal)
             {
                 var screen = WpfScreen.GetScreenFrom(this);
                 MaxHeight   = screen.WorkingArea.Height;
                 MaxWidth    = screen.WorkingArea.Width;
                 WindowState = WindowState.Maximized;
                 return;
             }
             WindowState = WindowState.Normal;
         }
     }
     catch { }
 }