This is a migrated thread and some comments may be shown as answers.

Geometry to XML

1 Answer 135 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Svyatoslav
Top achievements
Rank 1
Svyatoslav asked on 27 Oct 2016, 01:25 PM

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"
 IsEditable="False"
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));
            file.Close();
            using (var fStream = new FileStream(path: "./****.xml", mode: FileMode.Create, access: FileAccess.Write, share: FileShare.ReadWrite))
            {
                xml.Serialize(fStream, Done);
                fStream.Close();
            }
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?

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 01 Nov 2016, 08:28 AM
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).

Regards,
Martin
Telerik by Progress
Do you need help with upgrading your WPF project? Try the Telerik API Analyzer and share your thoughts!
Tags
Diagram
Asked by
Svyatoslav
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or