當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。