add my own symbol into a palette
SymbolPalette paletteCur = symbolPaletteGroupBar.CurrentSymbolPalette;
Group mysymbolmdl = new Group();
int inicio;
mysymbolmdl.AppendChildren(this.diagram1.Model.Nodes, out inicio);
if (ZY8201.MessageBoxYesNo.Show(ec.messageOwnerName, 77, "info") == DialogResult
{
FrmNameSymbol frmNameSymbol = new FrmNameSymbol(this);
frmNameSymbol.ShowDialog();
if (nameSymbol != "")
{
mysymbolmdl.Name = nameSymbol;
}
}
paletteCur.AppendChild(mysymbolmdl);
I have to appendchild before naming the symbol, in other case a big red cross appear in the diagram. I don't know what i'm doing wrong.
I would appreciate any help. Thanks
Thanks for using Syncfusion product.
We are glad to inform you that we have created simple sample to achieve your requirement. Please refer the below code snippet and sample for your references.
Here is the code snippet:
[C#]
//Creates a Symbols programmatically
SymbolPalette symbol = new SymbolPalette();
symbol.Name = "Symbol";
symbol.AppendChild(Rectangle);
symbol.AppendChild(Ellipse);
//Creates a PaletteGroupBar programmatically
PaletteGroupBar paletteBar = new PaletteGroupBar();
paletteBar.Dock = DockStyle.Left;
paletteBar.Font = new Font("Arial", 9);
paletteBar.BorderStyle = BorderStyle.None;
//Apply visual styles
paletteBar.VisualStyle = Syncfusion.Windows.Forms.VisualStyle.Office2010;
paletteBar.TextAlign = Syncfusion.Windows.Forms.Tools.TextAlignment.Left;
paletteBar.ClientSize = new Size(200, 100);
paletteBar.Collapsed = false;
paletteBar.Enabled = true;
paletteBar.Visible = true;
//Add symbols to palatte
paletteBar.AddPalette(symbol);
//Add paletteBar to the form
this.diagram1.Controls.Add(paletteBar);
Here is the sample:
Sample
Please let us know if any concerns.
Regards,
Naganathan K G
Thanks for your update.
We are glad to inform you that we have created simple sample to achieve your requirement. We suggest you to use Group node to create Group symbols and add these symbols to the SymbolPalatte in order to achieve your requirement. Please refer the below code snippet and sample for your references.
Here is the code snippet:
[C#]
Syncfusion.Windows.Forms.Diagram.Rectangle Rectangle = new Syncfusion.Windows.Forms.Diagram.Rectangle(100, 100, 100, 50);
Rectangle.FillStyle.Color = Color.SkyBlue;
Syncfusion.Windows.Forms.Diagram.Ellipse Ellipse = new Syncfusion.Windows.Forms.Diagram.Ellipse(0, 60, 100, 100);
Ellipse.FillStyle.Color = Color.SeaGreen;
Group grp = new Group();
grp.Name = "MyNewSymbol";
grp.AppendChild(Rectangle);
grp.AppendChild(Ellipse);
//Creates a Symbols programmatically
SymbolPalette symbol = new SymbolPalette();
symbol.Name = "Symbol";
symbol.AppendChild(grp);
Here is the sample:
Sample
Please let us know if any concerns.
Regards,
Naganathan K G
Group grp = new Group();
grp.Name = "MyNewSymbol";
for (int i = 0; i < this.diagram1.Model.Nodes.Count; i++)
{
grp.AppendChild(this.diagram1.Model.Nodes[i]);
}
SymbolPalette paletteCur = symbolPaletteGroupBar.CurrentSymbolPalette;
paletteCur.AppendChild(grp);
But if I use this instead of grp.Name = "mysymbol" it doesn't work:
if (ZY8201.MessageBoxYesNo.Show(ec.messageOwnerName, 77, "info") == DialogResult.Yes)
{
FrmNameSymbol frmNameSymbol = new FrmNameSymbol(this);
frmNameSymbol.ShowDialog();
if (nameSymbol != "")
{
grp.Name = nameSymbol;
}
Thanks for your update.
We are unable reproduce the reported issue at our end. We have modified your code snippet and created the simple sample to achieve your requirement. We suggest you to use Node’s Clone() method while append in the group node. Please refer the below sample and code snippet for your references.
Here is the code snippet:
[C#]
Group grp = new Group();
grp.Parent = diagram1.Model;
grp.Name = "mysymbol";
for (int i = 0; i < this.diagram1.View.SelectionList.Count; i++)
{
Node nod = this.diagram1.View.SelectionList[i].Clone() as Node;
grp.AppendChild(nod);
}
Here is the sample:
Sample
Here is the video:
Video
If we misunderstood your requirement, could you please share us more information of your requirement to adding name for group node probably sample or video which will help us to analyze further and provide better solution?
Please let us know if any concerns.
Regards,
Naganathan K G
Attachment: Video_1433508993_715381af.zip
Oh my god, what difficult is this:-(I don't have problems adding nodes into a group, I have problems when I name my new symbol outside with a new form.grp.name = "blablabla" works fineif I use a new form with a textbox where a client could insert the name they want, it doesn't work!! Is it so difficult to understand?Your sample is fantastic but you don't use a form for the name, you put it programmatically and I need the client could put the name they want.
Attachment: Video_1433508993_715381af.zip
As you could see on the video I don't have problems creating a new symbol (with a group of two diffent images). If I don't open a new form to name the new symbol I don't have problem, if I use an "external" form to name it when I click on the new symbol a big cross appear.
Oh my god, what difficult is this:-(I don't have problems adding nodes into a group, I have problems when I name my new symbol outside with a new form.grp.name = "blablabla" works fineif I use a new form with a textbox where a client could insert the name they want, it doesn't work!! Is it so difficult to understand?Your sample is fantastic but you don't use a form for the name, you put it programmatically and I need the client could put the name they want.
Attachment: Video_1433508993_715381af.zip
As you could see on the video I don't have problems creating a new symbol (with a group of two diffent images). If I don't open a new form to name the new symbol I don't have problem, if I use an "external" form to name it when I click on the new symbol a big cross appear.I don't know where is the problem, but it exists and this is the second thread I open with this issue.I sent you a video in the previous thread and now the code I'm using, I don't know what else could do, it's a bit hopeless.
And please you don't close this thread if I don't response in a few days, I will be outside next week but when I come back the problem will be there and I will need a solution.
Thanks for your update and sorry for the inconvenience caused.
|
I don't have problems adding nodes into a group, I have problems when I name my new symbol outside with a new form.
grp.name = "blablabla" works fine
if I use a new form with a textbox where a client could insert the name they want, it doesn't work!! Is it so difficult to understand? |
We are unable to reproduce reported issue at our end. We have modified the sample and also using new Form for set name for the node. Please refer the below code snippet and modified sample for your references.
Here is the code snippet:
[C#]
private void button1_Click(object sender, EventArgs e) { if(diagram1.View.SelectionList.Count > 0) { Group grp = new Group(); form2 = new Form2(); Button button = new Button(); button.Text = "OK"; button.Size = new System.Drawing.Size(100, 20); TextBox text = new TextBox(); text.Multiline = true; text.Size = new Size(270, 150); if (!form2.Controls.Contains(text)) form2.Controls.Add(text); if (!form2.Controls.Contains(button)) form2.Controls.Add(button); form2.Location = new Point((int)diagram1.Controller.MouseLocation.X, (int)diagram1.Controller.MouseLocation.Y); text.Location = new Point(0, 0); button.Location = new Point(100, 160);
for (int i = this.diagram1.View.SelectionList.Count - 1; i >= 0; i--) { Node nod = this.diagram1.View.SelectionList[i].Clone() as Node; if (i != this.diagram1.View.SelectionList.Count - 1) { nod.PinPoint = new PointF(Math.Abs(this.diagram1.View.SelectionList[i + 1].PinPoint.X - nod.PinPoint.X), Math.Abs(this.diagram1.View.SelectionList[i + 1].PinPoint.Y - nod.PinPoint.Y)); } grp.AppendChild(nod); } button.Click += button_Click; form2.ShowDialog(); grp.Name = text.Text; symbol.AppendChild(grp); } }
Here is the modified sample:
|
Please let us know if any concerns.
Regards,
Naganathan K G
- 10 Replies
- 2 Participants
-
BC Blanca Calderon
- May 27, 2015 12:49 PM UTC
- Jun 8, 2015 07:31 AM UTC