예제 #1
0
파일: DropBehavior.cs 프로젝트: vinla/cgwo
        protected override void OnAttached()
        {
            base.OnAttached();

            AssociatedObject.AllowDrop = true;

            AssociatedObject.DragOver += (s, e) =>
            {
                if ((DropCommand?.CanExecute(DragDropManager.DragData)).GetValueOrDefault())
                {
                    e.Effects = DragDropEffects.Move;
                }
                else
                {
                    e.Effects = DragDropEffects.None;
                }

                e.Handled = true;
            };

            AssociatedObject.Drop += (s, e) =>
            {
                if ((DropCommand?.CanExecute(DragDropManager.DragData)).GetValueOrDefault())
                {
                    DropCommand?.Execute(GetConvertedData(DragDropManager.DragData));
                }

                e.Handled = true;
            };
        }
예제 #2
0
파일: GraphView.cs 프로젝트: thbin/TraceLab
        private void HACK_Control_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            DropLinkEventArgs args = null;

            if (PotentialLinkSource != null)
            {
                object target = PotentialLinkTarget != null ? PotentialLinkTarget.Vertex : null;
                object edge   = LinkBeingMoved != null ? LinkBeingMoved.Edge : null;

                args           = new DropLinkEventArgs(PotentialLinkSource.Vertex, target, edge);
                LinkBeingMoved = null;
            }

            if (args != null && DropCommand.CanExecute(args))
            {
                /// checking if Target is different HACK_NODE is related to hard to reproduce error
                /// somehow when you drag a link quickly to the existing node, but you don't really reach it or you are too far from node, then the target appears to be HACK_NODE
                if (args.Target == null || (args.Target != null && args.Target.ToString().Equals("HACK_Node") == false))
                {
                    DropCommand.Execute(args);
                }
            }

            CancelAllDragging();
        }
예제 #3
0
        private bool IsValidDropTarget(IDataObject dataObject)
        {
            if (DropCommand == null)
            {
                return(false);
            }

            return(DropCommand.CanExecute(GetObjectFromData(dataObject)));
        }
예제 #4
0
        private void MultiSelectDataGrid_Drop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.StringFormat) &&
                DropCommand != null &&
                DropCommand.CanExecute(e.Data.GetData(DataFormats.StringFormat)))
            {
                DropCommand.Execute(e.Data.GetData(DataFormats.StringFormat));
            }

            if (DropDataCommand != null && DropDataCommand.CanExecute(e.Data))
            {
                DropDataCommand.Execute(e.Data);
            }
        }
예제 #5
0
파일: GraphView.cs 프로젝트: thbin/TraceLab
        void HACK_Control_PreviewMouseMove(object sender, MouseEventArgs e)
        {
            Point            clickPoint = e.GetPosition(GraphLayout);
            DependencyObject obj        = (DependencyObject)GraphLayout.InputHitTest(clickPoint);

            GraphSharp.Controls.VertexControl parent = null;
            if (obj != null)
            {
                parent = obj.GetParent <GraphSharp.Controls.VertexControl>(this);
            }

            if (parent != null && parent != PotentialLinkSource && DropCommand.CanExecute(new DropLinkEventArgs(PotentialLinkSource.Vertex, parent.Vertex, null)))
            {
                PotentialLinkTarget = parent;
            }
            else
            {
                PotentialLinkTarget = null;
            }
        }
        void IDropable.Drop(object data, DropLocation location)
        {
            var droppedElement = data as NodeItem;

            if (droppedElement == null)
            {
                return;
            }

            var arg = new NodeDropRequest
            {
                DroppedNode = droppedElement.State.DataContext,
                DropTarget  = Root,
                Location    = location
            };

            if (DropCommand != null && DropCommand.CanExecute(arg))
            {
                DropCommand.Execute(arg);
            }
        }