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


C# Graphics.DrawRoundedRectangle方法代码示例

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


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

示例1: OnDraw

        public override void OnDraw(Graphics g)
        {
            Brush brush = null;
            Pen pen = null;

            try
            {
                if (FillColor.A > 0)
                {
                    brush = new SolidBrush(FillColor);
                }

                if (BorderSize > 0 && BorderColor.A > 0)
                {
                    pen = new Pen(BorderColor, BorderSize);
                }

                g.SmoothingMode = SmoothingMode.HighQuality;
                g.DrawRoundedRectangle(brush, pen, Rectangle, Radius);
                g.SmoothingMode = SmoothingMode.None;
            }
            finally
            {
                if (brush != null) brush.Dispose();
                if (pen != null) pen.Dispose();
            }
        }
开发者ID:Grifs99,项目名称:ShareX,代码行数:27,代码来源:RoundedRectangleDrawingShape.cs

示例2: OnDraw

        public override void OnDraw(Graphics g)
        {
            Brush brush = null;
            Pen pen = null;

            try
            {
                if (FillColor.A > 0)
                {
                    brush = new SolidBrush(FillColor);
                }

                if (BorderSize > 0 && BorderColor.A > 0)
                {
                    pen = new Pen(BorderColor, BorderSize);
                }

                if (CornerRadius > 0)
                {
                    g.SmoothingMode = SmoothingMode.HighQuality;

                    if (BorderSize.IsEvenNumber())
                    {
                        g.PixelOffsetMode = PixelOffsetMode.Half;
                    }
                }

                g.DrawRoundedRectangle(brush, pen, Rectangle, CornerRadius);

                g.SmoothingMode = SmoothingMode.None;
                g.PixelOffsetMode = PixelOffsetMode.Default;
            }
            finally
            {
                if (brush != null) brush.Dispose();
                if (pen != null) pen.Dispose();
            }
        }
开发者ID:ElectronicWar,项目名称:ShareX,代码行数:38,代码来源:RectangleDrawingShape.cs

示例3: Draw

 public void Draw(Graphics g, Rectangle rect)
 {
     using(var b = GetBackgroundBrush(rect.Y + 1, rect.Bottom - 2))
     {
         g.FillRectangle(b, rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2);
     }
     g.DrawRectangle(InnerBorderPen, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3);
     g.DrawRoundedRectangle(OuterBorderPen, rect, 2);
 }
开发者ID:Kuzq,项目名称:gitter,代码行数:9,代码来源:BackgroundStyle.cs

示例4: DrawSelection

        public static void DrawSelection(Graphics g, Rectangle r, Color c)
        {
            //we're attempting to closely emulate the Explorer::TreeView selection style
            //it renders to a rectangle 1 less wide and high
            r.Width -= 1;
            r.Height -= 1;

            float rounding = 2.0f;
            Brush brush = new LinearGradientBrush(r, AlphaBlend(20, c),
                AlphaBlend(120, c), LinearGradientMode.Vertical);
            g.FillRoundedRectangle(brush, r, rounding);

            g.SmoothingMode = SmoothingMode.AntiAlias;
            brush = new SolidBrush(Color.FromArgb(127 * c.A / 255, Color.White));
            g.DrawRoundedRectangle(new Pen(brush, 1.0f), Rectangle.Inflate(r, -1, -1), rounding);
            brush = new SolidBrush(AlphaBlend(255, c));
            g.DrawRoundedRectangle(new Pen(brush, 1.0f), r, rounding);
        }
开发者ID:NicholasVanSickle,项目名称:C--Winforms-Dynamic-Tree-View,代码行数:18,代码来源:FakeNativeTreeStyleRenderer.cs

示例5: DrawBorder

        public override void DrawBorder(Graphics graphics)
        {
            Guard.NotNull(graphics, nameof(graphics));

            using (var fontCopy = new Font(Font, State == ShapeState.Selected ? FontStyle.Bold : FontStyle.Regular))
            {
                graphics.DrawString(text, fontCopy, Brushes.Black, new RectangleF(topLeft, boxRect.Size),
                    new StringFormat
                    {
                        Alignment = StringAlignment.Center,
                        LineAlignment = StringAlignment.Center,
                        FormatFlags = StringFormatFlags.NoWrap
                    });

                graphics.DrawRoundedRectangle(Pens.Black, boxRect, 7);
            }
        }
开发者ID:bkoelman,项目名称:DogAgilityCompetitionManagement,代码行数:17,代码来源:TextBlock.cs

示例6: DrawTips

        private void DrawTips(Graphics g)
        {
            int offset = 10;
            int padding = 3;

            string tipText;

            if (isDrawingMode)
            {
                tipText = Resources.RectangleAnnotate_DrawTips_Drawing_mode_on;
            }
            else
            {
                tipText = Resources.RectangleAnnotate_DrawTips_Drawing_mode_off;
            }

            Size textSize = g.MeasureString(tipText, tipFont).ToSize();
            int rectWidth = textSize.Width + padding * 2;
            int rectHeight = textSize.Height + padding * 2;
            Rectangle primaryScreenBounds = CaptureHelpers.GetPrimaryScreenBounds0Based();
            Rectangle textRectangle = new Rectangle(primaryScreenBounds.X + (primaryScreenBounds.Width / 2) - (rectWidth / 2), primaryScreenBounds.Y + offset, rectWidth, rectHeight);

            if (textRectangle.Offset(10).Contains(CurrentMousePosition0Based))
            {
                textRectangle.Y = primaryScreenBounds.Height - rectHeight - offset;
            }

            using (Brush brush = new SolidBrush(Color.FromArgb(175, Color.White)))
            using (Pen pen = new Pen(Color.FromArgb(175, Color.Black)))
            {
                g.DrawRoundedRectangle(brush, pen, textRectangle, 5);
            }

            using (StringFormat sf = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center })
            {
                g.DrawString(tipText, tipFont, Brushes.Black, textRectangle, sf);
            }
        }
开发者ID:BallisticLingonberries,项目名称:ShareX,代码行数:38,代码来源:RectangleAnnotate.cs

示例7: RoundeRectangle1

        // Example code taken from here : http://www.codeproject.com/Articles/38436/Extended-Graphics-Rounded-rectangles-Font-metrics
        // Wanted to test the graphics path and LinearGradientBrush code together.
        void RoundeRectangle1(Graphics g)
        {
            var width = this.ClientRectangle.Width;
            var height = this.ClientRectangle.Height;

            var GradientInactiveCaption = Color.FromArgb (255, 215, 228, 242);
            var GradientActiveCaptionDark2 = Color.FromArgb (255, 52, 112, 171);
            var GradientActiveCaptionDark5 = Color.FromArgb (255, 33, 79, 107);
            var InactiveBorderLight = Color.FromArgb (255, 143, 247, 253);

            g.SmoothingMode = SmoothingMode.AntiAlias;
            g.FillRoundedRectangle(new SolidBrush(GradientActiveCaptionDark2), 10, 10, width - 40, height - 60, 10);
            LinearGradientBrush brush = new LinearGradientBrush(
                new Point(width/2, 0),
                new Point(width/2, height),
                GradientInactiveCaption,
                GradientActiveCaptionDark5
                );
            g.FillRoundedRectangle(brush, 12, 12, width - 44, height - 64, 10);
            g.DrawRoundedRectangle(new Pen(InactiveBorderLight), 12, 12, width - 44, height - 64, 10);
            g.FillRoundedRectangle(new SolidBrush(Color.FromArgb(100, 70, 130, 180)), 12, 12 + ((height - 64) / 2), width - 44, (height - 64)/2, 10);
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:24,代码来源:DrawingView.cs

示例8: DrawBackground

        private void DrawBackground(Graphics g)
        {
            g.SetHighQuality();

            if (isHover)
            {
                g.DrawRoundedRectangle(backgroundHoverBrush, borderPen, new Rectangle(0, 0, ClientSize.Width - 1, ClientSize.Height - 1), 2);
            }
            else
            {
                g.DrawRoundedRectangle(backgroundBrush, borderPen, new Rectangle(0, 0, ClientSize.Width - 1, ClientSize.Height - 1), 2);
            }
        }
开发者ID:noscripter,项目名称:ShareX,代码行数:13,代码来源:GreenlightButton.cs

示例9: DrawRectangle

        protected void DrawRectangle(Graphics g, Color borderColor, int borderSize, Color fillColor, Rectangle rect, int cornerRadius)
        {
            Brush brush = null;
            Pen pen = null;

            try
            {
                if (fillColor.A > 0)
                {
                    brush = new SolidBrush(fillColor);
                }

                if (borderSize > 0 && borderColor.A > 0)
                {
                    pen = new Pen(borderColor, borderSize);
                }

                if (cornerRadius > 0)
                {
                    g.SmoothingMode = SmoothingMode.HighQuality;

                    if (borderSize.IsEvenNumber())
                    {
                        g.PixelOffsetMode = PixelOffsetMode.Half;
                    }
                }

                g.DrawRoundedRectangle(brush, pen, rect, cornerRadius);

                g.SmoothingMode = SmoothingMode.None;
                g.PixelOffsetMode = PixelOffsetMode.Default;
            }
            finally
            {
                if (brush != null) brush.Dispose();
                if (pen != null) pen.Dispose();
            }
        }
开发者ID:L1Q,项目名称:ShareX,代码行数:38,代码来源:RectangleDrawingShape.cs


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