在C#WindoeFormsApplication中,是否可以选择,从而用鼠标移动或删除绘制的形状?就像Windows的画图程序一样。
形状绘图工作得很好,所有点都存储在某个数组中。作为此线图示例
Point Latest { get; set; }
List<Point> _points = new List<Point>();
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
// Save the mouse coordinates
Latest = new Point(e.X, e.Y);
// Force to invalidate the form client area and immediately redraw itself.
Refresh();
}
protected override void OnPaint(PaintEventArgs e)
{
var g = e.Graphics;
base.OnPaint(e);
if (_points.Count > 0)
{
var pen = new Pen(Color.Navy);
var pt = _points[0];
for(var i=1; _points.Count > i; i++)
{
var next = _points[i]; …Run Code Online (Sandbox Code Playgroud) 如果在 Graphicspath 中添加一条线并定义了两端位置,是否可以读取这对点?
Point[] myArray =
{
new Point(30,30),
new Point(60,60),
};
GraphicsPath myPath2 = new GraphicsPath();
myPath2.AddLines(myArray2);
Run Code Online (Sandbox Code Playgroud)
从 myPath2 中,是否有类似的东西myPath2.Location可以给我点(30,30)和(60,60)?谢谢