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. Image for the cookie policy date

Associating a popup menu with a symbol

Hi, I would like some help on associating a popup menu with a symbol dragged from onto a diagram. It can be with syncfusion popup control. (I guess that it wouldn''t be possible with .Net context menu component, right ?). Anyway, depending on the symbol type I would like different options in the context menu. When we have symbols of the same type the options in the context menu are the same but the setting choosen may be different. How can this state be saved for each symbol ? Is there any component that helps doing this or we have to do it from scratch ? Regards, Jose Santos

9 Replies

AD Administrator Syncfusion Team September 22, 2004 03:33 PM

Hi Jose, Here is a sample that does what you are looking for. The main points are: - There are 2 custom Symbols: Rectangle and Triangle. Take a look MySymbol.cs where the Custom symbols are implemented with ISerializable along with overrides for GetObjectData and OnDeserialization. - In the Diagram''s MouseDown the Custom Symbol is selected when right-clicked. - In the Diagram''s MouseUp event, menuitems are added to the ContextMenus based on the Symbol which is right clicked. The colors of the Symbol are changed based on the selection in the Context Menu. - The Diagram can be saved by clicking on the Save Diagram Button and loaded by clicking on the Load Diagram Method. Also take a look at the DynamicSymbol sample that demonstrates how custom properties of Symbols can be serialized. Regards Arun


JS Jose Santos September 23, 2004 03:11 AM

Thanks, this is exactly what I was looking for. I wasn''t expecting you to use context menu but your component. I notice that you are adding and removing items to the context menu, I was expecting 2 context menus. It''s the same for the user, of course, but is this the usual way of working with context menus ? Thanks again!


AD Administrator Syncfusion Team September 23, 2004 12:19 PM

Hi Jose Yes, you can use the Syncfusion Popup Menus in your application. Also, you can use 2 context different menus, I was just demonstrating how you could go about implementing the features you were looking for. Regards Arun


AD Administrator Syncfusion Team October 8, 2004 12:48 PM

I add two events into your RectangleSymbol. Now you save the symbol and reload it. If you click on it, it will get error saying the this.rect is null. It look like we need to add code to get the this.rect when it is deserializing. Any idea? protected override void OnMouseEnter(NodeMouseEventArgs evtArgs) { // TODO: Add ConditionSysbol.OnMouseEnter implementation this.rect.FillStyle.Color = System.Drawing.Color.AntiqueWhite; } protected override void OnMouseLeave(NodeMouseEventArgs evtArgs) { // TODO: Add ConditionSysbol.OnMouseLeave implementation this.rect.FillStyle.Color = System.Drawing.Color.AliceBlue; } >Hi Jose, > >Here is a sample that does what you are looking for. The main points are: > >- There are 2 custom Symbols: Rectangle and Triangle. Take a look MySymbol.cs where the Custom symbols are implemented with ISerializable along with overrides for GetObjectData and OnDeserialization. >- In the Diagram''s MouseDown the Custom Symbol is selected when right-clicked. >- In the Diagram''s MouseUp event, menuitems are added to the ContextMenus based on the Symbol which is right clicked. The colors of the Symbol are changed based on the selection in the Context Menu. >- The Diagram can be saved by clicking on the Save Diagram Button and loaded by clicking on the Load Diagram Method. > >Also take a look at the DynamicSymbol sample that demonstrates how custom properties of Symbols can be serialized. > >Regards >Arun


AD Administrator Syncfusion Team October 8, 2004 01:59 PM

Hi Yes, you need to add references to the child objects of RectangleSymbol during deserialization. This modified code should address this issue: protected override void OnDeserialization(object sender) { base.OnDeserialization(sender); // Get references to the child objects this.rect = this.GetChildByName("Rectangle") as Syncfusion.Windows.Forms.Diagram.Rectangle; } Regards Arun


AD Administrator Syncfusion Team October 10, 2004 08:16 AM

Thank you for help. It works. One more question, How can I serialize a property in the symbol. E.g I have "Description" property like following code. After I deserialized, the mDescription is always null. How can I get the "Description" in the deserialization? TIA! private string mDescription; public string Description { set { mDescription=value; ResetText(); } get {return mDescription;} } >Hi > >Yes, you need to add references to the child objects of RectangleSymbol during deserialization. This modified code should address this issue: > >protected override void OnDeserialization(object sender) >{ > base.OnDeserialization(sender); > > // Get references to the child objects > this.rect = this.GetChildByName("Rectangle") as Syncfusion.Windows.Forms.Diagram.Rectangle; >} > >Regards >Arun


AD Administrator Syncfusion Team October 11, 2004 06:08 AM

Hi Take a look at the MySymbol.cs file in the DynamicSymbol sample. It demonstrates what you are looking for. Regards Arun


AL Allen December 18, 2017 11:29 AM

Could you have this sample code in VB.Net 3.5 ?


NG Naganathan Ganesh Babu Syncfusion Team December 19, 2017 03:35 AM

Hi Jose, 
  
Could you please let us know which versions of Syncfusion Essential studio diagram control currently you are using? It will be helpful for us to create and provide the sample at your version.  
 
Regards, 
 
Naganathan K G 


Loader.
Live Chat Icon For mobile
Up arrow icon