您好,
我们怎么能写Mouseleftclick或mouseRight单击"形状如矩形,椭圆形,这是自定义画布OnRender方法绘制的PathGeometry等事件。
我有一个自定义画布上WPF窗口。鼠标事件的画布上,我得出的形状。现在,我要生成形状的click事件。
代码:
protected override void OnRender(DrawingContext dc)
{
SolidColorBrush myBrush = new SolidColorBrush(Colors.Transparent);
Pen mypen=new Pen(Brushes.Black,1);
Rect myrect=new Rect (0,0,this.Width,this.Height);
dc.DrawRectangle(new SolidColorBrush(Colors.White),new Pen(Brushes.Black,1),myrect);
// Draw ellipse
if(Shapetype=="Ellipse")
{ dc.DrawEllipse(myBrush,mypen,Position,Shapewidth,Shapeheight);
}
// Draw Rectangle
if(Shapetype=="Rectangle")
{
Rect rect1=new Rect(startPoint.X,startPoint.Y,Shapewidth,Shapeheight);
dc.DrawRectangle(myBrush,mypen,rect1);
}
}
这里亚姆能够在画布上绘制矩形,椭圆形,我怎么能产生鼠标点击事件,当我点击画布上呈现的矩形或椭圆形的形状。
任何一个例子的帮助深表感谢!......