Create Custom node
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)
Attachment: DiagramSample_2520cbf.7z
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
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
SIGN IN To post a reply.
1 Reply
SG
Shyam G
Syncfusion Team
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
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
-
GE George
- Aug 7, 2019 09:33 PM UTC
- Aug 8, 2019 11:05 AM UTC