Пример #1
0
 /// <summary>
 /// Gets a values indicating whether provided connection matches this instance
 /// </summary>
 /// <param name="connectionToMatch">The connection to match.</param>
 /// <returns></returns>
 public bool Matches(TileConnection connectionToMatch)
 {
     return(this.FromId == connectionToMatch.FromId &&
            this.ToId == connectionToMatch.ToId &&
            this.FromOrientation == connectionToMatch.FromOrientation &&
            this.ToOrientation == connectionToMatch.ToOrientation);
 }
Пример #2
0
        /// <summary>
        /// Removes a connection.
        /// </summary>
        /// <param name="connection">The connection to remove.</param>
        private void RemoveConnection(TileConnection connection)
        {
            //Guard against temporary server issue, can be removed later
            if (connection.DiagramConnection == null)
            {
                return;
            }

            connection.DiagramConnection.Origin.DiagramConnections.Remove(connection.DiagramConnection);
            connection.DiagramConnection.Destination.DiagramConnections.Remove(connection.DiagramConnection);
            //this.scatterView.RemoveVisualConnection(connection.DiagramConnection, false);

            connection.DiagramConnection.EditOperationRequested -= this.OnConnectionEditRequested;
            connection.DiagramConnection = null;
        }
Пример #3
0
        /// <summary>
        /// Called when an edit operation on a connection is requested
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="point">The point.</param>
        private void OnConnectionEditRequested(object sender, Point point)
        {
            DiagramConnection connection = (DiagramConnection)sender;

            TileConnection tileConnection = connection.ToTileConnection();

            tileConnection.DiagramConnection = connection;

            DiagramConnectionEditOperation operation = new DiagramConnectionEditOperation()
            {
                Connection = tileConnection,
                X          = point.X,
                Y          = point.Y
            };

            //this.scatterView.DiagramConnectionEditCommand?.Execute(operation);
        }
Пример #4
0
        /// <summary>
        /// Adds a new connection.
        /// </summary>
        /// <param name="connection">The connection.</param>
        private void AddConnection(TileConnection connection)
        {
            ConnectableViewItem connectableFrom = this.GetConnectable(connection.FromId);

            if (connectableFrom == null)
            {
                return;
            }
            ConnectableViewItem connectableTo = this.GetConnectable(connection.ToId);

            if (connectableTo == null)
            {
                return;
            }


            //From
            HitTestInfo       hitTestInfo         = this.GetHitTestInfo(connection.FromOrientation);
            ConnectorInfo     originConnectorInfo = connectableFrom.CreateDiagramConnection(hitTestInfo);
            DiagramConnection newConnection       = new DiagramConnection(connectableFrom, originConnectorInfo, 0)
            {
                Id             = connection.Id,
                ConnectionType = connection.ConnectionType,
                RoutingMode    = connection.RoutingMode
            };

            newConnection.EditOperationRequested += this.OnConnectionEditRequested;
            //newConnection.CreateConnection(connection.Color, this.scatterView.DiagramSelectedConnectionColor, this.scatterView.DiagramConnectionHighlightColor, connection.Thickness, connection.Opacity);

            //To
            hitTestInfo = this.GetHitTestInfo(connection.ToOrientation);
            ConnectorInfo targetConnectorInfo = connectableTo.CreateDiagramConnection(hitTestInfo);

            //newConnection.CompletePendingConnection(connectableTo, targetConnectorInfo, this.scatterView.ControlTileScale);

            //Adds connection to related tiles
            newConnection.Origin.DiagramConnections.Add(newConnection);
            newConnection.Destination.DiagramConnections.Add(newConnection);

            connection.DiagramConnection = newConnection;

            //this.scatterView.AddVisualConnection(newConnection, false);
        }
Пример #5
0
        private void OnConnectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            //New connection added
            case NotifyCollectionChangedAction.Add:
                TileConnection addConnection = (TileConnection)e.NewItems[0];
                this.AddConnection(addConnection);
                break;

            case NotifyCollectionChangedAction.Remove:
                TileConnection deleteConnection = (TileConnection)e.OldItems[0];
                this.RemoveConnection(deleteConnection);
                break;

            case NotifyCollectionChangedAction.Reset:
                this.ClearConnections();
                break;
            }
        }
Пример #6
0
 /// <summary>
 /// Updates the provide tile connection.
 /// </summary>
 /// <param name="connection">The connection.</param>
 public void UpdateConnection(TileConnection connection)
 {
     //connection.DiagramConnection?.Update(connection, this.scatterView.ControlTileScale);
 }