Example #1
0
 private void ApplyContainerLayout()
 {
     if (TreeLayout.IsChecked.Value)
     {
         var settings = new TreeLayoutSettings
         {
             TreeLayoutType          = TreeLayoutType.TipOverTree,
             IgnoreContainers        = this.IgnoreContainersCheck.IsChecked.Value,
             LayoutContainerChildren = this.LayoutContainersCheck.IsChecked.Value,
             ComponentsGridWidth     = 15000
         };
         if (this.containerSampleRoots != null)
         {
             settings.Roots.AddRange(this.containerSampleRoots);
         }
         this.diagram.Layout(LayoutType.Tree, settings);
     }
     else
     {
         var settings = new SugiyamaSettings
         {
             IgnoreContainers        = this.IgnoreContainersCheck.IsChecked.Value,
             LayoutContainerChildren = this.LayoutContainersCheck.IsChecked.Value,
             ComponentsGridWidth     = 15000
         };
         this.diagram.Layout(LayoutType.Sugiyama, settings);
     }
 }
Example #2
0
        private void UpdateLayout(bool isAutoFitDone = false, bool isAsync = true)
        {
            if (this.IsAutoLayoutEnabled)
            {
                if (isAutoFitDone)
                {
                    this.Diagram.DiagramLayoutComplete -= this.Diagram_DiagramLayoutComplete;
                    this.Diagram.DiagramLayoutComplete += this.Diagram_DiagramLayoutComplete;
                }

                var sugiyamaSettings = new SugiyamaSettings
                {
                    AnimateTransitions = true,
                    Orientation        = Orientation.Vertical,
                    VerticalDistance   = 128,
                    HorizontalDistance = 128,
                    ComponentMargin    = new Size(128, 128)
                };

                if (isAsync)
                {
                    this.Diagram.LayoutAsync(LayoutType.Sugiyama, sugiyamaSettings);
                }
                else
                {
                    this.Diagram.Layout(LayoutType.Sugiyama, sugiyamaSettings);
                }

                this.Diagram.InvalidateVisual();
            }
            else
            {
                if (isAutoFitDone)
                {
                    this.Diagram.AutoFitAsync(new Thickness(10));
                }
            }
        }
		private void LayoutDiagram(object sender)
		{
			var diagram = sender as RadDiagram;
			if (diagram == null) return;
			var settings = new SugiyamaSettings
			{
				// you can use the vertical direction though it'd result in a less conventional apperance
				Orientation = Telerik.Windows.Diagrams.Core.Orientation.Horizontal,

				// the horizontal distance or separation between item on the same layer
				HorizontalDistance = 50d
			};

			// if you don't call Layout with some settings then default will be used
			diagram.Layout(settings);

			// auto-size them again
			foreach (var shape in diagram.Shapes)
			{
				shape.Height = double.NaN;
				shape.Width = double.NaN;
			}
		}
Example #4
0
 private void ApplyContainerLayout()
 {
     if (TreeLayout.IsChecked.Value)
     {
         var settings = new TreeLayoutSettings
         {
             TreeLayoutType = TreeLayoutType.TipOverTree,
             IgnoreContainers = this.IgnoreContainersCheck.IsChecked.Value,
             LayoutContainerChildren = this.LayoutContainersCheck.IsChecked.Value,
             ComponentsGridWidth = 15000
         };
         if (this.containerSampleRoots != null) settings.Roots.AddRange(this.containerSampleRoots);
         this.diagram.Layout(LayoutType.Tree, settings);
     }
     else
     {
         var settings = new SugiyamaSettings
         {
             IgnoreContainers = this.IgnoreContainersCheck.IsChecked.Value,
             LayoutContainerChildren = this.LayoutContainersCheck.IsChecked.Value,
             ComponentsGridWidth = 15000
         };
         this.diagram.Layout(LayoutType.Sugiyama, settings);
     }
 }
Example #5
0
        private void Timer_Tick(object sender, EventArgs e)
        {
            (sender as DispatcherTimer).Stop();
            if (cmdDiagramType.SelectedItem != null)
            {
                var type = ((DiagramTypes)cmdDiagramType.SelectedItem).DiagramType;
                if (type == EnumDiagramTypes.Sugiyama)
                {
                    SugiyamaSettings settings = new SugiyamaSettings();
                    diagram.Layout(LayoutType.Sugiyama, settings);
                }
                else
                {
                    TreeLayoutSettings settings = new TreeLayoutSettings();
                    if (type == EnumDiagramTypes.TreeHorizontal)
                    {
                        settings.TreeLayoutType = TreeLayoutType.TreeRight;
                    }
                    else if (type == EnumDiagramTypes.TreeVertical)
                    {
                        settings.TreeLayoutType = TreeLayoutType.TreeDown;
                    }
                    else if (type == EnumDiagramTypes.TreeRadial)
                    {
                        settings.TreeLayoutType = TreeLayoutType.RadialTree;
                    }
                    else if (type == EnumDiagramTypes.TreeTipOver)
                    {
                        settings.TreeLayoutType = TreeLayoutType.TipOverTree;
                    }
                    else if (type == EnumDiagramTypes.MindmapHorizontal)
                    {
                        settings.TreeLayoutType = TreeLayoutType.MindmapHorizontal;
                    }
                    else if (type == EnumDiagramTypes.MindmapVertical)
                    {
                        settings.TreeLayoutType = TreeLayoutType.MindmapVertical;
                    }
                    else if (type == EnumDiagramTypes.TreeUndefined)
                    {
                        settings.TreeLayoutType = TreeLayoutType.Undefined;
                    }

                    if (Roots.Any())
                    {
                        settings.Roots.AddRange(Roots);
                    }
                    diagram.Layout(LayoutType.Tree, settings);
                }



                diagram.AutoFit();

                //if (diagram.Items.Any())
                //    settings.Roots.Add((diagram.Items[0] as UserControl).Parent as RadDiagramShape);
                //
                //    diagram.Layout(LayoutType.Tree, settings);
                //    diagram.AutoFit();
                //    shapeS.Position = new Point(shapeS.Position.X, shapeF.Position.Y);
            }
        }