{
  "$schema": "https://ai.syncfusion.com/schema/registry-item.json",
  "name": "diagram-dynamic-properties",
  "framework": "winforms",
  "type": "registry:component",
  "component": "Diagram",
  "variant": "dynamic-properties",
  "dependencies": [
    "Syncfusion.Diagram.Windows"
  ],
  "description": "Diagram where selected shape properties are bound to a PropertyGrid that updates the underlying node on every change in the palette.",
  "meta": {
    "essentialStudioRelease": "2026 Volume 3 (v35.1.37)",
    "license": "commercial-or-community",
    "licenseNote": "The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md",
    "requiresLicenseKey": true,
    "requiresServerEndpoint": false,
    "platformIndex": "https://ai.syncfusion.com/winforms/llms.txt",
    "skillPack": "syncfusion/winforms-ui-components-skills",
    "docs": "https://ai.syncfusion.com/gallery/winforms/diagram-dynamic-properties.md"
  },
  "files": [
    {
      "target": "src/components/diagram-dynamic-properties/diagram.Designer.cs",
      "content": "namespace DynamicProperties\n{\n    public partial class Form1\n    {\n        /// <summary>\n        /// Required designer variable.\n        /// </summary>\n        private System.ComponentModel.IContainer components = null;\n\n        /// <summary>\n        /// Clean up any resources being used.\n        /// </summary>\n        /// <param name=\"disposing\">true if managed resources should be disposed; otherwise, false.</param>\n        protected override void Dispose(bool disposing)\n        {\n            if (disposing && (components != null))\n            {\n                components.Dispose();\n            }\n            base.Dispose(disposing);\n        }\n\n        #region Windows Form Designer generated code\n\n        /// <summary>\n        /// Required method for Designer support - do not modify\n        /// the contents of this method with the code editor.\n        /// </summary>\n        private void InitializeComponent()\n        {\n            components = new System.ComponentModel.Container();\n            diagram1 = new Syncfusion.Windows.Forms.Diagram.Controls.Diagram(components);\n            model1 = new Syncfusion.Windows.Forms.Diagram.Model(components);\n            button1 = new System.Windows.Forms.Button();\n            panel3 = new System.Windows.Forms.Panel();\n            label1 = new System.Windows.Forms.Label();\n            ((System.ComponentModel.ISupportInitialize)diagram1).BeginInit();\n            ((System.ComponentModel.ISupportInitialize)model1).BeginInit();\n            panel3.SuspendLayout();\n            SuspendLayout();\n            // \n            // diagram1\n            // \n            diagram1.Controller.Constraint = Syncfusion.Windows.Forms.Diagram.Constraints.PageEditable;\n            diagram1.Controller.DefaultConnectorTool = Syncfusion.Windows.Forms.Diagram.ConnectorTool.OrgLineConnectorTool;\n            diagram1.Controller.Nodes = null;\n            diagram1.Controller.PasteOffset = new System.Drawing.SizeF(10F, 10F);\n            diagram1.Dock = System.Windows.Forms.DockStyle.Fill;\n            diagram1.EnableTouchMode = false;\n            diagram1.HScroll = true;\n            diagram1.Location = new System.Drawing.Point(0, 0);\n            diagram1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);\n            diagram1.Model = model1;\n            diagram1.Name = \"diagram1\";\n            diagram1.Size = new System.Drawing.Size(784, 788);\n            diagram1.SmartSizeBox = false;\n            diagram1.TabIndex = 1;\n            diagram1.Text = \"diagram1\";\n            diagram1.TouchMode = false;\n            // \n            // \n            // \n            diagram1.View.Grid.MinPixelSpacing = 4F;\n            diagram1.View.Magnification = 100F;\n            diagram1.View.ZoomType = Syncfusion.Windows.Forms.Diagram.ZoomType.Center;\n            diagram1.VisualStyle = Syncfusion.Windows.Forms.Diagram.Controls.DiagramStyle.Default;\n            diagram1.VScroll = true;\n            // \n            // model1\n            // \n            model1.BackgroundStyle.PathBrushStyle = Syncfusion.Windows.Forms.Diagram.PathGradientBrushStyle.RectangleCenter;\n            model1.CustomUnitValue = 0.5F;\n            model1.DocumentScale.DisplayName = \"No Scale\";\n            model1.DocumentScale.Height = 1F;\n            model1.DocumentScale.Width = 1F;\n            model1.DocumentSize.Height = 1169F;\n            model1.DocumentSize.Width = 827F;\n            model1.LineStyle.DashPattern = null;\n            model1.LineStyle.LineColor = System.Drawing.Color.Black;\n            model1.LogicalSize = new System.Drawing.SizeF(827F, 1169F);\n            model1.ShadowStyle.Color = System.Drawing.Color.FromArgb(128, 105, 105, 105);\n            model1.ShadowStyle.ForeColor = System.Drawing.Color.FromArgb(128, 105, 105, 105);\n            // \n            // button1\n            // \n            button1.FlatAppearance.BorderColor = System.Drawing.Color.Silver;\n            button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;\n            button1.Font = new System.Drawing.Font(\"Segoe UI\", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);\n            button1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;\n            button1.Location = new System.Drawing.Point(657, 25);\n            button1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);\n            button1.Name = \"button1\";\n            button1.Size = new System.Drawing.Size(148, 45);\n            button1.TabIndex = 0;\n            button1.Text = \"Edit Info\";\n            button1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;\n\n            button1.UseVisualStyleBackColor = true;\n            button1.Click += button1_Click;\n            // \n            // panel3\n            // \n            panel3.Controls.Add(diagram1);\n            panel3.Dock = System.Windows.Forms.DockStyle.Bottom;\n            panel3.Location = new System.Drawing.Point(0, 75);\n            panel3.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);\n            panel3.Name = \"panel3\";\n            panel3.Size = new System.Drawing.Size(784, 788);\n            panel3.TabIndex = 0;\n            // \n            // label1\n            // \n            label1.Font = new System.Drawing.Font(\"Segoe UI\", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);\n            label1.Location = new System.Drawing.Point(-1, 25);\n            label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);\n            label1.Name = \"label1\";\n            label1.Size = new System.Drawing.Size(641, 49);\n            label1.TabIndex = 1;\n            label1.Text = \"Move the mouse pointer over the node to view the additional data associated with the node. Also,  you can edit the data by selecting the node, and clicking the EditInfo button\";\n            // \n            // Form1\n            // \n            AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);\n            AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\n            ClientSize = new System.Drawing.Size(784, 863);\n            Controls.Add(label1);\n            Controls.Add(panel3);\n            Controls.Add(button1);\n            Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);\n            MaximizeBox = false;\n            Name = \"Form1\";\n            StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;\n            Text = \"DynamicProperties\";\n            Load += Form1_Load;\n            ((System.ComponentModel.ISupportInitialize)diagram1).EndInit();\n            ((System.ComponentModel.ISupportInitialize)model1).EndInit();\n            panel3.ResumeLayout(false);\n            ResumeLayout(false);\n\n        }\n\n        #endregion\n\n        private Syncfusion.Windows.Forms.Diagram.Controls.Diagram diagram1;\n        private Syncfusion.Windows.Forms.Diagram.Model model1;\n        private System.Windows.Forms.Panel panel3;\n        private System.Windows.Forms.Button button1;\n        private System.Windows.Forms.Label label1;\n    }\n}\n\n"
    },
    {
      "target": "src/components/diagram-dynamic-properties/diagram.cs",
      "content": "using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Data;\nusing System.Drawing;\nusing System.Text;\nusing System.Windows.Forms;\nusing Syncfusion.Windows.Forms.Diagram;\nusing System.Xml;\nusing System.Drawing.Drawing2D;\nusing System.Collections;\nusing Syncfusion.Windows.Forms;\n\nnamespace DynamicProperties\n{\n    public partial class Form1 : MetroForm\n    {\n        #region Members\n        protected RadialTreeLayoutManager dtLayoutMgr;\n        ToolTip tooltips = new ToolTip();\n        #endregion\n\n        #region initializeForm\n        public Form1()\n        {\n            InitializeComponent();\n        }\n        #endregion\n\n        #region Events\n        private void Form1_Load(object sender, EventArgs e)\n        {\n            diagram1.Model.BeginUpdate();\n            this.diagram1.Controller.InPlaceEditing = false;\n            this.dtLayoutMgr = new RadialTreeLayoutManager(this.diagram1.Model, 0, 80, 80);\n            dtLayoutMgr.LeftMargin = 80;\n            dtLayoutMgr.TopMargin = 30;\n            dtLayoutMgr.AutoLayout = true;\n            diagram1.LayoutManager = dtLayoutMgr;\n            DiagramAppearance();\n#if !NETCORE\n            InitializeDiagramFromXMLData(@\"..\\..\\..\\..\\..\\..\\common\\Data\\Diagram\\xml\\DynamicProperties.xml\");\n#else\n            string dynamicXml = DynamicPropertiesDataSource.GetXmlPath();\n            if (dynamicXml != null)\n            {\n                InitializeDiagramFromXMLData(dynamicXml);\n            }\n#endif\n            diagram1.Model.EndUpdate();\n            diagram1.View.SelectionList.Clear();\n            CenterDiagram();\n            diagram1.Resize += (s, args) => CenterDiagram();\n            diagram1.EventSink.NodeMouseEnter += new NodeMouseEventHandler(EventSink_NodeMouseEnter);\n            diagram1.EventSink.NodeMouseLeave += new NodeMouseEventHandler(EventSink_NodeMouseLeave);\n        }\n\n        /// <summary>Re-applies the radial layout so that the diagram is horizontally centered.</summary>\n        private void CenterDiagram()\n        {\n            if (dtLayoutMgr == null || diagram1.ClientSize.Width <= 0 || diagram1.Model.Nodes.Count == 0)\n            {\n                return;\n            }\n\n            float left = float.MaxValue, right = float.MinValue;\n            foreach (Syncfusion.Windows.Forms.Diagram.Node node in diagram1.Model.Nodes)\n            {\n                left = Math.Min(left, node.BoundingRectangle.Left);\n                right = Math.Max(right, node.BoundingRectangle.Right);\n            }\n\n            float contentWidth = right - left;\n            float margin = Math.Max(0, (diagram1.ClientSize.Width - contentWidth) / 2);\n            float shift = margin - (left - dtLayoutMgr.LeftMargin);\n            if (Math.Abs(shift - dtLayoutMgr.LeftMargin) < 1)\n            {\n                return;\n            }\n\n            dtLayoutMgr.LeftMargin = shift;\n            dtLayoutMgr.UpdateLayout(null);\n        }\n\n        void EventSink_NodeMouseLeave(NodeMouseEventArgs evtArgs)\n        {\n            tooltips.Active = false;\n        }\n\n        void EventSink_NodeMouseEnter(NodeMouseEventArgs evtArgs)\n        {\n            if (!(evtArgs.Node is ConnectorBase) && evtArgs.Node.PropertyBag.Count > 0)\n            {\n                tooltips.IsBalloon = true;\n                string strData = string.Empty;\n                foreach (string key in evtArgs.Node.PropertyBag.Keys)\n                {\n                    strData += key + \" : \" + evtArgs.Node.PropertyBag[key] + \"\\n\";\n                }\n                tooltips.SetToolTip(this.diagram1, strData);\n                tooltips.Active = true;\n            }\n        }\n\n        private void button1_Click(object sender, EventArgs e)\n        {\n            if (diagram1.View.SelectionList.Count > 0)\n            {\n                PropertyBagDialog propertyBagDialog = new PropertyBagDialog();\n                propertyBagDialog.PropertyBag = diagram1.View.SelectionList[0].PropertyBag;\n                propertyBagDialog.ShowDialog();\n            }\n            else\n            {\n                MessageBox.Show(\"Please select a node to edit property info collection  \", \"Meesage\");\n            }\n        }\n#endregion\n\n#region Private Methods\n        /// <summary>\n        /// Change's the appearance of Diagram\n        /// </summary>\n        private void DiagramAppearance()\n        {            \n            this.diagram1.Model.LineStyle.LineColor = Color.Transparent;\n            this.diagram1.View.HandleRenderer.HandleColor = Color.AliceBlue;\n            this.diagram1.View.HandleRenderer.HandleOutlineColor = Color.SkyBlue;\n            this.diagram1.Model.RenderingStyle.SmoothingMode = SmoothingMode.HighQuality;\n            this.diagram1.Model.BoundaryConstraintsEnabled = false;\n            this.diagram1.View.BackgroundColor = Color.White;\n            this.diagram1.View.Grid.Visible = false;\n            this.diagram1.View.SelectionList.Clear();\n        }\n#endregion\n\n#region Initailize Diagram\n        \n        /// <summary>\n        /// Initialize diagram from XML file\n        /// </summary>\n        /// <param name=\"datasrcpath\">Path of the XML file</param>\n        protected void InitializeDiagramFromXMLData(string datasrcpath)\n        {\n            Hashtable lstEmployees = this.ReadEmployeeDataFromXMLFile(datasrcpath);\n\n            // Create a manager-employee nested list with top-level employees forming the root nodes\n            ArrayList sortedlist = this.GetSortedEmployeesList(lstEmployees);\n\n            foreach (Employee emply in sortedlist)\n            {\n                this.IterUpdateSubEmployeeCount(emply);\n            }\n\n            // Create diagram symbol nodes for each employee and initialize the diagram\n            this.CreateOrgDiagramFromList(sortedlist);\n            lstEmployees.Clear();\n            sortedlist.Clear();\n        }\n\n        /// <summary>\n        /// New function for reading data from xml file\n        /// </summary>\n        /// <param name=\"datasrc\">XML File</param>\n        protected Hashtable ReadEmployeeDataFromXMLFile(string datasrc)\n        {\n            Hashtable lstEmployee = new Hashtable();  \n\n            // Use the XML DOM to read data from the employees XML data file\n            XmlDocument xmldoc = new XmlDocument();\n#if SyncfusionFramework4_0\n            xmldoc.XmlResolver = null;\n#endif\n            xmldoc.Load(datasrc);\n            if (xmldoc.DocumentElement.HasChildNodes)\n            {\n                XmlNodeList employeelist = xmldoc.DocumentElement.ChildNodes;\n                for (int i = 0; i < employeelist.Count; i++)\n                {\n                    // Create an Employee instance to represent each employee\n                    Employee emply = new Employee();\n\n                    XmlNode employeenode = employeelist[i];\n                    XmlNodeList employeedatalist = employeenode.ChildNodes;\n                    IEnumerator employeedata = employeedatalist.GetEnumerator();\n                    employeedata.Reset();\n                    while (employeedata.MoveNext())\n                    {\n                        XmlNode dataelement = employeedata.Current as XmlNode;\n                        switch (dataelement.Name)\n                        {\n                            case \"Name\":\n                                emply.EmployeeName = dataelement.InnerText;\n                                break;\n                            case \"EmployeeID\":\n                                emply.EmployeeID = dataelement.InnerText;                                \n                                break;\n                            case \"Designation\":\n                                emply.Designation = dataelement.InnerText;                                \n                                break;\n                            case \"DOJ\":\n                                emply.DOJ = dataelement.InnerText;                                \n                                break;\n                            case \"ImageNo\":\n                                emply.ImageName = dataelement.InnerText;\n                                break;\n                            case \"ManagerID\":\n                                emply.ManagerID = dataelement.InnerText;\n                                break;\n                        }\n                    }\n                    lstEmployee.Add(emply.EmployeeID,emply);\n                }\n            }\n            return lstEmployee;\n        }\n\n        /// <summary>\n        ///  Rearrange the employees collection as a manager-subemployee nested tree\n        /// </summary>\n        /// <param name=\"htemployees\">Employee table</param>\n        /// <returns>returns the sorted list</returns>\n        protected ArrayList GetSortedEmployeesList(Hashtable htemployees)\n        {\n            ICollection employees = htemployees.Values;\n            ArrayList sortedlist = new ArrayList();\n            foreach (Employee emply in employees)\n            {\n                if (emply.ManagerID == string.Empty)\n                {\n                    // Employees without a ManagerID are top-level nodes in the org tree\n                    sortedlist.Add(emply);\n                }\n                else\n                {\n                    // Find the employee instance associated with the managerID and add this object as \n                    // a subemployee of the manager node.\n                    Employee manager = (Employee)htemployees[emply.ManagerID];\n                    if (manager != null)\n                        manager.SubEmployees.Add(emply);\n                }\n            }\n\n            return sortedlist;\n        }\n\n        /// <summary>\n        /// generates the sub employees count\n        /// </summary>\n        /// <param name=\"empl\">Employee business object</param>\n        protected void IterUpdateSubEmployeeCount(Employee empl)\n        {\n            empl.RecSubEmployeeCount = empl.SubEmployees.Count;\n            foreach (Employee subempl in empl.SubEmployees)\n            {\n                this.IterUpdateSubEmployeeCount(subempl);\n                empl.RecSubEmployeeCount += subempl.RecSubEmployeeCount;\n            }\n        }\n\n        /// <summary>\n        /// Create diagram symbol nodes for each employee in the organization and add these symbols to the diagram\n        /// Create links between manager and sub-employees to depict the org structure\n        /// </summary>\n        /// <param name=\"alemployees\"> Employees list</param>\n        protected void CreateOrgDiagramFromList(ArrayList alemployees)\n        {\n            // Temporarily suspend the Diagram Model redrawing\n            this.diagram1.Model.BeginUpdate();\n\n            foreach (Employee emply in alemployees)\n            {\n                string fileName = DynamicPropertiesDataSource.GetEmployeeImagePath(emply.ImageName);\n                BitmapNode employeeSymbol = new BitmapNode(new Bitmap(fileName), new RectangleF(100,100,75,75));\n                employeeSymbol.LineStyle.LineColor = Color.Transparent;\n                employeeSymbol.PropertyBag.Add(\"Name\",emply.EmployeeName);\n                employeeSymbol.PropertyBag.Add(\"ID\", emply.EmployeeID);\n                employeeSymbol.PropertyBag.Add(\"Designation\", emply.Designation);\n                this.diagram1.Model.AppendChild(employeeSymbol);\n                this.IterCreateEmployeeSymbol(emply, employeeSymbol);\n            }\n\n            // Enable the Model redraw\n            this.diagram1.Model.EndUpdate();\n\n            // Instruct the LayoutManager to calculate and layout the diagram nodes\n            LayoutNodes();\n        }\n\n\n        /// <summary>\n        ///  Iterative sub-employee symbol node creation\n        /// </summary>\n        /// <param name=\"emply\">Employess business object</param>\n        /// <param name=\"emplysymbol\">Employee Node</param>\n        protected void IterCreateEmployeeSymbol(Employee emply, BitmapNode bmpNode)\n        {\n            foreach (Employee subemply in emply.SubEmployees)\n            {\n                string fileName = DynamicPropertiesDataSource.GetEmployeeImagePath(subemply.ImageName);\n                // Create a BitmapNode for each of the sub-employees of the particular employee \n                BitmapNode subemplysymbol = new BitmapNode(new Bitmap(fileName), new RectangleF(100, 100, 75, 75));\n                subemplysymbol.LineStyle.LineColor = Color.Transparent;\n                subemplysymbol.PropertyBag.Add(\"Name\", subemply.EmployeeName);\n                subemplysymbol.PropertyBag.Add(\"ID\", subemply.EmployeeID);\n                subemplysymbol.PropertyBag.Add(\"Designation\", subemply.Designation);\n                this.diagram1.Model.AppendChild(subemplysymbol);\n\n                bmpNode.EnableCentralPort = true;\n                subemplysymbol.EnableCentralPort = true;\n                ConnectNodes(bmpNode, subemplysymbol);\n\n                this.IterCreateEmployeeSymbol(subemply, subemplysymbol);\n            }\n\n        }\n\n        /// <summary>\n        /// Connects the nodes\n        /// </summary>\n        /// <param name=\"parent\">Parent Node</param>\n        /// <param name=\"child\">Child node</param>\n        private void ConnectNodes(Node parent, Node child)\n        {\n            LineConnector lConnector = new LineConnector(PointF.Empty, new PointF(0, 1));\n            lConnector.LineStyle.LineWidth = 1f;\n            lConnector.LineStyle.LineColor = Color.Black;\n            lConnector.HeadDecorator.DecoratorShape = DecoratorShape.Filled45Arrow;            \n            lConnector.HeadDecorator.FillStyle.Color = Color.White;\n            this.diagram1.Model.AppendChild(lConnector);\n\n            if (parent.CentralPort != null && child.CentralPort != null)\n            {\n                parent.CentralPort.TryConnect(lConnector.TailEndPoint);\n                child.CentralPort.TryConnect(lConnector.HeadEndPoint);\n            }\n\n            this.diagram1.Controller.SendToBack();\n        }\n    \n#endregion\n        \n#region Helper Methods\n\n        private void LayoutNodes()\n        {\n            // Temporarily suspend the layoutmanager\n            this.diagram1.LayoutManager.AutoLayout = false;\n\n            this.diagram1.LayoutManager.Nodes.Clear();\n            this.diagram1.LayoutManager.Nodes.AddRange(this.diagram1.Model.Nodes);\n            this.diagram1.LayoutManager.UpdateLayout(null);\n        }\n#endregion\n    }\n}\n"
    }
  ]
}