예제 #1
0
        protected override void ProcessDragDrop(Point dropLocation, ISupportDrag dragObject)
        {
            GroupFieldDragDropContext dataContext1 = dragObject.GetDataContext() as GroupFieldDragDropContext;

            if (dataContext1 != null)
            {
                dataContext1.ViewTemplate.GroupDescriptors.Remove(dataContext1.GroupDescription);
            }
            else
            {
                GridViewRowInfo dataContext2 = dragObject.GetDataContext() as GridViewRowInfo;
                if (dataContext2 != null)
                {
                    if (this.RowInfo.ViewTemplate.SortDescriptors.Count > 0 || this.RowInfo.ViewTemplate.GroupDescriptors.Count > 0)
                    {
                        return;
                    }
                    bool             isDroppedAtLeft = RadGridViewDragDropService.IsDroppedAtTop(dropLocation, this.Size.Height);
                    GridViewTemplate viewTemplate    = this.Data.ViewTemplate;
                    int targetIndex      = viewTemplate.Rows.IndexOf(this.Data);
                    int draggedItemIndex = viewTemplate.Rows.IndexOf(dataContext2);
                    RadGridViewDragDropService.CalculateTargetIndex(isDroppedAtLeft, viewTemplate.RowCount, ref targetIndex, ref draggedItemIndex);
                    viewTemplate.Rows.Move(draggedItemIndex, targetIndex);
                }
                else
                {
                    base.ProcessDragDrop(dropLocation, dragObject);
                }
            }
        }
        public override Point GetDragHintLocation(ISupportDrop dropTarget, Point mousePosition)
        {
            GridHeaderCellElement headerCellElement  = dropTarget as GridHeaderCellElement;
            Rectangle             boundingRectangle1 = headerCellElement.ControlBoundingRectangle;
            Rectangle             boundingRectangle2 = headerCellElement.RowElement.TableElement.ViewElement.ControlBoundingRectangle;

            if (boundingRectangle1.Right > boundingRectangle2.Right)
            {
                boundingRectangle1.Width -= boundingRectangle1.Right - boundingRectangle2.Right;
            }
            if (boundingRectangle1.X < boundingRectangle2.X)
            {
                boundingRectangle1.Width -= boundingRectangle2.X - boundingRectangle1.X;
                boundingRectangle1.X      = boundingRectangle2.X;
            }
            Rectangle screen = this.GridViewElement.ElementTree.Control.RectangleToScreen(boundingRectangle1);
            Size      size   = Size.Empty;

            if (this.DragHint.Image != null)
            {
                size = this.DragHint.Image.Size;
            }
            Padding margins      = this.DragHint.Margins;
            Point   dropLocation = headerCellElement.PointFromScreen(mousePosition);

            if (this.orientation == Orientation.Vertical)
            {
                return(new Point((RadGridViewDragDropService.IsDroppedAtLeft(dropLocation, headerCellElement.Size.Width) ? screen.X : screen.Right) - size.Width / 2, screen.Y - margins.Top));
            }
            return(new Point(screen.X - margins.Left, screen.Bottom - margins.Top - size.Height / 2));
        }
        protected override void ProcessDragDrop(Point dropLocation, ISupportDrag dragObject)
        {
            object      dataContext  = dragObject.GetDataContext();
            RadPosition dropPosition = RadGridViewDragDropService.GetDropPosition(dropLocation, this.Size);
            ColumnGroupsViewDefinition viewDefinition = this.ViewTemplate.ViewDefinition as ColumnGroupsViewDefinition;

            if (viewDefinition != null)
            {
                if (dataContext is GridViewColumnGroup)
                {
                    ((GridViewColumnGroup)dataContext).IsVisible = true;
                    this.TableElement.UpdateLayout();
                    if (!this.ViewTemplate.AllowColumnReorder)
                    {
                        return;
                    }
                    this.DropColumnGroup(viewDefinition, (GridViewColumnGroup)dataContext, dropPosition);
                    return;
                }
                if (dataContext is GridViewDataColumn || dataContext is GridViewGroupColumn)
                {
                    this.DropInColumnGroupsView(viewDefinition, dataContext as GridViewColumn, dropPosition);
                    return;
                }
            }
            base.ProcessDragDrop(dropLocation, dragObject);
        }
예제 #4
0
 protected override void ProcessColumnDrop(Point dropLocation, GridViewColumn column)
 {
     if (TemplateGroupsElement.RaiseGroupByChanging(this.TemplateElement.ViewTemplate, this.Description, NotifyCollectionChangedAction.ItemChanged))
     {
         return;
     }
     RadGridViewDragDropService.InsertOnLeftOrRight <SortDescriptor>(RadGridViewDragDropService.IsDroppedAtLeft(dropLocation, this.Size.Width), (Collection <SortDescriptor>) this.Description.GroupNames, this.sortDescription, new SortDescriptor(column.Name, ListSortDirection.Ascending));
     TemplateGroupsElement.RaiseGroupByChanged(this.TemplateElement.ViewTemplate, this.Description, NotifyCollectionChangedAction.ItemChanged);
 }
예제 #5
0
        public override Point GetDragHintLocation(ISupportDrop dropTarget, Point mousePosition)
        {
            GridRowElement gridRowElement = dropTarget as GridRowElement;
            Rectangle      screen         = this.GridViewElement.ElementTree.Control.RectangleToScreen(gridRowElement.ControlBoundingRectangle);
            Size           size           = this.DragHint.Image.Size;
            Padding        margins        = this.DragHint.Margins;
            int            num            = RadGridViewDragDropService.IsDroppedAtTop(gridRowElement.PointFromScreen(mousePosition), gridRowElement.Size.Height) ? screen.Y : screen.Bottom;

            return(new Point(screen.X - margins.Left, num - size.Height / 2));
        }
예제 #6
0
        protected virtual void ProcessColumnDrop(Point dropLocation, GridViewColumn column)
        {
            GroupDescriptor groupDescriptor = new GroupDescriptor();

            groupDescriptor.GroupNames.Add(new SortDescriptor(column.Name, ListSortDirection.Ascending));
            if (TemplateGroupsElement.RaiseGroupByChanging(this.templateElement.ViewTemplate, groupDescriptor, NotifyCollectionChangedAction.Add))
            {
                return;
            }
            RadGridViewDragDropService.InsertOnLeftOrRight <GroupDescriptor>(RadGridViewDragDropService.IsDroppedAtLeft(dropLocation, this.Size.Width), (Collection <GroupDescriptor>) this.description.Owner, this.description, groupDescriptor);
            TemplateGroupsElement.RaiseGroupByChanged(this.templateElement.ViewTemplate, groupDescriptor, NotifyCollectionChangedAction.Add);
        }
예제 #7
0
        internal static void MoveOnLeftOrRight <T>(
            bool isDroppedAtLeft,
            Collection <T> collection,
            T targetItem,
            T draggedItem)
        {
            int targetIndex      = collection.IndexOf(targetItem);
            int draggedItemIndex = collection.IndexOf(draggedItem);
            int count            = collection.Count;

            RadGridViewDragDropService.CalculateTargetIndex(isDroppedAtLeft, count, ref targetIndex, ref draggedItemIndex);
            RadGridViewDragDropService.Move <T>(collection, draggedItemIndex, targetIndex);
        }
예제 #8
0
        private void ProcessGroupFieldDrop(Point dropLocation, GroupFieldDragDropContext context)
        {
            SortDescriptor   sortDescription  = context.SortDescription;
            GridViewTemplate viewTemplate     = context.ViewTemplate;
            GroupDescriptor  groupDescription = context.GroupDescription;

            if (TemplateGroupsElement.RaiseGroupByChanging(viewTemplate, groupDescription, NotifyCollectionChangedAction.Batch) || this.ProcessGroupFieldDropOverride(dropLocation, context))
            {
                return;
            }
            groupDescription.GroupNames.Remove(sortDescription);
            GroupDescriptor groupDescriptor = new GroupDescriptor();

            groupDescriptor.GroupNames.Add(sortDescription);
            RadGridViewDragDropService.InsertOnLeftOrRight <GroupDescriptor>(RadGridViewDragDropService.IsDroppedAtLeft(dropLocation, this.Size.Width), (Collection <GroupDescriptor>) this.description.Owner, this.description, groupDescriptor);
            if (groupDescription.GroupNames.Count == 0)
            {
                viewTemplate.DataView.GroupDescriptors.Remove(groupDescription);
            }
            TemplateGroupsElement.RaiseGroupByChanged(viewTemplate, groupDescriptor, NotifyCollectionChangedAction.Batch);
        }
        public override void UpdateDropContext(
            ISupportDrag draggedContext,
            ISupportDrop dropTarget,
            Point?location)
        {
            GridColumnGroupCellElement groupCellElement    = dropTarget as GridColumnGroupCellElement;
            GridHeaderCellElement      headerCellElement   = dropTarget as GridHeaderCellElement;
            GridViewGroupColumn        gridViewGroupColumn = groupCellElement != null ? groupCellElement.ColumnInfo as GridViewGroupColumn : (GridViewGroupColumn)null;

            if (headerCellElement == null || !location.HasValue)
            {
                this.orientation = Orientation.Vertical;
            }
            else
            {
                if (headerCellElement.RowElement == null || headerCellElement.RowElement.TableElement == null)
                {
                    return;
                }
                Rectangle boundingRectangle1 = headerCellElement.ControlBoundingRectangle;
                Rectangle boundingRectangle2 = headerCellElement.RowElement.TableElement.ViewElement.ControlBoundingRectangle;
                if (boundingRectangle1.Right > boundingRectangle2.Right)
                {
                    boundingRectangle1.Width -= boundingRectangle1.Right - boundingRectangle2.Right;
                }
                if (boundingRectangle1.X < boundingRectangle2.X)
                {
                    boundingRectangle1.Width -= boundingRectangle2.X - boundingRectangle1.X;
                    boundingRectangle1.X      = boundingRectangle2.X;
                }
                if ((RadGridViewDragDropService.GetDropPosition(headerCellElement.PointFromScreen(location.Value), headerCellElement.Size) & RadPosition.Bottom) != RadPosition.None && (gridViewGroupColumn != null && gridViewGroupColumn.Group.Rows.Count == 0 && draggedContext.GetDataContext() is GridViewGroupColumn || gridViewGroupColumn != null && gridViewGroupColumn.Group.Groups.Count == 0 && draggedContext.GetDataContext() is GridViewDataColumn || gridViewGroupColumn == null))
                {
                    this.orientation = Orientation.Horizontal;
                }
                else
                {
                    this.orientation = Orientation.Vertical;
                }
            }
        }
예제 #10
0
        protected override bool ProcessGroupFieldDropOverride(
            Point dropLocation,
            GroupFieldDragDropContext context)
        {
            SortDescriptor   sortDescription  = context.SortDescription;
            GridViewTemplate viewTemplate     = context.ViewTemplate;
            GroupDescriptor  groupDescription = context.GroupDescription;

            groupDescription.GroupNames.Remove(sortDescription);
            if (RadGridViewDragDropService.IsDroppedAtLeft(dropLocation, this.Size.Width))
            {
                this.Description.GroupNames.Insert(0, sortDescription);
            }
            else
            {
                this.Description.GroupNames.Add(sortDescription);
            }
            if (groupDescription.GroupNames.Count == 0)
            {
                viewTemplate.DataView.GroupDescriptors.Remove(groupDescription);
            }
            TemplateGroupsElement.RaiseGroupByChanged(context.ViewTemplate, context.GroupDescription, NotifyCollectionChangedAction.Batch);
            return(true);
        }
예제 #11
0
        protected override void HandleMouseMove(Point mousePosition)
        {
            ISupportDrop dropTarget = this.DropTarget;

            this.AutoScroll();
            base.HandleMouseMove(mousePosition);
            RadElement  radElement  = dropTarget as RadElement;
            RadPosition radPosition = RadPosition.None;

            if (radElement != null)
            {
                radPosition = RadGridViewDragDropService.GetDropPosition(radElement.PointFromScreen(mousePosition), radElement.ControlBoundingRectangle.Size);
            }
            if (dropTarget != this.DropTarget || dropTarget == null || radPosition != this.lastDropPosition)
            {
                this.SetDragDropBehavior();
            }
            this.lastDropPosition = radPosition;
            if (this.dragHintWindow == null)
            {
                return;
            }
            this.UpdateDragHintLocation(mousePosition);
        }
예제 #12
0
        protected override bool ProcessGroupFieldDropOverride(
            Point dropLocation,
            GroupFieldDragDropContext context)
        {
            bool isDroppedAtLeft = RadGridViewDragDropService.IsDroppedAtLeft(dropLocation, this.Size.Width);

            if (this.Description != context.GroupDescription)
            {
                SortDescriptor   sortDescription = context.SortDescription;
                GridViewTemplate viewTemplate    = context.ViewTemplate;
                context.GroupDescription.GroupNames.Remove(sortDescription);
                if (context.GroupDescription.GroupNames.Count == 0)
                {
                    viewTemplate.DataView.GroupDescriptors.Remove(context.GroupDescription);
                }
                RadGridViewDragDropService.InsertOnLeftOrRight <SortDescriptor>(isDroppedAtLeft, (Collection <SortDescriptor>) this.Description.GroupNames, this.sortDescription, sortDescription);
            }
            else
            {
                RadGridViewDragDropService.MoveOnLeftOrRight <SortDescriptor>(isDroppedAtLeft, (Collection <SortDescriptor>) this.Description.GroupNames, this.sortDescription, context.SortDescription);
            }
            TemplateGroupsElement.RaiseGroupByChanged(context.ViewTemplate, context.GroupDescription, NotifyCollectionChangedAction.Batch);
            return(true);
        }
예제 #13
0
 protected override Image GetDragHintCore()
 {
     return((Image)RadGridViewDragDropService.GetDragImageHint(this.TextAlignment, base.GetDragHintCore() as Bitmap, this.Layout.RightPart.Bounds, 100));
 }