Beispiel #1
0
        private DropReturnData EhAvailableItems_Drop(object data, object nonGuiTargetItem, DragDropRelativeInsertPosition insertPosition, bool isCtrlKeyPressed, bool isShiftKeyPressed)
        {
            // when dropping onto available items, it's only purpose is to remove some items from the item lists
            // thus the only operation here is move

            if (data is TItem)
            {
                return(new DropReturnData
                {
                    IsCopy = false,
                    IsMove = true // we want the item to be removed from the current item list
                });
            }
            else
            {
                return(DropFailedReturnData);
            }
        }
Beispiel #2
0
        private DropReturnData EhCurrentItems_Drop(object data, object nonGuiTargetItem, DragDropRelativeInsertPosition insertPosition, bool isCtrlKeyPressed, bool isShiftKeyPressed)
        {
            var droppedItem = default(TItem);

            if (data is Type)
            {
                object createdObj = null;
                try
                {
                    createdObj = System.Activator.CreateInstance((Type)data);
                }
                catch (Exception ex)
                {
                    Current.Gui.ErrorMessageBox("This object could not be dropped because it could not be created, message: " + ex.ToString(), "Error");
                    return(DropFailedReturnData);
                }

                if (!(createdObj is TItem))
                {
                    return(DropFailedReturnData);
                }

                droppedItem = (TItem)createdObj;
            } // end if data is type
            else if (data is TItem)
            {
                droppedItem = (TItem)data;
            } // end if data is TItem
            else
            {
                return(DropFailedReturnData);
            }

            int targetIndex = int.MaxValue;

            if (nonGuiTargetItem is SelectableListNode)
            {
                int idx = _currentItems.IndexOf((SelectableListNode)nonGuiTargetItem);
                if (idx >= 0 && insertPosition.HasFlag(DragDropRelativeInsertPosition.AfterTargetItem))
                {
                    ++idx;
                }
                targetIndex = idx;
            }

            var newNode = new SelectableListNode(droppedItem.ToString(), droppedItem, false);

            if (targetIndex >= _currentItems.Count)
            {
                _currentItems.Add(newNode);
            }
            else
            {
                _currentItems.Insert(targetIndex, newNode);
            }

            SetListDirty();

            return(new DropReturnData
            {
                IsCopy = isCtrlKeyPressed,
                IsMove = !isCtrlKeyPressed
            });
        }
Beispiel #3
0
 private DropCanAcceptDataReturnData EhAvailableItems_DropCanAcceptData(object data, object nonGuiTargetItem, DragDropRelativeInsertPosition insertPosition, bool isCtrlKeyPressed, bool isShiftKeyPressed)
 {
     // when dropping onto available items, it's only purpose is to remove some items from the current item lists
     // thus the only operation here is move
     return(new DropCanAcceptDataReturnData
     {
         CanCopy = false,
         CanMove = true, // we want the item to be removed from the current item list
         ItemIsSwallowingData = false
     });
 }
Beispiel #4
0
        private DropCanAcceptDataReturnData EhCurrentItems_DropCanAcceptData(object data, object nonGuiTargetItem, DragDropRelativeInsertPosition insertPosition, bool isCtrlKeyPressed, bool isShiftKeyPressed)
        {
            // investigate data

            if (data is TItem)
            {
                return(new DropCanAcceptDataReturnData
                {
                    CanCopy = true,
                    CanMove = false,
                    ItemIsSwallowingData = false
                });
            }
            else if (data is Type)
            {
                return(new DropCanAcceptDataReturnData
                {
                    CanCopy = true,
                    CanMove = false,
                    ItemIsSwallowingData = false
                });
            }
            else
            {
                return(new DropCanAcceptDataReturnData
                {
                    CanCopy = false,
                    CanMove = false,
                    ItemIsSwallowingData = false
                });
            }
        }