コード例 #1
0
ファイル: TXListView.cs プロジェクト: wwkkww1983/WMS
        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);
        }
コード例 #2
0
        protected override void OnRenderImageMargin(ToolStripRenderEventArgs e)
        {
            ToolStrip toolStrip = e.ToolStrip;
            Graphics  graphics  = e.Graphics;

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

            affectedBounds.Width--;
            affectedBounds.Height--;
            if (toolStrip is ToolStripDropDown)
            {
                affectedBounds.Width = _OffsetMargin;
                Color          menuImageMarginBackColor = MenuImageMarginBackColor;
                RoundRectangle roundRectangle           = new RoundRectangle(cornerRadius: new CornerRadius(MenuCornerRadius), rect: affectedBounds);
                GDIHelper.FillPath(graphics, new RoundRectangle(affectedBounds, new CornerRadius(MenuCornerRadius, 0, MenuCornerRadius, 0)), menuImageMarginBackColor, menuImageMarginBackColor);
                Image menuImageBackImage = MenuImageBackImage;
                if (menuImageBackImage != null && ShowMenuBackImage)
                {
                    ImageAttributes imageAttributes = new ImageAttributes();
                    GDIHelper.SetImageOpacity(imageAttributes, MenuImageBackImageOpacity);
                    graphics.DrawImage(Resources.logo_mini, new Rectangle(affectedBounds.X + 1, affectedBounds.Y + 2, menuImageBackImage.Width, menuImageBackImage.Height), 0, 0, menuImageBackImage.Width, menuImageBackImage.Height, GraphicsUnit.Pixel, imageAttributes);
                }
                Point pt  = new Point(affectedBounds.X + _OffsetMargin, affectedBounds.Y + 3);
                Point pt2 = new Point(affectedBounds.X + _OffsetMargin, affectedBounds.Bottom - 3);
                using (Pen pen = new Pen(SkinManager.CurrentSkin.BorderColor))
                {
                    graphics.DrawLine(pen, pt, pt2);
                }
            }
            else
            {
                base.OnRenderImageMargin(e);
            }
        }
コード例 #3
0
ファイル: TXListView.cs プロジェクト: wwkkww1983/WMS
 protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
 {
     base.OnDrawSubItem(e);
     if (base.View == View.Details && e.ItemIndex != -1)
     {
         Rectangle          bounds    = e.Bounds;
         ListViewItemStates itemState = e.ItemState;
         Graphics           graphics  = e.Graphics;
         GDIHelper.InitializeGraphics(graphics);
         Blend blend = new Blend();
         blend.Positions = new float[4]
         {
             0f,
             0.4f,
             0.7f,
             1f
         };
         blend.Factors = new float[4]
         {
             0f,
             0.3f,
             0.8f,
             0.2f
         };
         if ((itemState & ListViewItemStates.Selected) == ListViewItemStates.Selected)
         {
             Color selectedBeginColor = _SelectedBeginColor;
             Color selectedEndColor   = _SelectedEndColor;
             selectedBeginColor = SkinManager.CurrentSkin.HeightLightControlColor.First;
             selectedEndColor   = SkinManager.CurrentSkin.HeightLightControlColor.Second;
             blend.Factors      = SkinManager.CurrentSkin.HeightLightControlColor.Factors;
             blend.Positions    = SkinManager.CurrentSkin.HeightLightControlColor.Positions;
             GDIHelper.FillPath(graphics, new RoundRectangle(bounds, 0), selectedBeginColor, selectedEndColor, blend);
         }
         else
         {
             if (e.ColumnIndex == 0)
             {
                 bounds.Inflate(0, -1);
             }
             Color selectedBeginColor = (e.ItemIndex % 2 == 0) ? _RowBackColor1 : _RowBackColor2;
             Color selectedEndColor   = selectedBeginColor;
             GDIHelper.FillPath(graphics, new RoundRectangle(bounds, 0), selectedBeginColor, selectedEndColor, blend);
         }
         if (e.ColumnIndex == 0)
         {
             OnDrawFirstSubItem(e, graphics);
         }
         else
         {
             DrawNormalSubItem(e, graphics);
         }
     }
 }
コード例 #4
0
ファイル: TXTextBox.cs プロジェクト: wwkkww1983/WMS
        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);
            }
        }
コード例 #5
0
ファイル: TXListView.cs プロジェクト: wwkkww1983/WMS
            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);
                    }
                }
            }
コード例 #6
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);
            }
        }
コード例 #7
0
        protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e)
        {
            ToolStrip toolStrip = e.ToolStrip;
            Graphics  graphics  = e.Graphics;

            GDIHelper.InitializeGraphics(graphics);
            Rectangle      affectedBounds = e.AffectedBounds;
            RoundRectangle roundRect      = new RoundRectangle(cornerRadius: new CornerRadius(MenuCornerRadius), rect: affectedBounds);

            if (toolStrip is ToolStripDropDown || toolStrip is ContextMenuStrip)
            {
                CreateToolStripRegion(toolStrip, roundRect);
                GDIHelper.FillPath(graphics, roundRect, BackColor, BackColor);
            }
            else if (toolStrip is TXMenuStrip)
            {
                TXMenuStrip tXMenuStrip    = toolStrip as TXMenuStrip;
                Color       beginBackColor = tXMenuStrip.BeginBackColor;
                Color       endBackColor   = tXMenuStrip.EndBackColor;
                GDIHelper.FillPath(graphics, new RoundRectangle(affectedBounds, new CornerRadius(0)), beginBackColor, endBackColor);
            }
            else if (toolStrip is TXToolStrip)
            {
                affectedBounds.Inflate(1, 1);
                TXToolStrip tXToolStrip    = toolStrip as TXToolStrip;
                Color       beginBackColor = tXToolStrip.BeginBackColor;
                Color       endBackColor   = tXToolStrip.EndBackColor;
                GDIHelper.FillPath(graphics, new RoundRectangle(affectedBounds, new CornerRadius(0)), beginBackColor, endBackColor);
            }
            else if (toolStrip is TXStatusStrip)
            {
                TXStatusStrip tXStatusStrip  = toolStrip as TXStatusStrip;
                Color         beginBackColor = tXStatusStrip.BeginBackColor;
                Color         endBackColor   = tXStatusStrip.EndBackColor;
                GDIHelper.FillPath(graphics, new RoundRectangle(affectedBounds, new CornerRadius(0)), beginBackColor, endBackColor);
            }
        }
コード例 #8
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;
            }
        }
コード例 #9
0
        protected virtual void OnPaintUpDownButton(UpDownButtonPaintEventArgs e)
        {
            Graphics  graphics      = e.Graphics;
            Rectangle clipRectangle = e.ClipRectangle;
            Color     baseColor     = SkinManager.CurrentSkin.DefaultControlColor.First;
            Color     borderColor   = _BorderColor;
            Color     arrowColor    = Color.Green;
            Color     baseColor2    = SkinManager.CurrentSkin.DefaultControlColor.First;
            Color     borderColor2  = _BorderColor;
            Color     arrowColor2   = Color.Green;
            Rectangle rect          = clipRectangle;

            rect.X      += 2;
            rect.Y      += 2;
            rect.Width   = clipRectangle.Width / 2 - 4;
            rect.Height -= 4;
            Rectangle rect2 = clipRectangle;

            rect2.X       = rect.Right;
            rect2.Y      += 2;
            rect2.Width   = clipRectangle.Width / 2 - 4;
            rect2.Height -= 4;
            if (base.Enabled)
            {
                if (e.MouseOver)
                {
                    if (e.MousePress)
                    {
                        if (e.MouseInUpButton)
                        {
                            baseColor = SkinManager.CurrentSkin.HeightLightControlColor.First;
                        }
                        else
                        {
                            baseColor2 = SkinManager.CurrentSkin.HeightLightControlColor.First;
                        }
                    }
                    else if (e.MouseInUpButton)
                    {
                        baseColor = SkinManager.CurrentSkin.DefaultControlColor.First;
                    }
                    else
                    {
                        baseColor2 = SkinManager.CurrentSkin.DefaultControlColor.First;
                    }
                }
            }
            else
            {
                baseColor    = SystemColors.Control;
                borderColor  = SystemColors.ControlDark;
                arrowColor   = SystemColors.ControlDark;
                baseColor2   = SystemColors.Control;
                borderColor2 = SystemColors.ControlDark;
                arrowColor2  = SystemColors.ControlDark;
            }
            GDIHelper.FillPath(graphics, new RoundRectangle(clipRectangle, default(CornerRadius)), _BackColor, _BackColor);
            RenderButton(graphics, rect, baseColor, borderColor, arrowColor, ArrowDirection.Left);
            RenderButton(graphics, rect2, baseColor2, borderColor2, arrowColor2, ArrowDirection.Right);
            (base.Events[EventPaintUpDownButton] as UpDownButtonPaintEventHandler)?.Invoke(this, e);
        }