protected override DragDropOption PerformDropForeignItems(IList <IGalleryItem> droppingItems, IGalleryItem targetItem, DragDropOption actions, ModifierFlags modifiers) { SeriesItem series = (SeriesItem)targetItem; DragDropOption action = DragDropOption.None; foreach (IGalleryItem droppingItem in droppingItems) { if (droppingItem is ImageItem) { ImageItem image = (ImageItem)droppingItem; if (modifiers == ModifierFlags.None) { if (!series.Images.Contains(image)) { series.Images.Add(image.Copy()); action = DragDropOption.Move; } } else if (modifiers == ModifierFlags.Shift) { series.Images.Add(image.Copy()); action = DragDropOption.Copy; } } } return(action); }
public static DragDropEffects GetDragDropEffects(DragDropOption dragDropAction) { DragDropEffects effects = DragDropEffects.None; if ((dragDropAction & DragDropOption.Move) == DragDropOption.Move) effects |= DragDropEffects.Move; if ((dragDropAction & DragDropOption.Copy) == DragDropOption.Copy) effects |= DragDropEffects.Copy; return effects; }
protected override DragDropOption PerformDropForeignItems(IList <IGalleryItem> droppingItems, IGalleryItem targetItem, DragDropOption actions, ModifierFlags modifiers) { StudyItem study = (StudyItem)targetItem; DragDropOption action = DragDropOption.None; foreach (IGalleryItem droppingItem in droppingItems) { if (droppingItem is SeriesItem) { SeriesItem series = (SeriesItem)droppingItem; if (modifiers == ModifierFlags.None) { if (!study.Series.Contains(series)) { study.Series.Add(series.Copy()); action = DragDropOption.Move; } } else if (modifiers == ModifierFlags.Shift) { study.Series.Add(series.Copy()); action = DragDropOption.Copy; } } else if (droppingItem is ImageItem) { ImageItem image = (ImageItem)droppingItem; if (modifiers == ModifierFlags.None) { SeriesNode seriesNode = (SeriesNode)GetNodeAncestor(image.Node, 1); StudyNode studyNode = (StudyNode)GetNodeAncestor(seriesNode, 1); if (study.Node != studyNode) { SeriesItem series = new SeriesItem(seriesNode.Copy(false)); series.Images.Add(image.Copy()); series.UpdateIcon(); study.Series.Add(series); action = DragDropOption.Move; } } else if (modifiers == ModifierFlags.Shift) { SeriesNode seriesNode = (SeriesNode)GetNodeAncestor(image.Node, 1); SeriesItem series = new SeriesItem(seriesNode.Copy(false)); series.Images.Add(image.Copy()); series.UpdateIcon(); study.Series.Add(series); action = DragDropOption.Copy; } } } return(action); }
private void OnItemDragDrop(object sender, DragEventArgs e) { DragDropObject data = new DragDropObject(e.Data); DragDropOption action = DragDropOption.None; DragDropOption allowedActions = ConvertEnum.GetDragDropAction(e.AllowedEffect); ModifierFlags modifiers = ConvertEnum.GetModifierFlags(e); Point clientPoint = _listView.PointToClient(new Point(e.X, e.Y)); IGalleryItem targetItem; bool skipNearestItem = false; if (_component.AllowsDropOnItem) { targetItem = GetTargetItemAt(clientPoint, false); if (targetItem != null) { action = _component.PerformDrop(data, targetItem, allowedActions, modifiers); skipNearestItem = true; if (action != DragDropOption.None) { DrawInsertionMark(_gallery.IndexOf(targetItem), true, clientPoint); } } } if (_component.AllowsDropAtIndex && action == DragDropOption.None) { int targetIndex = GetNearestTargetIndexAt(clientPoint); if (targetIndex >= 0) { action = _component.PerformDrop(data, targetIndex, allowedActions, modifiers); if (action != DragDropOption.None) { DrawInsertionMark(targetIndex, false, clientPoint); } } } if (!skipNearestItem && _component.AllowsDropOnItem && action == DragDropOption.None) { targetItem = GetTargetItemAt(clientPoint, true); if (targetItem != null) { action = _component.PerformDrop(data, targetItem, allowedActions, modifiers); if (action != DragDropOption.None) { DrawInsertionMark(_gallery.IndexOf(targetItem), true, clientPoint); } } } e.Effect = ConvertEnum.GetDragDropEffects(action); DrawInsertionMark(-1, false, Point.Empty); }
public static DragDropEffects GetDragDropEffects(DragDropOption dragDropAction) { DragDropEffects effects = DragDropEffects.None; if ((dragDropAction & DragDropOption.Move) == DragDropOption.Move) { effects |= DragDropEffects.Move; } if ((dragDropAction & DragDropOption.Copy) == DragDropOption.Copy) { effects |= DragDropEffects.Copy; } return(effects); }
public static DragDropOption GetDragDropAction(DragDropEffects dragDropEffects) { DragDropOption action = DragDropOption.None; if ((dragDropEffects & DragDropEffects.Move) == DragDropEffects.Move) { action |= DragDropOption.Move; } if ((dragDropEffects & DragDropEffects.Copy) == DragDropEffects.Copy) { action |= DragDropOption.Copy; } return(action); }
/// <summary> /// Signals the component that a drag & drop operation involving the specified /// <see cref="IGalleryItem"/>s has ended with the given action being taken on the items by the drop target. /// </summary> /// <param name="draggedItems">The <see cref="IGalleryItem"/>s that were dragged.</param> /// <param name="action">The <see cref="DragDropOption"/> action that was taken on the items by the drop target.</param> public override sealed void EndDrag(IList <IGalleryItem> draggedItems, DragDropOption action) { if (_draggedItems != null && draggedItems == _draggedItems) { if ((action & DragDropOption.Move) == DragDropOption.Move) { foreach (IGalleryItem draggedItem in draggedItems) { base.DataSource.Remove(draggedItem); } } _draggedItems = null; } }
/// <summary> /// Performs a drag-drop of <see cref="IGalleryItem"/>s from within this gallery to the specified target index. /// </summary> /// <param name="droppedItems">The list of <see cref="IGalleryItem"/>s to drop.</param> /// <param name="targetIndex">The target index at which the <paramref name="droppedItems"/> are being dropped.</param> /// <param name="actions">The interaction to take.</param> /// <param name="modifiers">The modifier keys that were pressed at the time of the drop.</param> /// <returns>The actual interaction on the <paramref name="droppedItems"/> that was taken.</returns> protected virtual DragDropOption PerformDropLocalItems(IList <IGalleryItem> droppedItems, int targetIndex, DragDropOption actions, ModifierFlags modifiers) { DragDropOption performedAction = DragDropOption.None; if (modifiers == ModifierFlags.None) { // check for null drops and drops to a point within the source data if (droppedItems.Count == 0) { return(DragDropOption.None); } int draggedIndex = base.DataSource.IndexOf(droppedItems[0]); if (targetIndex >= draggedIndex && targetIndex < draggedIndex + droppedItems.Count) { return(DragDropOption.None); } // we are dragging something, and the item we want to drop is the same as that which we are dragging // then this is a reordering operation if (droppedItems != this.DraggedItems) { return(DragDropOption.None); } if (draggedIndex < targetIndex) { targetIndex -= droppedItems.Count; } Stack <IGalleryItem> stack = new Stack <IGalleryItem>(); foreach (IGalleryItem droppedItem in droppedItems) { base.DataSource.Remove(droppedItem); stack.Push(droppedItem); } while (stack.Count > 0) { base.DataSource.Insert(targetIndex, stack.Pop()); } this.DraggedItems = null; performedAction = DragDropOption.Move; } return(performedAction); }
protected override DragDropOption PerformDropLocalItems(IList <IGalleryItem> droppedItems, int targetIndex, DragDropOption actions, ModifierFlags modifiers) { DragDropOption performedActions = base.PerformDropLocalItems(droppedItems, targetIndex, actions, modifiers); if (performedActions == DragDropOption.None && modifiers == ModifierFlags.Shift) { bool allow = true; foreach (IGalleryItem droppedItem in droppedItems) { if (droppedItem is IStudyComposerItem) { IStudyComposerItem item = (IStudyComposerItem)droppedItem; base.DataSource.Insert(targetIndex, item.Clone()); } } performedActions = DragDropOption.Copy; } return(performedActions); }
protected override DragDropOption CheckDropLocalItems(IList <IGalleryItem> droppingItems, int targetIndex, DragDropOption actions, ModifierFlags modifiers) { DragDropOption allowedActions = base.CheckDropLocalItems(droppingItems, targetIndex, actions, modifiers); if (allowedActions == DragDropOption.None && modifiers == ModifierFlags.Shift) { bool allow = true; foreach (IGalleryItem droppingItem in droppingItems) { if (!(droppingItem is IStudyComposerItem)) { allow &= false; } } if (allow) { return(DragDropOption.Copy); } } return(allowedActions); }
/// <summary> /// Checks if drag-dropping <see cref="IGalleryItem"/>s from within this gallery to the specified target index is allowed. /// </summary> /// <param name="droppingItems">The list of <see cref="IGalleryItem"/>s to drop.</param> /// <param name="targetIndex">The target index at which the <paramref name="droppingItems"/> are being dropped.</param> /// <param name="actions">The interactions that are being allowed by the data source.</param> /// <param name="modifiers">The modifier keys that currently being pressed.</param> /// <returns>The allowed interactions for dropping the <paramref name="droppingItems"/> here.</returns> protected virtual DragDropOption CheckDropLocalItems(IList <IGalleryItem> droppingItems, int targetIndex, DragDropOption actions, ModifierFlags modifiers) { DragDropOption allowedActions = DragDropOption.None; if (modifiers == ModifierFlags.None) { // check for null drops and drops to a point within the source data if (droppingItems.Count == 0) { return(DragDropOption.None); } int draggedIndex = base.DataSource.IndexOf(droppingItems[0]); if (targetIndex >= draggedIndex && targetIndex < draggedIndex + droppingItems.Count) { return(DragDropOption.None); } // we are dragging an item, and the item we want to drop is the same as that which we are dragging // then this is a reordering operation allowedActions = actions & DragDropOption.Move; } return(allowedActions); }
/// <summary> /// Checks if drag-dropping <see cref="IGalleryItem"/>s from within this gallery on top of the specified item is allowed. /// </summary> /// <param name="droppingItems">The list of <see cref="IGalleryItem"/>s to drop.</param> /// <param name="targetItem">The target <see cref="IGalleryItem"/> at which the <paramref name="droppingItems"/> are being dropped.</param> /// <param name="actions">The interactions that are being allowed by the data source.</param> /// <param name="modifiers">The modifier keys that currently being pressed.</param> /// <returns>The allowed interactions for dropping the <paramref name="droppingItems"/> here.</returns> protected virtual DragDropOption CheckDropLocalItems(IList<IGalleryItem> droppingItems, IGalleryItem targetItem, DragDropOption actions, ModifierFlags modifiers) { return DragDropOption.None; }
/// <summary> /// /// </summary> /// <remarks> /// This method or <see cref="PerformDrop(IDragDropObject,IGalleryItem,DragDropOption,ModifierFlags)"/> may be called /// additional times if the returned action is <see cref="DragDropOption.None"/> in order to attempt other ways to drop the item in /// an acceptable manner. It is thus very important that the result be set properly if the drop was accepted and no further attempts /// should be made. /// </remarks> /// <param name="droppedData"></param> /// <param name="targetIndex"></param> /// <param name="action"></param> /// <param name="modifiers"></param> /// <returns></returns> public virtual DragDropOption PerformDrop(IDragDropObject droppedData, int targetIndex, DragDropOption action, ModifierFlags modifiers) { return(DragDropOption.None); }
/// <summary> /// Checks for allowed drag & drop actions involving the specified foreign data and the given target on this component. /// </summary> /// <param name="droppingData">The <see cref="IDragDropObject"/> object that encapsulates all forms of the foreign data.</param> /// <param name="targetIndex">The target index that the user is trying to drop at.</param> /// <param name="actions"></param> /// <param name="modifiers">The modifier keys that are being held by the user.</param> /// <returns>The allowed <see cref="DragDropKind"/> actions for this attempted drag & drop operation.</returns> public virtual DragDropOption CheckDrop(IDragDropObject droppingData, int targetIndex, DragDropOption actions, ModifierFlags modifiers) { return(DragDropOption.None); }
private void button1_Click(object sender, RoutedEventArgs e) { if (optCreateAsChild.IsChecked.GetValueOrDefault(false)) { this.DragDropOption = Material.DragDropOption.CreateAsChild; } else { this.DragDropOption = Material.DragDropOption.Merge; } this.DialogResult = true; Hide(); }
/// <summary> /// Performs a drag-drop of <see cref="IGalleryItem"/>s from outside this gallery on top of the specified item. /// </summary> /// <param name="droppedItems">The list of <see cref="IGalleryItem"/>s to drop.</param> /// <param name="targetItem">The target <see cref="IGalleryItem"/> at which the <paramref name="droppedItems"/> are being dropped.</param> /// <param name="actions">The interaction to take.</param> /// <param name="modifiers">The modifier keys that were pressed at the time of the drop.</param> /// <returns>The actual interaction on the <paramref name="droppedItems"/> that was taken.</returns> protected virtual DragDropOption PerformDropForeignItems(IList <IGalleryItem> droppedItems, IGalleryItem targetItem, DragDropOption actions, ModifierFlags modifiers) { return(DragDropOption.None); }
/// <summary> /// Checks if drag-dropping <see cref="IGalleryItem"/>s from within this gallery on top of the specified item is allowed. /// </summary> /// <param name="droppingItems">The list of <see cref="IGalleryItem"/>s to drop.</param> /// <param name="targetItem">The target <see cref="IGalleryItem"/> at which the <paramref name="droppingItems"/> are being dropped.</param> /// <param name="actions">The interactions that are being allowed by the data source.</param> /// <param name="modifiers">The modifier keys that currently being pressed.</param> /// <returns>The allowed interactions for dropping the <paramref name="droppingItems"/> here.</returns> protected virtual DragDropOption CheckDropLocalItems(IList <IGalleryItem> droppingItems, IGalleryItem targetItem, DragDropOption actions, ModifierFlags modifiers) { return(DragDropOption.None); }
/// <summary> /// /// </summary> /// <param name="droppedData"></param> /// <param name="targetItem"></param> /// <param name="action"></param> /// <param name="modifiers"></param> /// <returns></returns> public override sealed DragDropOption PerformDrop(IDragDropObject droppedData, IGalleryItem targetItem, DragDropOption action, ModifierFlags modifiers) { DragDropOption performedAction; IList<IGalleryItem> droppedItems = ExtractGalleryItemList(droppedData); if (droppedItems != null) { if (_draggedItems == droppedItems) { performedAction = PerformDropLocalItems(droppedItems, targetItem, action, modifiers); } else { performedAction = PerformDropForeignItems(droppedItems, targetItem, action, modifiers); } } else { performedAction = PerformDropForeignObject(droppedData, targetItem, action, modifiers); } return performedAction; }
/// <summary> /// Checks if drag-dropping <see cref="IGalleryItem"/>s from within this gallery to the specified target index is allowed. /// </summary> /// <param name="droppingItems">The list of <see cref="IGalleryItem"/>s to drop.</param> /// <param name="targetIndex">The target index at which the <paramref name="droppingItems"/> are being dropped.</param> /// <param name="actions">The interactions that are being allowed by the data source.</param> /// <param name="modifiers">The modifier keys that currently being pressed.</param> /// <returns>The allowed interactions for dropping the <paramref name="droppingItems"/> here.</returns> protected virtual DragDropOption CheckDropLocalItems(IList<IGalleryItem> droppingItems, int targetIndex, DragDropOption actions, ModifierFlags modifiers) { DragDropOption allowedActions = DragDropOption.None; if (modifiers == ModifierFlags.None) { // check for null drops and drops to a point within the source data if (droppingItems.Count == 0) return DragDropOption.None; int draggedIndex = base.DataSource.IndexOf(droppingItems[0]); if (targetIndex >= draggedIndex && targetIndex < draggedIndex + droppingItems.Count) return DragDropOption.None; // we are dragging an item, and the item we want to drop is the same as that which we are dragging // then this is a reordering operation allowedActions = actions & DragDropOption.Move; } return allowedActions; }
/// <summary> /// Performs a drag-drop of a non-<see cref="IGalleryItem"/> object from outside this gallery on top of the specified item. /// </summary> /// <param name="droppedData">The data object to drop.</param> /// <param name="targetItem">The target <see cref="IGalleryItem"/> at which the <paramref name="droppedData"/> is being dropped.</param> /// <param name="actions">The interaction to take.</param> /// <param name="modifiers">The modifier keys that were pressed at the time of the drop.</param> /// <returns>The actual interaction on the <paramref name="droppedData"/> that was taken.</returns> protected virtual DragDropOption PerformDropForeignObject(IDragDropObject droppedData, IGalleryItem targetItem, DragDropOption actions, ModifierFlags modifiers) { return DragDropOption.None; }
/// <summary> /// Performs a drag-drop of <see cref="IGalleryItem"/>s from outside this gallery on top of the specified item. /// </summary> /// <param name="droppedItems">The list of <see cref="IGalleryItem"/>s to drop.</param> /// <param name="targetItem">The target <see cref="IGalleryItem"/> at which the <paramref name="droppedItems"/> are being dropped.</param> /// <param name="actions">The interaction to take.</param> /// <param name="modifiers">The modifier keys that were pressed at the time of the drop.</param> /// <returns>The actual interaction on the <paramref name="droppedItems"/> that was taken.</returns> protected virtual DragDropOption PerformDropForeignItems(IList<IGalleryItem> droppedItems, IGalleryItem targetItem, DragDropOption actions, ModifierFlags modifiers) { return DragDropOption.None; }
/// <summary> /// Performs a drag-drop of a non-<see cref="IGalleryItem"/> object from outside this gallery to the specified index. /// </summary> /// <param name="droppedData">The data object to drop.</param> /// <param name="targetIndex">The target index at which the <paramref name="droppedData"/> is being dropped.</param> /// <param name="actions">The interaction to take.</param> /// <param name="modifiers">The modifier keys that were pressed at the time of the drop.</param> /// <returns>The actual interaction on the <paramref name="droppedData"/> that was taken.</returns> protected virtual DragDropOption PerformDropForeignObject(IDragDropObject droppedData, int targetIndex, DragDropOption actions, ModifierFlags modifiers) { return DragDropOption.None; }
/// <summary> /// Performs a drag-drop of <see cref="IGalleryItem"/>s from within this gallery to the specified target index. /// </summary> /// <param name="droppedItems">The list of <see cref="IGalleryItem"/>s to drop.</param> /// <param name="targetIndex">The target index at which the <paramref name="droppedItems"/> are being dropped.</param> /// <param name="actions">The interaction to take.</param> /// <param name="modifiers">The modifier keys that were pressed at the time of the drop.</param> /// <returns>The actual interaction on the <paramref name="droppedItems"/> that was taken.</returns> protected virtual DragDropOption PerformDropLocalItems(IList<IGalleryItem> droppedItems, int targetIndex, DragDropOption actions, ModifierFlags modifiers) { DragDropOption performedAction = DragDropOption.None; if (modifiers == ModifierFlags.None) { // check for null drops and drops to a point within the source data if (droppedItems.Count == 0) return DragDropOption.None; int draggedIndex = base.DataSource.IndexOf(droppedItems[0]); if (targetIndex >= draggedIndex && targetIndex < draggedIndex + droppedItems.Count) return DragDropOption.None; // we are dragging something, and the item we want to drop is the same as that which we are dragging // then this is a reordering operation if (droppedItems != this.DraggedItems) return DragDropOption.None; if (draggedIndex < targetIndex) targetIndex -= droppedItems.Count; Stack<IGalleryItem> stack = new Stack<IGalleryItem>(); foreach (IGalleryItem droppedItem in droppedItems) { base.DataSource.Remove(droppedItem); stack.Push(droppedItem); } while (stack.Count > 0) { base.DataSource.Insert(targetIndex, stack.Pop()); } this.DraggedItems = null; performedAction = DragDropOption.Move; } return performedAction; }
/// <summary> /// Checks if drag-dropping <see cref="IGalleryItem"/>s from outside this gallery to the specified target index is allowed. /// </summary> /// <param name="droppingItems">The list of <see cref="IGalleryItem"/>s to drop.</param> /// <param name="targetIndex">The target index at which the <paramref name="droppingItems"/> are being dropped.</param> /// <param name="actions">The interactions that are being allowed by the data source.</param> /// <param name="modifiers">The modifier keys that currently being pressed.</param> /// <returns>The allowed interactions for dropping the <paramref name="droppingItems"/> here.</returns> protected virtual DragDropOption CheckDropForeignItems(IList <IGalleryItem> droppingItems, int targetIndex, DragDropOption actions, ModifierFlags modifiers) { return(DragDropOption.None); }
/// <summary> /// Checks if drag-dropping non-<see cref="IGalleryItem"/> objects from outside this gallery to the specified index is allowed. /// </summary> /// <param name="droppingData">The data object to drop.</param> /// <param name="targetIndex">The target index at which the <paramref name="droppingData"/> is being dropped.</param> /// <param name="actions">The interactions that are being allowed by the data source.</param> /// <param name="modifiers">The modifier keys that currently being pressed.</param> /// <returns>The allowed interactions for dropping the <paramref name="droppingData"/> here.</returns> protected virtual DragDropOption CheckDropForeignObject(IDragDropObject droppingData, int targetIndex, DragDropOption actions, ModifierFlags modifiers) { return(DragDropOption.None); }
private void OnItemDrag(object sender, ItemDragEventArgs e) { List <IGalleryItem> list = new List <IGalleryItem>(); List <object> objectList = new List <object>(); ListViewItem specificLvi = (ListViewItem)e.Item; IGalleryItem specificDraggedItem = (IGalleryItem)specificLvi.Tag; // save selection and focus IList savedSelection = new List <IGalleryItem>(); object savedFocus = _listView.FocusedItem.Tag; if (_listView.SelectedItems.Count > 0) { foreach (ListViewItem lvi in _listView.SelectedItems) { IGalleryItem item = (IGalleryItem)lvi.Tag; list.Add(item); objectList.Add(item.Item); savedSelection.Add(item); } } else { list.Add(specificDraggedItem); objectList.Add(specificDraggedItem.Item); } _selectionEventsEnabled = false; IList <IGalleryItem> draggedItems = list.AsReadOnly(); DragDropOption allowedActions = _component.BeginDrag(draggedItems); DragDropOption actualAction = DragDropOption.None; if (allowedActions != DragDropOption.None) { DataObject data = new DataObject(); data.SetData(draggedItems); // for GalleryComponent consumers, provide a list of the items that were dragged data.SetData(objectList.ToArray()); // for foreign consumers, provide an array of the objects wrapped by the dragged/selected items data.SetData(specificDraggedItem); // for foreign consumers, provide the actual item that was dragged, not the selected ones DragDropEffects allowedEffects = ConvertEnum.GetDragDropEffects(allowedActions); DragDropEffects actualEffect = _listView.DoDragDrop(data, allowedEffects); actualAction = ConvertEnum.GetDragDropAction(actualEffect); } _component.EndDrag(draggedItems, actualAction); // restore selection and focus _listView.SelectedIndices.Clear(); for (int n = 0; n < _listView.Items.Count; n++) { ListViewItem lvi = _listView.Items[n]; if (savedSelection.Contains(lvi.Tag)) { _listView.SelectedIndices.Add(n); savedSelection.Remove(lvi.Tag); } if (lvi.Tag == savedFocus) { lvi.Focused = true; } } _selectionEventsEnabled = true; // if any previously-selected items are left in the list, then the selection has changed overall and we need to update the component selection if (savedSelection.Count > 0) { OnSelectionChanged(null, null); } }
/// <summary> /// Checks for allowed drag & drop actions involving the specified foreign data and the given target on this component. /// </summary> /// <param name="droppingData">The <see cref="IDragDropObject"/> object that encapsulates all forms of the foreign data.</param> /// <param name="targetItem">The target item that the user is trying to drop on to.</param> /// <param name="actions"></param> /// <param name="modifiers">The modifier keys that are being held by the user.</param> /// <returns>The allowed <see cref="DragDropKind"/> action for this attempted drag & drop operation.</returns> public override sealed DragDropOption CheckDrop(IDragDropObject droppingData, IGalleryItem targetItem, DragDropOption actions, ModifierFlags modifiers) { DragDropOption allowedActions; IList<IGalleryItem> droppingItems = ExtractGalleryItemList(droppingData); if (droppingItems != null) { if (_draggedItems == droppingItems) { allowedActions = CheckDropLocalItems(droppingItems, targetItem, actions, modifiers); } else { allowedActions = CheckDropForeignItems(droppingItems, targetItem, actions, modifiers); } } else { allowedActions = CheckDropForeignObject(droppingData, targetItem, actions, modifiers); } return actions & allowedActions; }
protected override DragDropOption CheckDropForeignItems(IList <IGalleryItem> droppingItems, IGalleryItem targetItem, DragDropOption actions, ModifierFlags modifiers) { SeriesItem series = (SeriesItem)targetItem; bool allowed = true; foreach (IGalleryItem droppingItem in droppingItems) { if (droppingItem is ImageItem) { ImageItem image = (ImageItem)droppingItem; if (modifiers == ModifierFlags.None) { allowed &= !(series.Images.Contains(image)); // disallow moves where the item is already in the target tree } else if (modifiers == ModifierFlags.Shift) { allowed &= true; } } else { allowed &= false; } } if (allowed) { if (modifiers == ModifierFlags.None) { return(DragDropOption.Move); } else if (modifiers == ModifierFlags.Shift) { return(DragDropOption.Copy); } } return(DragDropOption.None); }
/// <summary> /// Performs a drag-drop of a non-<see cref="IGalleryItem"/> object from outside this gallery on top of the specified item. /// </summary> /// <param name="droppedData">The data object to drop.</param> /// <param name="targetItem">The target <see cref="IGalleryItem"/> at which the <paramref name="droppedData"/> is being dropped.</param> /// <param name="actions">The interaction to take.</param> /// <param name="modifiers">The modifier keys that were pressed at the time of the drop.</param> /// <returns>The actual interaction on the <paramref name="droppedData"/> that was taken.</returns> protected virtual DragDropOption PerformDropForeignObject(IDragDropObject droppedData, IGalleryItem targetItem, DragDropOption actions, ModifierFlags modifiers) { return(DragDropOption.None); }
/// <summary> /// Signals the component that a drag & drop operation involving the specified /// <see cref="IGalleryItem"/>s has ended with the given action being taken on the items by the drop target. /// </summary> /// <param name="draggedItems">The <see cref="IGalleryItem"/>s that were dragged.</param> /// <param name="action">The <see cref="DragDropOption"/> action that was taken on the items by the drop target.</param> public override sealed void EndDrag(IList<IGalleryItem> draggedItems, DragDropOption action) { if (_draggedItems != null && draggedItems == _draggedItems) { if ((action & DragDropOption.Move) == DragDropOption.Move) { foreach (IGalleryItem draggedItem in draggedItems) { base.DataSource.Remove(draggedItem); } } _draggedItems = null; } }
/// <summary> /// Signals the component that a drag & drop operation involving the specified /// <see cref="IGalleryItem"/>s has ended with the given action being taken on the items by the drop target. /// </summary> /// <param name="draggedItems">The <see cref="IGalleryItem"/>s that were dragged.</param> /// <param name="action">The <see cref="DragDropOption"/> action that was taken on the items by the drop target.</param> public virtual void EndDrag(IList <IGalleryItem> draggedItems, DragDropOption action) { }
/// <summary> /// Checks for allowed drag & drop actions involving the specified foreign data and the given target on this component. /// </summary> /// <param name="droppingData">The <see cref="IDragDropObject"/> object that encapsulates all forms of the foreign data.</param> /// <param name="targetItem">The target item that the user is trying to drop on to.</param> /// <param name="actions"></param> /// <param name="modifiers">The modifier keys that are being held by the user.</param> /// <returns>The allowed <see cref="DragDropKind"/> action for this attempted drag & drop operation.</returns> public override sealed DragDropOption CheckDrop(IDragDropObject droppingData, IGalleryItem targetItem, DragDropOption actions, ModifierFlags modifiers) { DragDropOption allowedActions; IList <IGalleryItem> droppingItems = ExtractGalleryItemList(droppingData); if (droppingItems != null) { if (_draggedItems == droppingItems) { allowedActions = CheckDropLocalItems(droppingItems, targetItem, actions, modifiers); } else { allowedActions = CheckDropForeignItems(droppingItems, targetItem, actions, modifiers); } } else { allowedActions = CheckDropForeignObject(droppingData, targetItem, actions, modifiers); } return(actions & allowedActions); }
/// <summary> /// Checks for allowed drag & drop actions involving the specified foreign data and the given target on this component. /// </summary> /// <param name="droppingData">The <see cref="IDragDropObject"/> object that encapsulates all forms of the foreign data.</param> /// <param name="targetItem">The target item that the user is trying to drop on to.</param> /// <param name="actions"></param> /// <param name="modifiers">The modifier keys that are being held by the user.</param> /// <returns>The allowed <see cref="DragDropKind"/> action for this attempted drag & drop operation.</returns> public virtual DragDropOption CheckDrop(IDragDropObject droppingData, IGalleryItem targetItem, DragDropOption actions, ModifierFlags modifiers) { return(DragDropOption.None); }
/// <summary> /// /// </summary> /// <param name="droppedData"></param> /// <param name="targetItem"></param> /// <param name="action"></param> /// <param name="modifiers"></param> /// <returns></returns> public override sealed DragDropOption PerformDrop(IDragDropObject droppedData, IGalleryItem targetItem, DragDropOption action, ModifierFlags modifiers) { DragDropOption performedAction; IList <IGalleryItem> droppedItems = ExtractGalleryItemList(droppedData); if (droppedItems != null) { if (_draggedItems == droppedItems) { performedAction = PerformDropLocalItems(droppedItems, targetItem, action, modifiers); } else { performedAction = PerformDropForeignItems(droppedItems, targetItem, action, modifiers); } } else { performedAction = PerformDropForeignObject(droppedData, targetItem, action, modifiers); } return(performedAction); }
/// <summary> /// /// </summary> /// <param name="droppedData"></param> /// <param name="targetItem"></param> /// <param name="action"></param> /// <param name="modifiers"></param> /// <returns></returns> public virtual DragDropOption PerformDrop(IDragDropObject droppedData, IGalleryItem targetItem, DragDropOption action, ModifierFlags modifiers) { return(DragDropOption.None); }
/// <summary> /// Checks if drag-dropping <see cref="IGalleryItem"/>s from outside this gallery to the specified target index is allowed. /// </summary> /// <param name="droppingItems">The list of <see cref="IGalleryItem"/>s to drop.</param> /// <param name="targetIndex">The target index at which the <paramref name="droppingItems"/> are being dropped.</param> /// <param name="actions">The interactions that are being allowed by the data source.</param> /// <param name="modifiers">The modifier keys that currently being pressed.</param> /// <returns>The allowed interactions for dropping the <paramref name="droppingItems"/> here.</returns> protected virtual DragDropOption CheckDropForeignItems(IList<IGalleryItem> droppingItems, int targetIndex, DragDropOption actions, ModifierFlags modifiers) { return DragDropOption.None; }