public int catchPointIndex = -1; //捕捉热点的索引 public override void mouseDown(object sender, MouseEventArgs e, DRAWForm drawForm) { catchPointIndex = -1; //重置捕捉热点的索引 if (this.getOperShape() != null) { this.getOperShape().setUnSelected(); } //清除前操作对象中选中的状态 ArrayList allShapes = this.getRefDRAWPanel().getCurrentShapes(); //得到画板上的所有图形 int catchPoint = -1; int i = 0; for (; i < allShapes.Count; i++) //对每个图形进行捕捉测试 { /*捕捉集合中的一个图形*/ catchPoint = ((BaseShape)allShapes[i]).catchShapPoint(this.getOldDragPoint()); if (catchPoint > -1) { break; } //捕获到后,跳出循环 } if (catchPoint > -1) { catchPointIndex = catchPoint; //捕获到后,将临时的热点设置到工具属性中 ((BaseShape)allShapes[i]).setSelected(); //设置捕捉到的图形为选中状态 this.setOperShape(((BaseShape)allShapes[i])); //选中的图形设定到本类的操作图形的状态中 } this.getRefDRAWPanel().Refresh(); //刷新画板 }
public void superMouseDown(object sender, MouseEventArgs e, DRAWForm drawForm) //公共鼠标按下 { this.setDownPoint(new Point(e.X, e.Y)); //鼠标按下点的设定 this.setOldDragPoint(new Point(e.X, e.Y)); //旧的鼠标拖动点的设定 this.setNewDragPoint(new Point(e.X, e.Y)); //新的鼠标拖动点的设定 this.mouseDown(sender, e, drawForm); //鼠标按下的处理 }
public override void mouseDown(object sender, MouseEventArgs e, DRAWForm drawForm) { this.setOperShape(new EllipseShape()); this.getOperShape().setP1(this.getDownPoint()); this.getOperShape().penColor = drawForm.clr; this.getOperShape().penwidth = drawForm.lineWidth; this.getRefDRAWPanel().getCurrentShapes().Add(this.getOperShape()); }
public override void mouseDown(object sender, MouseEventArgs e, DRAWForm drawForm) { this.setOperShape(new LineShape()); //新建一个线型对象 this.getOperShape().setP1(this.getDownPoint()); //设置起始点 this.getOperShape().penColor = drawForm.clr; //设置颜色 this.getOperShape().penwidth = drawForm.lineWidth; //设置线条宽度 /*在当前图形集合中添加这条图形*/ this.getRefDRAWPanel().getCurrentShapes().Add(this.getOperShape()); }
public void setRefDRAWPanel(DRAWForm refDRAWPanel) //关联画板 { this.refDRAWPanel = refDRAWPanel; }
/*鼠标按下的处理*/ public abstract void mouseDown(object sender, MouseEventArgs e, DRAWForm drawForm);