当前位置: 首页>>代码示例>>C#>>正文


C# RECT.ToRectangle方法代码示例

本文整理汇总了C#中RECT.ToRectangle方法的典型用法代码示例。如果您正苦于以下问题:C# RECT.ToRectangle方法的具体用法?C# RECT.ToRectangle怎么用?C# RECT.ToRectangle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RECT的用法示例。


在下文中一共展示了RECT.ToRectangle方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetWindowRect

 // helper function return directly a Rectangle object
 public static Rectangle GetWindowRect(IntPtr hWnd)
 {
     Debug.Assert(hWnd != IntPtr.Zero);
     RECT rect = new RECT();
     if (GetWindowRect(hWnd, ref rect) == false)
         throw new Exception("GetWindowRect failed");
     return rect.ToRectangle();
 }
开发者ID:duanshuaimin,项目名称:upScreen,代码行数:9,代码来源:WinApiWrapper.cs

示例2: GetDesktopBitmap

        /// <summary>
        /// Gets a segment of the desktop as an image.
        /// </summary>
        /// <returns>A <see cref="System.Drawing.Image"/> containg an image of the full desktop.</returns>
        internal static Image GetDesktopBitmap(IntPtr hWnd, bool colorNonFormArea, Color backgroundColor)
        {
            Image capture = null;

            try
            {
                RECT rect = new RECT();
                GetWindowRect(hWnd, ref rect);
                capture = GetDesktopBitmap(rect.ToRectangle());

                if (colorNonFormArea)
                    return ColorNonRegionFormArea(hWnd, capture, backgroundColor);
                else
                    return capture;
            }
            finally
            {
                if (capture != null && colorNonFormArea)
                    capture.Dispose();
            }
        }
开发者ID:pusp,项目名称:o2platform,代码行数:25,代码来源:NativeMethods.cs

示例3: ToRectangle

 public static global::System.Drawing.Rectangle ToRectangle(RECT Rectangle)
 {
     return Rectangle.ToRectangle();
 }
开发者ID:hiiru,项目名称:lab,代码行数:4,代码来源:WinAPI.cs

示例4: RebarMessageCaptured

        private bool RebarMessageCaptured(ref Message m)
        {
            // Make sure the menu bar obeys the Explorer setting.
            // Was this really so hard, Microsoft?
            if(m.Msg == RB.SETBANDINFO) {
                REBARBANDINFO pInfo = (REBARBANDINFO)Marshal.PtrToStructure(m.LParam, typeof(REBARBANDINFO));
                if((PInvoke.GetClassName(pInfo.hwndChild) == "ToolbarWindow32") && (pInfo.wID == 1)) {
                    if(MenuHasFocus || MenuBarShown) {
                        pInfo.fStyle &= ~RBBS.HIDDEN;
                    }
                    else {
                        pInfo.fStyle |= RBBS.HIDDEN;
                    }
                    Marshal.StructureToPtr(pInfo, m.LParam, false);
                }
                return false;
            }

            if(m.Msg == WM.ERASEBKGND && (Config.Skin.UseRebarBGColor || Config.Skin.UseRebarImage)) {
                bool fFilled = false;
                using(Graphics graphics = Graphics.FromHdc(m.WParam)) {
                    RECT rect;
                    PInvoke.GetWindowRect(Handle, out rect);
                    Rectangle rectRebar = new Rectangle(0, 0, rect.Width, rect.Height);

                    // Fill the Rebar background color
                    if(Config.Skin.UseRebarBGColor) {
                        using(SolidBrush brush = new SolidBrush(Config.Skin.RebarColor)) {
                            graphics.FillRectangle(brush, rectRebar);
                            fFilled = true;
                        }
                    }
                    else if(Config.Skin.RebarStretchMode == StretchMode.Real) {
                        rebarController.DefWndProc(ref m);
                    }

                    // Draw the Rebar image
                    if(VisualStyleRenderer.IsSupported && Config.Skin.UseRebarImage && Config.Skin.RebarImageFile.Length > 0) {
                        if(bmpRebar == null) {
                            CreateRebarImage();
                        }
                        if(bmpRebar != null) {
                            List<Rectangle> rectTargets = new List<Rectangle>();
                            if(Config.Skin.RebarImageSeperateBars) {
                                int bandCount = (int)PInvoke.SendMessage(rebarController.Handle, RB.GETBANDCOUNT, IntPtr.Zero, IntPtr.Zero);
                                graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
                                RECT rectBand = new RECT();
                                RECT rectMargin = new RECT();
                                for(int i = 0; i < bandCount; i++) {
                                    if(PInvoke.SendMessage(rebarController.Handle, RB.GETRECT, (IntPtr)i, ref rectBand) == IntPtr.Zero) {
                                        continue;
                                    }
                                    PInvoke.SendMessage(rebarController.Handle, RB.GETBANDBORDERS, (IntPtr)i, ref rectMargin);
                                    rectBand.left -= !QTUtility.IsXP ? 4 : rectMargin.left;
                                    rectBand.top -= rectMargin.top;
                                    rectBand.right += rectMargin.right;
                                    rectBand.bottom += rectMargin.bottom;
                                    rectTargets.Add(rectBand.ToRectangle());
                                }
                            }
                            else {
                                rectTargets.Add(rectRebar);
                            }

                            foreach(Rectangle destRect in rectTargets) {
                                switch(Config.Skin.RebarStretchMode) {
                                    case StretchMode.Real:
                                        Rectangle rectDest2 = new Rectangle(new Point(0, 0), destRect.Size);
                                        Rectangle rectBmp = new Rectangle(new Point(0, 0), bmpRebar.Size);
                                        rectBmp.Intersect(rectDest2);
                                        rectDest2.Intersect(rectBmp);
                                        rectDest2.Offset(destRect.Location);
                                        graphics.DrawImage(bmpRebar, rectDest2, rectBmp, GraphicsUnit.Pixel);
                                        break;

                                    case StretchMode.Tile:
                                        textureBrushRebar = textureBrushRebar ?? new TextureBrush(bmpRebar);
                                        textureBrushRebar.TranslateTransform(destRect.X, destRect.Y);
                                        graphics.FillRectangle(textureBrushRebar, destRect);
                                        textureBrushRebar.ResetTransform();
                                        break;

                                    default: // Full
                                        // todo: make this a function
                                        graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
                                        Padding margin = Config.Skin.RebarSizeMargin;
                                        int left = margin.Left;
                                        int top = margin.Top;
                                        int right = margin.Right;
                                        int bottom = margin.Bottom;
                                        int vertical = margin.Vertical;
                                        int horizontal = margin.Horizontal;
                                        int width = bmpRebar.Width;
                                        int height = bmpRebar.Height;
                                        Rectangle[] dstRects = new Rectangle[] {
                                            new Rectangle(destRect.X, destRect.Y, left, top),
                                            new Rectangle(destRect.X + left, destRect.Y, destRect.Width - horizontal, top),
                                            new Rectangle(destRect.Right - right, destRect.Y, right, top),
                                            new Rectangle(destRect.X, destRect.Y + top, left, destRect.Height - vertical),
                                            new Rectangle(destRect.X + left, destRect.Y + top, destRect.Width - horizontal, destRect.Height - vertical),
//.........这里部分代码省略.........
开发者ID:svn2github,项目名称:QTTabBar,代码行数:101,代码来源:RebarController.cs

示例5: GetRect

 public Rectangle? GetRect(bool detect)
 {
     if (!this.rect.HasValue && detect)
     {
         RECT rect = new RECT();
         User32.GetWindowRect(this.handle, out rect);
         this.rect = new Nullable<Rectangle>(rect.ToRectangle());
     }
     return this.rect;
 }
开发者ID:machisuji,项目名称:Kieker,代码行数:10,代码来源:Types.cs

示例6: GetWindowRectangle

        public static Rectangle GetWindowRectangle(IntPtr hwnd)
        {
            RECT rect = new RECT();
            Win32APIImports.GetWindowRect(hwnd, out rect);
            Rectangle rectangle = rect.ToRectangle();

            return rectangle;
        }
开发者ID:tklepzig,项目名称:Luna,代码行数:8,代码来源:Win32APIImports.cs

示例7: rebarController_MessageCaptured

        private bool rebarController_MessageCaptured(ref System.Windows.Forms.Message m) {
            if((m.Msg == WM.ERASEBKGND) && (QTUtility.CheckConfig(Settings.ToolbarBGColor) || QTUtility.CheckConfig(Settings.RebarImage))) {
                bool flag = false;
                using(Graphics graphics = Graphics.FromHdc(m.WParam)) {
                    RECT rect;
                    PInvoke.GetWindowRect(this.rebarController.Handle, out rect);
                    Rectangle rectangle = new Rectangle(0, 0, rect.Width, rect.Height);
                    if(QTUtility.CheckConfig(Settings.ToolbarBGColor)) {
                        using(SolidBrush brush = new SolidBrush(QTUtility.RebarBGColor)) {
                            graphics.FillRectangle(brush, rectangle);
                            flag = true;
                        }
                    }
                    if((VisualStyleRenderer.IsSupported && QTUtility.CheckConfig(Settings.RebarImage)) && (QTUtility.Path_RebarImage.Length > 0)) {
                        if(this.bmpRebar == null) {
                            this.CreateRebarImage();
                        }
                        if(this.bmpRebar != null) {
                            switch(((QTUtility.ConfigValues[11] & 0x60) | (QTUtility.ConfigValues[13] & 1))) {
                                case 1: {
                                        if(!flag) {
                                            this.rebarController.DefWndProc(ref m);
                                        }
                                        int num2 = (int)PInvoke.SendMessage(this.rebarController.Handle, 0x40c, IntPtr.Zero, IntPtr.Zero);
                                        RECT rect2 = new RECT();
                                        IntPtr lParam = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(RECT)));
                                        graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
                                        for(int i = 0; i < num2; i++) {
                                            RECT rect3 = new RECT();
                                            IntPtr ptr2 = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(RECT)));
                                            PInvoke.SendMessage(this.rebarController.Handle, 0x422, (IntPtr)i, ptr2);
                                            rect3 = (RECT)Marshal.PtrToStructure(ptr2, typeof(RECT));
                                            Marshal.FreeHGlobal(ptr2);
                                            if(IntPtr.Zero != PInvoke.SendMessage(this.rebarController.Handle, 0x409, (IntPtr)i, lParam)) {
                                                rect2 = (RECT)Marshal.PtrToStructure(lParam, typeof(RECT));
                                                rect2.left -= QTUtility.IsVista ? 4 : rect3.left;
                                                rect2.top -= rect3.top;
                                                rect2.right += rect3.right;
                                                rect2.bottom += rect3.bottom;
                                                graphics.DrawImage(this.bmpRebar, rect2.ToRectangle());
                                            }
                                        }
                                        Marshal.FreeHGlobal(lParam);
                                        break;
                                    }
                                case 0x20: {
                                        if(!flag) {
                                            this.rebarController.DefWndProc(ref m);
                                        }
                                        Rectangle destRect = new Rectangle(Point.Empty, this.bmpRebar.Size);
                                        graphics.DrawImage(this.bmpRebar, destRect, destRect, GraphicsUnit.Pixel);
                                        break;
                                    }
                                case 0x40:
                                    if(this.textureBrushRebar == null) {
                                        this.textureBrushRebar = new TextureBrush(this.bmpRebar);
                                    }
                                    graphics.FillRectangle(this.textureBrushRebar, rectangle);
                                    break;

                                default:
                                    graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
                                    graphics.DrawImage(this.bmpRebar, rectangle);
                                    break;
                            }
                            flag = true;
                        }
                    }
                }
                if(flag) {
                    m.Result = (IntPtr)1;
                    return true;
                }
            }
            return false;
        }
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:76,代码来源:QTTabBarClass.cs

示例8: UpdateWindowBounds

 void IPreviewHandler.SetRect(ref RECT rect)
 {
     _windowBounds = rect.ToRectangle();
     UpdateWindowBounds();
 }
开发者ID:jorgeds001,项目名称:CodeSamples,代码行数:5,代码来源:PreviewHandler.cs

示例9: ToRectangle

 public static Rectangle ToRectangle(RECT Rectangle)
 {
     return Rectangle.ToRectangle();
 }
开发者ID:Wolfgang-HBIC,项目名称:HLUTool,代码行数:4,代码来源:WinAPI.cs

示例10: MessageCaptured

        private bool MessageCaptured(ref Message m) {
            // Make sure the menu bar obeys the Explorer setting.
            // Was this really so hard, Microsoft?
            if(m.Msg == RB.SETBANDINFO) {
                REBARBANDINFO pInfo = (REBARBANDINFO)Marshal.PtrToStructure(m.LParam, typeof(REBARBANDINFO));
                if((PInvoke.GetClassName(pInfo.hwndChild) == "ToolbarWindow32") && (pInfo.wID == 1)) {
                    if(MenuBarShown) {
                        pInfo.fStyle &= ~RBBS.HIDDEN;
                    }
                    else {
                        pInfo.fStyle |= RBBS.HIDDEN;
                    }
                    Marshal.StructureToPtr(pInfo, m.LParam, false);
                }
                return false;
            }

            if(m.Msg == WM.ERASEBKGND && (QTUtility.CheckConfig(Settings.ToolbarBGColor) || QTUtility.CheckConfig(Settings.RebarImage))) {
                bool fFilled = false;
                using(Graphics graphics = Graphics.FromHdc(m.WParam)) {
                    RECT rect;
                    PInvoke.GetWindowRect(Handle, out rect);
                    Rectangle rectangle = new Rectangle(0, 0, rect.Width, rect.Height);

                    // Fill the Rebar background color
                    if(QTUtility.CheckConfig(Settings.ToolbarBGColor)) {
                        using(SolidBrush brush = new SolidBrush(QTUtility.RebarBGColor)) {
                            graphics.FillRectangle(brush, rectangle);
                            fFilled = true;
                        }
                    }

                    // Draw the Rebar image
                    if(VisualStyleRenderer.IsSupported && QTUtility.CheckConfig(Settings.RebarImage) && QTUtility.Path_RebarImage.Length > 0) {
                        if(bmpRebar == null) {
                            CreateRebarImage();
                        }
                        if(bmpRebar != null) {
                            switch(((QTUtility.ConfigValues[11] & 0x60) | (QTUtility.ConfigValues[13] & 1))) {
                                case 1: { // Stretch on each band
                                    if(!fFilled) rebarController.DefWndProc(ref m);
                                    int bandCount = (int)PInvoke.SendMessage(rebarController.Handle, RB.GETBANDCOUNT, IntPtr.Zero, IntPtr.Zero);
                                    graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
                                    RECT rectBand = new RECT();
                                    RECT rectMargin = new RECT();
                                    
                                    // Draw the bitmap on each band
                                    for(int i = 0; i < bandCount; i++) {
                                        if(PInvoke.SendMessage(rebarController.Handle, RB.GETRECT, (IntPtr)i, ref rectBand) == IntPtr.Zero) {
                                            continue;
                                        }
                                        PInvoke.SendMessage(rebarController.Handle, RB.GETBANDBORDERS, (IntPtr)i, ref rectMargin);
                                        rectBand.left   -= !QTUtility.IsXP ? 4 : rectMargin.left;
                                        rectBand.top    -= rectMargin.top;
                                        rectBand.right  += rectMargin.right;
                                        rectBand.bottom += rectMargin.bottom;
                                        graphics.DrawImage(bmpRebar, rectBand.ToRectangle());
                                    }
                                    break;
                                }
                                case 0x20: { // Real size
                                    if(!fFilled) rebarController.DefWndProc(ref m);
                                    Rectangle destRect = new Rectangle(Point.Empty, bmpRebar.Size);
                                    graphics.DrawImage(bmpRebar, destRect, destRect, GraphicsUnit.Pixel);
                                    break;
                                }
                                case 0x40: // Tile
                                    textureBrushRebar = textureBrushRebar ?? new TextureBrush(bmpRebar);
                                    graphics.FillRectangle(textureBrushRebar, rectangle);
                                    break;

                                default: // Full size
                                    graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
                                    graphics.DrawImage(bmpRebar, rectangle);
                                    break;
                            }
                            fFilled = true;
                        }
                    }
                }
                if(fFilled) {
                    m.Result = (IntPtr)1;
                    return true;
                }
            }
            return false;
        }
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:87,代码来源:RebarController.cs


注:本文中的RECT.ToRectangle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。