GraphicsPath相当难的问题
原码如下:
using System;
using System.Drawing;
using System.Windows.Forms;
namespace DrawDeom
{
public partial class Form2 : Form
{
private Point[] aDraw = new Point[100];
System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
public Form2()
{
InitializeComponent();
Run100();
}
private void Run100()
{
System.Random rnd = new Random();
int x, y;
for (int i = 0; i < aDraw.Length; i++)
{
x = rnd.Next(this.Width);
y = rnd.Next(this.Height);
aDraw[i].X = x;
aDraw[i].Y = y;
path.AddEllipse(x, y, 5, 5);
}
}
private void Draw(Graphics _g)
{
Pen redPen = new Pen(Color.Red, 1);
_g.DrawPath(redPen, path);
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Draw(e.Graphics);
}
protected override void OnMouseMove(MouseEventArgs e)
{
Point p = System.Windows.Forms.Control.MousePosition;
toolStripStatusLabel1.Text = string.Format("X:{0}-Y{1}", p.X, p.Y);
p = this.PointToClient(p);
if (path.IsVisible(p.X, p.Y))
{
toolStripStatusLabel1.ForeColor = Color.Red;
toolTip1.ToolTipTitle = "标题";
//显示当前圆的索引或左上角坐标
toolTip1.Show("当前图形:XX", this);
}
else
{
toolStripStatusLabel1.ForeColor = Color.Black;
toolTip1.Hide(this);
}
}
}
}
相关推荐
GDI+编程之GraphicsPath应用 !
有关判定指定控件内的鼠标是否移动到GraphicsPath路径内,并以此引发该控件的重绘事件。
C#中GraphicsPath的AddString方法用法实例
本文实例讲述了C#中GraphicsPath的AddString方法用法。分享给大家供大家参考。具体如下: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Drawing.Drawing2D; namespace advanced_drawing { public partial cl
C#中GraphicsPath的Warp方法用法实例
本文实例讲述了C#中GraphicsPath的Warp方法用法。分享给大家供大家参考。具体实现方法如下: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Drawing.Drawing2D; namespace advanced_drawing { public partial cla
C#中GraphicsPath的Flatten方法用法实例
本文实例讲述了C#中GraphicsPath的Flatten方法。分享给大家供大家参考。具体实现方法如下: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Drawing.Drawing2D; namespace advanced_drawing { public partial cl
C#中GraphicsPath的Widen方法用法实例
主要介绍了C#中GraphicsPath的Widen方法用法,实例分析了Widen方法的使用技巧,需要的朋友可以参考下


