Geometry to XML

2 posts, 0 answers
  1. Svyatoslav
    Svyatoslav avatar
    22 posts
    Member since:
    Oct 2016

    Posted 27 Oct 2016 Link to this post

    Good afternoon. How can I save the geometry of the selected objects to RadDiagram in xaml file? Now I take the RadDiagramShape geometry, convert it to a string and written in the xaml file. But when I try the reverse conversion, an error is thrown

    1) the RadDiagramShape declare

    <telerik:RadDiagramShape x:Name="ConditionShape"
    AllowCopy="False" AllowCut="False" AllowDelete="False" AllowDrop="False" AllowPaste="True" Background="Azure" 
    Geometry="{telerik:CommonShape ShapeType=RectangleShape }" StrokeThickness="1" Height="100" Width="100" RenderTransformOrigin="0.5,0.5" Position="180,50"/>

    2) the entry in the xaml file

    Init.overview.LibraryItems.FunctionItem[end].Data = Convert.ToString(ShapeFactory.GetShapeGeometry(FlowChartShapeType.DecisionShape));
     FunctionLibrary Done = new FunctionLibrary();
                Done = Init.overview;
                XmlSerializer xml = new XmlSerializer(typeof(FunctionLibrary));
                using (var fStream = new FileStream(path: "./****.xml", mode: FileMode.Create, access: FileAccess.Write, share: FileShare.ReadWrite))
                    xml.Serialize(fStream, Done);
    3) the result in a file
          <Data>M56;0,5L111,5;37,5 56;74,5 0,5;37,5z</Data>

    4)  and the inverse transform

    var converter = new System.Windows.Media.GeometryConverter();
    var data = (Geometry) converter.ConvertFromString(ListCode[i].Data);
    ConditionShape.Geometry = data;

    this line is not recognized as geometry. how to convert in the required format?

  2. Martin Ivanov
    Martin Ivanov avatar
    1410 posts

    Posted 01 Nov 2016 Link to this post

    Hello Svyatoslav,

    I already answered your questions in the other forum thread. About the saving, you can also take a look at the serialization feature of the diagram. However, keep in mind the feature will save the entire diagram (not only the geometries).

    Telerik by Progress
    Do you need help with upgrading your WPF project? Try the Telerik API Analyzer and share your thoughts!
Back to Top