Esempio n. 1
0
        private void DiagramLoaded(object sender, RoutedEventArgs e)
        {
            this.diagram.Shapes.ToList().ForEach(x =>
            {
                var connectorUpRight = new RadDiagramConnector()
                {
                    Offset = new Point(1, 0.25), Name = x.Name + "Connector1Right"
                };
                var connectorDownRight = new RadDiagramConnector()
                {
                    Offset = new Point(1, 0.75), Name = x.Name + "Connector2Right"
                };
                var connectorLeftUp = new RadDiagramConnector()
                {
                    Offset = new Point(0, 0.25), Name = x.Name + "Connector3Left"
                };
                var connectorLeftDown = new RadDiagramConnector()
                {
                    Offset = new Point(0, 0.75), Name = x.Name + "Connector4Left"
                };

                x.Connectors.Add(connectorUpRight);
                x.Connectors.Add(connectorDownRight);
                x.Connectors.Add(connectorLeftUp);
                x.Connectors.Add(connectorLeftDown);
            });

            var shape     = new RadDiagramShape();
            var connector = new RadDiagramConnector()
            {
                Offset = new Point(1, 0.5), Name = "CustoMConnector1"
            };

            shape.Connectors.Add(connector);
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (this.Shape == null)
            {
                this.validationBox.Text = "Selected Item is not a Shape!";
                this.validationBox.Foreground = validationFailBrush;
                return;
            }

            double xPos = 0, yPos = 0;
            if (!double.TryParse(this.xBox.Text, out xPos) || !double.TryParse(this.yBox.Text, out yPos) ||
                xPos < 0 || xPos > 1 || yPos < 0 || yPos > 1)
            {
                this.validationBox.Foreground = validationFailBrush;
                this.validationBox.Text = "Incorrect X or Y !";
                return;
            }
            this.validationBox.Foreground = validationSuccessBrush;
            this.validationBox.Text = "Connector Added Successfully !";

            RadDiagramConnector connector = new RadDiagramConnector();
            connector.Offset = new Point(xPos, yPos);
            connector.Name = "CustomConnector" + connector.GetHashCode();
            this.Shape.Connectors.Add(connector);
        }        
Esempio n. 3
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (this.Shape == null)
            {
                this.validationBox.Text       = "Selected Item is not a Shape!";
                this.validationBox.Foreground = validationFailBrush;
                return;
            }

            double xPos = 0, yPos = 0;

            if (!double.TryParse(this.xBox.Text, out xPos) || !double.TryParse(this.yBox.Text, out yPos) ||
                xPos < 0 || xPos > 1 || yPos < 0 || yPos > 1)
            {
                this.validationBox.Foreground = validationFailBrush;
                this.validationBox.Text       = "Incorrect X or Y !";
                return;
            }
            this.validationBox.Foreground = validationSuccessBrush;
            this.validationBox.Text       = "Connector Added Successfully !";

            RadDiagramConnector connector = new RadDiagramConnector();

            connector.Offset = new Point(xPos, yPos);
            connector.Name   = "CustomConnector" + connector.GetHashCode();
            this.Shape.Connectors.Add(connector);
        }
        public bool MouseDown(PointerArgs e)
        {
            this.areCtrlShiftDown = (Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift &&
                                    (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control;

            if (this.areCtrlShiftDown)
            {
                RadDiagramShape topShape = this.HitService.GetTopItemNearPoint(e.Point, 0) as RadDiagramShape;
                if (topShape != null)
                {
                    RadDiagramConnector connector = new RadDiagramConnector() { }; 
                    connector.Name = "NewConnector" + connector.GetHashCode().ToString();

                    double xRatio = (e.Point.X - topShape.Bounds.X) / topShape.Width;
                    double yRatio = (e.Point.Y - topShape.Bounds.Y) / topShape.Height;

                    connector.Offset = new Point(xRatio, yRatio);
                    topShape.Connectors.Add(connector);

                    this.lastUsedShape = topShape;
                    return true;
                }
            }
            return false;
        }
        public override bool MouseUp(PointerArgs e)
        {
            RadDiagramShape shape = this.HitService.GetTopItemNearPoint(e.Point, 0) as RadDiagramShape;

            // Normal execution if we release the mouse over connector.
            if (shape != null && this.IsActiveConnectorUnderPoint(shape, e.Point))
            {
                return base.MouseUp(e);
            }

            // Add custom connector.
            if (shape != null && this.InitialPoint != null && shape != this.HitItem && this.HitItem != null)
            {
                Point intersectPoint = new Point();
                Utils.IntersectionPointOnRectangle(shape.Bounds, this.InitialPoint.Value, e.Point, ref intersectPoint);
                lastCustomConnector = new RadDiagramConnector() { };
                lastCustomConnector.Name = "CustomConnector" + lastCustomConnector.GetHashCode().ToString();

                double xRatio = (intersectPoint.X - shape.Bounds.X) / shape.Width;
                double yRatio = (intersectPoint.Y - shape.Bounds.Y) / shape.Height;

                lastCustomConnector.Offset = new Point(xRatio, yRatio);
                shape.Connectors.Add(lastCustomConnector);
            }

            // This will create the new connection.
            base.MouseUp(e);

            // Repositions the added connection to the custom connector we created.
            if (this.ActiveConnection != null && this.lastCustomConnector != null)
            {
                this.ActiveConnection.Attach(this.ActiveConnection.SourceConnectorResult, lastCustomConnector);
            }
            return false;
        }
Esempio n. 6
0
 //Creates custom connectors needed for the TipOverTree layout.
 private void EnsureConnectors()
 {
     if (this.viewModel.CurrentTreeLayoutType == TreeLayoutType.TipOverTree)
     {
         var shapesWithIncomingLinks = this.diagram.Shapes.Where(x => x.IncomingLinks.Any()).ToList();
         shapesWithIncomingLinks.ForEach(y =>
         {
             if (y.Connectors.Count == 5)
             {
                 var customConnector = new RadDiagramConnector {
                     Offset = new Point(0.15, 1)
                 };
                 customConnector.Name = CustomConnectorPosition.TreeLeftBottom;
                 y.Connectors.Add(customConnector);
             }
         });
     }
 }
Esempio n. 7
0
        private void DiagramLoaded(object sender, RoutedEventArgs e)
        {
            this.diagram.Shapes.ToList().ForEach(x =>
            {
                var connectorUpRight = new RadDiagramConnector() { Offset = new Point(1, 0.25), Name = x.Name + "Connector1" };
                var connectorDownRight = new RadDiagramConnector() { Offset = new Point(1, 0.75), Name = x.Name + "Connector2" };
                var connectorLeftUp = new RadDiagramConnector() { Offset = new Point(0, 0.25), Name = x.Name + "Connector3" };
                var connectorLeftDown = new RadDiagramConnector() { Offset = new Point(0, 0.75), Name = x.Name + "Connector4" };

                x.Connectors.Add(connectorUpRight);
                x.Connectors.Add(connectorDownRight);
                x.Connectors.Add(connectorLeftUp);
                x.Connectors.Add(connectorLeftDown);
            });

            var shape = new RadDiagramShape();
            var connector = new RadDiagramConnector() { Offset = new Point(1, 0.5), Name = "CustoMConnector1" };
            shape.Connectors.Add(connector);
        }
Esempio n. 8
0
        public override bool MouseUp(PointerArgs e)
        {
            RadDiagramShape shape = this.HitService.GetTopItemNearPoint(e.Point, 0) as RadDiagramShape;

            // Normal execution if we release the mouse over connector.
            if (shape != null && this.IsActiveConnectorUnderPoint(shape, e.Point))
            {
                return(base.MouseUp(e));
            }

            // Add custom connector.
            if (shape != null && this.InitialPoint != null && shape != this.HitItem && this.HitItem != null)
            {
                Point intersectPoint = new Point();
                Utils.IntersectionPointOnRectangle(shape.Bounds, this.InitialPoint.Value, e.Point, ref intersectPoint);
                lastCustomConnector = new RadDiagramConnector()
                {
                };
                lastCustomConnector.Name = "CustomConnector" + lastCustomConnector.GetHashCode().ToString();

                double xRatio = (intersectPoint.X - shape.Bounds.X) / shape.Width;
                double yRatio = (intersectPoint.Y - shape.Bounds.Y) / shape.Height;

                lastCustomConnector.Offset = new Point(xRatio, yRatio);
                shape.Connectors.Add(lastCustomConnector);

                this.diagram.ItemsChanged += DiagramItemsChanged;
            }

            // This will create the new connection.
            base.MouseUp(e);

            // Repositions the added connection to the custom connector we created.
            if (this.lastAddedConnection != null && this.lastCustomConnector != null)
            {
                lastAddedConnection.Attach(lastAddedConnection.SourceConnectorResult, lastCustomConnector);
            }
            return(false);
        }
        private void EnsureConnectors()
        {
            this.diagram.Shapes.ForEach(shape =>
            {
                shape.Connectors.Clear();
                foreach (ConnectorDescription item in this.layoutTypeBasedConnectors[this.viewModel.CurrentTreeLayoutType])
                {
                    RadDiagramConnector connector = new RadDiagramConnector()
                    {
                        Offset = item.Offset,
                        Name = item.Name,
                        Visibility = item.Visibility
                    };
                    Canvas.SetLeft(connector, item.CanvasLeft);
                    Canvas.SetTop(connector, item.CanvasTop);
                    shape.Connectors.Add(connector);
                }
            });

            if (this.viewModel.CurrentTreeLayoutType == TreeLayoutType.TipOverTree)
            {
                var shapesWithIncomingLinks = this.diagram.Shapes.Where(x => x.IncomingLinks.Any()).ToList();
                shapesWithIncomingLinks.ForEach(y =>
                {
                    y.Connectors.ForEach(con =>
                        (con as RadDiagramConnector).Visibility = con.Name != CustomConnectorPosition.TreeLeftBottom ? Visibility.Collapsed : Visibility.Visible);
                });
            }
        }
Esempio n. 10
0
		//Creates custom connectors needed for the TipOverTree layout.
		private void EnsureConnectors()
		{
			if (this.viewModel.CurrentTreeLayoutType == TreeLayoutType.TipOverTree)
			{
				var shapesWithIncomingLinks = this.diagram.Shapes.Where(x => x.IncomingLinks.Any()).ToList();
				shapesWithIncomingLinks.ForEach(y =>
				{
					if (y.Connectors.Count == 5)
					{
						var customConnector = new RadDiagramConnector { Offset = new Point(0.15, 1) };
						customConnector.Name = CustomConnectorPosition.TreeLeftBottom;
						y.Connectors.Add(customConnector);
					}
				});
			}
		}