Пример #1
0
        static void ToggleBorder(IntPtr hWnd)
        {
            if (hWnd == IntPtr.Zero)
            {
                return;
            }

            var hdc = GetWindowDC(hWnd);

            var rect = new Screna.Window(hWnd).Rectangle;

            var borderThickness = Settings.Instance.RegionBorderThickness;

            // Top
            PatBlt(hdc, 0, 0, rect.Width, borderThickness, DstInvert);

            // Left
            PatBlt(hdc, 0, borderThickness, borderThickness, rect.Height - 2 * borderThickness, DstInvert);

            // Right
            PatBlt(hdc, rect.Width - borderThickness, borderThickness, borderThickness, rect.Height - 2 * borderThickness, DstInvert);

            // Bottom
            PatBlt(hdc, 0, rect.Height - borderThickness, rect.Width, borderThickness, DstInvert);
        }
Пример #2
0
        void ToggleBorder(IntPtr Window)
        {
            if (Window == IntPtr.Zero)
            {
                return;
            }

            var hdc = GetWindowDC(Window);

            var rect = new Screna.Window(Window).Rectangle;

            var borderThickness = _settings.UI.RegionBorderThickness;

            // Top
            PatBlt(hdc, 0, 0, rect.Width, borderThickness, DstInvert);

            // Left
            PatBlt(hdc, 0, borderThickness, borderThickness, rect.Height - 2 * borderThickness, DstInvert);

            // Right
            PatBlt(hdc, rect.Width - borderThickness, borderThickness, borderThickness, rect.Height - 2 * borderThickness, DstInvert);

            // Bottom
            PatBlt(hdc, 0, rect.Height - borderThickness, rect.Width, borderThickness, DstInvert);
        }
Пример #3
0
        void SnapButton_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            _captured = true;

            DragMove();

            _captured = false;

            try
            {
                if (win == IntPtr.Zero)
                {
                    win = WindowFromPoint(new Point((int)(Left - 1), (int)Top - 1) * Dpi.Instance);
                }
                else
                {
                    ToggleBorder(win);
                }

                if (win != IntPtr.Zero)
                {
                    SelectedRegion = new Screna.Window(win).Rectangle;
                }
            }
            finally
            {
                win = IntPtr.Zero;
            }
        }
Пример #4
0
        RegionSelector()
        {
            InitializeComponent();

            Show();
            _regSelhWnd = (HwndSource)PresentationSource.FromVisual(this);
            Window      = new Window(_regSelhWnd.Handle);
            Hide();
        }
Пример #5
0
        RegionSelector()
        {
            InitializeComponent();

            Show();
            _regSelhWnd = (HwndSource)PresentationSource.FromVisual(this);
            Window = new Window(_regSelhWnd.Handle);
            Hide();
        }
Пример #6
0
        void ModernButton_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            _captured = true;

            DragMove();

            _captured = false;

            ToggleBorder(win);

            try { SelectedRegion = new Screna.Window(win).Rectangle; }
            finally
            {
                win = IntPtr.Zero;
            }
        }
Пример #7
0
        void SnapButton_PreviewMouseLeftButtonDown(object Sender, MouseButtonEventArgs E)
        {
            _captured = true;

            DragMove();

            _captured = false;

            try
            {
                if (_win == IntPtr.Zero)
                {
                    _win = WindowFromPoint(new Point((int)(Left - 1), (int)Top - 1) * Dpi.Instance);
                }
                else
                {
                    ToggleBorder(_win);
                }

                if (_win != IntPtr.Zero)
                {
                    SelectedRegion = new Screna.Window(_win).Rectangle;

                    // Prevent going outside
                    if (Left < 0)
                    {
                        // Decrease Width
                        try { Width += Left; }
                        catch { }
                        finally { Left = 0; }
                    }

                    if (Top < 0)
                    {
                        // Decrease Height
                        try { Height += Top; }
                        catch { }
                        finally { Top = 0; }
                    }
                }
            }
            finally
            {
                _win = IntPtr.Zero;
            }
        }
Пример #8
0
        public static void Toggle(IntPtr Window, int BorderThickness)
        {
            if (Window == IntPtr.Zero)
            {
                return;
            }

            var hdc = GetWindowDC(Window);

            var rect = new Screna.Window(Window).Rectangle;

            // Top
            PatBlt(hdc, 0, 0, rect.Width, BorderThickness, DstInvert);

            // Left
            PatBlt(hdc, 0, BorderThickness, BorderThickness, rect.Height - 2 * BorderThickness, DstInvert);

            // Right
            PatBlt(hdc, rect.Width - BorderThickness, BorderThickness, BorderThickness, rect.Height - 2 * BorderThickness, DstInvert);

            // Bottom
            PatBlt(hdc, 0, rect.Height - BorderThickness, rect.Width, BorderThickness, DstInvert);
        }