Join a Line and Ellipse -


i did find how bind line ellipse through xaml, i'm not familiar binding, , though i've researched it, still don't understand how binding work user input.

is there way, programmatically have ellipse joined end of line when line rotates on diameter, ellipse rotates it? wrote done in code, not xaml.

    using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; using system.windows; using system.windows.controls; using system.windows.data; using system.windows.documents; using system.windows.input; using system.windows.media; using system.windows.media.imaging; using system.windows.navigation; using system.windows.shapes;  namespace wpfapplication1 {     /// <summary>     /// interaction logic mainwindow.xaml     /// </summary>     public partial class mainwindow : window     {         public mainwindow()         {             initializecomponent();         }         public void geo()         {             freecanvas.children.clear();             double one, two, three, four, ang;             if(double.tryparse(txtone.text, out one))                 if(double.tryparse(txttwo.text, out two))                     if(double.tryparse(txtthree.text, out three))                         if (double.tryparse(txtfour.text, out four))                             if(double.tryparse(txtangle.text, out ang))                         {                             rotatetransform ans = new rotatetransform();                             ans.angle = ang;                             ans.centerx = 75;                             ans.centery = 150;                                                           line linea = new line();                             linea.stroke = brushes.black;                             linea.strokethickness = 2;                             linea.x1 = 75;                             linea.y1 = 150;                             linea.x2 = 75;                             linea.y2 = 250;                             linea.horizontalalignment = horizontalalignment.center;                             linea.verticalalignment = verticalalignment.top;                             freecanvas.children.add(linea);                              line lineb = new line();                             lineb.stroke = brushes.black;                             lineb.strokethickness = 2;                             lineb.x1 = 75;                             lineb.y1 = 50;                             lineb.x2 = 75;                             lineb.y2 = 150;                             //lineb.horizontalalignment = horizontalalignment.center;                             //lineb.verticalalignment = verticalalignment.top;                             lineb.rendertransform = ans;                             freecanvas.children.add(lineb);                              line linec = new line();                             linec.stroke = brushes.black;                             linec.strokethickness = 2;                             linec.x1 = -25;                             linec.y1 = 150;                             linec.x2 = 175;                             linec.y2 = 150;                             linec.horizontalalignment = horizontalalignment.center;                             linec.verticalalignment = verticalalignment.top;                             freecanvas.children.add(linec);                              pathfigure pthfigure = new pathfigure();                             pthfigure.startpoint = new point(-25, 150);                              arcsegment arcseg = new arcsegment();                             arcseg.point = new point(175, 150);                             arcseg.size = new size(100, 100);                             arcseg.islargearc = true;                             arcseg.sweepdirection = sweepdirection.clockwise;                             arcseg.rotationangle = 90;                              pathsegmentcollection mypathsegmentcollection = new pathsegmentcollection();                             mypathsegmentcollection.add(arcseg);                              pthfigure.segments = mypathsegmentcollection;                              pathfigurecollection pthfigurecollection = new pathfigurecollection();                             pthfigurecollection.add(pthfigure);                              pathgeometry pthgeometry = new pathgeometry();                             pthgeometry.figures = pthfigurecollection;                              path arcpath = new path();                             arcpath.stroke = new solidcolorbrush(colors.black);                             arcpath.strokethickness = 1.5;                             arcpath.data = pthgeometry;                             //arcpath.fill = new solidcolorbrush(colors.yellow);                             freecanvas.children.add(arcpath);                              ellipse ella = new ellipse();                             ella.width = 10;                             ella.height = 10;                             ella.stroke = brushes.black;                             ella.fill = brushes.lime;                             translatetransform ella1 = new translatetransform(70, 145);                             ella.rendertransform = ella1;                             freecanvas.children.add(ella);                              ellipse ellb = new ellipse();                             ellb.width = 10;                             ellb.height = 10;                             ellb.stroke = brushes.black;                             ellb.fill = brushes.yellow;                             translatetransform ellb1 = new translatetransform(70, 45);                             ellb.rendertransform = ellb1;                             freecanvas.children.add(ellb);                            }          }          private void btntest_click(object sender, routedeventargs e)         {             geo();         }     } } 

never mind, figured out. posted segment of code provided answer.

                            rads = math.pi * ang / 180;                              x1 = math.sin(rads) * 80;                             y1 = math.cos(rads) * 80;                             x2 = math.sin(rads) * 30;                             y2 = math.cos(rads) * 30;                              ellipse ella = new ellipse();                             ella.width = 10;                             ella.height = 10;                             ella.stroke = brushes.black;                             ella.fill = brushes.lime;                             translatetransform ella1 = new translatetransform(70 + x1, 145 - y1);                             ella.rendertransform = ella1;                             freecanvas.children.add(ella);                              ellipse ellb = new ellipse();                             ellb.width = 10;                             ellb.height = 10;                             ellb.stroke = brushes.black;                             ellb.fill = brushes.yellow;                             translatetransform ellb1 = new translatetransform(70 + x2, 145 - y2);                             ellb.rendertransform = ellb1;                             freecanvas.children.add(ellb); 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

android - CollapsingToolbarLayout: position the ExpandedText programmatically -

Listeners to visualise results of load test in JMeter -