Hi stoyo
In my project Im drawing Radial tree.But in Output
all nodes Overlap each other.. I dont know What happened..
Below i provided my source code
private void fillWeb()
{
try
{
string strSql = "SELECT * FROM Web WHERE W_Parent = 1 ORDER BY W_ID";
OleDbCommand cmd = mcn.CreateCommand();
cmd.CommandText = strSql;
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "Web");
cmd.Dispose();
// Create the root of the tree.
this.mboxRoot=this.fc.Factory.CreateShapeNode(fc.Bounds.Width / 4, fc.Bounds.Height / 6, 10, 10);
//this.mboxRoot = this.fc.CreateBox(fc.Size.Width / 4, fc.Size.Height / 6, 10, 10);
this.mboxRoot.Text = "Home";
this.mboxRoot.Tag = 1;
this.mboxRoot.Brush=new MindFusion.Drawing.LinearGradientBrush(
Color.Yellow, Color.BurlyWood, 20);
//this.mboxRoot.Brush = Color.AliceBlue;
// We want all node's children to move when their parent is moved.
this.mgrpRoot=this.fc.Factory.CreateGroup(this.mboxRoot);
this.mgrpRoot.Tag = 1;
this.mboxCurrent=this.mboxRoot;
foreach (DataRow dr in ds.Tables["Web"].Rows)
{
ShapeNode b = addChild(this.mboxCurrent);
b.Tag = dr[0];
b.Text = dr[0].ToString();
b.ToolTip = dr[3].ToString() + dr[2].ToString();
if (dr[2].ToString().IndexOf(".") > 0)
{
b.Brush=new MindFusion.Drawing.SolidBrush(Color.AliceBlue);
b.Pen=new MindFusion.Drawing.Pen(Color.LightGray);
}
else
{
b.Brush=new MindFusion.Drawing.SolidBrush(Color.MintCream);
b.Pen=new MindFusion.Drawing.Pen(Color.MintCream);
addChilds(b);
}
}
ds.Dispose();
da.Dispose();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
/////////////////////// add child
private ShapeNode addChild(ShapeNode bParent)
{
// Get the group of the parent node.
Group gParent = fc.FindGroup(bParent.Tag);
// Create the new node and add it to the parent group
// so its position is updated when the parent is moved.
ShapeNode b = fc.Factory.CreateShapeNode(0, 0, 5, 5);
gParent.AttachToCorner(b,0);
// Link the parent node with the child.
DiagramLink a = fc.Factory.CreateDiagramLink(bParent, b);
a.Pen=new MindFusion.Drawing.Pen(Color.Red);
// Update the counter.
this.mintUniqueId++;
b.Tag = this.mintUniqueId;
// Start a new group to which node children will be added.
Group g = fc.Factory.CreateGroup(b);
g.Tag = this.mintUniqueId;
// Rearrange the tree.
reArrange();
return b;
}
private void reArrange()
{
if (this.mtl == null)
{
this.mtl = new MindFusion.Diagramming.Layout.TreeLayout (this.mboxRoot,
MindFusion.Diagramming.Layout.TreeLayoutType.Radial, false, MindFusion.Diagramming.Layout.TreeLayoutLinkType.Rounded,
MindFusion.Diagramming.Layout.TreeLayoutDirection.TopToBottom, 169, 120, true,new SizeF(10, 10), true);
}
this.mtl.Arrange(this.fc);
}
//////////////////////////////
private void addChilds(ShapeNode pBox)
{
try
{
String strSql = "SELECT * FROM Web WHERE W_Parent = " + pBox.Tag.ToString() + " ORDER BY W_ID";
OleDbCommand cmd = mcn.CreateCommand();
cmd.CommandText = strSql;
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "User_Log");
cmd.Dispose();
if (ds.Tables["User_Log"].Rows.Count > 0)
{
// We want all node's children to move when their parent is moved.
Group grp = this.fc.Factory.CreateGroup(pBox);
pBox.Tag=this.mgrpRoot.Tag;
foreach ( DataRow dr in ds.Tables["User_Log"].Rows)
{
ShapeNode b = addChild(pBox);
b.Tag = dr[0];
b.Text = dr[0].ToString();
b.ToolTip = dr[3].ToString() + dr[2].ToString();
if (dr[2].ToString().IndexOf(".") > 0)
{
b.Brush=new MindFusion.Drawing.SolidBrush(Color.AliceBlue);
b.Pen=new MindFusion.Drawing.Pen(Color.LightGray);
}
else
{
b.Brush=new MindFusion.Drawing.SolidBrush(Color.MintCream);
b.Pen=new MindFusion.Drawing.Pen(Color.LightGray);
addChilds(b);
}
}
}
ds.Dispose();
da.Dispose();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
I dont know how to insert image in this forum that's why i hav Given source code ,,Pls dont mistake me