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

Popular posts from this blog

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -