示例#1
0
        private void dndPreviewMouseMove(object sender, MouseEventArgs e)
        {
            Point  mousePos = e.GetPosition(this);
            Vector diff     = dndStartPoint - mousePos;

            var    headersPresenter   = UIWpf.FindVisualChild <DataGridColumnHeadersPresenter>(this);
            double headerActualHeight = headersPresenter.ActualHeight;

            if (mousePos.Y <= headerActualHeight) // if header
            {
                e.Handled = false;
                return;
            }

            if (hasButtonBeenDown && isDraggin == false &&
                !UIWpf.IsMouseOverScrollbar(sender, dndStartPoint) &&
                (e.LeftButton == MouseButtonState.Pressed) && (
                    (Math.Abs(diff.X) > Dnd.MinimumHorizontalDragDistance) ||
                    (Math.Abs(diff.Y) > Dnd.MinimumVerticalDragDistance)))
            {
                isDraggin = true;

                RestoreSelectedVertexes();

                IVertex dndVertex = MinusZero.Instance.CreateTempVertex();

                if (Vertex.Get(@"SelectedEdges:\") != null)
                {
                    foreach (IEdge ee in Vertex.GetAll(@"SelectedEdges:\"))
                    {
                        dndVertex.AddEdge(null, ee.To);
                    }
                }
                else
                {
                    IVertex v = GetEdgeByLocation(dndStartPoint);
                    if (v != null)
                    {
                        dndVertex.AddEdge(null, v);
                    }
                }

                if (dndVertex.Count() > 0)
                {
                    DataObject dragData = new DataObject("Vertex", dndVertex);
                    dragData.SetData("DragSource", this);

                    Dnd.DoDragDrop(this, dragData);

                    e.Handled = true;
                }

                isDraggin = false;
            }

            // e.Handled = true;
        }
示例#2
0
        private void dndPreviewMouseMove(object sender, MouseEventArgs e)
        {
            Point  mousePos = e.GetPosition(this);
            Vector diff     = dndStartPoint - mousePos;

            if (hasButtonBeenDown &&
                !UIWpf.IsMouseOverScrollbar(sender, dndStartPoint) &&
                (e.LeftButton == MouseButtonState.Pressed) && (
                    (Math.Abs(diff.X) > Dnd.MinimumHorizontalDragDistance) ||
                    (Math.Abs(diff.Y) > Dnd.MinimumVerticalDragDistance)))
            {
                isDraggin = true;

                IVertex dndVertex = MinusZero.Instance.CreateTempVertex();

                if (Vertex.Get(@"SelectedEdges:\") != null)
                {
                    foreach (IEdge ee in Vertex.GetAll(@"SelectedEdges:\"))
                    {
                        dndVertex.AddEdge(null, ee.To);
                    }
                }
                else
                {
                    IVertex v = GetEdgeByLocation(dndStartPoint);
                    if (v != null)
                    {
                        dndVertex.AddEdge(null, v);
                    }
                }

                if (dndVertex.Count() > 0)
                {
                    DataObject dragData = new DataObject("Vertex", dndVertex);
                    dragData.SetData("DragSource", this);

                    Dnd.DoDragDrop(this, dragData);
                }

                isDraggin = false;
            }
        }