示例#1
0
        protected override void PerformDropToViewCore(DragDropManagerBase sourceManager)
        {
            GridViewHitInfoBase hitInfo = GetHitInfo(HitElement);

            if (BanDrop(hitInfo.RowHandle, hitInfo, sourceManager, DropTargetType.None))
            {
                ClearDragInfo(sourceManager);
                return;
            }
            PerformDropToView(sourceManager, hitInfo as TableViewHitInfo, LastPosition, SetReorderDropInfo, (_) => SetMoveToGroupRowDropInfo, SetAddRowsDropInfo);
        }
示例#2
0
        private void MainWindow_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            DependencyObject    target  = e.OriginalSource as DependencyObject;
            GridViewHitInfoBase hitInfo = AssociatedObject.CalcHitInfo(target);

            if (hitInfo != null && hitInfo.RowHandle >= 0)
            {
                if ((hitInfo.Column == null || hitInfo.Column.FieldName == "Name") && (target is TextBlock || target is Image))
                {
                    AllowDragDrop();
                    return;
                }

                object row = AssociatedObject.DataControl.GetRow(hitInfo.RowHandle);

                if (target.ParentExists <CheckEdit>())
                {
                    if (AssociatedObject.DataControl.SelectedItems.Contains(row))
                    {
                        AssociatedObject.DataControl.SelectedItems.Remove(row);
                    }
                    else
                    {
                        AssociatedObject.DataControl.SelectedItems.Add(row);
                    }

                    e.Handled = true;
                }

                if (AssociatedObject.DataControl.SelectedItems.Contains(row))
                {
                    AllowDragDrop();
                }
                else
                {
                    ShowSelectionRectangle();
                }
            }
            else
            {
                AssociatedObject.DataControl.CurrentItem = null;
                ShowSelectionRectangle();
            }
        }
        private void grid_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Point  location = e.GetPosition(grid);
            double hOffset  = location.X - startPosition.X;

            if (FlowDirection == System.Windows.FlowDirection.RightToLeft)
            {
                hOffset = -hOffset;
            }

            hitInfoPopup.HorizontalOffset = hOffset;
            hitInfoPopup.VerticalOffset   = location.Y - startPosition.Y;

            GridViewHitInfoBase info = GetHitInfo(e);

            hitInfoList.Clear();

            AddHitInfo("HitTest", TypeDescriptor.GetProperties(info)["HitTest"].GetValue(info).ToString());

            AddHitInfo("Column", info.Column != null ? info.Column.HeaderCaption as string : "No column");
            AddHitInfo("RowHandle", GetRowHandleDescription(info.RowHandle));
            AddHitInfo("CellValue", info.Column != null ? grid.GetCellDisplayText(info.RowHandle, info.Column) : null);
            info.Accept(CreateDemoHitTestVisitor());
        }