コード例 #1
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);
        }
コード例 #2
0
        public static WpfScreen GetScreenFrom(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);
        }
コード例 #3
0
        private static void HandleGlowBorder(object sender, SizeChangedEventArgs e)
        {
            var border = sender as Border;
            var window = border.Parent as Window ?? border.TemplatedParent as Window;

            if (window == null)
            {
                return;
            }

            if (window.WindowState == WindowState.Maximized)
            {
                // Need to keep the margin or else we loose pixels from the windows caption buttons etc
                border.Margin = new Thickness(GLOW_BORDER_MARGIN);
                // border.BorderThickness = new Thickness(0);
                // force a redraw
                window.InvalidateVisual();
                return;
            }

            // Snapped windows are a little more awkward to detect
            // todo: Need to get current screen height not primary
            var workingArea = WpfScreen.GetScreenFrom(window).WorkingArea;

            if (window.Top == workingArea.Top &&
                window.Height == workingArea.Height)
            {
                border.Margin = new Thickness(
                    window.Left == workingArea.Left ? 0 : GLOW_BORDER_MARGIN,
                    0,
                    window.Left + window.Width == workingArea.Right ? 0 : GLOW_BORDER_MARGIN,
                    0);
                border.BorderThickness = new Thickness(
                    window.Left == workingArea.Left ? 0 : 1,
                    0,
                    window.Left + window.Width == workingArea.Right ? 0 : 1,
                    0);
                return;
            }
            border.Margin          = new Thickness(GLOW_BORDER_MARGIN);
            border.BorderThickness = new Thickness(1);
        }