コード例 #1
0
        private void AddConnectionLine(Node toNode)
        {
            NodeConnectionLine connectionLine = new NodeConnectionLine(this,
                                                                       NodeEllipse.GetNodeEllipseByName(this._canvas, toNode.Name), this._canvas);

            this._lines.Add(connectionLine);
        }
コード例 #2
0
        public void SetCoordinates(Point p)
        {
            // Constrain the X Position
            p.X = Clamp((int)p.X, 0, this._canvas.ActualWidth - this._measurements.Width);

            // Constrain the Y Position
            p.Y = Clamp(p.Y, 0, this._canvas.ActualHeight - this._measurements.Height);

            this._measurements.X = p.X;
            this._measurements.Y = p.Y;

            p.X = Math.Max(0, p.X);
            p.Y = Math.Max(0, p.Y);

            this._node.Position = new System.Drawing.Point((int)p.X, (int)p.Y);

            Canvas.SetLeft(this, p.X);
            Canvas.SetTop(this, p.Y);

            // Fix the OneWayConnectionBug
            foreach (string name in this._graph.GetAllNodeNames())
            {
                if (this._node.Name != name && this._graph.GetNode(name).IsDirectlyConnectedToNode(this._node))
                {
                    NodeEllipse.GetNodeEllipseByName(this._canvas, name).UpdateConnectionCoordinates();
                }
            }

            this.UpdateConnectionCoordinates();
            for (int i = 0; i < this._lines.Count; i++)
            {
                if (this._lines[i].ToNodeEllipse.GetNode().IsDirectlyConnectedToNode(this._node))
                {
                    this._lines[i].ToNodeEllipse.UpdateConnectionCoordinates();
                }
            }
        }