示例#1
0
        internal void DrawComboBoxXP(IntPtr hWnd, Graphics g, Rectangle borderArea, Rectangle buttonArea, ExComboBoxState cbstate, bool drawborder)
        {
            int    num;
            int    num2;
            IntPtr ptr2;

            switch (cbstate)
            {
            case ExComboBoxState.Normal:
                num  = 1;
                num2 = 1;
                break;

            case ExComboBoxState.Hot:
                num  = 2;
                num2 = 1;
                break;

            case ExComboBoxState.HotOnButton:
                num  = 2;
                num2 = 2;
                break;

            case ExComboBoxState.Focused:
                num  = 5;
                num2 = 1;
                break;

            case ExComboBoxState.FocusedOnButton:
                num  = 5;
                num2 = 2;
                break;

            case ExComboBoxState.PressButton:
                num  = 5;
                num2 = 3;
                break;

            case ExComboBoxState.DropDown:
                num  = 5;
                num2 = 1;
                break;

            case ExComboBoxState.Disabled:
                num  = 4;
                num2 = 4;
                break;

            default:
                num  = 1;
                num2 = 1;
                break;
            }
            IntPtr hdc = g.GetHdc();

            if (drawborder)
            {
                ptr2 = OpenThemeData(hWnd, "Edit");
                if (ptr2 != IntPtr.Zero)
                {
                    RECT pRect = new RECT(borderArea.Left, borderArea.Top, borderArea.Right, borderArea.Bottom);
                    if (IsThemeBackgroundPartiallyTransparent(ptr2, 4, num))
                    {
                        DrawThemeParentBackground(ptr2, hdc, ref pRect);
                    }
                    DrawThemeBackground(ptr2, hdc, 1, num, ref pRect, IntPtr.Zero);
                    CloseThemeData(ptr2);
                }
            }
            ptr2 = OpenThemeData(hWnd, "ComboBox");
            if (ptr2 != IntPtr.Zero)
            {
                RECT rect2 = new RECT(buttonArea.Left, buttonArea.Top, buttonArea.Right, buttonArea.Bottom);
                if ((osver == ExOSVersion.Vista) || (osver == ExOSVersion.Seven))
                {
                    rect2.left++;
                }
                DrawThemeBackground(ptr2, hdc, 1, num2, ref rect2, IntPtr.Zero);
                CloseThemeData(ptr2);
            }
            g.ReleaseHdc();
        }
示例#2
0
        internal void DrawComboBoxVista(IntPtr hWnd, Graphics g, Rectangle borderArea, Rectangle buttonArea, MultiLineComboBoxStyle cbstyle, ExComboBoxState cbstate, bool drawborder, ref Bitmap overlayBitmap, float overlayRate, ref Bitmap resultBitmap)
        {
            int    num5;
            int    num6;
            IntPtr ptr5;
            int    width  = borderArea.Width;
            int    height = borderArea.Height;

            if ((resultBitmap != null) && ((resultBitmap.Width != width) || (resultBitmap.Height != height)))
            {
                resultBitmap.Dispose();
                resultBitmap = null;
            }
            if (resultBitmap == null)
            {
                resultBitmap = new Bitmap(width, height);
            }
            IntPtr   hdc      = g.GetHdc();
            Graphics graphics = Graphics.FromImage(resultBitmap);
            IntPtr   hDC      = graphics.GetHdc();
            IntPtr   zero     = IntPtr.Zero;

            if (cbstyle != MultiLineComboBoxStyle.DropDownList)
            {
                switch (cbstate)
                {
                case ExComboBoxState.Normal:
                    num5 = 1;
                    num6 = 1;
                    goto Label_020E;

                case ExComboBoxState.Hot:
                    num5 = 2;
                    num6 = 1;
                    goto Label_020E;

                case ExComboBoxState.HotOnButton:
                    num5 = 2;
                    num6 = 2;
                    goto Label_020E;

                case ExComboBoxState.Focused:
                    num5 = 3;
                    num6 = 1;
                    goto Label_020E;

                case ExComboBoxState.FocusedOnButton:
                    num5 = 3;
                    num6 = 2;
                    goto Label_020E;

                case ExComboBoxState.PressButton:
                    num5 = 3;
                    num6 = 3;
                    goto Label_020E;

                case ExComboBoxState.DropDown:
                    num5 = 3;
                    num6 = 3;
                    goto Label_020E;

                case ExComboBoxState.Disabled:
                    num5 = 4;
                    num6 = 4;
                    goto Label_020E;
                }
                num5 = 1;
                num6 = 1;
            }
            else
            {
                int num3;
                int num4;
                switch (cbstate)
                {
                case ExComboBoxState.Normal:
                    num3 = 1;
                    break;

                case ExComboBoxState.Hot:
                case ExComboBoxState.HotOnButton:
                case ExComboBoxState.Focused:
                case ExComboBoxState.FocusedOnButton:
                    num3 = 2;
                    break;

                case ExComboBoxState.PressButton:
                case ExComboBoxState.DropDown:
                    num3 = 3;
                    break;

                case ExComboBoxState.Disabled:
                    num3 = 4;
                    break;

                default:
                    num3 = 1;
                    break;
                }
                if (cbstate != ExComboBoxState.Disabled)
                {
                    num4 = 1;
                }
                else
                {
                    num4 = 4;
                }
                IntPtr hTheme = OpenThemeData(hWnd, "ComboBox");
                if (hTheme != IntPtr.Zero)
                {
                    RECT pRect = new RECT(borderArea.Left, borderArea.Top, borderArea.Right, borderArea.Bottom);
                    if (IsThemeBackgroundPartiallyTransparent(hTheme, 5, num3))
                    {
                        DrawThemeParentBackground(hTheme, hdc, ref pRect);
                    }
                    DrawThemeBackground(hTheme, hdc, 5, num3, ref pRect, IntPtr.Zero);
                    GetThemeBackgroundRegion(hTheme, hdc, 5, num3, ref pRect, ref zero);
                    DrawThemeBackground(hTheme, hDC, 5, num3, ref pRect, IntPtr.Zero);
                    pRect = new RECT(buttonArea.Left, buttonArea.Top, buttonArea.Right, buttonArea.Bottom);
                    DrawThemeBackground(hTheme, hDC, 6, num4, ref pRect, IntPtr.Zero);
                    CloseThemeData(hTheme);
                }
                goto Label_02E6;
            }
Label_020E:
            ptr5 = OpenThemeData(hWnd, "ComboBox");
            if (ptr5 != IntPtr.Zero)
            {
                RECT rect2 = new RECT(borderArea.Left, borderArea.Top, borderArea.Right, borderArea.Bottom);
                if (IsThemeBackgroundPartiallyTransparent(ptr5, 4, num5))
                {
                    DrawThemeParentBackground(ptr5, hdc, ref rect2);
                }
                DrawThemeBackground(ptr5, hdc, 4, num5, ref rect2, IntPtr.Zero);
                GetThemeBackgroundRegion(ptr5, hdc, 4, num5, ref rect2, ref zero);
                DrawThemeBackground(ptr5, hDC, 4, num5, ref rect2, IntPtr.Zero);
                rect2 = new RECT(buttonArea.Left, buttonArea.Top, buttonArea.Right, buttonArea.Bottom);
                DrawThemeBackground(ptr5, hDC, 6, num6, ref rect2, IntPtr.Zero);
                CloseThemeData(ptr5);
            }
Label_02E6:
            g.ReleaseHdc();
            graphics.ReleaseHdc();
            if ((overlayBitmap != null) && ((overlayBitmap.Width != width) || (overlayBitmap.Height != height)))
            {
                overlayBitmap.Dispose();
                overlayBitmap = null;
            }
            if ((overlayRate > 0f) && (overlayBitmap != null))
            {
                ColorMatrix newColorMatrix = new ColorMatrix
                {
                    Matrix00 = 1f,
                    Matrix11 = 1f,
                    Matrix22 = 1f,
                    Matrix33 = overlayRate,
                    Matrix44 = 1f
                };
                ImageAttributes imageAttr = new ImageAttributes();
                imageAttr.SetColorMatrix(newColorMatrix);
                graphics.DrawImage(overlayBitmap, new Rectangle(0, 0, width, height), 0, 0, width, height, GraphicsUnit.Pixel, imageAttr);
            }
            Region region = Region.FromHrgn(zero);
            Region clip   = g.Clip;

            g.Clip = region;
            g.DrawImage(resultBitmap, 0, 0);
            g.Clip = clip;
            region.Dispose();
            DeleteObject(zero);
        }