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. Image for the cookie policy date
close icon

The connect-line is not working for me. What I missed? Thanks!

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

using Syncfusion.Windows.Forms.Diagram;
using Syncfusion.Windows.Forms.Diagram.Controls;
using System.Collections.Generic;

namespace Sample_LinkCmd
{
///
/// Summary description for Form1.
///

public class Form1 : System.Windows.Forms.Form
{
private Syncfusion.Windows.Forms.Diagram.Controls.PropertyEditor propertyEditor1;
private Syncfusion.Windows.Forms.Diagram.Controls.Diagram diagram1;
private Model model1;
private IContainer components;

private static Dictionary g_Node = new Dictionary();

public Form1()
{
InitializeComponent();
}

///
/// Clean up any resources being used.
///

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
................
}
#endregion

///
/// The main entry point for the application.
///

[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void DrawNotes()
{

}

private void DrawNodeRelation()
{

}

private void Form1_Load(object sender, System.EventArgs e)
{
this.diagram1.Model = this.model1;
// Use the InsertNodesCmd to insert the two symbols into the diagram
this.diagram1.Model.BeginUpdate();

NodeCollection symbols = new NodeCollection();

for (int i = 0; i < 10; i++)
{
MySymbol symbolX = new MySymbol(i.ToString());
symbolX.PinPoint = new PointF(100 + symbol1.PinPointOffset.Width, 100 + symbol1.PinPointOffset.Height);
symbolX.setParentId("parent of " + i);
symbolX.EnableCentralPort = true;
//symbols.Add(symbolX);

g_Node.Add(i.ToString(), symbolX);
symbols.Add(g_Node[i.ToString()]);

}
for (int i = 1; i < g_Node.Count; i++)
{
//int position = 0;
LineConnector lineX = new LineConnector(g_Node[i.ToString()].PinPoint, g_Node[(i-1).ToString()].PinPoint);
lineX.TailDecorator.DecoratorShape = DecoratorShape.OpenFancyArrow;
symbols.Add(lineX);

g_Node[i.ToString()].CentralPort.TryConnect(lineX.HeadEndPoint);
g_Node[(i-1).ToString()].CentralPort.TryConnect(lineX.TailEndPoint);

}


this.diagram1.Model.AppendChildren(symbols, out position);


HierarchicLayoutManager hierarchyLayout = new HierarchicLayoutManager(diagram1.Model, 0, 10, 20);
hierarchyLayout.RotationAngle = 180;
this.diagram1.LayoutManager = hierarchyLayout;
this.diagram1.LayoutManager.UpdateLayout(null);


this.diagram1.Model.EndUpdate();

}

private void diagram1_Click(object sender, EventArgs e)
{

}
}
}

=============================================

using System;
using System.Drawing;
using System.ComponentModel;
using System.Runtime.Serialization;

using Syncfusion.Windows.Forms.Diagram;

namespace Sample_LinkCmd
{
///
/// Summary description for MySymbol.
///

[Serializable()]
public class MySymbol : Group
{
private Syncfusion.Windows.Forms.Diagram.Rectangle outerRect = null;
private Ellipse innerEllipse = null;
private string m_sParentId = null;

public MySymbol(string strTitle)
{
//////////////////////////////////////////////////////////////////
// Add child nodes to the symbol programmatically
//////////////////////////////////////////////////////////////////

// Add an outer rectangle
this.outerRect = new Syncfusion.Windows.Forms.Diagram.Rectangle(0, 0, 120, 80);
this.outerRect.Name = "Rectangle";
this.outerRect.FillStyle.Type = Syncfusion.Windows.Forms.Diagram.FillStyleType.LinearGradient;
this.outerRect.FillStyle.ForeColor = System.Drawing.Color.Orange;
this.outerRect.FillStyle.Color = Color.Orange;
this.outerRect.ShadowStyle.Visible = true;
this.AppendChild(outerRect);

// Add an inner ellipse
this.innerEllipse = new Ellipse(10, 10, 100, 60);
this.innerEllipse.Name = "Ellipse";
this.AppendChild(innerEllipse);

Label lbl = new Label(this, strTitle);
lbl.ReadOnly = true;
this.Labels.Add(lbl);
}

public void setParentId(string sParentId)
{
this.m_sParentId = sParentId;
}

public string getParentId()
{
return this.m_sParentId;
}
}
}





3 Replies

KF Kona Fo April 15, 2009 09:18 PM UTC

Attached the C# Project.

Thanks for your help!!!

~Stanley



988_LinkCmd_Sample_src_43145252.zip


AD Administrator Syncfusion Team April 16, 2009 02:26 PM UTC

Hi Stanly,

The problem in your application is that,ParentId setting for the symbol is incorrect.And also adding symbols to the diagram is not proper.The functionality of the HierarchicLayoutManager is that,arranging nodes related to their corresponding parent node.So set the parent node properly before layouting the nodes

I have modified your c# sample .Here is the link

http://files.syncfusion.com/support/Diagram.Windows/Forums/F80606/main.htm


Let me know if you shall need any further clarifications in this regard.

Thanks and Regards,
Gowri





KF Kona Fo April 17, 2009 10:56 PM UTC

Thanks for the fix!
~Stanley


Loader.
Live Chat Icon For mobile
Up arrow icon