Example #1
0
        private void DrawBackGround(Graphics g)
        {
            GDIHelper.InitializeGraphics(g);
            Rectangle      rect      = new Rectangle(1, 1, base.Width - 3, base.Height - 3);
            RoundRectangle roundRect = new RoundRectangle(rect, new CornerRadius(_CornerRadius));

            switch (_ControlState)
            {
            case EnumControlState.Default:
                if (base.FlatStyle != 0)
                {
                    GDIHelper.FillRectangle(g, roundRect, SkinManager.CurrentSkin.DefaultControlColor);
                    GDIHelper.DrawPathBorder(g, roundRect);
                }
                break;

            case EnumControlState.HeightLight:
                GDIHelper.FillRectangle(g, roundRect, SkinManager.CurrentSkin.HeightLightControlColor);
                GDIHelper.DrawPathBorder(g, roundRect);
                break;

            case EnumControlState.Focused:
                GDIHelper.FillRectangle(g, roundRect, SkinManager.CurrentSkin.FocusedControlColor);
                GDIHelper.DrawPathBorder(g, roundRect);
                GDIHelper.DrawPathInnerBorder(g, roundRect);
                break;
            }
        }
Example #2
0
        protected override void OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e)
        {
            base.OnDrawColumnHeader(e);
            Graphics graphics = e.Graphics;

            GDIHelper.InitializeGraphics(graphics);
            Rectangle bounds = e.Bounds;

            GDIHelper.FillPath(graphics, new RoundRectangle(bounds, 0), _HeaderBeginColor, _HeaderEndColor);
            bounds.Height--;
            if (BorderStyle != 0)
            {
                using (Pen pen = new Pen(BorderColor))
                {
                    graphics.DrawLine(pen, new Point(bounds.Right, bounds.Bottom), new Point(bounds.Right, bounds.Top));
                    graphics.DrawLine(pen, new Point(bounds.Left, bounds.Bottom), new Point(bounds.Right, bounds.Bottom));
                }
            }
            else
            {
                GDIHelper.DrawPathBorder(graphics, new RoundRectangle(bounds, 0), _BorderColor);
            }
            bounds.Height++;
            TextFormatFlags formatFlags = GetFormatFlags(e.Header.TextAlign);
            Rectangle       rectangle   = new Rectangle(bounds.X + 3, bounds.Y, bounds.Width - 6, bounds.Height);
            Image           image       = null;
            Size            imageSize   = new Size(16, 16);
            Rectangle       empty       = Rectangle.Empty;

            if (e.Header.ImageList != null)
            {
                image = ((e.Header.ImageIndex == -1) ? null : e.Header.ImageList.Images[e.Header.ImageIndex]);
            }
            GDIHelper.DrawImageAndString(graphics, bounds, image, imageSize, e.Header.Text, _Font, e.ForeColor);
        }
Example #3
0
        protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
        {
            ToolStripItem item     = e.Item;
            Graphics      graphics = e.Graphics;

            GDIHelper.InitializeGraphics(graphics);
            if (item.Tag != null && item.Tag.Equals("Vicky"))
            {
                int       num  = (item.Width >= item.Height) ? item.Height : item.Width;
                Rectangle rect = new Rectangle(0, 0, num, num);
                rect.Inflate(-1, -1);
                Color empty      = Color.Empty;
                Color empty2     = Color.Empty;
                Color lightColor = Color.FromArgb(255, 220, 102);
                Blend blend      = new Blend();
                blend.Positions = new float[3]
                {
                    0f,
                    0.5f,
                    1f
                };
                blend.Factors = new float[3]
                {
                    0.25f,
                    0.75f,
                    1f
                };
                Color color = (item.Selected || item.Pressed) ? Color.FromArgb(24, 116, 205) : SkinManager.CurrentSkin.BorderColor;
                float width = 1f;
                graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
                if (item.Selected || item.Pressed)
                {
                    width  = 2f;
                    empty  = Color.FromArgb(255, 226, 48);
                    empty2 = Color.FromArgb(255, 220, 102);
                    GDIHelper.DrawCrystalButton(graphics, rect, empty, empty2, lightColor, blend);
                }
                using (Pen pen = new Pen(color, width))
                {
                    graphics.DrawEllipse(pen, rect);
                }
            }
            else
            {
                Rectangle      rect      = new Rectangle(1, 1, item.Width - 4, item.Height - 3);
                RoundRectangle roundRect = new RoundRectangle(rect, ItemCornerRadius);
                if (item.Selected || item.Pressed)
                {
                    GDIHelper.FillRectangle(graphics, roundRect, SkinManager.CurrentSkin.HeightLightControlColor);
                    GDIHelper.DrawPathBorder(graphics, roundRect);
                }
            }
        }
Example #4
0
        private void DrawDefaultBorder(Graphics g, Rectangle textRect)
        {
            Rectangle rect = default(Rectangle);

            rect.X      = 0;
            rect.Y      = textRect.Height / 2;
            rect.Height = base.Height - textRect.Height / 2 - 1;
            rect.Width  = base.Width - 1;
            RoundRectangle roundRect = new RoundRectangle(rect, new CornerRadius(_CornerRadius));

            g.SetClip(textRect, CombineMode.Exclude);
            GDIHelper.DrawPathBorder(g, roundRect, _BorderColor, _BorderWidth);
            g.ResetClip();
        }
Example #5
0
        protected override void OnRenderDropDownButtonBackground(ToolStripItemRenderEventArgs e)
        {
            ToolStripItem item     = e.Item;
            Graphics      graphics = e.Graphics;

            GDIHelper.InitializeGraphics(graphics);
            Rectangle      rect      = new Rectangle(0, 0, item.Width - 1, item.Height - 1);
            RoundRectangle roundRect = new RoundRectangle(rect, ItemCornerRadius);

            if (item.Selected || item.Pressed)
            {
                GDIHelper.FillRectangle(graphics, roundRect, SkinManager.CurrentSkin.HeightLightControlColor);
                GDIHelper.DrawPathBorder(graphics, roundRect);
            }
        }
Example #6
0
 private void DrawFormBorder(Graphics g)
 {
     if (base.WindowState != FormWindowState.Maximized)
     {
         Rectangle      rect           = new Rectangle(0, 0, base.Width - 2, base.Height - 2);
         RoundRectangle roundRectangle = new RoundRectangle(rect, new CornerRadius(CornerRadius));
         GDIHelper.DrawPathBorder(g, roundRectangle);
         using (GraphicsPath path = (_CornerRadius == 0) ? roundRectangle.ToGraphicsBezierPath() : roundRectangle.ToGraphicsArcPath())
         {
             using (Pen pen = new Pen(SkinManager.CurrentSkin.BorderColor))
             {
                 g.DrawPath(pen, path);
             }
         }
     }
 }
Example #7
0
        private void DrawComboBox(Graphics g)
        {
            GDIHelper.InitializeGraphics(g);
            Rectangle rect = new Rectangle(Point.Empty, base.Size);

            rect.Width--;
            rect.Height--;
            RoundRectangle roundRect = new RoundRectangle(rect, 0);
            Color          color     = base.Enabled ? _BackColor : SystemColors.Control;

            g.SetClip(EditRect, CombineMode.Exclude);
            GDIHelper.FillRectangle(g, roundRect, color);
            g.ResetClip();
            DrawButton(g);
            GDIHelper.DrawPathBorder(g, roundRect);
        }
Example #8
0
        private void DrawBorder(Graphics g)
        {
            GDIHelper.InitializeGraphics(g);
            Rectangle      rect      = new Rectangle(1, 1, base.Width - 3, base.Height - 3);
            RoundRectangle roundRect = new RoundRectangle(rect, _CornerRadius);
            Color          color     = (!_TextBox.Enabled || _TextBox.ReadOnly) ? Color.FromArgb(215, 250, 243) : Color.White;

            _TextBox.BackColor = color;
            GDIHelper.FillPath(g, roundRect, color, color);
            GDIHelper.DrawPathBorder(g, roundRect, _BorderColor);
            if (_ControlState == EnumControlState.HeightLight)
            {
                GDIHelper.DrawPathBorder(g, roundRect, SkinManager.CurrentSkin.HeightLightControlColor.Second);
                GDIHelper.DrawPathOuterBorder(g, roundRect, SkinManager.CurrentSkin.HeightLightControlColor.First);
            }
        }
Example #9
0
 private void NcPaint(ref Message msg)
 {
     if (base.BorderStyle != 0)
     {
         IntPtr windowDC = Win32.GetWindowDC(msg.HWnd);
         if (windowDC == IntPtr.Zero)
         {
             throw new Win32Exception();
         }
         Rectangle rect = new Rectangle(0, 0, base.Width - 1, base.Height - 1);
         using (Graphics g = Graphics.FromHdc(windowDC))
         {
             GDIHelper.DrawPathBorder(g, new RoundRectangle(rect, 0), _BorderColor);
         }
         msg.Result = IntPtr.Zero;
         Win32.ReleaseDC(msg.HWnd, windowDC);
     }
 }
Example #10
0
        private void DrawContent(Graphics g)
        {
            GDIHelper.InitializeGraphics(g);
            int       width     = base.Width;
            int       height    = base.Height;
            Rectangle rectangle = new Rectangle(_Margin, height / 2 - _BoxSize.Height / 2, _BoxSize.Width, _BoxSize.Height);
            Size      size      = g.MeasureString(Text, Font).ToSize();
            Rectangle rect      = default(Rectangle);

            rect.X      = rectangle.Right + _Margin;
            rect.Y      = _Margin;
            rect.Height = base.Height - _Margin * 2;
            rect.Width  = size.Width;
            RoundRectangle   roundRect    = new RoundRectangle(rectangle, _CornerRadius);
            EnumControlState controlState = _ControlState;

            if (controlState == EnumControlState.HeightLight)
            {
                GDIHelper.DrawPathBorder(g, roundRect, SkinManager.CurrentSkin.OuterBorderColor);
                GDIHelper.DrawPathInnerBorder(g, roundRect, SkinManager.CurrentSkin.HeightLightControlColor.First);
            }
            else
            {
                GDIHelper.DrawCheckBox(g, roundRect);
            }
            Color forceColor = base.Enabled ? ForeColor : SkinManager.CurrentSkin.UselessColor;

            GDIHelper.DrawImageAndString(g, rect, null, Size.Empty, Text, Font, forceColor);
            switch (base.CheckState)
            {
            case CheckState.Checked:
                GDIHelper.DrawCheckedStateByImage(g, rectangle);
                break;

            case CheckState.Indeterminate:
            {
                Rectangle rect2 = rectangle;
                rect2.Inflate(-3, -3);
                Color color = Color.FromArgb(46, 117, 35);
                GDIHelper.FillRectangle(g, new RoundRectangle(rect2, _CornerRadius), color);
                break;
            }
            }
        }
Example #11
0
        protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e)
        {
            ToolStrip toolStrip = e.ToolStrip;
            Graphics  graphics  = e.Graphics;

            GDIHelper.InitializeGraphics(graphics);
            Rectangle affectedBounds = e.AffectedBounds;

            if (toolStrip is ToolStripDropDown)
            {
                affectedBounds.Width--;
                affectedBounds.Height--;
                RoundRectangle roundRect = new RoundRectangle(cornerRadius: new CornerRadius(MenuCornerRadius), rect: affectedBounds);
                GDIHelper.DrawPathBorder(graphics, roundRect, MenuBorderColor);
            }
            else
            {
                base.OnRenderToolStripBorder(e);
            }
        }
Example #12
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            int      num      = (BorderWidth > 0) ? BorderWidth : 0;
            Graphics graphics = e.Graphics;

            GDIHelper.InitializeGraphics(graphics);
            GradientColor  color     = new GradientColor(_BackBeginColor, _BackEndColor, null, null);
            Rectangle      rect      = new Rectangle(0, 0, base.Size.Width - 1, base.Size.Height - 1);
            RoundRectangle roundRect = new RoundRectangle(rect, new CornerRadius(_CornerRadius));

            GDIHelper.FillRectangle(graphics, roundRect, color);
            if (_BorderWidth > 0)
            {
                rect.X      += _BorderWidth - 1;
                rect.Y      += _BorderWidth - 1;
                rect.Width  -= _BorderWidth - 1;
                rect.Height -= _BorderWidth - 1;
                GDIHelper.DrawPathBorder(graphics, new RoundRectangle(rect, new CornerRadius(_CornerRadius)), _BorderColor, BorderWidth);
            }
        }
Example #13
0
            protected override void WndProc(ref Message m)
            {
                base.WndProc(ref m);
                int msg = m.Msg;

                if (msg == 15 || msg == 71)
                {
                    IntPtr dC = Win32.GetDC(m.HWnd);
                    try
                    {
                        using (Graphics graphics = Graphics.FromHdc(dC))
                        {
                            Rectangle rect = _owner.HeaderEndRect();
                            GDIHelper.InitializeGraphics(graphics);
                            GDIHelper.FillPath(graphics, new RoundRectangle(rect, 0), _owner._HeaderBeginColor, _owner._HeaderEndColor);
                            rect.Width--;
                            rect.Height--;
                            if (_owner.BorderStyle != 0)
                            {
                                using (Pen pen = new Pen(_owner.BorderColor))
                                {
                                    graphics.DrawLine(pen, new Point(rect.Left, rect.Bottom), new Point(rect.Left, rect.Top));
                                    graphics.DrawLine(pen, new Point(rect.Right, rect.Bottom), new Point(rect.Right, rect.Top));
                                    graphics.DrawLine(pen, new Point(rect.Left, rect.Bottom), new Point(rect.Right, rect.Bottom));
                                }
                            }
                            else
                            {
                                GDIHelper.DrawPathBorder(graphics, new RoundRectangle(rect, 0), _owner._BorderColor);
                            }
                        }
                    }
                    finally
                    {
                        Win32.ReleaseDC(m.HWnd, dC);
                    }
                }
            }
Example #14
0
        internal void RenderButton(Graphics g, Rectangle rect, Color baseColor, Color borderColor, Color arrowColor, ArrowDirection direction)
        {
            CornerRadius cornerRadius = default(CornerRadius);

            switch (direction)
            {
            case ArrowDirection.Left:
                cornerRadius = new CornerRadius(2, 0, 2, 0);
                break;

            case ArrowDirection.Right:
                cornerRadius = new CornerRadius(0, 2, 0, 2);
                break;
            }
            RoundRectangle roundRect = new RoundRectangle(rect, cornerRadius);

            GDIHelper.FillPath(g, roundRect, baseColor, baseColor);
            GDIHelper.DrawPathBorder(g, roundRect);
            using (SolidBrush brush = new SolidBrush(arrowColor))
            {
                RenderArrowInternal(g, rect, direction, brush);
            }
        }
Example #15
0
        private void DrawTabPages(Graphics g)
        {
            Point pt    = PointToClient(Control.MousePosition);
            bool  flag  = false;
            bool  flag2 = base.Alignment == TabAlignment.Top || base.Alignment == TabAlignment.Bottom;
            LinearGradientMode linearGradientMode = flag2 ? LinearGradientMode.Vertical : LinearGradientMode.Horizontal;

            if (flag2)
            {
                IntPtr upDownButtonHandle = UpDownButtonHandle;
                if (upDownButtonHandle != IntPtr.Zero && Win32.IsWindowVisible(upDownButtonHandle))
                {
                    RECT lpRect = default(RECT);
                    Win32.GetWindowRect(upDownButtonHandle, ref lpRect);
                    Rectangle r = Rectangle.FromLTRB(lpRect.left, lpRect.top, lpRect.right, lpRect.bottom);
                    r = RectangleToClient(r);
                    switch (base.Alignment)
                    {
                    case TabAlignment.Top:
                        r.Y = 0;
                        break;

                    case TabAlignment.Bottom:
                        r.Y = base.ClientRectangle.Height - DisplayRectangle.Height;
                        break;
                    }
                    r.Height = base.ClientRectangle.Height;
                    g.SetClip(r, CombineMode.Exclude);
                    flag = true;
                }
            }
            for (int i = 0; i < base.TabCount; i++)
            {
                TabPage   tabPage     = base.TabPages[i];
                Rectangle tabRect     = GetTabRect(i);
                bool      flag3       = tabRect.Contains(pt);
                bool      flag4       = base.SelectedIndex == i;
                Color     color       = _BaseTabolor;
                Color     borderColor = _BorderColor;
                Blend     blend       = new Blend();
                blend.Positions = new float[5]
                {
                    0f,
                    0.3f,
                    0.5f,
                    0.7f,
                    1f
                };
                blend.Factors = new float[5]
                {
                    0.1f,
                    0.3f,
                    0.5f,
                    0.8f,
                    1f
                };
                if (flag4)
                {
                    color = _CheckedTabColor;
                }
                else if (flag3)
                {
                    color           = _HeightLightTabColor;
                    blend.Positions = new float[5]
                    {
                        0f,
                        0.3f,
                        0.6f,
                        0.8f,
                        1f
                    };
                    blend.Factors = new float[5]
                    {
                        0.2f,
                        0.4f,
                        0.6f,
                        0.5f,
                        0.4f
                    };
                }
                Rectangle rect = new Rectangle(tabRect.Left, tabRect.Bottom, tabRect.Width, 1);
                g.SetClip(rect, CombineMode.Exclude);
                CornerRadius cornerRadius = new CornerRadius(_TabCornerRadius, _TabCornerRadius, 0, 0);
                tabRect.X     += _TabMargin;
                tabRect.Width -= _TabMargin;
                tabRect.Y++;
                tabRect.Height--;
                RoundRectangle roundRect = new RoundRectangle(tabRect, cornerRadius);
                GDIHelper.InitializeGraphics(g);
                switch (_TabStyle)
                {
                case EnumTabStyle.AnglesWing:
                    cornerRadius   = new CornerRadius(_TabCornerRadius);
                    tabRect.X     += _TabCornerRadius;
                    tabRect.Width -= _TabCornerRadius * 2;
                    roundRect      = new RoundRectangle(tabRect, cornerRadius);
                    using (GraphicsPath path = roundRect.ToGraphicsAnglesWingPath())
                    {
                        using (LinearGradientBrush linearGradientBrush = new LinearGradientBrush(roundRect.Rect, color, _BackColor, LinearGradientMode.Vertical))
                        {
                            linearGradientBrush.Blend = blend;
                            g.FillPath(linearGradientBrush, path);
                        }
                    }
                    using (GraphicsPath path = roundRect.ToGraphicsAnglesWingPath())
                    {
                        using (Pen pen = new Pen(_BorderColor, 1f))
                        {
                            g.DrawPath(pen, path);
                        }
                    }
                    break;

                case EnumTabStyle.Default:
                    GDIHelper.FillPath(g, roundRect, color, _BackColor, blend);
                    GDIHelper.DrawPathBorder(g, roundRect, _BorderColor);
                    break;
                }
                g.ResetClip();
                if (base.Alignment == TabAlignment.Top)
                {
                    Image image     = null;
                    Size  imageSize = Size.Empty;
                    if (base.ImageList != null && tabPage.ImageIndex >= 0)
                    {
                        image     = base.ImageList.Images[tabPage.ImageIndex];
                        imageSize = image.Size;
                    }
                    GDIHelper.DrawImageAndString(g, tabRect, image, imageSize, tabPage.Text, _CaptionFont, _CaptionForceColor);
                }
                else
                {
                    bool hasImage = DrawTabImage(g, tabPage, tabRect);
                    DrawtabText(g, tabPage, tabRect, hasImage);
                }
            }
            if (flag)
            {
                g.ResetClip();
            }
            if (base.SelectedIndex > -1)
            {
                bool flag5 = true;
            }
        }