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


C# Graphics.FillPath方法代码示例

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


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

示例1: FillPathEllipse

public void FillPathEllipse(PaintEventArgs e)
{
             
    // Create solid brush.
    SolidBrush redBrush = new SolidBrush(Color.Red);
             
    // Create graphics path object and add ellipse.
    GraphicsPath graphPath = new GraphicsPath();
    graphPath.AddEllipse(0, 0, 200, 100);
             
    // Fill graphics path to screen.
    e.Graphics.FillPath(redBrush, graphPath);
}
开发者ID:.NET开发者,项目名称:System.Drawing,代码行数:13,代码来源:Graphics.FillPath

示例2: Graphics.FillPath(Brushes.AliceBlue, myPath);

//引入命名空间
using System;
  using System.Drawing;
  using System.Drawing.Drawing2D;
  using System.Collections;
  using System.ComponentModel;
  using System.Windows.Forms;
  using System.Data;

  public class Form1 : System.Windows.Forms.Form
  {
    GraphicsPath myPath = new GraphicsPath();

    private bool isImageClicked = false;

    public Form1()
    {
      InitializeComponent();
      myPath.StartFigure();
      myPath.AddLine(new Point(150, 10), new Point(120, 150));
      myPath.AddArc(200, 200, 100, 100, 0, 90);
      Point[] points = {new Point(350, 325), new Point(250, 350), new Point(250, 250), new Point(350, 275)};
      myPath.AddCurve(points);
      myPath.CloseFigure();

      CenterToScreen();
    }
    private void InitializeComponent()
    {
      this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
      this.ClientSize = new System.Drawing.Size(292, 273);
      this.Text = "Form1";
      this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseUp);
      this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);

    }

    static void Main() 
    {
      Application.Run(new Form1());
    }

    private void Form1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
    {
      Point mousePt = new Point(e.X, e.Y);
            
            if(myPath.IsVisible(mousePt))
      {
        isImageClicked = true;
        this.Text = "You clicked the strange shape...";
      } else {
        isImageClicked = false;
        this.Text = "Images";
      }

      Invalidate();
    }

    private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
    {
      Graphics g = e.Graphics;

      g.FillPath(Brushes.AliceBlue, myPath);

      if(isImageClicked == true)
      {
        Pen outline = new Pen(Color.Black, 2);
                g.DrawPath(outline, myPath);
      }
    }
  }
开发者ID:C#程序员,项目名称:System.Drawing,代码行数:71,代码来源:Graphics.FillPath


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