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


C# Graphics.DrawPath方法代码示例

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


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

示例1: OnPaint

    protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
    {
        G = e.Graphics;
        G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

        G.Clear(BackColor);
        G.SmoothingMode = SmoothingMode.AntiAlias;

        GP1 = ThemeModule.CreateRound(0, 0, Width - 1, Height - 1, 7);
        GP2 = ThemeModule.CreateRound(1, 1, Width - 3, Height - 3, 7);

        if (IsMouseDown)
        {
            PB1 = new PathGradientBrush(GP1);
            PB1.CenterColor = Color.FromArgb(60, 60, 60);
            PB1.SurroundColors = new Color[] { Color.FromArgb(55, 55, 55) };
            PB1.FocusScales = new PointF(0.8f, 0.5f);

            G.FillPath(PB1, GP1);
        }
        else
        {
            GB1 = new LinearGradientBrush(ClientRectangle, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90f);
            G.FillPath(GB1, GP1);
        }

        G.DrawPath(P1, GP1);
        G.DrawPath(P2, GP2);

        SZ1 = G.MeasureString(Text, Font);
        PT1 = new PointF(5, Height / 2 - SZ1.Height / 2);

        if (IsMouseDown)
        {
            PT1.X += 1f;
            PT1.Y += 1f;
        }

        G.DrawString(Text, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1);
        G.DrawString(Text, Font, Brushes.White, PT1);
    }
开发者ID:stimpy76,项目名称:OpenMuS9,代码行数:41,代码来源:NSTheme.cs

示例2: Run

        public static void Run()
        {
            // ExStart:DrawingUsingGraphicsPath
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_DrawingAndFormattingImages();

            // Create an instance of BmpOptions and set its various properties
            BmpOptions ImageOptions = new BmpOptions();
            ImageOptions.BitsPerPixel = 24;

            // Create an instance of FileCreateSource and assign it to Source property
            ImageOptions.Source = new FileCreateSource(dataDir + "sample_1.bmp", false);

            // Create an instance of Image and initialize an instance of Graphics
            using (Image image = Image.Create(ImageOptions, 500, 500))
            {
                Graphics graphics = new Graphics(image);
                graphics.Clear(Color.White);

                // Create an instance of GraphicsPath and Instance of Figure, add EllipseShape, RectangleShape and TextShape to the figure
                GraphicsPath graphicspath = new GraphicsPath();
                Figure figure = new Figure();
                figure.AddShape(new EllipseShape(new RectangleF(0, 0, 499, 499)));
                figure.AddShape(new RectangleShape(new RectangleF(0, 0, 499, 499)));
                figure.AddShape(new TextShape("Aspose.Imaging", new RectangleF(170, 225, 170, 100), new Font("Arial", 20), StringFormat.GenericTypographic));
                graphicspath.AddFigures(new[] { figure });
                graphics.DrawPath(new Pen(Color.Blue), graphicspath);

                // Create an instance of HatchBrush and set its properties also Fill path by supplying the brush and GraphicsPath objects
                HatchBrush hatchbrush = new HatchBrush();
                hatchbrush.BackgroundColor = Color.Brown;
                hatchbrush.ForegroundColor = Color.Blue;
                hatchbrush.HatchStyle = HatchStyle.Vertical;
                graphics.FillPath(hatchbrush, graphicspath);
                image.Save();
                Console.WriteLine("Processing completed successfully.");
            }
            // ExEnd:DrawingUsingGraphicsPath
        }
开发者ID:aspose-imaging,项目名称:Aspose.Imaging-for-.NET,代码行数:39,代码来源:DrawingUsingGraphicsPath.cs

示例3: OnPaint

    protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
    {
        G = e.Graphics;
        G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

        G.Clear(BackColor);
        G.SmoothingMode = SmoothingMode.AntiAlias;

        GP1 = ThemeModule.CreateRound(0, 0, Width - 1, Height - 1, 7);
        GP2 = ThemeModule.CreateRound(1, 1, Width - 3, Height - 3, 7);

        PB1 = new PathGradientBrush(GP1);
        PB1.CenterColor = Color.FromArgb(50, 50, 50);
        PB1.SurroundColors = new Color[] { Color.FromArgb(45, 45, 45) };
        PB1.FocusScales = new PointF(0.3f, 0.3f);

        G.FillPath(PB1, GP1);
        G.DrawPath(P1, GP1);
        G.DrawPath(P2, GP2);

        R1 = new Rectangle(5, 0, Width - 10, Height + 2);
        R2 = new Rectangle(6, 1, Width - 10, Height + 2);

        R3 = new Rectangle(1, 1, (Width / 2) - 1, Height - 3);

        if (_Checked)
        {
            G.DrawString("On", Font, Brushes.Black, R2, SF1);
            G.DrawString("On", Font, Brushes.White, R1, SF1);

            R3.X += (Width / 2) - 1;
        }
        else {
            G.DrawString("Off", Font, B1, R2, SF2);
            G.DrawString("Off", Font, B2, R1, SF2);
        }

        GP3 = ThemeModule.CreateRound(R3, 7);
        GP4 = ThemeModule.CreateRound(R3.X + 1, R3.Y + 1, R3.Width - 2, R3.Height - 2, 7);

        GB1 = new LinearGradientBrush(ClientRectangle, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90f);

        G.FillPath(GB1, GP3);
        G.DrawPath(P2, GP3);
        G.DrawPath(P3, GP4);

        Offset = R3.X + (R3.Width / 2) - 3;

        for (int I = 0; I <= 1; I++)
        {
            if (_Checked)
            {
                G.FillRectangle(B1, Offset + (I * 5), 7, 2, Height - 14);
            }
            else {
                G.FillRectangle(B3, Offset + (I * 5), 7, 2, Height - 14);
            }

            G.SmoothingMode = SmoothingMode.None;

            if (_Checked)
            {
                G.FillRectangle(B4, Offset + (I * 5), 7, 2, Height - 14);
            }
            else {
                G.FillRectangle(B5, Offset + (I * 5), 7, 2, Height - 14);
            }

            G.SmoothingMode = SmoothingMode.AntiAlias;
        }
    }
开发者ID:massimoca,项目名称:Wedit,代码行数:71,代码来源:Theme.cs

示例4: DrawDocumentTab

                public static void DrawDocumentTab(Graphics g, Rectangle rect, Color backColorBegin, Color backColorEnd, Color edgeColor, TabDrawType tabType, bool closed)
                {
                    GraphicsPath path;
                    Region Region;
                    Brush brush = null;
                    Pen pen;
                    brush = new LinearGradientBrush(rect, backColorBegin, backColorEnd, LinearGradientMode.Vertical);
                    pen = new pen(edgeColor, 1.0F);
                    path = new GraphicsPath();

                    if (tabType == TabDrawType.First)
                    {
                        path.AddLine(rect.Left + 1, rect.Bottom + 1, rect.Left + rect.Height, rect.Top + 2);
                        path.AddLine(rect.Left + rect.Height + 4, rect.Top, rect.Right - 3, rect.Top);
                        path.AddLine(rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom + 1);
                    }
                    else
                    {
                        if (tabType == TabDrawType.Active)
                        {
                            path.AddLine(rect.Left + 1, rect.Bottom + 1, rect.Left + rect.Height, rect.Top + 2);
                            path.AddLine(rect.Left + rect.Height + 4, rect.Top, rect.Right - 3, rect.Top);
                            path.AddLine(rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom + 1);
                        }
                        else
                        {
                            path.AddLine(rect.Left, rect.Top + 6, rect.Left + 4, rect.Top + 2);
                            path.AddLine(rect.Left + 8, rect.Top, rect.Right - 3, rect.Top);
                            path.AddLine(rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom + 1);
                            path.AddLine(rect.Right - 1, rect.Bottom + 1, rect.Left, rect.Bottom + 1);
                        }
                    }
                    Region = new Region(path);
                    g.FillRegion(brush, Region);
                    g.DrawPath(pen, path);
                }
开发者ID:okyereadugyamfi,项目名称:softlogik,代码行数:36,代码来源:DrawHelper.cs

示例5: updateClock

    /*
    private void updateClock() {
        lblSongTime.Text = timeToString(coolProgressBar1.Value) + " / " + timeToString(coolProgressBar1.Maximum);
        lblSongTime.Refresh();
    }
     */
    private void RenderText(Graphics g)
    {
        g.SmoothingMode = SmoothingMode.AntiAlias;
        g.CompositingQuality = CompositingQuality.HighQuality;
        g.CompositingMode = CompositingMode.SourceOver;

        String text = valueToString(this.Value) + " / " + valueToString(this.Maximum);

        GraphicsPath stroke = new GraphicsPath();
        stroke.AddString(text, this.Font.FontFamily, (int)FontStyle.Regular, this.Font.Size * 1.2f, new Point(0, 0), StringFormat.GenericDefault);
        RectangleF bounds = stroke.GetBounds();
        /* Align right */
        Matrix translationMatrix = new Matrix();
        translationMatrix.Translate((this.Width - bounds.Width - 8) / 2, (this.Height - bounds.Height - 5) / 2);
        stroke.Transform(translationMatrix);
        g.DrawPath(new Pen(Brushes.Black, 3.0f), stroke); /* Stroke */
        g.FillPath(Brushes.White, stroke); /* Text */
    }
开发者ID:klange,项目名称:acoustics-windows,代码行数:24,代码来源:CoolProgressBar.cs

示例6: Paint


//.........这里部分代码省略.........
							// draw with a path instead
							float emSize = g.DpiX * f.SizeInPoints / 72f;
							path.AddString(word.Text, f.FontFamily, (int)f.Style, emSize, new PointF(word.Left - word.LastMeasureOffset.X + offset.X, word.Top + offset.Y), StringFormat.GenericDefault);
							gradientPath.AddString(word.Text, f.FontFamily, (int)f.Style, emSize, new PointF(word.Left - word.LastMeasureOffset.X + offset.X, word.Top + offset.Y), StringFormat.GenericDefault);

							if (body.ActualTextGlowColor.IsEmpty == false)
							{
								// draw a glow around the text
								int glowSize = Convert.ToInt32(emSize / 2.5);
								using (Bitmap glowBitmap = new Bitmap(Convert.ToInt32(word.Width) + glowSize, Convert.ToInt32(word.Height) + glowSize))
								{
									using (Graphics glowGraphics = Graphics.FromImage(glowBitmap))
									{
										using (GraphicsPath glowTextPath = new GraphicsPath())
										{
											// draw only the word in the corner, we'll place it onto the parent graphics in the right location later
											glowTextPath.AddString(word.Text, f.FontFamily, (int)f.Style, emSize, new PointF(0, 0), StringFormat.GenericDefault);
											using (Pen widen = new Pen(System.Drawing.Color.Black, glowSize / 2))
												glowTextPath.Widen(widen);

											using (Brush glowBrush = new SolidBrush(body.ActualTextGlowColor))
												glowGraphics.FillPath(glowBrush, glowTextPath);
										}
										Convolution.BoxFilter boxFilter = new Convolution.BoxFilter();
										// 3 box filters approximate a gaussian blur
										using (Bitmap bm2 = boxFilter.FastBoxBlur(glowBitmap, 4))
										using (Bitmap bm3 = boxFilter.FastBoxBlur(bm2, 4))
										using (Bitmap blurred = boxFilter.FastBoxBlur(bm3, 4))
											g.DrawImage(blurred, word.Left - word.LastMeasureOffset.X + offset.X - 2, word.Top + offset.Y - 2);
									}
								}
							}

							// draw actual text
							if (body.ActualTextGradientColor.IsEmpty)
							{
								using (SolidBrush textBrush = new SolidBrush(CssValue.GetActualColor(Color)))
									g.FillPath(textBrush, path);

								// and then the outline on top of the text
								if (body != null && body.ActualTextOutline > 0 && body.ActualTextOutlineColor.IsEmpty == false)
								{
									using (Pen pen = new Pen(body.ActualTextOutlineColor, body.ActualTextOutline))
										g.DrawPath(pen, path);
								}
							}
						}
					}

					if (body.ActualTextGradientColor.IsEmpty == false)
					{
						using (LinearGradientBrush textBrush = new LinearGradientBrush(body.Bounds, CssValue.GetActualColor(Color), body.ActualTextGradientColor, body.ActualTextGradientAngle))
							g.FillPath(textBrush, gradientPath);

						// and then the outline on top of the text
						if (body != null && body.ActualTextOutline > 0 && body.ActualTextOutlineColor.IsEmpty == false)
						{
							using (Pen pen = new Pen(body.ActualTextOutlineColor, body.ActualTextOutline))
								g.DrawPath(pen, gradientPath);
						}
					}
				}
			}
            for (int i = 0; i < rects.Length; i++)
            {
                RectangleF actualRect = rects[i]; actualRect.Offset(offset);

				if (CssDefaults.SystemTextDirectionRTL && InitialContainer != null)
				{
					switch (TextAlign)
					{
						case CssConstants.Right:
							actualRect.Offset(0 - (InitialContainer.Bounds.Width - actualRect.Width), 0);
							break;
						case CssConstants.Center:
							if(Words.Count > 0)
								actualRect.Offset(0 - actualRect.Width, 0);
							break;
						/*case CssConstants.Justify:*/
						default:
							actualRect.Offset(InitialContainer.Bounds.Width - actualRect.Width, 0);
							break;
					}
				}

                PaintDecoration(g, actualRect, i == 0, i == rects.Length - 1);
            }
            
            foreach (CssBox b in Boxes)
            {
                b.Paint(g);
            }

            CreateListItemBox(g);

            if (ListItemBox != null)
            {
                ListItemBox.Paint(g);
            }
        }
开发者ID:BDizzle,项目名称:System.Drawing.Html,代码行数:101,代码来源:CssBox.cs

示例7: Render

    internal override void Render(Graphics g)
    {
        UpdateGP();

        Brush brush;
        if (anchored)
            brush = new HatchBrush(HatchStyle.HorizontalBrick,Color.DarkGray,fillcolor);
        else
            brush = new SolidBrush(fillcolor);

        g.FillPath(brush,gp);
        g.DrawPath(Pens.Black,gp);

        brush.Dispose();

        Point cg = CG;
        g.FillRectangle(Brushes.Black,cg.X-30,cg.Y-30,61,61);
    }
开发者ID:pichiliani,项目名称:CoPhysicsSimulator,代码行数:18,代码来源:MagicObjects.cs

示例8: OnPaint

    protected override void OnPaint(PaintEventArgs e)
    {
        G = e.Graphics;

        base.OnPaint(e);

        G.Clear(Parent.BackColor);

        if (Enabled)
        {
            using (SolidBrush Back = new SolidBrush(Color.FromArgb(34, 34, 33)))
            {
                G.FillPath(Back, Helpers.RoundRect(new Rectangle(0, 0, 16, 16), 1));
            }

            using (Pen Border = new Pen(Color.FromArgb(33, 33, 32)))
            {
                G.DrawPath(Border, Helpers.RoundRect(new Rectangle(0, 0, 16, 16), 1));
            }

            using (SolidBrush TextBrush = new SolidBrush(Color.FromArgb(220, 220, 219)))
            {
                using (Font TextFont = new Font("Segoe UI", 9))
                {
                    G.DrawString(Text, TextFont, TextBrush, new Point(22, 0));
                }
            }

            if (Checked)
            {
                using (SolidBrush TextBrush = new SolidBrush(Color.FromArgb(220, 220, 219)))
                {
                    using (Font TextFont = new Font("Marlett", 12))
                    {
                        G.DrawString("b", TextFont, TextBrush, new Point(-2, 1));
                    }
                }

            }

        }
        else
        {
            using (SolidBrush Back = new SolidBrush(Color.FromArgb(37, 37, 36)))
            {
                G.FillPath(Back, Helpers.RoundRect(new Rectangle(0, 0, 16, 16), 1));
            }

            using (Pen Border = new Pen(Color.FromArgb(36, 36, 35)))
            {
                G.DrawPath(Border, Helpers.RoundRect(new Rectangle(0, 0, 16, 16), 1));
            }

            using (SolidBrush TextBrush = new SolidBrush(Color.FromArgb(130, 130, 129)))
            {
                using (Font TextFont = new Font("Segoe UI", 9))
                {
                    G.DrawString(Text, TextFont, TextBrush, new Point(22, 0));
                }
            }

            if (Checked)
            {
                using (SolidBrush TextBrush = new SolidBrush(Color.FromArgb(130, 130, 129)))
                {
                    using (Font TextFont = new Font("Marlett", 12))
                    {
                        G.DrawString("b", TextFont, TextBrush, new Point(-2, 1));
                    }
                }

            }

        }
    }
开发者ID:RedNax67,项目名称:GoBot,代码行数:75,代码来源:DarkTheme.cs

示例9: DrawOuterStroke

 /// <summary>
 /// Draws the outer border for the control
 /// using the ButtonColor property.
 /// </summary>
 /// <param name="g">The graphics object used in the paint event.</param>
 private void DrawOuterStroke(Graphics g)
 {
     if (this.ButtonStyle == Style.Flat && this.mButtonState == State.None) { return; }
     Rectangle r = this.ClientRectangle;
     r.Width -= 1; r.Height -= 1;
     using (GraphicsPath rr = RoundRect(r, CornerRadius, CornerRadius, CornerRadius, CornerRadius))
         {
         using (Pen p = new Pen(this.ButtonColor))
             {
             g.DrawPath(p, rr);
             }
         }
 }
开发者ID:RobertFurer,项目名称:Picasso23,代码行数:18,代码来源:VistaButton.cs

示例10: Draw3DBorder

    private void Draw3DBorder(Graphics g, float offset, Brush color, bool fill, float r, float percent)
    {
        int pen_width = 2;
        float x = this.ClientRectangle.Left + (pen_width / 2) + offset;
        float y = this.ClientRectangle.Top + (pen_width / 2) + offset;
        float w = (this.ClientRectangle.Width - (pen_width / 2 + 2 + offset * 2)) * percent;
        float h = this.ClientRectangle.Height - (pen_width / 2 + 2 + offset * 2);

        Pen pen = new Pen(color, (float)pen_width);
        GraphicsPath path = new GraphicsPath();

        if (w < 2 * r) {
            w = 2 * r;
        }

        path.AddLine(x + r, y, x + (w - r * 2), y);
        path.AddArc(x + w - r * 2, y, r * 2, r * 2, 270, 90);
        path.AddLine(x + w, y + r, x + w, y + h - r * 2);
        path.AddArc(x + w - r * 2, y + h - r * 2, r * 2, r * 2, 0, 90);
        path.AddLine(x + w - r * 2, y + h, x + r, y + h);
        path.AddArc(x, y + h - r * 2, r * 2, r * 2, 90, 90);
        path.AddLine(x, y + h - r * 2, x, y + r);
        path.AddArc(x, y, r * 2, r * 2, 180, 90);
        path.CloseFigure();

        g.SmoothingMode = SmoothingMode.AntiAlias;
        if (fill) {
            g.FillPath(color, path);
        } else {
            g.DrawPath(pen, path);
        }
    }
开发者ID:klange,项目名称:acoustics-windows,代码行数:32,代码来源:CoolProgressBar.cs

示例11: DrawColorLine

 public void DrawColorLine(Graphics graphics, Rectangle bounds, double min, double max, DataSeries series, Pen upPen, Pen downPen)
 {
     if (Bars == null) return;
     int barPaintWidth = ChartControl.ChartStyle.GetBarPaintWidth(ChartControl.BarWidth);
     SmoothingMode smoothingMode = graphics.SmoothingMode;
     int num2 = -1;
     int num3 = -1;
     Pen pen = null;
     GraphicsPath path = null;
     for (int i = 0;
          i <= (Math.Min(ChartControl.BarsPainted, series.Count - ChartControl.FirstBarPainted) - 1);
          i++)
     {
         int index = ((ChartControl.LastBarPainted - ChartControl.BarsPainted) + 1) + i;
         if (ChartControl.ShowBarsRequired || ((index - Displacement) >= BarsRequired))
         {
             double d = series.Get(index);
             if (!double.IsNaN(d))
             {
                 int num7 = (((ChartControl.CanvasRight - ChartControl.BarMarginRight) - (barPaintWidth / 2)) -
                             ((ChartControl.BarsPainted - 1) * ChartControl.BarSpace)) + (i * ChartControl.BarSpace);
                 int num8 = (bounds.Y + bounds.Height) - ((int)(((d - min) / ChartControl.MaxMinusMin(max, min)) * bounds.Height));
                 if (num2 >= 0)
                 {
                     Pen pen2 = (d > 0.0) ? upPen : downPen;
                     if (pen2 != pen)
                     {
                         if (path != null)
                             if (pen != null) graphics.DrawPath(pen, path);
                         path = new GraphicsPath();
                         pen = pen2;
                     }
                     if (path != null) path.AddLine(num2, num3, num7, num8);
                 }
                 num2 = num7;
                 num3 = num8;
             }
             if (pen != null)
             {
                 graphics.SmoothingMode = SmoothingMode.AntiAlias;
                 graphics.DrawPath(pen, path);
                 graphics.SmoothingMode = smoothingMode;
             }
         }
     }
 }
开发者ID:roonius,项目名称:TradingStudies,代码行数:46,代码来源:ABTrend.cs

示例12: RoundedRect

                public static void RoundedRect(Graphics aGraph, Rectangle aRect, int aR, Pen aPen, Brush aBrush)
                {
                    // First, build path:
                    GraphicsPath lPath = new GraphicsPath();

                    lPath.StartFigure();
                    lPath.AddArc(aRect.Left, aRect.Top, aR, aR, 180, 90);
                    lPath.AddArc(aRect.Left + aRect.Width - aR, aRect.Top, aR, aR, 270, 90);
                    lPath.AddArc(aRect.Left + aRect.Width - aR, aRect.Top + aRect.Height - aR, aR, aR, 0, 90);
                    lPath.AddArc(aRect.Left + 0, aRect.Top + aRect.Height - aR, aR, aR, 90, 90);
                    lPath.CloseFigure();

                    if (aBrush != null)
                        aGraph.FillPath(aBrush, lPath);

                    if (aPen != null)
                        aGraph.DrawPath(aPen, lPath);
                }
开发者ID:ahalassy,项目名称:reportsmart,代码行数:18,代码来源:GraphicsTools.cs


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