c# - WPF Create Label and Path in one Object -
i try create class label , path 1 single object did this:
class myline : shape { point p1,p2; label lbl; path arrow; public void addtocanvas(canvas x) { x.children.insert(0, lbl); x.children.insert(0, arrow); updatelbl(); updatearrow(); } public void removefromcanvas(canvas x) { x.children.remove(lbl); x.children.remove(arrow); } // ... etc }
it's work fine can't remove myline canvas single object,i have remove path label.
class mainclass { // ... code public void drawmyline(myline m) { _canvas.children.add(m); // work fine } object selectdeobject; public void canvasmouseleftbuttondown(object sender, mousebuttoneventargs e) { selectdeobject = _canvas.inputhittest(e.getposition(_canvas)) frameworkelement; } public void delete() { if (selectdeobject != null) { if (selectdeobject myline) // false { myline t = selectdeobject myline; t.removefromcanvas(_canvas); } else if(selectdeobject path) { _canvas.children.remove((selectdeobject path)) // delete path , keep label } else if(selectdeobject label) { _canvas.children.remove((selectdeobject label)) // delete label , keep path } } } }
any make selected object act 1 single object ?
Comments
Post a Comment