c# - Create Path programatically doesn't works as Desired -


i have custom control

        <grid name="panelinferior" grid.row="5" grid.columnspan="5">             <grid.columndefinitions>                 <columndefinition x:name="nombrepiezaholder" width="2*"/>                 <columndefinition x:name="simbol1" width="1*"/>                 <columndefinition x:name="simbol2" width="1*"/>                 <columndefinition x:name="simbol3" width="1*"/>                 <columndefinition x:name="simbol4" width="1*"/>                             </grid.columndefinitions>             <grid.rowdefinitions>                 <rowdefinition height="1*"/>             </grid.rowdefinitions>             <textblock x:name="nombrepieza" text="{binding elementname=esta_pieza,path=pieza.id}" margin="0" height="auto" width="auto" panel.zindex="0" verticalalignment="center" foreground="{dynamicresource {x:static systemcolors.hottrackbrushkey}}" fontweight="extrabold" horizontalalignment="center"/>             <viewbox x:name="panelinferior1" grid.row="0" grid.column="1" height="auto" width="auto">                 <grid x:name="panelinferior1contenedor" >                 </grid>             </viewbox>             <viewbox x:name="panelinferior2" grid.row="0" grid.column="2" height="auto" width="auto">                 <grid x:name="panelinferior2contenedor">                     <path x:name="endodonciaporrealizar" data="m-2.1394273e-06,993.43869 l68.000003,995 32.942219,2.8478794e-06 z" height="200" margin="0" stretch="fill" width="200" fill="#ffbb2727"/>                 </grid>             </viewbox>             <viewbox x:name="panelinferior3" grid.row="0" grid.column="3" height="auto" width="auto">                 <grid x:name="panelinferior3contenedor">                 </grid>             </viewbox>             <viewbox x:name="panelinferior4" grid.row="0" grid.column="4" height="auto" width="auto">                 <grid x:name="panelinferior4contenedor">                 </grid>             </viewbox>         </grid>     </grid> </usercontrol> 

the grid panelinferior has 4 places draw in @ run time, in simple column 2 has allready path in it(just tests) if add path same properties doesn't draw other 1 (column2)

this string passed de texttopath function:

x:name="endodonciaporrealizar"~data="m-2.1394273e-06,993.43869 l68.000003,995 32.942219,2.8478794e-06"~height="200"~margin="0"~stretch="fill"~width="200"~fill="#ffbb2727" 

this code creates path @ run time

   public static path texttopath(string pathtext, string name )     {         path newpath = new path();         newpath.name = name;         string propertiename = "";         string propertievalue = "";         string[] properties = pathtext.split('~');         foreach (string propertie in properties)         {             string[] propertieparts = propertie.split('=');             propertiename = propertieparts[0];             propertievalue = propertieparts[1].replace('"', " ".tochararray()[0]);             switch (propertiename)             {                 case "data":                     newpath.data = geometry.parse(propertievalue);                     break;                 case "height":                     if (propertievalue == " auto ")                         newpath.height = double.nan;                     else                         newpath.height = double.parse(propertievalue);                     break;                 case "width":                     if (propertievalue == " auto ")                         newpath.width = double.nan;                     else                         newpath.width = double.parse(propertievalue);                     break;                 case "fill":                     newpath.fill = (solidcolorbrush)(new brushconverter().convertfrom(propertievalue));                     break;                 case "margin":                     string[] margins = propertievalue.split(',');                     switch (margins.count())                     {                         case 1:                             newpath.margin = new thickness(double.parse(propertievalue));                             break;                         case 4:                             newpath.margin = new thickness(                                 double.parse(margins[0]),                                 double.parse(margins[1]),                                 double.parse(margins[2]),                                 double.parse(margins[3])                                 );                             break;                     }                     break;                 case "horizontalalignment":                     switch (propertievalue)                     {                         case "left":                             newpath.horizontalalignment = horizontalalignment.left;                             break;                         case "center":                             newpath.horizontalalignment = horizontalalignment.center;                             break;                         case "right":                             newpath.horizontalalignment = horizontalalignment.right;                             break;                         case "stretch":                             newpath.horizontalalignment = horizontalalignment.stretch;                             break;                     }                     break;                 case "stretch":                     switch (propertievalue)                     {                         case "fill":                             newpath.stretch = stretch.fill;                             break;                         case "none":                             newpath.stretch = stretch.none;                             break;                         case "uniform":                             newpath.stretch = stretch.uniform;                             break;                         case "uniformtofill":                             newpath.stretch = stretch.uniformtofill;                             break;                     }                     break;                 case "verticalalignment":                     switch (propertievalue)                     {                         case "bottom":                             newpath.verticalalignment = verticalalignment.bottom;                             break;                         case "center":                             newpath.verticalalignment = verticalalignment.center;                             break;                         case "stretch":                             newpath.verticalalignment = verticalalignment.stretch;                             break;                         case "top":                             newpath.verticalalignment = verticalalignment.top;                             break;                     }                     break;             }         }         return newpath;     } 

and code add new path grid (in case simbolo.path = null , posicion = posicionsimbolo.abajo

   public void drawsimbol(isimbolo simbolo)     {         if (!simbolo.dibujado)         {             //si no se especifica la propiedad path del simbolo, se procede colorear la superficie              if (simbolo.path == null)             {                 if (simbolo.fillcolor != null)                 {                     shape thisshape = idsuperficietoshape(simbolo.superficie.id);                     if (thisshape != null)                         thisshape.fill = (solidcolorbrush)(new brushconverter().convertfrom(simbolo.fillcolor));                 }             }             else             {                 try                 {                     posicionsimbolo posicion = simboltools.posicion(simbolo.dibujaren);                     contadorsimbolos += 1;                     switch (posicion)                     {                         case posicionsimbolo.abajo:                             posicionpanelinferior +=1;                             string nombre = string.format("panelinferior{0}", posicionpanelinferior.tostring().trim());                             path mypath = simboltools.texttopath(simbolo.path, nombre);                             switch (posicionpanelinferior)                             {                                 case 1:                                     panelinferior1contenedor.children.add(mypath);                                     break;                                 case 2:                                     panelinferior2contenedor.children.add(mypath);                                     break;                                 case 3:                                     panelinferior3contenedor.children.add(mypath);                                     break;                                 case 4:                                     panelinferior4contenedor.children.add(mypath);                                     break;                             }                             mypath.visibility = system.windows.visibility.visible;                             break;                     }                 }                 catch (exception e)                 {                     throw new paradigmanexception(errores.gramas_nosepudodibujarsimbolo,e);                 }             }         }     }  

i expect 2 paths has same shape result:

enter image description here

after have questions: 1- why shape not same? 2- there way retrieve xaml code path added code? because want compare static xaml of path column2 3- proper way créate path programatically match path de column2?

xamlwriter can used dump resulting xaml regardless of how it's been created.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -