How to change a diagram

Feb 2, 2015 at 10:10 PM
Edited Feb 3, 2015 at 2:44 AM
Hi everyone there!

First, sorry for my English and my programming knowledge. I'm an amateur developer who has discovered this pluggin for C# because I'm looking for a way to make a diagram in a form and change its text labels in function of the parameters that the user enters.

So, I've being reading the software help and I've adviced there aren't an example to do this. I've made a diagram in the designer and I can see it when I run the program but I don't know how to change the text property of the shapes. I think I've understood reading the help, that the shapes aren't named when you design. So, what should I do?

I hope you can help me. Thank you.



PD: After post this, I've been testing NShape deeply and I have a new question: How can I do this when I have the .nspj file into the project resources? Which files do I have in the resources folder?

xmlStore1.DirectoryName = @"C:\Documents and Settings\All Users\Common Files\NShape\Mi proyecto";
xmlStore1.FileExtension = "nspj";
// Set the name of the project that should be loaded from the store
project1.Name = "Prueba";
project1.LibrarySearchPaths.Add(@"C:\Documents and Settings\All Users\Common Files\NShape\bin\Debug");
project1.AutoLoadLibraries = true;
// Open the NShape project
project1.Open();
// Load the diagram and display it
display1.LoadDiagram("Diagrama");
Coordinator
Feb 5, 2015 at 11:14 AM
Edited Feb 5, 2015 at 11:15 AM
Hello pedreroo.
So, I've being reading the software help and I've adviced there aren't an example to do this. I've made a diagram in the designer and I can see it when I run the program but I don't know how to change the text property of the shapes. I think I've understood reading the help, that the shapes aren't named when you design. So, what should I do?
If I understand you correctly, you are looking for a way how to find your shapes by name.
I's correct, shapes do not have names, but all shapes have a string property "Data" where you can store user specific data (which will be saved in the Repository files, too).
PD: After post this, I've been testing NShape deeply and I have a new question: How can I do this when I have the .nspj file into the project resources? Which files do I have in the resources folder?
If you want to load the repository from a resource (which will be compiled into your application/library, you have to open the resource as stream or read it as string (the internet should know how to do that) and load it into the XmlStore by calling something like that:
string xmlString = ... // Get XML string from the Resources

project.Close();
project.Repository = null;
project.Name = "New Project Name";

using (MemoryStream memStream = new MemoryStream(Encoding.UTF8.GetBytes(xmlString)))
    project.ReadXml(memStream);
// The project is already open at this point, you can open diagrams now...