Exemplo n.º 1
0
        protected override Image GetDragHintCore()
        {
            ISupportDrag imageElement = (ISupportDrag)this.imageElement;
            Image        dragHint1    = ((ISupportDrag)this.ContentElement).GetDragHint();

            if (imageElement == null)
            {
                return(dragHint1);
            }
            Image dragHint2 = imageElement.GetDragHint();

            if (dragHint2 == null)
            {
                return(dragHint1);
            }
            if (dragHint1 == null)
            {
                return(dragHint2);
            }
            Bitmap bitmap = new Bitmap(dragHint2.Width + dragHint1.Width, Math.Max(dragHint2.Height, dragHint1.Height));

            using (Graphics graphics = Graphics.FromImage((Image)bitmap))
            {
                graphics.DrawImage(dragHint2, Point.Empty);
                graphics.DrawImage(dragHint1, new Point(dragHint2.Width, 0));
            }
            return((Image)bitmap);
        }
Exemplo n.º 2
0
        private bool dragStart(ParameterDic pm, IUIInput input, string mode)
        {
            ISupportDrag isd = pm.GetValue <ISupportDrag>(DragSourceKey);

            if (pm.GetValue <string>(DragDropModeKey) == null && isd != null)
            {
                var         draggables = isd.GetDraggables();
                IDataObject dataObj    = isd is ISupportShellDrag ?
                                         (isd as ISupportShellDrag).GetDataObject(draggables) : null;
                DragDropEffectsEx effect = isd.QueryDrag(draggables);

                pm.SetValue(DragDropModeKey, mode);
                pm.SetValue(DragDropDeviceKey, input.InputType);
                pm.SetValue(DragDropDraggingItemsKey, draggables);
                pm.SetValue(DragDropEffectsKey, effect);
                pm.SetValue(DragDropDragSourceKey, isd);
                pm.SetValue(ParameterDic.CombineVariable(DragDropDragSourceKey, ".IsDraggingFrom", false), true);
                pm.SetValue(DragDropStartPositionKey, pm.GetValue <Point>(CurrentPositionAdjustedKey));
                pm.SetValue(InputKey, new DragInput(input, dataObj, DragDropEffectsEx.Copy, (eff) => { }));

                return(true);
            }

            return(false);
        }
Exemplo n.º 3
0
        protected override Image GetDragHintCore()
        {
            ISupportDrag draggableImage   = imageElement as ISupportDrag;
            ISupportDrag draggableContent = this.ContentElement as ISupportDrag;
            Image        hint             = draggableContent.GetDragHint();

            if (draggableImage == null)
            {
                return(hint);
            }

            Image image = draggableImage.GetDragHint();

            if (image == null)
            {
                return(hint);
            }

            if (hint == null)
            {
                return(image);
            }

            Bitmap newHint = new Bitmap(image.Width + hint.Width, Math.Max(image.Height, hint.Height));

            using (Graphics graphics = Graphics.FromImage(newHint))
            {
                graphics.DrawImage(image, Point.Empty);
                graphics.DrawImage(hint, new Point(image.Width, 0));
            }

            return(newHint);
        }
        public override IScriptCommand Execute(ParameterDic pm)
        {
            if (SkipIfExists && pm.HasValue(DestinationKey))
            {
                return(NextCommand);
            }

            IEnumerable <IDraggable> value = new List <IDraggable>();

            ISupportShellDrop issd    = pm.GetValue <ISupportShellDrop>(ISupportDropKey);
            IDataObject       dataObj = pm.GetValue <IDataObject>(DataObjectKey);

            if (dataObj.GetDataPresent(typeof(ISupportDrag)))
            {
                ISupportDrag isd = (ISupportDrag)dataObj.GetData(typeof(ISupportDrag));
                value = isd.GetDraggables();
            }
            else
            if (issd != null && dataObj != null)
            {
                value = (issd.QueryDropDraggables(dataObj) ?? new List <IDraggable>());
            }

            pm.SetValue(DestinationKey, value, SkipIfExists);
            return(NextCommand);
        }
        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);
        }
        protected override bool ProcessDragOver(Point currentMouseLocation, ISupportDrag dragObject)
        {
            object dataContext = dragObject.GetDataContext();

            if (!this.ViewTemplate.AllowColumnReorder)
            {
                return(false);
            }
            if (dataContext is GridViewColumnGroup)
            {
                return(true);
            }
            if (dataContext is GridViewGroupColumn)
            {
                GridViewGroupColumn gridViewGroupColumn = (GridViewGroupColumn)dataContext;
                for (GridViewColumnGroup gridViewColumnGroup = this.GridViewGroupColumn.Group; gridViewColumnGroup != null; gridViewColumnGroup = gridViewColumnGroup.Parent)
                {
                    if (gridViewColumnGroup == gridViewGroupColumn.Group)
                    {
                        return(false);
                    }
                }
            }
            return(base.ProcessDragOver(currentMouseLocation, dragObject));
        }
Exemplo n.º 7
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);
                }
            }
        }
 protected override bool ProcessDragOver(Point currentMouseLocation, ISupportDrag dragObject)
 {
     if (dragObject.GetDataContext() is GroupFieldDragDropContext)
     {
         return(true);
     }
     return(base.ProcessDragOver(currentMouseLocation, dragObject));
 }
Exemplo n.º 9
0
 protected override bool ProcessDragOver(Point mousePosition, ISupportDrag dragObject)
 {
     if (this.Parent is RootRadElement && this.Items.Count == 0)
     {
         return(true);
     }
     return(base.ProcessDragOver(mousePosition, dragObject));
 }
Exemplo n.º 10
0
 public SnapshotDragItem(RadItem item)
 {
     this.supportDrag = (ISupportDrag)item;
     this.context     = this.supportDrag.GetDataContext();
     this.hint        = this.InitializeDragHint();
     this.AllowDrag   = this.supportDrag.AllowDrag;
     this.controlBoundingRectangle = item.ControlBoundingRectangle;
     this.elementTree = item.ElementTree;
 }
Exemplo n.º 11
0
        public bool CanDragOver(ISupportDrag dragObject)
        {
            object dataContext = dragObject.GetDataContext();

            if (dataContext is GridViewDataColumn)
            {
                return((dataContext as GridViewColumn).CanDragToGroup(this.ViewTemplate));
            }
            return(dataContext is GroupFieldDragDropContext && this.ViewTemplate == (dataContext as GroupFieldDragDropContext).ViewTemplate);
        }
Exemplo n.º 12
0
        protected override bool ProcessDragOver(Point currentMouseLocation, ISupportDrag dragObject)
        {
            GridViewColumn dataContext = dragObject.GetDataContext() as GridViewColumn;

            if (dataContext != null && dataContext.OwnerTemplate != null && dataContext.OwnerTemplate.MasterTemplate != this.ColumnInfo.OwnerTemplate.MasterTemplate)
            {
                return(false);
            }
            return(base.ProcessDragOver(currentMouseLocation, dragObject));
        }
Exemplo n.º 13
0
        protected override bool ProcessDragOver(Point currentMouseLocation, ISupportDrag dragObject)
        {
            GridViewColumn dataContext = dragObject.GetDataContext() as GridViewColumn;

            if (dataContext != null && dataContext.OwnerTemplate != null && !(dataContext.OwnerTemplate.ViewDefinition is HtmlViewDefinition))
            {
                return(dataContext.IsVisible);
            }
            return(false);
        }
Exemplo n.º 14
0
        private void DoDrag(Point mousePt)
        {
            RadItem draggedElement = this.Context as RadItem;

            this.SetHintWindowPosition(mousePt);

            Point        oldDropLocation = this.dropLocation;
            ISupportDrop dropTarget      = this.GetDropTarget(Control.MousePosition, out this.dropLocation);

            if (dropTarget == null || !this.IsDropTargetValid(dropTarget))
            {
                Cursor.Current = this.InvalidCursor;
                this.doCommit  = false;
                return;
            }

            if (dropTarget != null)
            {
                ISupportDrag draggedContext = this.Context as ISupportDrag;
                if (this.target != dropTarget)
                {
                    if (this.target != null)
                    {
                        this.target.DragLeave(oldDropLocation, draggedContext);
                    }

                    this.target = dropTarget;
                    this.target.DragEnter(this.dropLocation, draggedContext);
                }

                this.doCommit = this.target.DragOver(this.dropLocation, draggedContext);

                RadDragOverEventArgs args = new RadDragOverEventArgs(draggedContext, this.target);
                args.CanDrop = this.doCommit;
                this.OnPreviewDragOver(args);

                //use the CanDrop member of the event as it may be altered
                this.doCommit = args.CanDrop;

                if (this.doCommit)
                {
                    //TODO: Provide logic for updating cursor with events and DragDropEffects
                    Cursor.Current = this.ValidCursor;
                }
                else
                {
                    Cursor.Current = this.InvalidCursor;
                }
            }
            else
            {
                this.target   = null;
                this.doCommit = false;
            }
        }
Exemplo n.º 15
0
        private ISupportDrop HitTestElementTree(ComponentThemableElementTree elementTree, Point screenMouse, out Point resultDropLocation)
        {
            if (elementTree == null)
            {
                resultDropLocation = Point.Empty;
                return(null);
            }

            resultDropLocation = Point.Empty;
            Point        clientMouse  = elementTree.Control.PointToClient(screenMouse);
            RadElement   hitElement   = elementTree.GetElementAtPoint(clientMouse);
            ISupportDrag dragInstance = this.Context as ISupportDrag;

            ISupportDrop dropTarget = null;
            ISupportDrop hitTarget  = null;

            while (hitElement != null)
            {
                hitTarget  = hitElement as ISupportDrop;
                dropTarget = null;

                if (hitTarget != null && hitTarget.AllowDrop)
                {
                    RadElement dropTargetElement = hitTarget as RadElement;

                    if (dropTargetElement != null)
                    {
                        resultDropLocation = dropTargetElement.PointFromControl(clientMouse);
                    }
                    else
                    {
                        resultDropLocation = clientMouse;
                    }

                    dropTarget = hitTarget;
                }

                //raise PreviewDropTarget event
                PreviewDropTargetEventArgs args = new PreviewDropTargetEventArgs(dragInstance, hitTarget);
                args.DropTarget = dropTarget;
                this.OnPreviewDropTarget(args);
                dropTarget = args.DropTarget;

                if (dropTarget != null)
                {
                    return(dropTarget);
                }

                hitElement = hitElement.Parent;
            }

            return(null);
        }
Exemplo n.º 16
0
        protected override void ProcessDragDrop(Point dropLocation, ISupportDrag dragObject)
        {
            GroupFieldDragDropContext dataContext = dragObject.GetDataContext() as GroupFieldDragDropContext;

            if (dataContext != null)
            {
                dataContext.ViewTemplate.GroupDescriptors.Remove(dataContext.GroupDescription);
            }
            else
            {
                base.ProcessDragDrop(dropLocation, dragObject);
            }
        }
Exemplo n.º 17
0
        protected override bool ProcessDragOver(Point currentMouseLocation, ISupportDrag dragObject)
        {
            if (dragObject.GetDataContext() is GroupFieldDragDropContext)
            {
                return(true);
            }
            GridViewRowInfo dataContext = dragObject.GetDataContext() as GridViewRowInfo;

            if (dataContext == null)
            {
                return(base.ProcessDragOver(currentMouseLocation, dragObject));
            }
            return(this.RowInfo.ViewTemplate.SortDescriptors.Count <= 0 && this.RowInfo.ViewTemplate.GroupDescriptors.Count <= 0 && dataContext.ViewTemplate == this.Data.ViewTemplate);
        }
Exemplo n.º 18
0
        protected override bool ProcessDragOver(Point currentMouseLocation, ISupportDrag dragObject)
        {
            object dataContext = dragObject.GetDataContext();
            bool   flag        = false;

            if (dataContext is GroupFieldDragDropContext)
            {
                flag = this.templateElement.ViewTemplate == (dataContext as GroupFieldDragDropContext).ViewTemplate;
            }
            else if (dataContext is GridViewColumn)
            {
                flag = (dataContext as GridViewColumn).CanDragToGroup(this.templateElement.ViewTemplate);
            }
            return(flag);
        }
Exemplo n.º 19
0
 public void BeginDrag(Point mouseBeginPoint, ISupportDrag draggedObject)
 {
     if (this.State == RadServiceState.Working)
     {
         return;
     }
     this.beginPoint             = new Point?(mouseBeginPoint);
     this.startedProgramatically = true;
     this.Start((object)draggedObject);
     if (this.State != RadServiceState.Working)
     {
         return;
     }
     this.PrepareContext();
     this.initialized = true;
 }
        protected override void ProcessDragDrop(Point dropLocation, ISupportDrag dragObject)
        {
            RadPageViewItem dragItem = dragObject as RadPageViewItem;

            if (dragItem == null)
            {
                return;
            }
            RadPageViewItem hitItem = this.ItemFromPoint(this.GetMousePosition(dropLocation));

            if (hitItem == null)
            {
                return;
            }
            this.PerformItemDrop(dragItem, hitItem);
        }
Exemplo n.º 21
0
        protected override void ProcessDragDrop(Point dropLocation, ISupportDrag dragObject)
        {
            GridViewColumn dataContext = dragObject.GetDataContext() as GridViewColumn;

            if (!dataContext.AllowHide)
            {
                return;
            }
            GridViewGroupColumn gridViewGroupColumn = dataContext as GridViewGroupColumn;

            if (gridViewGroupColumn != null && !gridViewGroupColumn.Group.AllowHide)
            {
                return;
            }
            dataContext.IsVisible = false;
        }
Exemplo n.º 22
0
        /// <summary>
        /// Begins a drag pass. Allows for service automation.
        /// </summary>
        /// <param name="mouseBeginPoint">The position of the mouse cursor in screen coordinates.</param>
        /// <param name="draggedObject">An instance of IDraggable that is dragged.</param>
        public void BeginDrag(Point mouseBeginPoint, ISupportDrag draggedObject)
        {
            if (this.State == RadServiceState.Working)
            {
                return;
            }

            this.beginPoint = mouseBeginPoint;

            this.Start(draggedObject);

            if (this.State == RadServiceState.Working)
            {
                this.PrepareContext();
                this.initialized = true;
            }
        }
Exemplo n.º 23
0
        protected override void ProcessDragDrop(Point dropLocation, ISupportDrag dragObject)
        {
            object dataContext = dragObject.GetDataContext();

            if (dataContext is GridViewDataColumn)
            {
                this.ProcessDragDropColumn(dataContext);
            }
            else
            {
                if (!(dataContext is GroupFieldDragDropContext))
                {
                    return;
                }
                this.ProcessDragDropFieldContext(dataContext);
            }
        }
Exemplo n.º 24
0
        private void DoDrag(Point mousePt)
        {
            object context1 = this.Context;

            this.SetHintWindowPosition(mousePt);
            Point        dropLocation = this.dropLocation;
            ISupportDrop dropTarget   = this.GetDropTarget(mousePt, out this.dropLocation);

            if (dropTarget == null || !this.IsDropTargetValid(dropTarget))
            {
                Cursor.Current = this.InvalidCursor;
                this.doCommit  = false;
            }
            else if (dropTarget != null)
            {
                ISupportDrag context2 = this.Context as ISupportDrag;
                if (this.target != dropTarget)
                {
                    if (this.target != null)
                    {
                        this.target.DragLeave(dropLocation, context2);
                    }
                    this.target = dropTarget;
                    this.target.DragEnter(this.dropLocation, context2);
                }
                this.doCommit = this.target.DragOver(this.dropLocation, context2);
                RadDragOverEventArgs e = new RadDragOverEventArgs(context2, this.target);
                e.CanDrop = this.doCommit;
                this.OnPreviewDragOver(e);
                this.doCommit = e.CanDrop;
                if (this.doCommit)
                {
                    Cursor.Current = this.ValidCursor;
                }
                else
                {
                    Cursor.Current = this.InvalidCursor;
                }
            }
            else
            {
                this.target   = (ISupportDrop)null;
                this.doCommit = false;
            }
        }
        protected virtual System.Type GetDragContext(ISupportDrag dragInstance)
        {
            BaseListViewVisualItem listViewVisualItem = dragInstance as BaseListViewVisualItem;

            if (listViewVisualItem == null)
            {
                return((System.Type)null);
            }
            if ((object)(listViewVisualItem.Data.Tag as System.Type) != null)
            {
                return((System.Type)listViewVisualItem.Data.Tag);
            }
            if (listViewVisualItem.Data.Tag != null)
            {
                return(listViewVisualItem.Data.Tag.GetType());
            }
            return((System.Type)null);
        }
Exemplo n.º 26
0
        protected override void ProcessDragDrop(Point dropLocation, ISupportDrag dragObject)
        {
            RadPageViewItem dragItem = dragObject as RadPageViewItem;

            Debug.Assert(dragItem != null, "Invalid drop notification");
            if (dragItem == null)
            {
                return;
            }

            RadPageViewItem hitItem = this.ItemFromPoint(dropLocation);

            Debug.Assert(hitItem != null, "Invalid drop notification");
            if (hitItem != null)
            {
                this.PerformItemDrop(dragItem, hitItem);
            }
        }
Exemplo n.º 27
0
        public DragDropInfo(ISupportDrag <T> dragSource)
        {
            SupportedEffects  = dragSource.SupportedDragDropEffects;
            SelectedItems     = new List <DragDropItemInfo <T> >();
            HandledInternally = false;

            if (SupportedEffects != DragDropEffects.None)
            {
                T[] selectedItems = dragSource.SelectedItems;
                if (selectedItems != null && selectedItems.Length > 0)
                {
                    foreach (T selItem in selectedItems)
                    {
                        SelectedItems.Add(dragSource.GetItemInfo(selItem));
                    }
                }
            }
        }
Exemplo n.º 28
0
 protected override bool ProcessDragOver(Point currentMouseLocation, ISupportDrag dragObject)
 {
     if (dragObject is ColumnChooserItem)
     {
         object             dataContext        = dragObject.GetDataContext();
         GridViewDataColumn gridViewDataColumn = dataContext as GridViewDataColumn;
         if (gridViewDataColumn != null)
         {
             return(!gridViewDataColumn.IsVisible);
         }
         GridViewColumnGroup gridViewColumnGroup = dataContext as GridViewColumnGroup;
         if (gridViewColumnGroup != null)
         {
             return(!gridViewColumnGroup.IsVisible);
         }
     }
     return(false);
 }
Exemplo n.º 29
0
        protected override bool ProcessDragOver(Point currentMouseLocation, ISupportDrag dragObject)
        {
            object dataContext1 = dragObject.GetDataContext();

            if (dataContext1 is GridViewColumn)
            {
                GridViewColumn dataContext2 = dragObject.GetDataContext() as GridViewColumn;
                if (this.GridViewElement.Template.VirtualMode)
                {
                    return(false);
                }
                return(dataContext2.CanDragToGroup());
            }
            if (dataContext1 is GroupFieldDragDropContext)
            {
                return((dataContext1 as GroupFieldDragDropContext).GroupDescription.GroupNames.Count > 1);
            }
            return(false);
        }
        protected override bool ProcessDragOver(Point mousePosition, ISupportDrag dragObject)
        {
            RadPageViewItem dragItem = dragObject as RadPageViewItem;

            if (dragItem == null || dragItem.Owner != this)
            {
                return(false);
            }
            Point           mousePosition1 = this.GetMousePosition(mousePosition);
            RadPageViewItem hitItem        = this.ItemFromPoint(mousePosition1);

            if (!this.CanDropOverItem(dragItem, hitItem))
            {
                return(false);
            }
            this.EnsureItemVisible(hitItem);
            this.ItemsParent.UpdateLayout();
            return(hitItem.ControlBoundingRectangle.Contains(mousePosition1));
        }