public static IContainerShape CreateContainerShape(this RadDiagram diagram, string title = null, string name = null) { if (string.IsNullOrEmpty(title)) { title = "Container"; } if (string.IsNullOrEmpty(name)) { name = "Container_" + Rand.Next(665686356); } var shape = new RadDiagramContainerShape { Width = 250, Height = 150, Name = name, Content = title, //Stroke = Brushes.DimGray, IsCollapsible = true, StrokeThickness = 1, CollapsedContent = null, }; diagram.AddShape(shape); return(shape); }
private void btnGenerateContainer_Click_1(object sender, RoutedEventArgs e) { RadDiagramContainerShape Container = new RadDiagramContainerShape(); Container.Position = new Point { X = this.diagram.Viewport.Left, Y = this.diagram.Viewport.Top }; Container.AllowDrop = false; Container.Width = 100; Container.Height = 100; Container.IsResizingEnabled = false; List <IConnector> cs = new List <IConnector>(); foreach (var connen in Container.Connectors) { cs.Add(connen); } foreach (var connen in cs) { Container.Connectors.Remove(connen); } diagram.AddShape(Container); }
private static void ExportContainerShape(RadDiagramContainerShape container, Rect enclosingBounds, RadFixedPage page) { var bounds = new Rect(container.Bounds.X - enclosingBounds.X, container.Bounds.Y - enclosingBounds.Y, container.Bounds.Width, container.Bounds.Height); var transformGroup = new TransformGroup(); transformGroup.Children.Add(new RotateTransform() { Angle = container.RotationAngle, CenterX = bounds.Width / 2, CenterY = bounds.Height / 2 }); transformGroup.Children.Add(new TranslateTransform() { X = bounds.X, Y = bounds.Y }); var position = new MatrixPosition(transformGroup.Value); FixedContentEditor containerEditor = CreateEditor(new EditorInfo(page, position, container, bounds, container.BorderBrush, container.RotationAngle), true); containerEditor.DrawRectangle(new Rect(new Point(), bounds.ToSize())); containerEditor.GraphicProperties.StrokeThickness = 0.5; var headerHeight = container.ContentBounds.Y - container.Bounds.Y - DiagramConstants.ContainerMargin; containerEditor.DrawRectangle(new Rect(new Point(0, headerHeight), new Size(bounds.Width, 0.5))); if (container.IsCollapsible) { var buttonTop = headerHeight / 2 - 2.5; var buttonLeft = bounds.Width - 20; if (container.IsCollapsed) { containerEditor.DrawLine(new Point(buttonLeft, buttonTop), new Point(buttonLeft + 4, buttonTop + 4)); containerEditor.DrawLine(new Point(buttonLeft + 4, buttonTop + 4), new Point(buttonLeft + 8, buttonTop)); if (container.CollapsedContent != null) { var contentHeight = container.ActualHeight - headerHeight; ExportContent(container, bounds, container.RotationAngle, page, (s) => { return(new Point(bounds.Center().X - s.Width / 2, bounds.Bottom - contentHeight / 2 - s.Height / 2)); }, container.CollapsedContent.ToString()); } } else { containerEditor.DrawLine(new Point(buttonLeft, buttonTop + 4), new Point(buttonLeft + 4, buttonTop)); containerEditor.DrawLine(new Point(buttonLeft + 4, buttonTop), new Point(buttonLeft + 8, buttonTop + 4)); } } if (container.Content != null) { ExportContent(container, bounds, container.RotationAngle, page, (s) => { return(new Point(bounds.Center().X - s.Width / 2, bounds.Top + headerHeight / 2 - s.Height / 2)); }); } }
private void ChangeConnectionVisibility(Telerik.Windows.Diagrams.Core.IShape sourceShape, bool isVisible) { foreach (var connection in sourceShape.OutgoingLinks) { connection.Visibility = isVisible ? Telerik.WinControls.ElementVisibility.Hidden : Telerik.WinControls.ElementVisibility.Visible; connection.Target.Visibility = isVisible ? Telerik.WinControls.ElementVisibility.Hidden : Telerik.WinControls.ElementVisibility.Visible; RadDiagramContainerShape container = connection.Target as RadDiagramContainerShape; if (container != null) { foreach (var item in container.Items) { item.Visibility = isVisible? Telerik.WinControls.ElementVisibility.Hidden : Telerik.WinControls.ElementVisibility.Visible; } } this.ChangeConnectionVisibility(connection.Target, isVisible); } }
private Point InsertAtPositionOfDroppedContainer(RadDiagramContainerShape container) { var childShapes = container.Items; if (childShapes.Count() == 0) { return(new Point(container.Position.X + 20, container.Position.Y + 20)); } else if (childShapes.Count() == 1) { var firstShape = childShapes[0] as NodeViewModelBase; return(new Point(firstShape.Position.X + 120 + 20, firstShape.Position.Y)); } else { var oddShape = childShapes[childShapes.Count - 2] as NodeViewModelBase; return(new Point(oddShape.Position.X, oddShape.Position.Y + 30 + 20)); } }
public static IContainerShape CreateContainerShape(this RadDiagram diagram, string title = null, string name = null) { if (string.IsNullOrEmpty(title)) title = "Container"; if (string.IsNullOrEmpty(name)) name = "Container_" + Rand.Next(665686356); var shape = new RadDiagramContainerShape { Width = 250, Height = 150, Name = name, Content = title, //Stroke = Brushes.DimGray, IsCollapsible = true, StrokeThickness = 1, CollapsedContent = null, }; diagram.AddShape(shape); return shape; }
private void OnLoaded(object sender, RoutedEventArgs routedEventArgs) { var shapes = new Dictionary<string, RadDiagramShape> { { "Start", new RadDiagramShape { Geometry = ShapeFactory.GetShapeGeometry(FlowChartShapeType.StartShape), GlidingStyle = GlidingStyle.Ellipse, Position = new Point(380, 50), Background = new SolidColorBrush(Colors.Green), Width = 50, Height = 50, BorderBrush = new SolidColorBrush(Colors.Transparent), Effect = effect } }, { "Stop", new RadDiagramShape { Geometry = ShapeFactory.GetShapeGeometry(FlowChartShapeType.StartShape), GlidingStyle = GlidingStyle.Ellipse, Position = new Point(386, 573), Background = new SolidColorBrush(Colors.Orange), Width = 50, Height = 50, BorderBrush = new SolidColorBrush(Colors.Transparent), Effect = effect } }, { "New?", new RadDiagramShape { Geometry = ShapeFactory.GetShapeGeometry(FlowChartShapeType.DecisionShape) , GlidingStyle = GlidingStyle.Diamond, Position = new Point(350, 150), Background = new SolidColorBrush(Colors.Orange), Content = "New?", BorderBrush = new SolidColorBrush(Colors.Transparent), Effect = effect } }, { "CreateCart", new RadDiagramShape { Geometry = ShapeFactory.GetShapeGeometry(FlowChartShapeType.CreateRequestShape), GlidingStyle = GlidingStyle.Rectangle, Position = new Point(222,280), Background = new SolidColorBrush(Colors.Blue), Content = "Create New", BorderBrush = new SolidColorBrush(Colors.Transparent), Effect = effect } }, { "FetchCart", new RadDiagramShape { Geometry = ShapeFactory.GetShapeGeometry(FlowChartShapeType.CreateRequestShape), GlidingStyle = GlidingStyle.Rectangle, Position = new Point(478,280), Background = new SolidColorBrush(Colors.Blue), Content = "Fetch Existing", BorderBrush = new SolidColorBrush(Colors.Transparent), Effect = effect } }, { "Database", new RadDiagramShape { Geometry = ShapeFactory.GetShapeGeometry(FlowChartShapeType.Database1Shape), GlidingStyle = GlidingStyle.Rectangle, Position = new Point(725,255), Background = new SolidColorBrush(Colors.LightGray), Content = "Oracle", BorderBrush = new SolidColorBrush(Colors.Transparent), Effect = effect, Opacity = .85 } }, { "BizTalk", new RadDiagramShape { Geometry = ShapeFactory.GetShapeGeometry(CommonShapeType.RoundedRectangleShape), GlidingStyle = GlidingStyle.Rectangle, Position = new Point(890,255), Background = new SolidColorBrush(Colors.Gray), Content = "BizTalk", BorderBrush = new SolidColorBrush(Colors.Transparent), Effect = effect, Opacity = .85 } }, { "Azure", new RadDiagramShape { Geometry = ShapeFactory.GetShapeGeometry(CommonShapeType.CloudShape), GlidingStyle = GlidingStyle.Rectangle, Position = new Point(1070,255), Background =new SolidColorBrush(Colors.Blue), Content = "Azure", BorderBrush = new SolidColorBrush(Colors.Transparent), Effect = effect, Opacity = .6 } }, { "Present", new RadDiagramShape { Geometry = ShapeFactory.GetShapeGeometry(FlowChartShapeType.DocumentShape), GlidingStyle = GlidingStyle.Rectangle, Position = new Point(355,432), Background = new SolidColorBrush(Colors.Green), Content = "Present", BorderBrush = new SolidColorBrush(Colors.Transparent), Effect = effect, Opacity = 1 } }, { "FSM", new RadDiagramShape { Geometry = null, GlidingStyle = GlidingStyle.Rectangle, Position = new Point(830,400), Background = new SolidColorBrush(Colors.Blue), Foreground = new SolidColorBrush(Colors.Black), Content = "FSM", BorderBrush = new SolidColorBrush(Colors.Transparent), Effect = effect, Opacity = 1 } }, }; // add all shapes shapes.ForEach(s => diagram.AddShape(s.Value)); var ctShapes = new[] { "Database", "FSM", "Azure", "BizTalk" }; var container = new RadDiagramContainerShape { Position = new Point(692, 204), Width = 565, Height = 305, Content = "Backend", Stroke = new SolidColorBrush(Colors.Red), StrokeDashArray = new DoubleCollection { 1, 1 }, Background = new SolidColorBrush(Colors.LightGray), Foreground = new SolidColorBrush(Colors.Gray), ZIndex = -5 }; ctShapes.ForEach(s => container.Items.Add(shapes[s])); diagram.AddShape(container); shapes["CreateCart"].RotationAngle = 315; shapes["FetchCart"].RotationAngle = 45; var c1 = diagram.AddConnection(shapes["Start"], shapes["New?"]) as RadDiagramConnection; c1.Content = "always"; var c2 = diagram.AddConnection(shapes["New?"], shapes["CreateCart"]) as RadDiagramConnection; c2.Content = "yes"; var c3 = diagram.AddConnection(shapes["New?"], shapes["FetchCart"]) as RadDiagramConnection; c3.Content = "no"; var c4 = diagram.AddConnection(container, shapes["FetchCart"]) as RadDiagramConnection; c4.StrokeDashArray = new DoubleCollection { 2, 2 }; c4.SourceCapType = CapType.Arrow6Filled; c4.Opacity = .5; var c5 = diagram.AddConnection(shapes["Database"], shapes["BizTalk"]) as RadDiagramConnection; c5.StrokeDashArray = new DoubleCollection { 3, 2 }; c5.SourceCapType = CapType.Arrow5Filled; c5.Content = "Orchestration"; c5.Opacity = .5; var c6 = diagram.AddConnection(shapes["Azure"], shapes["BizTalk"]) as RadDiagramConnection; c6.StrokeDashArray = new DoubleCollection { 3, 2 }; c6.SourceCapType = CapType.Arrow5Filled; c6.Content = "Async"; c6.Opacity = .5; var c7 = diagram.AddConnection(shapes["FSM"], shapes["BizTalk"]) as RadDiagramConnection; c7.StrokeDashArray = new DoubleCollection { 3, 2 }; c7.SourceCapType = CapType.Arrow5Filled; c7.Content = "Async"; c7.Opacity = .5; var c8 = diagram.AddConnection(shapes["FSM"], shapes["Database"]) as RadDiagramConnection; c8.StrokeDashArray = new DoubleCollection { 3, 2 }; c8.SourceCapType = CapType.Arrow5Filled; c8.Content = "Async"; c8.BezierTension = .72; c8.ManipulationPoints[0].Position = new Point(50, 550); c8.UpdateLayout(); c8.Opacity = .5; var c9 = diagram.AddConnection(shapes["CreateCart"], shapes["Present"]) as RadDiagramConnection; c9.TargetCapType = CapType.Arrow1Filled; var c10 = diagram.AddConnection(shapes["FetchCart"], shapes["Present"]) as RadDiagramConnection; var c11 = diagram.AddConnection(shapes["Present"], shapes["Stop"]) as RadDiagramConnection; }
private static void ExportContainerShape(RadDiagramContainerShape container, Rect enclosingBounds, RadFixedPage page) { var bounds = new Rect(container.Bounds.X - enclosingBounds.X, container.Bounds.Y - enclosingBounds.Y, container.Bounds.Width, container.Bounds.Height); var transformGroup = new TransformGroup(); transformGroup.Children.Add(new RotateTransform() { Angle = container.RotationAngle, CenterX = bounds.Width / 2, CenterY = bounds.Height / 2 }); transformGroup.Children.Add(new TranslateTransform() { X = bounds.X, Y = bounds.Y }); var position = new MatrixPosition(transformGroup.Value); FixedContentEditor containerEditor = CreateEditor(new EditorInfo(page, position, container, bounds, container.BorderBrush, container.RotationAngle), true); containerEditor.DrawRectangle(new Rect(new Point(), bounds.ToSize())); containerEditor.GraphicProperties.StrokeThickness = 0.5; var headerHeight = container.ContentBounds.Y - container.Bounds.Y - DiagramConstants.ContainerMargin; containerEditor.DrawRectangle(new Rect(new Point(0, headerHeight), new Size(bounds.Width, 0.5))); if (container.IsCollapsible) { var buttonTop = headerHeight / 2 - 2.5; var buttonLeft = bounds.Width - 20; if (container.IsCollapsed) { containerEditor.DrawLine(new Point(buttonLeft, buttonTop), new Point(buttonLeft + 4, buttonTop + 4)); containerEditor.DrawLine(new Point(buttonLeft + 4, buttonTop + 4), new Point(buttonLeft + 8, buttonTop)); if (container.CollapsedContent != null) { var contentHeight = container.ActualHeight - headerHeight; ExportContent(container, bounds, container.RotationAngle, page, (s) => { return new Point(bounds.Center().X - s.Width / 2, bounds.Bottom - contentHeight / 2 - s.Height / 2); }, container.CollapsedContent.ToString()); } } else { containerEditor.DrawLine(new Point(buttonLeft, buttonTop + 4), new Point(buttonLeft + 4, buttonTop)); containerEditor.DrawLine(new Point(buttonLeft + 4, buttonTop), new Point(buttonLeft + 8, buttonTop + 4)); } } if (container.Content != null) { ExportContent(container, bounds, container.RotationAngle, page, (s) => { return new Point(bounds.Center().X - s.Width / 2, bounds.Top + headerHeight / 2 - s.Height / 2); }); } }
private void btnGenerateContainer_Click_1(object sender, RoutedEventArgs e) { RadDiagramContainerShape Container = new RadDiagramContainerShape(); Container.Position = new Point { X = this.diagram.Viewport.Left, Y = this.diagram.Viewport.Top }; Container.AllowDrop = false; Container.Width = 100; Container.Height = 100; Container.IsResizingEnabled = false; List<IConnector> cs = new List<IConnector>(); foreach (var connen in Container.Connectors) { cs.Add(connen); } foreach (var connen in cs) { Container.Connectors.Remove(connen); } diagram.AddShape(Container); }
private void OnLoaded(object sender, RoutedEventArgs routedEventArgs) { var shapes = new Dictionary <string, RadDiagramShape> { { "Start", new RadDiagramShape { Geometry = ShapeFactory.GetShapeGeometry(FlowChartShapeType.StartShape), GlidingStyle = GlidingStyle.Ellipse, Position = new Point(380, 50), Background = new SolidColorBrush(Colors.Green), Width = 50, Height = 50, BorderBrush = new SolidColorBrush(Colors.Transparent), Effect = effect } }, { "Stop", new RadDiagramShape { Geometry = ShapeFactory.GetShapeGeometry(FlowChartShapeType.StartShape), GlidingStyle = GlidingStyle.Ellipse, Position = new Point(386, 573), Background = new SolidColorBrush(Colors.Orange), Width = 50, Height = 50, BorderBrush = new SolidColorBrush(Colors.Transparent), Effect = effect } }, { "New?", new RadDiagramShape { Geometry = ShapeFactory.GetShapeGeometry(FlowChartShapeType.DecisionShape), GlidingStyle = GlidingStyle.Diamond, Position = new Point(350, 150), Background = new SolidColorBrush(Colors.Orange), Content = "New?", BorderBrush = new SolidColorBrush(Colors.Transparent), Effect = effect } }, { "CreateCart", new RadDiagramShape { Geometry = ShapeFactory.GetShapeGeometry(FlowChartShapeType.CreateRequestShape), GlidingStyle = GlidingStyle.Rectangle, Position = new Point(222, 280), Background = new SolidColorBrush(Colors.Blue), Content = "Create New", BorderBrush = new SolidColorBrush(Colors.Transparent), Effect = effect } }, { "FetchCart", new RadDiagramShape { Geometry = ShapeFactory.GetShapeGeometry(FlowChartShapeType.CreateRequestShape), GlidingStyle = GlidingStyle.Rectangle, Position = new Point(478, 280), Background = new SolidColorBrush(Colors.Blue), Content = "Fetch Existing", BorderBrush = new SolidColorBrush(Colors.Transparent), Effect = effect } }, { "Database", new RadDiagramShape { Geometry = ShapeFactory.GetShapeGeometry(FlowChartShapeType.Database1Shape), GlidingStyle = GlidingStyle.Rectangle, Position = new Point(725, 255), Background = new SolidColorBrush(Colors.LightGray), Content = "Oracle", BorderBrush = new SolidColorBrush(Colors.Transparent), Effect = effect, Opacity = .85 } }, { "BizTalk", new RadDiagramShape { Geometry = ShapeFactory.GetShapeGeometry(CommonShapeType.RoundedRectangleShape), GlidingStyle = GlidingStyle.Rectangle, Position = new Point(890, 255), Background = new SolidColorBrush(Colors.Gray), Content = "BizTalk", BorderBrush = new SolidColorBrush(Colors.Transparent), Effect = effect, Opacity = .85 } }, { "Azure", new RadDiagramShape { Geometry = ShapeFactory.GetShapeGeometry(CommonShapeType.CloudShape), GlidingStyle = GlidingStyle.Rectangle, Position = new Point(1070, 255), Background = new SolidColorBrush(Colors.Blue), Content = "Azure", BorderBrush = new SolidColorBrush(Colors.Transparent), Effect = effect, Opacity = .6 } }, { "Present", new RadDiagramShape { Geometry = ShapeFactory.GetShapeGeometry(FlowChartShapeType.DocumentShape), GlidingStyle = GlidingStyle.Rectangle, Position = new Point(355, 432), Background = new SolidColorBrush(Colors.Green), Content = "Present", BorderBrush = new SolidColorBrush(Colors.Transparent), Effect = effect, Opacity = 1 } }, { "FSM", new RadDiagramShape { Geometry = null, GlidingStyle = GlidingStyle.Rectangle, Position = new Point(830, 400), Background = new SolidColorBrush(Colors.Blue), Foreground = new SolidColorBrush(Colors.Black), Content = "FSM", BorderBrush = new SolidColorBrush(Colors.Transparent), Effect = effect, Opacity = 1 } }, }; // add all shapes shapes.ForEach(s => diagram.AddShape(s.Value)); var ctShapes = new[] { "Database", "FSM", "Azure", "BizTalk" }; var container = new RadDiagramContainerShape { Position = new Point(692, 204), Width = 565, Height = 305, Content = "Backend", Stroke = new SolidColorBrush(Colors.Red), StrokeDashArray = new DoubleCollection { 1, 1 }, Background = new SolidColorBrush(Colors.LightGray), Foreground = new SolidColorBrush(Colors.Gray), ZIndex = -5 }; ctShapes.ForEach(s => container.Items.Add(shapes[s])); diagram.AddShape(container); shapes["CreateCart"].RotationAngle = 315; shapes["FetchCart"].RotationAngle = 45; var c1 = diagram.AddConnection(shapes["Start"], shapes["New?"]) as RadDiagramConnection; c1.Content = "always"; var c2 = diagram.AddConnection(shapes["New?"], shapes["CreateCart"]) as RadDiagramConnection; c2.Content = "yes"; var c3 = diagram.AddConnection(shapes["New?"], shapes["FetchCart"]) as RadDiagramConnection; c3.Content = "no"; var c4 = diagram.AddConnection(container, shapes["FetchCart"]) as RadDiagramConnection; c4.StrokeDashArray = new DoubleCollection { 2, 2 }; c4.SourceCapType = CapType.Arrow6Filled; c4.Opacity = .5; var c5 = diagram.AddConnection(shapes["Database"], shapes["BizTalk"]) as RadDiagramConnection; c5.StrokeDashArray = new DoubleCollection { 3, 2 }; c5.SourceCapType = CapType.Arrow5Filled; c5.Content = "Orchestration"; c5.Opacity = .5; var c6 = diagram.AddConnection(shapes["Azure"], shapes["BizTalk"]) as RadDiagramConnection; c6.StrokeDashArray = new DoubleCollection { 3, 2 }; c6.SourceCapType = CapType.Arrow5Filled; c6.Content = "Async"; c6.Opacity = .5; var c7 = diagram.AddConnection(shapes["FSM"], shapes["BizTalk"]) as RadDiagramConnection; c7.StrokeDashArray = new DoubleCollection { 3, 2 }; c7.SourceCapType = CapType.Arrow5Filled; c7.Content = "Async"; c7.Opacity = .5; var c8 = diagram.AddConnection(shapes["FSM"], shapes["Database"]) as RadDiagramConnection; c8.StrokeDashArray = new DoubleCollection { 3, 2 }; c8.SourceCapType = CapType.Arrow5Filled; c8.Content = "Async"; c8.BezierTension = .72; c8.ManipulationPoints[0].Position = new Point(50, 550); c8.UpdateLayout(); c8.Opacity = .5; var c9 = diagram.AddConnection(shapes["CreateCart"], shapes["Present"]) as RadDiagramConnection; c9.TargetCapType = CapType.Arrow1Filled; var c10 = diagram.AddConnection(shapes["FetchCart"], shapes["Present"]) as RadDiagramConnection; var c11 = diagram.AddConnection(shapes["Present"], shapes["Stop"]) as RadDiagramConnection; }