Пример #1
0
        public void DragComplete(IDraggable draggable)
        {
            if (draggable == null)
            {
                return;
            }

            if (draggable == dragConnection)
            {
                var target = getDraggableAt(dragConnection.X, dragConnection.Y);

                if (target is SignalSourceViewModel && draggedPort is SignalSinkViewModel)
                {
                    connect(target as SignalSourceViewModel, draggedPort as SignalSinkViewModel);
                }
                else if (target is SignalSinkViewModel && draggedPort is SignalSourceViewModel)
                {
                    connect(draggedPort as SignalSourceViewModel, target as SignalSinkViewModel);
                }

                dragConnection = null;
                draggedPort    = null;

                Refresh();
            }
        }
Пример #2
0
        public IDraggable BeginDragAt(int x, int y)
        {
            var draggable = getDraggableAt(x, y);

            if (draggable is SignalSinkViewModel)
            {
                var sink = draggable as SignalSinkViewModel;
                if (sink.Sink.Source != null)
                {
                    draggedPort = getSourceModelForSink(sink);

                    disconnect(sink);

                    dragConnection = new DragConnection
                    {
                        X      = sink.X,
                        Y      = sink.Y,
                        Width  = sink.Width,
                        Height = sink.Height
                    };
                    return(dragConnection);
                }
            }

            if (draggable is SignalSinkViewModel ||
                draggable is SignalSourceViewModel)
            {
                draggedPort    = draggable;
                dragConnection = new DragConnection
                {
                    X      = draggable.X,
                    Y      = draggable.Y,
                    Width  = draggable.Width,
                    Height = draggable.Height
                };
                return(dragConnection);
            }

            return(draggable);
        }
Пример #3
0
        public void DragComplete(IDraggable draggable)
        {
            if (draggable == null) return;

            if (draggable == dragConnection)
            {
                var target = getDraggableAt(dragConnection.X, dragConnection.Y);

                if (target is SignalSourceViewModel && draggedPort is SignalSinkViewModel)
                {
                    connect(target as SignalSourceViewModel, draggedPort as SignalSinkViewModel);
                }
                else if (target is SignalSinkViewModel && draggedPort is SignalSourceViewModel)
                {
                    connect(draggedPort as SignalSourceViewModel, target as SignalSinkViewModel);
                }

                dragConnection = null;
                draggedPort = null;

                Refresh();
            }
        }
Пример #4
0
        public IDraggable BeginDragAt(int x, int y)
        {
            var draggable = getDraggableAt(x, y);

            if (draggable is SignalSinkViewModel)
            {
                var sink = draggable as SignalSinkViewModel;
                if (sink.Sink.Source != null)
                {
                    draggedPort = getSourceModelForSink(sink);

                    disconnect(sink);

                    dragConnection = new DragConnection
                    {
                        X = sink.X,
                        Y = sink.Y,
                        Width = sink.Width,
                        Height = sink.Height
                    };
                    return dragConnection;
                }
            }

            if (draggable is SignalSinkViewModel
                || draggable is SignalSourceViewModel)
            {

                draggedPort = draggable;
                dragConnection = new DragConnection
                {
                    X = draggable.X,
                    Y = draggable.Y,
                    Width = draggable.Width,
                    Height = draggable.Height
                };
                return dragConnection;
            }

            return draggable;
        }