本文整理汇总了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);
}
示例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);
}
}
}