Example #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;
        }
Example #2
0
        public IVertex GetEdgeByLocation(Point point)
        {
            var    headersPresenter   = UIWpf.FindVisualChild <DataGridColumnHeadersPresenter>(ThisDataGrid);
            double headerActualHeight = headersPresenter.ActualHeight;

            if (point.Y <= headerActualHeight) // if header
            {
                return(null);
            }

            foreach (var item in ThisDataGrid.Items)
            {
                var row = ThisDataGrid.ItemContainerGenerator.ContainerFromItem(item) as DataGridRow;

                if (row != null)
                {
                    DataGridRow roww = (DataGridRow)row;

                    if (VisualTreeHelper.HitTest(roww, TranslatePoint(point, roww)) != null)
                    {
                        if (point.X >= ThisDataGrid.Columns.First().ActualWidth&& roww.IsEditing)
                        {
                            return(null);
                        }

                        IVertex v = MinusZero.Instance.CreateTempVertex();
                        Edge.AddEdgeEdges(v, (IEdge)roww.Item);
                        return(v);
                    }
                }
            }

            // DO WANT THIS FEATURE ?
            //
            if (GeneralUtil.CompareStrings(MinusZero.Instance.Root.Get(@"User\CurrentUser:\Settings:\AllowBlankAreaDragAndDrop:").Value, "StartAndEnd"))
            {
                return(Vertex.Get("BaseEdge:"));
            }
            else
            {
                return(null);
            }
        }