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.
Unfortunately, activation email could not send to your email. Please try again.

Centering the root node?

Thread ID:

Created:

Updated:

Platform:

Replies:

97375 Nov 22,2010 01:05 PM Nov 24,2010 08:35 AM Silverlight 1
loading
Tags: Diagram
Brad Lefferdink
Asked On November 22, 2010 01:05 PM

Is there a way to have the root node of a DirectedTree auto center? For eaxample, when I do a Top-bottom layout, unless I manually set the resulting DiagramView.Bounds (or in code after initial load of page), the root node gets drawn at 0,0 and the diagram only scrolls to the right if necessary.

Is something like the following the only solution? (see MainPage_Loaded event handler):

public MainPage2()
{
InitializeComponent();

_diagramControl = new Syncfusion.Windows.Diagram.DiagramControl();
_diagramControl.IsSymbolPaletteEnabled = false;
_diagramControl.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
_diagramControl.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;

_diagramView = new DiagramView();
//_diagramView.Bounds = new Thickness(0, 0, 450, 10);
_diagramView.IsPageEditable = false;
_diagramControl.View = _diagramView;

_diagramModel = new DiagramModel();
_diagramModel.VerticalSpacing = 50;
_diagramModel.HorizontalSpacing = 30;
_diagramModel.SpaceBetweenSubTrees = 50;
_diagramModel.LayoutType = LayoutType.DirectedTreeLayout;
_diagramModel.Orientation = TreeOrientation.TopBottom;
_diagramControl.Model = _diagramModel;

LayoutRoot.Children.Add(_diagramControl);


#region For Testing
//Omitted code...
#endregion For Testing


(_diagramModel.Connections[_diagramModel.Connections.Count - 1] as LineConnector).Loaded += new RoutedEventHandler(MainPage_Loaded);
}


void MainPage_Loaded(object sender, RoutedEventArgs e)
{
DirectedTreeLayout dtl = new DirectedTreeLayout(_diagramModel, _diagramView);
//dtl.RefreshLayout(); //StartNodeArrangement();

double leftMost = 0;
double rightMost = 0;

foreach (Node node in _diagramModel.Nodes)
{
if (node.Equals(_diagramModel.Nodes[0] as Node))
{
leftMost = node.OffsetX;
rightMost = node.OffsetX + node.Width;
}
else
{
if (node.Visibility == System.Windows.Visibility.Visible)
{
if (node.OffsetX < leftMost)
leftMost = node.OffsetX;

if ((node.OffsetX + node.Width) > rightMost)
rightMost = node.OffsetX + node.Width;
}
}
}

//_diagramView.Bounds = new Thickness(0, 0, ((rightMost - leftMost) / 2) - ((_diagramModel.Nodes[0] as Node).Width / 2), 0);
_diagramView.Bounds = new Thickness(0, 0, ((rightMost - leftMost) + 20), 0);

dtl.RefreshLayout();

}



Sundar M [Syncfusion]
Replied On November 24, 2010 08:35 AM

Hi Brad,

Regarding directed tree layout’s root node position, in our 8.3v and older version releases, by default the root node of a directed tree layout is placed at 0,0. However in our currently released 8.4 version, the default position of the root node is placed at the center of the DiagramPage.

Please let us know if you have any queries.

Regards,
Sundar M.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;