The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
I wish to add a symbol to a diagram programmatically. It appears that both the following alternatives achieve the same thing, with the exception that AppendChild requires DiagramRefresh() to be called.
Are there any significant differences between these two approaches?
What is the recommended approach from syncfusion?
//Append Child variant
SymbolPalette palette = paletteGroupBar.GetPalette(0);
CustomSymbolModel symbolModel = palette.GetChild(0) as CustomSymbolModel;
Symbol newSymbol = symbolModel.CreateSymbol();
newSymbol.X = 20;
newSymbol.Y = 40;
diagram.Controller.Model.AppendChild(newSymbol);
//A refresh is needed before the new symbol appears.
diagram.Refresh();
//Execute command variant
SymbolPalette palette = paletteGroupBar.GetPalette(0);
CustomSymbolModel symbolModel = palette.GetChild(0) as CustomSymbolModel;
Symbol newSymbol = symbolModel.CreateSymbol();
NodeCollection nodes = new NodeCollection();
nodes.Add(newSymbol);
InsertNodesCmd insCmd = new InsertNodesCmd();
insCmd.Location = new Point(30, 50);
insCmd.Nodes.Concat(nodes);
diagram.Controller.ExecuteCommand(insCmd);
ADAdministrator Syncfusion Team June 20, 2005 02:12 PM UTC
I''m thinking that the difference is with ExecuteCommand you have the ability to undo, while you can''t with AppendChild :)
ADAdministrator Syncfusion Team June 21, 2005 02:55 PM UTC
As Kevin pointed out, using the Essential Diagram Command classes through the Controller will append the executed command to the diagram''s undo/redo stack providing you with the ability to undo the operation if necessary.
Regards,
Prakash Surendra
Syncfusion Inc.,