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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Create Custom node

Thread ID:

Created:

Updated:

Platform:

Replies:

146549 Aug 7,2019 09:33 PM UTC Aug 8,2019 11:05 AM UTC WinForms 1
loading
Tags: Diagram
George
Asked On August 7, 2019 09:33 PM UTC

Hi I am trying to create simple custom Node
One to add a specific image from resources and another custom to add  a bitmap like the one you are using(i just want to have a custom one)
1. The problem is that I cannot see anything
2. WHile create a node  I want to setup a start point but I have access only to PinPoint (which is Not the same)

if (ofd.ShowDialog() == DialogResult.OK)
            {
                Bitmap bm = new Bitmap(ofd.FileName);
                BitmapNode barNode = new BitmapNode(bm);
                barNode.PropertyBag.Add("Type", "Bitmap");
                barNode.PropertyBag.Add("Path", ofd.FileName);
                barNode.PinPoint = new PointF(rectBounding.Location.X, rectBounding.Location.Y);
                barNode.Size = new SizeF(rectBounding.Size.Width, rectBounding.Size.Height);
                barNode.LineStyle.LineWidth = 0;

                return barNode;
            }

3. I would like in the right click (contextmenu) to keep only the "Align" , "Flip" , "Order"  and  "Rotate" . But as you can see in the sample I habe to click 3-4 times before achieve the desired result

 if (e.Button == MouseButtons.Right)
            {
                for (int i = 0; i < diagram1.ContextMenuStrip.Items.Count; i++)
                {
                    if (diagram1.ContextMenuStrip.Items[i] is ToolStripSeparator)
                    {
                        ToolStripSeparator item = diagram1.ContextMenuStrip.Items[i] as ToolStripSeparator;
                        diagram1.ContextMenuStrip.Items.Remove(item);
                    }

                    if (!(diagram1.ContextMenuStrip.Items[i] is ToolStripSeparator))
                    {
                        ToolStripMenuItem item = diagram1.ContextMenuStrip.Items[i] as ToolStripMenuItem;

                        if (item.Text != "Align" && item.Text != "Flip" && item.Text != "Order" && item.Text != "Rotate" )
                        {
                            diagram1.ContextMenuStrip.Items.Remove(item);
                        }
                    }
                }
                
            }

Attachment: DiagramSample_2520cbf.7z

Shyam G [Syncfusion]
Replied On August 8, 2019 11:05 AM UTC

Hi George,  
 
The problem is that I cannot see anything  
On further analyzing your sample, we found that you have set minimum value for the Diagram.Model’s LogicalSize and created a node outside of the diagram’s drawing area. So only, the node doesn’t add into the diagram page.   
  
We suggest you to disable the Diagram.Model’s BoundaryConstraintsEnabled property while drawing/creating the node outside of the drawing area. 
  
Code example:  
  
this.diagram1.Model.BoundaryConstraintsEnabled = false;  
WHile create a node  I want to setup a start point but I have access only to PinPoint (which is Not the same)  
The PinPoint property represents the middle position of the node which is calculated by dividing the node’s size by half. So please use below code example to achieve your requirement.  
  
Code example:  
  
[C#]  
  
barNode.PinPoint = newPointF(rectBounding.Location.X + rectBounding.Width / 2, rectBounding.Location.Y + rectBounding.Height / 2);  
I would like in the right click (contextmenu) to keep only the "Align" , "Flip" , "Order" and  "Rotate" . But as you can see in the sample I habe to click 3-4 times before achieve the desired result  
We have modified your code example to achieve your requirement    
  
Code example:  
  
[C#]  
int i = diagram1.ContextMenuStrip.Items.Count - 1;  
                while(diagram1.ContextMenuStrip.Items.Count - 1 != 3)  
                {  
                    if(diagram1.ContextMenuStrip.Items[i] isToolStripSeparator)  
                    {  
                        ToolStripSeparator item = diagram1.ContextMenuStrip.Items[i] asToolStripSeparator;  
                       diagram1.ContextMenuStrip.Items.Remove(item);  
                    }  
                    else  
                    {  
                        ToolStripMenuItem item = diagram1.ContextMenuStrip.Items[i] asToolStripMenuItem;  
                        if (item.Text !="Align" && item.Text != "Flip" && item.Text !="Order" && item.Text != "Rotate")  
                        {  
                           diagram1.ContextMenuStrip.Items.Remove(item);  
  
                        }  
                    }  
                    i--;  
                }  
  
 
Please refer to a modified sample.  
 
Regards,  
Shyam G 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon