We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Change Symbol Names

Thread ID:

Created:

Updated:

Platform:

Replies:

19499 Sep 28,2004 03:17 AM UTC Oct 20,2004 06:02 PM UTC Windows Forms 10
loading
Tags: Diagram
Jarrod Lloyd
Asked On September 28, 2004 03:17 AM UTC

Currently I have custom symbols in my pallette which the User may select. I have all these symbols tied to the same PlugInAssembly and PlugInClass. The problem is that I generate this list at runtime, and I want to be able to change the symbol label when it is dragged onto the diagram, with reference to the symbol name in the pallette (I want them to be the same). Also, would it be possible to tag an object to the symbool when it is created in the pallette. Thanks Jarrod

Administrator [Syncfusion]
Replied On September 28, 2004 03:35 PM UTC

Hi Jarrod, 1. You can use the Model''s ChildrenChanging to what you are seeking as per my update in this posting. 2. You can add your properties to Symbols by calling SetPropertyValue(). Here is a modified version of the sample posted earlier with the appropriate changes demonstrating both these features. Regards, Arun

Jarrod Lloyd
Replied On September 28, 2004 07:59 PM UTC

Hi Arun, I tried what you said, but it ended up that the label was the name of the plugIn Class, not the the text on the Pallette Symbol. To show yyou what I mean, if I add symbols to the pallette as below: MySymbolModel = mypalette->AddSymbol("MyLabelName"); MySymbolModel = mypalette->AddSymbol("MyLabelName2"); When I select the first symbol, I would like the label on the symbol on the diagram to be "MyLabelName", not the name of the pluginclass. Thanks for your help Jarrod

Administrator [Syncfusion]
Replied On September 28, 2004 10:04 PM UTC

Hi Jarrod I am enclosing a screenshot of the application after dragging and dropping 2 symbols from the palette. The following are the 2 lines of code in the Form''s load that are highlighted: MySymbolModel = mypalette.AddSymbol("MySymbol"); MySymbolModel2 = mypalette.AddSymbol("MyOtherSymbol"); As you can see the Symbols have the labels MySymbol and MyOtherSymbol. The labels are programmatically added to the Symbol instance when they are dragged and dropped onto the Diagram in the Model''s ChildrenChanging event. You can add the label and set it''s desired text and position here. Regards Arun

Jarrod Lloyd
Replied On September 28, 2004 10:46 PM UTC

Arun, Will your code work if the symbol names are not the same as the plugInClass names? Jarrod

Administrator [Syncfusion]
Replied On September 29, 2004 05:24 PM UTC

Hi Jarrod, Yes it should work. I added the following lines of code at the end of each Symbol classes: In the MySymbol Class: this.Name = "DiffName"; In the MyOtherSymbol Class: this.Name = "AnotherName"; and then built and ran the sample. As you can see the labels are different now as seen in this screenshot and the label text is different from the name of the Plugin class. As mentioned,you can set the label text after getting hold of the Symbol instance to be anything you want it to be in the Model''s ChildrenChanging event. In the sample refer to the following code: private void diagram1_Model_ChildrenChanging(object sender, Syncfusion.Windows.Forms.Diagram.NodeCollection.EventArgs evtArgs) { if (evtArgs.ChangeType.ToString() == "Insert") { if (evtArgs.Node.GetType() == typeof(MySymbol)) { MySymbol mys = (MySymbol)evtArgs.Node; mys.AddLabel(mys.Name,BoxPosition.Center); } else if(evtArgs.Node.GetType() == typeof(MyOtherSymbol)) { MyOtherSymbol myos = (MyOtherSymbol)evtArgs.Node; myos.AddLabel(myos.Name,BoxPosition.Center); } } } As you can see in this case the label''s text is set to be the name of the Symbol. Regards Arun

Jarrod Lloyd
Replied On October 1, 2004 12:29 AM UTC

Arun, I think I need to give you a clearer picture of what I want to do. I have a list of objects, and from these I make a pallette of symbols which are all of the same class. I then select an item in this pallette and drag it on the diagram. Therefore, they will all be the same type, so using the evtArgs->Node->GetType() will not work. Do you know a way I can determine the label on the symbolModel in the pallette, and change the created symbol to have this label. Thanks Jarrod

Administrator [Syncfusion]
Replied On October 1, 2004 11:14 AM UTC

Hi Jarrod, Here is a modified code snippet that does what you are looking for. Note that GetType() is used in the Model''s ChildrenChanging event to get the instance of the Symbol being dragged and dropped on to the Diagram. private void diagram1_Model_ChildrenChanging(object sender, Syncfusion.Windows.Forms.Diagram.NodeCollection.EventArgs evtArgs) { if (evtArgs.ChangeType.ToString() == "Insert") { if (evtArgs.Node.GetType() == typeof(MySymbol)) { MySymbol mys = (MySymbol)evtArgs.Node; mys.AddLabel(this.paletteGroupBar1.SelectedSymbolModel.Name.ToString(),BoxPosition.Center); } } Regards Arun

Jarrod Lloyd
Replied On October 3, 2004 10:22 PM UTC

Thanks, that''s exactly what I was looking for Jarrod

Truman Lackey
Replied On October 20, 2004 03:12 PM UTC

>Hi Jarrod, > >Here is a modified code snippet that does what you are looking for. Note that GetType() is used in the Model''s ChildrenChanging event to get the instance of the Symbol being dragged and dropped on to the Diagram. > >private void diagram1_Model_ChildrenChanging(object sender, Syncfusion.Windows.Forms.Diagram.NodeCollection.EventArgs evtArgs) >{ > if (evtArgs.ChangeType.ToString() == "Insert") > { > if (evtArgs.Node.GetType() == typeof(MySymbol)) > { > MySymbol mys = (MySymbol)evtArgs.Node; > mys.AddLabel(this.paletteGroupBar1.SelectedSymbolModel.Name.ToString(),BoxPosition.Center); > } >} > >Regards >Arun > I am trying the same type of thing in vb but I am running into a problem with the selectedsymbolmodel. It returns nothing when the event is fired for model_childrenchanging. I have a sub that is capturing the palette symbol model selected event and it is not entered on a drag and drop from a palette to a diagram.

Administrator [Syncfusion]
Replied On October 20, 2004 06:02 PM UTC

Hi Truman, Here is a sample that demonstrates how a custom Symbol can be added to the Diagram: 1. Programmatically. The Symbol is added to the Diagram when you build and run the sample. 2. Using the InsertSymbolTool. You can activate this Tool by clicking on the Insert Symbol button and add a Symbol to the Diagram. 3. Dragging and dropping the custom Symbol from the PaletteGroupBar control. The sample shows how you can add the symbol to a Symbol Palette and add this Palette to the PaletteGroupBar. Item #3 from the above list should address your question. Regards Arun

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;