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

Diagram Objects in a List or array

1 Answer 12 Views
This is a migrated thread and some comments may be shown as answers.
Jacques
Top achievements
Rank 1
Jacques asked on 28 Jan 2019, 01:00 PM

Hi.

Is there a way to get the text box values from the from the objects in my diagram into an array or a list? I would like to use the text box string values of the objects on the diagram values for program logic. 

Then i would also like t get all the X and Y coordinates of each object on the diagram into a list that will enable me to write logic based on the position of the X and Y values of my objects in my diagram.

Thank You!
Jacques

1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 29 Jan 2019, 09:12 AM
Hi Jacques,

You can iterate the Shapes collection of the diagram store whatever information is necessary. It is also possible to use the SaveLoad API and retrieve the XML representation of the entire control. This will include information about the shapes names, position, connections etc. Calling the Save method on the diagram will also fire the ShapeSerialized event for each of the shapes. You can handle it add access the entity object and its properties. The event also exposes a SerializationInfo object giving information about the serialized data per shape: 
private void RadDiagram1_ShapeSerialized(object sender, Telerik.Windows.Diagrams.Core.SerializationEventArgs<Telerik.Windows.Diagrams.Core.IShape> e)
{
    RadDiagramShape shape = e.Entity as RadDiagramShape;
    if (shape != null)
    {
        string text = shape.Text;
        Telerik.Windows.Diagrams.Core.Point position = shape.Position;
 
        string serializedText = e.SerializationInfo[SerializationConstants.ShapeText]?.ToString();
        string serializedPostion = e.SerializationInfo[SerializationConstants.Position]?.ToString();
    }           
}
 
private void radButton1_Click(object sender, EventArgs e)
{
    string xmlData = this.radDiagram1.Save();
}

I hope this will help. Let me know if you have other questions.

Regards,
Hristo
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Asked by
Jacques
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Share this question
or