protected void CustomPaint()
        {
            using (Graphics g = this.CreateGraphics())
            {
                base.Paint(g);

                if (!MainForm.IsHidden)
                {
                    if (Native.IsThemeActive() != 0)
                    {
                        if (_decorator == null)
                        {
                            var taskbarLocation = this.MainForm.TaskbarLocation;

                            bool leftToRight = taskbarLocation == Native.ABEdge.Top || taskbarLocation == Native.ABEdge.Bottom;
                            _decorator = new PushPanelDecorator(true, Width, Height, Padding, this);
                        }
                        _decorator.Paint(g, _isClicked, _hover);
                    }
                    NotificationAreaProxy.PaintIcon(_data.BitmapIndex,
                        (this.Width - ButtonConstants.SmallIconSize) / 2,
                        (this.Height - ButtonConstants.SmallIconSize) / 2, this.Handle);
                }
            }

            // Tell Windows that the button is now rendered. This will prevent it from calling paint again until actually needed.
            Native.RECT rect = new Native.RECT()
            {
                left = this.ClientRectangle.Left,
                right = this.ClientRectangle.Right,
                top = this.ClientRectangle.Top,
                bottom = this.ClientRectangle.Bottom
            };
            Native.ValidateRect(this.Handle, ref rect);
        }
Пример #2
0
        internal override bool TryDrawThemeBackground(
            IntPtr hTheme,
            IntPtr hdc,
            int iPartId,
            int iStateId,
            ref Native.RECT pRect,
            ref Native.RECT pClipRect)
        {
            if (iPartId is not Native.TVP_GLYPH and not Native.TVP_HOTGLYPH)
            {
                return(false);
            }

            using var g = Graphics.FromHdc(hdc);

            var rect = Rectangle.FromLTRB(pRect.left, pRect.top, pRect.right, pRect.bottom);

            Misc.Direction direction = iStateId is Native.GLPS_CLOSED or Native.HGLPS_CLOSED
                ? Misc.Direction.Right
                : Misc.Direction.Down;

            Images.PaintArrow7x4(
                g,
                direction,
                rect,
                pen: Misc.Config.DarkMode ? DarkColors.LightTextPen : SystemPens.WindowText);

            return(true);
        }
		public void Update(Graphics g, string text, Font font, Padding internalBounds,
			Rectangle bounds, Color color, TextFormatFlags formatFlags, IThemeTextOption[] options) {

			IntPtr compatHdc = this._TextHDC;

			if (bounds.Equals(_TextHDCBounds)) {
				//Same bounds, reuse HDC and Clear it
				IntPtr hClearBrush = Native.GDI.CreateSolidBrush(ColorTranslator.ToWin32(Color.Black));
				Native.RECT cleanRect = new Native.RECT(bounds);
				Native.GDI.FillRect(compatHdc, ref cleanRect, hClearBrush);
				Native.GDI.DeleteObject(hClearBrush);
			}
			else {
				//Other bounds, create new HDC
				IntPtr outputHdc = g.GetHdc();
				IntPtr DIB;
				compatHdc = CreateNewHDC(outputHdc, bounds, out DIB);

				//Store new data
				_TextHDC = compatHdc;
				_TextHDCBounds = bounds;

				//Clear up
				CleanUpHDC(DIB);
				g.ReleaseHdc(outputHdc);
			}

			DrawOnHDC(compatHdc, text, font, internalBounds, bounds, color, formatFlags, options);
		}
Пример #4
0
        public void Update(Graphics g, string text, Font font, Padding internalBounds,
                           Rectangle bounds, Color color, TextFormatFlags formatFlags, IThemeTextOption[] options)
        {
            IntPtr compatHdc = this._TextHDC;

            if (bounds.Equals(_TextHDCBounds))
            {
                //Same bounds, reuse HDC and Clear it
                IntPtr      hClearBrush = Native.GDI.CreateSolidBrush(ColorTranslator.ToWin32(Color.Black));
                Native.RECT cleanRect   = new Native.RECT(bounds);
                Native.GDI.FillRect(compatHdc, ref cleanRect, hClearBrush);
                Native.GDI.DeleteObject(hClearBrush);
            }
            else
            {
                //Other bounds, create new HDC
                IntPtr outputHdc = g.GetHdc();
                IntPtr DIB;
                compatHdc = CreateNewHDC(outputHdc, bounds, out DIB);

                //Store new data
                _TextHDC       = compatHdc;
                _TextHDCBounds = bounds;

                //Clear up
                CleanUpHDC(DIB);
                g.ReleaseHdc(outputHdc);
            }

            DrawOnHDC(compatHdc, text, font, internalBounds, bounds, color, formatFlags, options);
        }
Пример #5
0
        public void Perform(IntPtr window)
        {
            Native.RECT rect = new Native.RECT();
            Native.GetWindowRect(window, ref rect);
            int width  = rect.right - rect.left;
            int height = rect.bottom - rect.top;

            Native.MoveWindow(window, X, Y, width, height, true);
        }
Пример #6
0
        public void Perform(IntPtr window)
        {
            var rect = new Native.RECT();

            Native.GetWindowRect(window, ref rect);
            int x = rect.left;
            int y = rect.top;

            Native.MoveWindow(window, x, y, Width, Height, true);
        }
Пример #7
0
 private void buttonSet_Click(object sender, RoutedEventArgs e)
 {
     if (WindowSequenceConfig.CurrentlySelectedWindow != IntPtr.Zero)
     {
         Native.RECT rect = new Native.RECT();
         Native.GetWindowRect(WindowSequenceConfig.CurrentlySelectedWindow, ref rect);
         textBoxWidth.Text  = (rect.right - rect.left).ToString();
         textBoxHeight.Text = (rect.bottom - rect.top).ToString();
     }
 }
Пример #8
0
 private void buttonSet_Click(object sender, RoutedEventArgs e)
 {
     if (WindowSequenceConfig.CurrentlySelectedWindow != IntPtr.Zero)
     {
         Native.RECT rect = new Native.RECT();
         Native.GetWindowRect(WindowSequenceConfig.CurrentlySelectedWindow, ref rect);
         textBoxMoveX.Text = rect.left.ToString();
         textBoxMoveY.Text = rect.top.ToString();
     }
 }
Пример #9
0
 internal virtual bool TryDrawThemeBackground(
     IntPtr hTheme,
     IntPtr hdc,
     int iPartId,
     int iStateId,
     ref Native.RECT pRect,
     ref Native.RECT pClipRect)
 {
     return(false);
 }
		public void Draw(Graphics g, Rectangle rect) {
			//Convert to native rect
			Native.RECT RECT = new Native.RECT(rect);

			//Get HDC
			IntPtr outputHDC = g.GetHdc();

			//Draw
			Native.GDI.BitBlt(outputHDC, rect.X, rect.Y, rect.Width, rect.Height, _TextHDC, 0, 0, Native.GDI.BitBltOp.SRCCOPY);

			//Clean up
			g.ReleaseHdc(outputHDC);
		}
Пример #11
0
 /// <summary>
 /// Gets window pos Y.
 /// </summary>
 /// <param name="mainWindowHandle"> </param>
 public static int GetWindowPosY(IntPtr mainWindowHandle)
 {
     try
     {
         Native.RECT windowRect = new Native.RECT();
         Native.GetWindowRect(mainWindowHandle, ref windowRect);
         return(windowRect.top);
     }
     catch (Exception exception)
     {
         Logging.WriteError("GetWindowPosY(IntPtr mainWindowHandle): " + exception);
         return(0);
     }
 }
Пример #12
0
        public void Draw(Graphics g, Rectangle rect)
        {
            //Convert to native rect
            Native.RECT RECT = new Native.RECT(rect);

            //Get HDC
            IntPtr outputHDC = g.GetHdc();

            //Draw
            Native.GDI.BitBlt(outputHDC, rect.X, rect.Y, rect.Width, rect.Height, _TextHDC, 0, 0, Native.GDI.BitBltOp.SRCCOPY);

            //Clean up
            g.ReleaseHdc(outputHDC);
        }
Пример #13
0
        /// <summary>
        /// Capture Wow Window to Image.
        /// </summary>
        /// <param name="mainWindowHandle"> </param>
        /// <returns></returns>
        public static Image ScreenshotWindow(IntPtr mainWindowHandle)
        {
            try
            {
                IntPtr handle = mainWindowHandle;
                // get te hDC of the target window
                IntPtr hdcSrc = Native.GetWindowDC(handle);

                // get the size
                Native.RECT windowRect = new Native.RECT();
                Native.GetWindowRect(handle, ref windowRect);
                int width  = windowRect.right - windowRect.left;
                int height = windowRect.bottom - windowRect.top;

                // create a device context we can copy to
                IntPtr hdcDest = Native.CreateCompatibleDC(hdcSrc);

                // create a bitmap we can copy it to,
                // using GetDeviceCaps to get the width/height
                IntPtr hBitmap = Native.CreateCompatibleBitmap(hdcSrc, width, height);

                // select the bitmap object
                IntPtr hOld = Native.SelectObject(hdcDest, hBitmap);

                // bitblt over
                Native.BitBlt(hdcDest, 0, 0, width, height, hdcSrc, 0, 0, 0x00CC0020);

                // restore selection
                Native.SelectObject(hdcDest, hOld);

                // clean up
                Native.DeleteDC(hdcDest);
                Native.ReleaseDC(handle, hdcSrc);

                // get a .NET image object for it
                Image img = Image.FromHbitmap(hBitmap);

                // free up the Bitmap object
                Native.DeleteObject(hBitmap);
                //img.Save(bitmapFilePath);
                return(img);
            }
            catch (Exception exception)
            {
                Logging.WriteError("ScreenshotWindow(IntPtr mainWindowHandle): " + exception);
            }
            return(new Bitmap(1, 1));
        }
Пример #14
0
        public void ClickWindow(IntPtr wh)
        {
            Native.RECT rect = new Native.RECT();
            if (!Native.GetWindowRect(new HandleRef(null, wh), out rect))
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }
            Rectangle windowSize = rect.ToRectangle();
            int       y          = 20;
            int       x          = 20;

            Native.PostMessage(wh, Native.WM_LBUTTONDOWN, 0, Native.MakeLParam(x, y));
            Thread.Sleep(100);
            Native.PostMessage(wh, Native.WM_LBUTTONUP, 0, Native.MakeLParam(x, y));
            Thread.Sleep(100);
        }
        /// <summary>
        /// Make thumbnail visible
        /// </summary>
        public void DrawThumbnail(Rectangle r, IntPtr thumbnail)
        {
            Native.RECT dest = new Native.RECT()
            {
                left   = r.Left,
                top    = r.Top,
                right  = r.Right,
                bottom = r.Bottom
            };

            DwmApi.DWM_THUMBNAIL_PROPERTIES dskThumbProps = new DwmApi.DWM_THUMBNAIL_PROPERTIES();
            dskThumbProps.dwFlags = DwmApi.DWM_THUMBNAIL_FLAGS.DWM_TNP_SOURCECLIENTAREAONLY
                                    | DwmApi.DWM_THUMBNAIL_FLAGS.DWM_TNP_VISIBLE
                                    | DwmApi.DWM_THUMBNAIL_FLAGS.DWM_TNP_RECTDESTINATION;
            dskThumbProps.fSourceClientAreaOnly = true;
            dskThumbProps.fVisible      = true;
            dskThumbProps.opacity       = 255;
            dskThumbProps.rcDestination = dest;

            DwmApi.DwmUpdateThumbnailProperties(thumbnail, ref dskThumbProps);
        }
Пример #16
0
        private void UpdateMagnifier()
        {
            System.Drawing.Point mousePosition = System.Windows.Forms.Control.MousePosition;

            // Set the source rectangle for the magnification
            Native.RECT sourceRect = new Native.RECT();
            sourceRect.Left   = mousePosition.X - (int)sourceRectHalfSize.Width;
            sourceRect.Top    = mousePosition.Y - (int)sourceRectHalfSize.Height;
            sourceRect.Right  = sourceRect.Left + (int)sourceRectSize.Width;
            sourceRect.Bottom = sourceRect.Top + (int)sourceRectSize.Height;
            Native.MagSetWindowSource(hwndMag, sourceRect);

            // Force magnification redraw
            Native.InvalidateRect(hwndMag, IntPtr.Zero, true);

            // Update position, WPF units are affected by monitor's DPI
            Left = (mousePosition.X / Utils.GraphicsUtil.GetDpiScale()) - actualHalfSize.Width;
            Top  = (mousePosition.Y / Utils.GraphicsUtil.GetDpiScale()) - actualHalfSize.Height;
            magnifierOverlay.Left = Left;
            magnifierOverlay.Top  = Top;
        }
Пример #17
0
        private Bitmap GetScreenshot(IntPtr hwnd)
        {
            Native.RECT rect = new Native.RECT();

            if (!Native.GetWindowRect(new HandleRef(null, hwnd), out rect))
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }

            Thread.Sleep(500);

            Rectangle windowSize = rect.ToRectangle();
            Bitmap    target     = new Bitmap(windowSize.Width, windowSize.Height);

            using (Graphics g = Graphics.FromImage(target))
            {
                g.CopyFromScreen(windowSize.X, windowSize.Y, 0, 0, new System.Drawing.Size(windowSize.Width, windowSize.Height));
            }


            return(target);
        }
Пример #18
0
        public override void Resize(object sender, EventArgs eventArgs)
        {
            try
            {
                //ToDo: Rewrite code
                var ax = Convert.ToInt32(-SystemInformation.FrameBorderSize.Width);
                var ay = Convert.ToInt32(-(SystemInformation.CaptionHeight + SystemInformation.FrameBorderSize.Height));
                int b  = Convert.ToInt32(InterfaceControl.Width + (SystemInformation.FrameBorderSize.Width * 2));
                int a  = Convert.ToInt32(InterfaceControl.Height + SystemInformation.CaptionHeight +
                                         (SystemInformation.FrameBorderSize.Height * 2));

                var r      = new Rectangle();
                var rect   = new Native.RECT();
                var c      = Native.GetWindowRect(Handle, out r);
                int width  = 0;
                int height = 0;
                if (Native.GetClientRect(Handle, out rect))
                {
                    width  = rect.Right - rect.Left;
                    height = rect.Bottom - rect.Top;
                }
                Double W  = width;
                Double H  = height;
                Double w1 = b;
                Double h1 = a;
                double S  = w1 / W > h1 / H ? h1 / H : w1 / W;
                Debug.WriteLine(Convert.ToInt32(W * S) + "  " + Convert.ToInt32(H * S));
                Native.MoveWindow(Handle, ax, ay, Convert.ToInt32(W * S - S), Convert.ToInt32(H * S - S) + 1, true);
            }
            catch (Exception ex)
            {
                Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg,
                                                    Language.strPuttyResizeFailed + Constants.vbNewLine + ex.Message,
                                                    true);
            }
        }
Пример #19
0
        internal override bool TryDrawThemeBackground(
            IntPtr hTheme,
            IntPtr hdc,
            int iPartId,
            int iStateId,
            ref Native.RECT pRect,
            ref Native.RECT pClipRect)
        {
            using var g = Graphics.FromHdc(hdc);
            if (iPartId is Native.TTP_STANDARD or Native.TTP_STANDARDTITLE)
            {
                var rect = Rectangle.FromLTRB(pRect.left, pRect.top, pRect.right, pRect.bottom);

                g.FillRectangle(DarkColors.Fen_ControlBackgroundBrush, rect);
                g.DrawRectangle(
                    DarkColors.GreySelectionPen,
                    new Rectangle(
                        rect.X,
                        rect.Y,
                        rect.Width - 1,
                        rect.Height - 1
                        ));
                return(true);
            }
Пример #20
0
        private static void DrawOnHDC(IntPtr compatHdc, string text, Font font, Padding internalBounds,
                                      Rectangle bounds, Color color, TextFormatFlags formatFlags, IThemeTextOption[] options)
        {
            //Create the Font to use
            IntPtr hFont = font.ToHfont();

            Native.GDI.SelectObject(compatHdc, hFont);

            //Get theme renderer
            VisualStyleRenderer renderer = new VisualStyleRenderer(VisualStyleElement.Window.Caption.Active);

            //Prepare options
            NativeMethods.DTTOPTS dttOpts = new NativeMethods.DTTOPTS();
            dttOpts.dwSize  = Marshal.SizeOf(dttOpts);
            dttOpts.dwFlags = NativeMethods.DTTOPSFlags.DTT_COMPOSITED | NativeMethods.DTTOPSFlags.DTT_TEXTCOLOR;
            dttOpts.crText  = ColorTranslator.ToWin32(color);
            foreach (IThemeTextOption op in options)
            {
                op.Apply(ref dttOpts);
            }

            //Set full bounds with padding
            Native.RECT RECT = new Native.RECT(internalBounds.Left, internalBounds.Top,
                                               bounds.Width - internalBounds.Right, bounds.Height - internalBounds.Bottom);

            //Draw
            int ret = NativeMethods.DrawThemeTextEx(renderer.Handle, compatHdc, 0, 0, text, -1, (int)formatFlags, ref RECT, ref dttOpts);

            if (ret != 0)
            {
                Marshal.ThrowExceptionForHR(ret);
            }

            //Clean up
            Native.GDI.DeleteObject(hFont);
        }
Пример #21
0
        public override void Resize(object sender, EventArgs eventArgs)
        {
            try
            {
                //ToDo: Rewrite code
                var ax = Convert.ToInt32(-SystemInformation.FrameBorderSize.Width);
                var ay = Convert.ToInt32(-(SystemInformation.CaptionHeight + SystemInformation.FrameBorderSize.Height));
                int b = Convert.ToInt32(InterfaceControl.Width + SystemInformation.FrameBorderSize.Width * 2);
                int a = Convert.ToInt32(InterfaceControl.Height + SystemInformation.CaptionHeight +
                                        (SystemInformation.FrameBorderSize.Height * 2));

                var r = new Rectangle();
                var rect = new Native.RECT();
                var c = Native.GetWindowRect(Handle, out r);
                int width = 0;
                int height = 0;
                if (Native.GetClientRect(Handle, out rect))
                {
                    width = rect.Right - rect.Left;
                    height = rect.Bottom - rect.Top;
                }
                Double W = width;
                Double H = height;
                Double w1 = b;
                Double h1 = a;
                double S = w1 / W > h1 / H ? h1 / H : w1 / W;
                Debug.WriteLine(Convert.ToInt32(W * S) + "  " + Convert.ToInt32(H * S) );
                Native.MoveWindow(Handle, ax, ay, Convert.ToInt32(W * S - S), Convert.ToInt32(H * S - S)+1, true);
            }
            catch (Exception ex)
            {
                Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg,
                                                    Language.strPuttyResizeFailed + Constants.vbNewLine + ex.Message,
                                                    true);
            }
        }
		private static void DrawOnHDC(IntPtr compatHdc, string text, Font font, Padding internalBounds,
			Rectangle bounds, Color color, TextFormatFlags formatFlags, IThemeTextOption[] options) {

			//Create the Font to use
			IntPtr hFont = font.ToHfont();
			Native.GDI.SelectObject(compatHdc, hFont);

			//Get theme renderer
			VisualStyleRenderer renderer = new VisualStyleRenderer(VisualStyleElement.Window.Caption.Active);

			//Prepare options
			NativeMethods.DTTOPTS dttOpts = new NativeMethods.DTTOPTS();
			dttOpts.dwSize = Marshal.SizeOf(dttOpts);
			dttOpts.dwFlags = NativeMethods.DTTOPSFlags.DTT_COMPOSITED | NativeMethods.DTTOPSFlags.DTT_TEXTCOLOR;
			dttOpts.crText = ColorTranslator.ToWin32(color);
			foreach (IThemeTextOption op in options)
				op.Apply(ref dttOpts);

			//Set full bounds with padding
			Native.RECT RECT = new Native.RECT(internalBounds.Left, internalBounds.Top,
				bounds.Width - internalBounds.Right, bounds.Height - internalBounds.Bottom);

			//Draw
			int ret = NativeMethods.DrawThemeTextEx(renderer.Handle, compatHdc, 0, 0, text, -1, (int)formatFlags, ref RECT, ref dttOpts);
			if (ret != 0)
				Marshal.ThrowExceptionForHR(ret);

			//Clean up
			Native.GDI.DeleteObject(hFont);
		}
Пример #23
0
        internal override bool TryDrawThemeBackground(
            IntPtr hTheme,
            IntPtr hdc,
            int iPartId,
            int iStateId,
            ref Native.RECT pRect,
            ref Native.RECT pClipRect)
        {
            using var g = Graphics.FromHdc(hdc);

            #region Background

            var rect = Rectangle.FromLTRB(pRect.left, pRect.top, pRect.right, pRect.bottom);

            Brush brush;
            switch (iPartId)
            {
            case Native.SBP_ARROWBTN:
                brush = DarkColors.DarkBackgroundBrush;
                break;

            case Native.SBP_GRIPPERHORZ:
            case Native.SBP_GRIPPERVERT:
                // The "gripper" is a subset of the thumb, except sometimes it extends outside of it and
                // causes problems with our thumb width correction, so just don't draw it
                return(true);

            case Native.SBP_THUMBBTNHORZ:
            case Native.SBP_THUMBBTNVERT:

                #region Correct the thumb width

                // Match Windows behavior - the thumb is 1px in from each side
                // The "gripper" rect gives us the right width, but the wrong length
                switch (iPartId)
                {
                case Native.SBP_THUMBBTNHORZ:
                    g.DrawLine(DarkColors.DarkBackgroundPen, rect.X, rect.Y, rect.Right, rect.Y);
                    g.DrawLine(DarkColors.DarkBackgroundPen, rect.X, rect.Bottom - 1, rect.Right, rect.Bottom - 1);
                    rect = new Rectangle(rect.X, rect.Y + 1, rect.Width, rect.Height - 2);
                    break;

                case Native.SBP_THUMBBTNVERT:
                    g.DrawLine(DarkColors.DarkBackgroundPen, rect.X, rect.Y, rect.X, rect.Bottom);
                    g.DrawLine(DarkColors.DarkBackgroundPen, rect.Right - 1, rect.Y, rect.Right - 1, rect.Bottom);
                    rect = new Rectangle(rect.X + 1, rect.Y, rect.Width - 2, rect.Height);
                    break;
                }

                #endregion

                brush = iStateId switch
                {
                    Native.SCRBS_NORMAL => DarkColors.GreySelectionBrush,
                    Native.SCRBS_HOVER => DarkColors.Fen_ThumbScrollBarHoverBrush,
                    Native.SCRBS_HOT => DarkColors.GreyHighlightBrush,
                    Native.SCRBS_PRESSED => DarkColors.ActiveControlBrush,
                    _ => DarkColors.GreySelectionBrush
                };
                break;

            default:
                brush = DarkColors.DarkBackgroundBrush;
                break;
            }

            g.FillRectangle(brush, rect);

            #endregion

            #region Arrow

            if (iPartId == Native.SBP_ARROWBTN)
            {
                Pen pen;
                switch (iStateId)
                {
                case Native.ABS_UPPRESSED:
                case Native.ABS_DOWNPRESSED:
                case Native.ABS_LEFTPRESSED:
                case Native.ABS_RIGHTPRESSED:
                    pen = DarkColors.ActiveControlPen;
                    break;

                case Native.ABS_UPDISABLED:
                case Native.ABS_DOWNDISABLED:
                case Native.ABS_LEFTDISABLED:
                case Native.ABS_RIGHTDISABLED:
                    pen = DarkColors.GreySelectionPen;
                    break;

                case Native.ABS_UPHOT:
                case Native.ABS_DOWNHOT:
                case Native.ABS_LEFTHOT:
                case Native.ABS_RIGHTHOT:
                    pen = DarkColors.GreyHighlightPen;
                    break;

                /*
                 * case Native.ABS_UPNORMAL:
                 * case Native.ABS_DOWNNORMAL:
                 * case Native.ABS_LEFTNORMAL:
                 * case Native.ABS_RIGHTNORMAL:
                 */
                default:
                    pen = DarkColors.GreySelectionPen;
                    break;
                }

                Misc.Direction direction;
                switch (iStateId)
                {
                case Native.ABS_LEFTNORMAL:
                case Native.ABS_LEFTHOT:
                case Native.ABS_LEFTPRESSED:
                case Native.ABS_LEFTHOVER:
                case Native.ABS_LEFTDISABLED:
                    direction = Misc.Direction.Left;
                    break;

                case Native.ABS_RIGHTNORMAL:
                case Native.ABS_RIGHTHOT:
                case Native.ABS_RIGHTPRESSED:
                case Native.ABS_RIGHTHOVER:
                case Native.ABS_RIGHTDISABLED:
                    direction = Misc.Direction.Right;
                    break;

                case Native.ABS_UPNORMAL:
                case Native.ABS_UPHOT:
                case Native.ABS_UPPRESSED:
                case Native.ABS_UPHOVER:
                case Native.ABS_UPDISABLED:
                    direction = Misc.Direction.Up;
                    break;

                /*
                 * case Native.ABS_DOWNNORMAL:
                 * case Native.ABS_DOWNHOT:
                 * case Native.ABS_DOWNPRESSED:
                 * case Native.ABS_DOWNHOVER:
                 * case Native.ABS_DOWNDISABLED:
                 */
                default:
                    direction = Misc.Direction.Down;
                    break;
                }

                Images.PaintArrow7x4(
                    g,
                    direction,
                    rect,
                    pen: pen
                    );
            }

            #endregion

            return(true);
        }
Пример #24
0
 public static extern int FillRect(IntPtr hDC, [In] ref Native.RECT lprc, IntPtr hbr);
Пример #25
0
        /// <summary>
        ///     Catches the Hotkeys
        /// </summary>
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == Native.WM_HOTKEY)
            {
                uint keystroke          = ((uint)m.LParam >> 16) & 0x0000FFFF;
                uint keystroke_modifier = ((uint)m.LParam) & 0x0000FFFF;

                // Global hotkey to make a window borderless
                if ((keystroke == MakeBorderless_HotKey) && (keystroke_modifier == MakeBorderless_HotKeyModifier))
                {
                    // Find the currently-active window
                    IntPtr hCurrentActiveWindow = Native.GetForegroundWindow();

                    // Only if that window isn't Borderless Windows itself
                    if (hCurrentActiveWindow != this.Handle)
                    {
                        // Figure out the process details based on the current window handle
                        ProcessDetails pd = controller.Processes.FromHandle(hCurrentActiveWindow);
                        if (pd == null)
                        {
                            Task.WaitAll(controller.RefreshProcesses());
                            pd = controller.Processes.FromHandle(hCurrentActiveWindow);
                            if (pd == null)
                            {
                                return;
                            }
                        }
                        // If we have information about this process -and- we've already made it borderless, then reverse the process
                        if (pd.MadeBorderless)
                        {
                            Manipulation.RestoreWindow(pd);
                        }
                        // Otherwise, this is a fresh request to remove the border from the current window
                        else
                        {
                            this.controller.RemoveBorder(pd);
                        }
                    }

                    return; // handled the message, do not call base WndProc for this message
                }

                if ((keystroke == MouseHide_HotKey) && (keystroke_modifier == MouseHide_HotKeyModifier))
                {
                    Manipulation.ToggleMouseCursorVisibility(this);

                    return; // handled the message, do not call base WndProc for this message
                }

                if ((keystroke == MouseLock_HotKey) && (keystroke_modifier == 0))
                {
                    IntPtr hWnd = Native.GetForegroundWindow();

                    // get size of clientarea
                    Native.RECT rect = new Native.RECT();
                    Native.GetClientRect(hWnd, ref rect);

                    // get top,left point of clientarea
                    Native.POINTAPI p = new Native.POINTAPI {
                        X = 0, Y = 0
                    };
                    Native.ClientToScreen(hWnd, ref p);

                    Rectangle clipRect = new Rectangle(p.X, p.Y, rect.Right - rect.Left, rect.Bottom - rect.Top);

                    Cursor.Clip = (Cursor.Clip.Equals(clipRect)) ? Rectangle.Empty : clipRect;

                    return; // handled the message, do not call base WndProc for this message
                }
            }

            base.WndProc(ref m);
        }
Пример #26
0
 internal static extern int DrawThemeTextEx(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, string text, int iCharCount, int dwFlags, ref Native.RECT pRect, ref DTTOPTS pOptions);
Пример #27
0
 public static extern bool GetWindowRect(IntPtr hWnd, ref Native.RECT lpRect);