/// <summary> /// Initializes a new instance of the TreeDragFeedbackEventArgs class. /// </summary> /// <param name="parentNode"></param> /// <param name="insertPosition"></param> public TreeDragFeedbackEventArgs(Node parentNode, int insertPosition, Node dragNode, DragDropEffects effect) { ParentNode = parentNode; InsertPosition = insertPosition; _DragNode = dragNode; _Effect = effect; }
public override void FinishDrag(UIElement draggedElt, DragDropEffects finalEffects) { if ((finalEffects & DragDropEffects.Move) == DragDropEffects.Move) { (SourceUI as Canvas).Children.Remove(draggedElt); } }
public void Dropped(IDropInfo dropInfo, DragDropEffects effects) { bool isCopy, isMove; GuiHelper.ConvertDragDropEffectToCopyMove(effects, out isCopy, out isMove); _projectBrowseControl._controller.FolderTree_DragEnded(isCopy, isMove); }
/// <summary> /// This method is called when the drag and drop operation is completed and /// the item being dragged was dropped on the Rhino layer list control. /// </summary> public override bool OnDropOnLayerListCtrl(IWin32Window layerListCtrl, int layerIndex, DataObject data, DragDropEffects dropEffect, Point point) { SampleCsDragData dragData = GetSampleCsDragData(data); if (null == dragData) return false; if (layerIndex < 0) { MessageBox.Show( RhUtil.RhinoApp().MainWnd(), "String \"" + dragData.DragString + "\" Dropped on layer list control, not on a layer", "SampleCsDragDrop", MessageBoxButtons.OK, MessageBoxIcon.Information ); } else { MRhinoDoc doc = RhUtil.RhinoApp().ActiveDoc(); if (null != doc && layerIndex < doc.m_layer_table.LayerCount()) { MessageBox.Show( RhUtil.RhinoApp().MainWnd(), "String \"" + dragData.DragString + "\" Dropped on layer \"" + doc.m_layer_table[layerIndex].m_name + "\"", "SampleCsDragDrop", MessageBoxButtons.OK, MessageBoxIcon.Information ); } } return true; }
/// <summary> /// Constructeur du descripteur d'événement /// </summary> /// <param name="allowedEffects">valeur initiale des effets possibles</param> /// <param name="data">objet transitionnel de suivi de l'opération de glissement</param> /// <param name="button">bouton lié au démarrage de l'opération de glissement</param> /// <param name="location">coordonnées client de l'impact initial du bouton enfoncé</param> /// <param name="cancel">valeur initiale de la propriété <see cref="Cancel"/></param> public DragStartEventArgs( DragDropEffects allowedEffects, IDataObject data, MouseButtons button, Point location, bool cancel ) { AllowedEffects = allowedEffects; Data = data; Button = button; Location = location; Cancel = cancel; }
public DropNodeValidatingEventArgs(IDataObject data, int keyState, int x, int y, DragDropEffects allowedEffects, DragDropEffects effect, TreeNode sourceNode, TreeNode targetNode, NodePosition position) :base (data, keyState, x, y, allowedEffects, effect) { SourceNode = sourceNode; TargetNode = targetNode; Position = position; }
/// <summary> /// Initializes a new instance of the <see cref="DragLeaveArgs" /> class. /// </summary> /// <param name="data">The data.</param> /// <param name="keyStates">The key states.</param> /// <param name="dropTarget">The drop target.</param> /// <param name="allowedEffects">The allowed effects.</param> public DragLeaveArgs( IDataObject data, DragDropKeyStates keyStates, Object dropTarget, DragDropEffects allowedEffects ) : base( data, keyStates, dropTarget ) { Ensure.That( allowedEffects ).Named( "allowedEffects" ).IsTrue( v => v.IsDefined() ); this.AllowedEffects = allowedEffects; }
internal DropSourceBehavior(ICollection dragComponents, Control source, Point initialMouseLocation) { this.serviceProviderSource = source.Site; if (this.serviceProviderSource != null) { this.behaviorServiceSource = (BehaviorService) this.serviceProviderSource.GetService(typeof(BehaviorService)); if ((this.behaviorServiceSource != null) && ((dragComponents != null) && (dragComponents.Count > 0))) { this.srcHost = (IDesignerHost) this.serviceProviderSource.GetService(typeof(IDesignerHost)); if (this.srcHost != null) { this.data = new BehaviorDataObject(dragComponents, source, this); this.allowedEffects = DragDropEffects.Move | DragDropEffects.Copy; this.dragComponents = new DragComponent[dragComponents.Count]; this.parentGridSize = Size.Empty; this.lastEffect = DragDropEffects.None; this.lastFeedbackLocation = new Point(-1, -1); this.lastSnapOffset = Point.Empty; this.dragImageRect = Rectangle.Empty; this.clearDragImageRect = Rectangle.Empty; this.InitiateDrag(initialMouseLocation, dragComponents); } } } }
public DragEventArgs(IDataObject data, int keyState, int x, int y, DragDropEffects allowedEffect, DragDropEffects effect) { this.x=x; this.y=y; this.keystate=keyState; this.allowed_effect=allowedEffect; this.current_effect=effect; this.data_object=data; }
public void FinishDrag(UIElement draggedElement, Point location, DragDropEffects finalEffects) { ToolboxItem item = GetToolboxItem(draggedElement); if (item != null) { item.IsBeingDragged = false; } }
/// <summary> /// Notifies the DragDropHelper that the specified Window received /// a DragEnter event. /// </summary> /// <param name="dropHelper">The DragDropHelper instance to notify.</param> /// <param name="window">The Window the received the DragEnter event.</param> /// <param name="data">The DataObject containing a drag image.</param> /// <param name="cursorOffset">The current cursor's offset relative to the window.</param> /// <param name="effect">The accepted drag drop effect.</param> public static void DragEnter(this IDropTargetHelper dropHelper, Window window, IDataObject data, Point cursorOffset, DragDropEffects effect) { IntPtr windowHandle = IntPtr.Zero; if (window != null) windowHandle = (new WindowInteropHelper(window)).Handle; Win32Point pt = WpfDragDropLibExtensions.ToWin32Point(cursorOffset); dropHelper.DragEnter(windowHandle, (ComIDataObject)data, ref pt, (int)effect); }
/// <summary> /// Initializes a new instance of the <see cref="DragOverArgs" /> class. /// </summary> /// <param name="data">The data.</param> /// <param name="keyStates">The key states.</param> /// <param name="dropTarget">The drop target.</param> /// <param name="allowedEffects">The allowed effects.</param> /// <param name="position">The position.</param> public DragOverArgs( IDataObject data, DragDropKeyStates keyStates, Object dropTarget, DragDropEffects allowedEffects, Point position ) : base( data, keyStates, dropTarget ) { Ensure.That( allowedEffects ).Named( "allowedEffects" ).IsTrue( v => v.IsDefined() ); this.AllowedEffects = allowedEffects; this.Position = position; }
public DragHelper(UIElement dragSource, IDataDropObjectProvider callback, UIElement dragScope) { this.allowedEffects = DragDropEffects.Copy | DragDropEffects.Move; this.opacity = 0.7; this.DragSource = dragSource; this.Callback = callback; this.DragScope = dragScope; }
public void FinishDrag(UIElement draggedElt, DragDropEffects finalEffects) { //if ((finalEffects & DragDropEffects.Move) == DragDropEffects.Move) //{ //TODO: should I have something here???? //} }
/// <summary> /// Support only copy /// </summary> /// <param name="supportedEffects">Effects supported by the drag source</param> /// <returns>Effets allowed by the drop target</returns> protected DragDropEffects ProvideCopy(int keyState, DragDropEffects supportedEffects) { // allow only copy if ((supportedEffects & DragDropEffects.Copy) > 0) return DragDropEffects.Copy; else return DragDropEffects.None; }
/// <summary> /// Constructor with parameters</summary> /// <param name="data">System.Windows.Forms.IDataObject that contains the data associated with this event</param> /// <param name="keyState">Current state of the Shift, Ctrl, and Alt keys</param> /// <param name="x">X-coordinate of mouse pointer</param> /// <param name="y">Y-coordinate of mouse pointer</param> /// <param name="allowedEffect">>Drag and drop operations allowed by the originator (or source) of the drag and drop event</param> /// <param name="effect">Drag and drop operations allowed by the target of the drag and drop event</param> public DragEventArgs(object data, int keyState, int x, int y, DragDropEffects allowedEffect, DragDropEffects effect) { this.data = data; this.keyState = keyState; this.x = x; this.y = y; this.allowedEffect = allowedEffect; this.effect = effect; }
/// <summary> /// Notifies the DragDropHelper that the specified Control received /// a DragEnter event. /// </summary> /// <param name="dropHelper">The DragDropHelper instance to notify.</param> /// <param name="control">The Control the received the DragEnter event.</param> /// <param name="data">The DataObject containing a drag image.</param> /// <param name="cursorOffset">The current cursor's offset relative to the window.</param> /// <param name="effect">The accepted drag drop effect.</param> public static void DragEnter(this IDropTargetHelper dropHelper, Control control, System.Windows.Forms.IDataObject data, Point cursorOffset, DragDropEffects effect) { IntPtr controlHandle = IntPtr.Zero; if (control != null) controlHandle = control.Handle; Win32Point pt = cursorOffset.ToWin32Point(); dropHelper.DragEnter(controlHandle, (ComIDataObject) data, ref pt, (int) effect); }
public DragEventArgs(IDataObject data, int keyState, int x, int y, DragDropEffects allowedEffect, DragDropEffects effect) { _data = data; _keyState = keyState; _x = x; _y = y; _allowedEffect = allowedEffect; _effect = effect; }
public void DoDragDropSelectedNodes(DragDropEffects allowedEffects) { if (SelectedNodes.Count > 0) { TreeNodeAdv[] nodes = new TreeNodeAdv[SelectedNodes.Count]; SelectedNodes.CopyTo(nodes, 0); DoDragDrop(nodes, allowedEffects); } }
public DragAdorner(UIElement adornedElement, UIElement adornment, DragDropEffects effects = DragDropEffects.None) : base(adornedElement) { this.m_AdornerLayer = AdornerLayer.GetAdornerLayer(adornedElement); this.m_AdornerLayer.Add(this); this.m_Adornment = adornment; this.IsHitTestVisible = false; this.Effects = 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; }
//------------------------------------------------------ // // Constructors // //------------------------------------------------------ #region Constructors /// <summary> /// Initializes a new instance of the GiveFeedbackEventArgs class. /// </summary> /// <param name="effects"> /// The effect of the drag operation. /// </param> /// <param name="useDefaultCursors"> /// Use the default cursors. /// </param> internal GiveFeedbackEventArgs(DragDropEffects effects, bool useDefaultCursors) { if (!DragDrop.IsValidDragDropEffects(effects)) { Debug.Assert(false, "Invalid effects"); } this._effects = effects; this._useDefaultCursors = useDefaultCursors; }
public void setFeedback(int feedbackCode) { dragFeedback = feedbackCode == 1 ? DragDropEffects.Copy : feedbackCode == 2 ? DragDropEffects.Move : feedbackCode == 4 ? DragDropEffects.Link : feedbackCode == 8 ? DragDropEffects.Scroll : feedbackCode == 11 ? DragDropEffects.All : DragDropEffects.None; }
public void FinishDrag(UIElement draggedElt, DragDropEffects finalEffects) { if ((finalEffects & DragDropEffects.Copy) == DragDropEffects.Copy) { XmlReader reader = XmlReader.Create(new StringReader(_serializedElt)); UIElement elt = XamlReader.Load(reader) as UIElement; (_sourceAndTargetElt as Canvas).Children.Add(elt); } }
/// <summary> /// Sets the drop description of the IDataObject and then notifies the /// DragDropHelper that the specified Control received a DragEnter event. /// </summary> /// <param name="control">The Control the received the DragEnter event.</param> /// <param name="data">The DataObject containing a drag image.</param> /// <param name="cursorOffset">The current cursor's offset relative to the window.</param> /// <param name="effect">The accepted drag drop effect.</param> /// <param name="descriptionMessage">The drop description message.</param> /// <param name="descriptionInsert">The drop description insert.</param> /// <remarks> /// Because the DragLeave event in SWF does not provide the IDataObject in the /// event args, this DragEnter override of the DropTargetHelper will cache a /// copy of the IDataObject based on the provided Control so that it may be /// cleared using the DragLeave override that takes a Control parameter. Note that /// if you use this override of DragEnter, you must call the DragLeave override /// that takes a Control parameter to avoid a possible memory leak. However, calling /// this method multiple times with the same Control parameter while not calling the /// DragLeave method will not leak memory. /// </remarks> public static void DragEnter(Control control, IDataObject data, Point cursorOffset, DragDropEffects effect, string descriptionMessage, string descriptionInsert) { data.SetDropDescription((DropImageType) effect, descriptionMessage, descriptionInsert); DragEnter(control, data, cursorOffset, effect); if (!s_dataContext.ContainsKey(control)) s_dataContext.Add(control, data); else s_dataContext[control] = data; }
internal static DragDropEffects DragActionsToEffects (UInt32 actions) { DragDropEffects effects = DragDropEffects.None; if ((actions & 1) != 0) effects |= DragDropEffects.Copy; if ((actions & (1 << 4)) != 0) effects |= DragDropEffects.Move; if ((actions & 0xFFFFFFFF) != 0) effects |= DragDropEffects.All; return effects; }
public override void FinishDrag(UIElement draggedElt, DragDropEffects finalEffects) { if ((finalEffects & DragDropEffects.Move) == DragDropEffects.Move) { Panel panel = SourceUI as Panel; if (panel != null) { panel.Children.Remove(draggedElt); } } }
public ExtendedDragEventHandlerArgs( IDataObject data, int keyState, int x, int y, DragDropEffects allowedEffect, DragDropEffects effect, HtmlDocumentHandle document = default (HtmlDocumentHandle)) : base(data, keyState, x, y, allowedEffect, effect) { Document = document; }
int UnsafeNativeMethods.IOleDropTarget.OleDragOver(int grfKeyState, long pt, ref int pdwEffect) { NativeMethods.POINTL pointl = new NativeMethods.POINTL { x = this.GetX(pt), y = this.GetY(pt) }; DragEventArgs e = this.CreateDragEventArgs(null, grfKeyState, pointl, pdwEffect); this.owner.OnDragOver(e); pdwEffect = (int) e.Effect; this.lastEffect = e.Effect; return 0; }
protected override void OnDragEnter(DragEventArgs drgevent) { if (!_inside) { _inside = true; base.OnDragEnter(drgevent); _lastEffect = drgevent.Effect; } else { drgevent.Effect = _lastEffect; } }
public RawDragEvent(IDragDropDevice inputDevice, RawDragEventType type, IInputElement inputRoot, Point location, IDataObject data, DragDropEffects effects, InputModifiers modifiers) : base(inputDevice, 0) { Type = type; InputRoot = inputRoot; Location = location; Data = data; Effects = effects; Modifiers = modifiers; }
internal override DragDropEffects StartDrag(IntPtr handle, object data, DragDropEffects allowed_effects) { return(display.StartDrag(handle, data, allowed_effects)); }
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); } }
public static DragDropEffects CanDropClipboard(ShellItem item) { IntPtr dataObject; ShellAPI.OleGetClipboard(out dataObject); IntPtr targetPtr; ShellDll.IDropTarget target; DragDropEffects retVal = DragDropEffects.None; if (GetIDropTarget(item, out targetPtr, out target)) { #region Check Copy DragDropEffects effects = DragDropEffects.Copy; if (target.DragEnter( dataObject, ShellAPI.MK.CONTROL, new ShellAPI.POINT(0, 0), ref effects) == ShellAPI.S_OK) { if (effects == DragDropEffects.Copy) { retVal |= DragDropEffects.Copy; } target.DragLeave(); } #endregion #region Check Move effects = DragDropEffects.Move; if (target.DragEnter( dataObject, ShellAPI.MK.SHIFT, new ShellAPI.POINT(0, 0), ref effects) == ShellAPI.S_OK) { if (effects == DragDropEffects.Move) { retVal |= DragDropEffects.Move; } target.DragLeave(); } #endregion #region Check Lick effects = DragDropEffects.Link; if (target.DragEnter( dataObject, ShellAPI.MK.ALT, new ShellAPI.POINT(0, 0), ref effects) == ShellAPI.S_OK) { if (effects == DragDropEffects.Link) { retVal |= DragDropEffects.Link; } target.DragLeave(); } #endregion Marshal.ReleaseComObject(target); Marshal.Release(targetPtr); } return(retVal); }
public void Drop(IResource targetResource, IDataObject data, DragDropEffects allowedEffect, int keyState) { // Nothing to do, it's just reordering }
/// <summary> /// Occurs when an object is dragged over the control's bounds. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DragOverHandler(object sender, DragEventArgs e) { var targetNode = GetDragDropTargetNode(e); var keyState = (KeyStates)e.KeyState; if ((keyState & KeyStates.Control) == KeyStates.Control) { e.Effect = DragDropEffects.Copy; } else if ((keyState & KeyStates.Shift) == KeyStates.Shift) { e.Effect = DragDropEffects.Move; } else { e.Effect = DragDropEffects.Copy; } if (targetNode == null) { if (e.Effect != DragDropEffects.None) { lastValidDragDropEffect = e.Effect; e.Effect = DragDropEffects.None; } if (lastDragDropTarget != null) { lastDragDropTarget.BackColor = lastDragDropBackColor; } lastDragDropTarget = null; return; } if (targetNode == lastDragDropTarget) { if (DateTime.Now - lastDragDropDateTime >= new TimeSpan(5000000)) { targetNode.Expand(); } return; } var sourceNode = GetDragDropSourceNode(e); if (IsDragDropValid(sourceNode, targetNode)) { if (e.Effect == DragDropEffects.None) { e.Effect = lastValidDragDropEffect; } lastDragDropBackColor = targetNode.BackColor; targetNode.BackColor = Color.BlueViolet; } else { if (e.Effect != DragDropEffects.None) { lastValidDragDropEffect = e.Effect; e.Effect = DragDropEffects.None; } } if (lastDragDropTarget != null) { lastDragDropTarget.BackColor = lastDragDropBackColor; } lastDragDropTarget = targetNode; lastDragDropDateTime = DateTime.Now; }
public void DragEnded(DragDropEffects effects, FrameworkElement dragSource) { ; }
internal static void DoDragDrop(object data, DragDropEffects effect, DragDropRenderHandler render = null) { DraggingData = data; dragControlEffects = effect; dragRender = render; }
/// <summary> /// Start a drag&drop operation for the items currently selected in the results list /// </summary> private void StartDragSelectedResults() { // Make sure there actually is a selection if (resultsListView.SelectedIndices.Count < 1) { // No item selecte, don't drag return; } IEnumerable <SearchResultListItem> selectedItems = GetSelectedItems(); AresTargetDirectoryProvider targetDirectoryProvider = new AresTargetDirectoryProvider(m_selectedAudioSource, String.Empty); TargetDirectoryProvider.Current = targetDirectoryProvider; AudioSearchResultType overallItemAudioType = FindAndVerifySelectedAudioType(selectedItems); // Decide depending on the overall AudioType of the selected items DragDropEffects dragDropResult = DragDropEffects.None; List <string> stubFiles = null; switch (overallItemAudioType) { // If the dragged items are Music or Sound files case AudioSearchResultType.MusicFile: case AudioSearchResultType.SoundFile: IEnumerable <IFileSearchResult> selectedFileResults = selectedItems // Extract the IFileSearchResult from the SearchResultListItem .Select(item => item.SearchResult as IFileSearchResult) // Filter out null/incompatible search results .Where(result => result != null); BeforeStartDrag(selectedFileResults, targetDirectoryProvider, out stubFiles); dragDropResult = StartDragFileSearchResults(selectedFileResults, overallItemAudioType, targetDirectoryProvider); if (dragDropResult == DragDropEffects.Copy) { AfterCompleteDrag(selectedFileResults, targetDirectoryProvider); } else { AfterCancelDrag(selectedFileResults, targetDirectoryProvider, stubFiles); } TargetDirectoryProvider.Current = null; return; // If the dragged items are ModeElements case AudioSearchResultType.ModeElement: IEnumerable <IModeElementSearchResult> selectedModeElementResults = selectedItems // Extract the IModeElementSearchResult from the SearchResultListItem .Select(item => item.SearchResult as IModeElementSearchResult) // Filter out null/incompatible search results .Where(result => result != null); BeforeStartDrag(selectedModeElementResults, targetDirectoryProvider, out stubFiles); dragDropResult = StartDragModeElementSearchResults(selectedModeElementResults, targetDirectoryProvider); if (dragDropResult == DragDropEffects.Move) { AfterCompleteDrag(selectedModeElementResults, targetDirectoryProvider); } else { AfterCancelDrag(selectedModeElementResults, targetDirectoryProvider, stubFiles); } TargetDirectoryProvider.Current = null; return; } }
private void ListDragSource_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { if ((e.Button & MouseButtons.Left) == MouseButtons.Left) { if (!ListDragTarget.Lock) { bool draggable = true; if (sender == ListDragTarget) { draggable = ListDragTarget.RemovableForTaskFlow(IndexOfItemUnderMouseToDrag); } if (!draggable) { Cursor.Current = Cursors.No; } // If the mouse moves outside the rectangle, start the drag. if (draggable && dragBoxFromMouseDown != Rectangle.Empty && !dragBoxFromMouseDown.Contains(e.X, e.Y)) { // Create custom cursors for the drag-and-drop operation. try { TaskListBox ctrl = (TaskListBox)sender; MyNormalCursor = ctrl.CreateCursor(IndexOfItemUnderMouseToDrag, true); MyNodropCursor = ctrl.CreateCursor(IndexOfItemUnderMouseToDrag, false); } catch { } finally { // The screenOffset is used to account for any desktop bands // that may be at the top or left side of the screen when // determining when to cancel the drag drop operation. screenOffset = SystemInformation.WorkingArea.Location; object data = ((TaskListBox)sender).GetDragData(IndexOfItemUnderMouseToDrag); if (sender == ListDragTarget) { ((TaskListBox)sender).RemoveAt(IndexOfItemUnderMouseToDrag); AlignHelpMessage(); } // Proceed with the drag-and-drop, passing in the list item. DragDropEffects dropEffect = ((TaskListBox)sender).DoDragDrop(data, DragDropEffects.All | DragDropEffects.Copy); // Dispose of the cursors since they are no longer needed. if (MyNormalCursor != null) { MyNormalCursor.Dispose(); } if (MyNodropCursor != null) { MyNodropCursor.Dispose(); } } } } } else { if (sender is TaskListBox) { TaskListBox listbox = (TaskListBox)sender; int newHoveredIndex = listbox.IndexFromPoint(e.Location); if (newHoveredIndex == -1) { this.ToolTip.ShowAlways = false; } if (hoveredIndex != newHoveredIndex) { hoveredIndex = newHoveredIndex; if (hoveredIndex > -1) { AbstractProcessingTask task = listbox.Get(hoveredIndex); if (task != null) { this.ToolTip.Active = false; this.ToolTip.SetToolTip(listbox, task.ToolTip); this.ToolTip.Active = true; this.ToolTip.ShowAlways = true; } } } } } }
/// <inheritdoc /> public virtual void DragDropOperationFinished(DragDropEffects operationResult, IDragInfo dragInfo) { // nothing here }
public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects) { }
void btn_MouseDown(object sender, MouseEventArgs e) { Button button = (Button)sender; //set property grid ElementGrid.PropertyValueChanged -= Grid_PropertyValueChanged; ReportElement element = null; if (button.Tag != null) { element = button.Tag as ReportElement; } if (element != null) { element.InitEditor(); bool collapseCategories = (ElementGrid.SelectedObject == null); ElementGrid.SelectedObject = button.Tag; //Collapse Advanced categories if (collapseCategories && !collapseElementCategoriesDone) { CollapseCategories(ElementGrid); collapseElementCategoriesDone = true; } } ElementGrid.PropertyValueChanged += Grid_PropertyValueChanged; if (e != null) { DragDropEffects dde1 = DoDragDrop(sender, DragDropEffects.Move); } if (button.Parent != null) { SelectedButton = button; redrawButtons(); } //select meta element in TreeView if (element != null) { SetMetaColumn(elementTreeView.Nodes, element); } if (e != null && e.Button == MouseButtons.Right) { ContextMenuStrip menu = new ContextMenuStrip(); ToolStripMenuItem item = new ToolStripMenuItem("Remove"); item.Click += new EventHandler(delegate(object sender2, EventArgs e2) { removeElementFromPanel(button, false); }); if (!Model.IsSubModel) { menu.Items.Add(item); } item = new ToolStripMenuItem("Copy"); item.Click += new EventHandler(delegate(object sender2, EventArgs e2) { copyElementFromPanel(button); }); if (!Model.IsSubModel) { menu.Items.Add(item); } item = new ToolStripMenuItem("Prompt at run-time"); item.Click += new EventHandler(delegate(object sender2, EventArgs e2) { if (element.MetaColumn.IsAggregate == true) { aggregateRestrictionsPanel.AddRestriction(element.MetaColumn, true); } else { restrictionsPanel.AddRestriction(element.MetaColumn, true); } }); menu.Items.Add(item); if (!Model.IsSubModel) { menu.Items.Add(new ToolStripSeparator()); item = new ToolStripMenuItem("Remove all elements"); item.Click += new EventHandler(delegate(object sender2, EventArgs e2) { removeElementFromPanel(button, true); }); menu.Items.Add(item); item = new ToolStripMenuItem("Clear all Sort Orders"); item.Click += new EventHandler(delegate(object sender2, EventArgs e2) { ElementPanel panel = (ElementPanel)button.Parent; foreach (var control in panel.Controls) { ReportElement el = ((Button)control).Tag as ReportElement; if (el != null) { el.SortOrder = ReportElement.kNoSortKeyword; } } btn_MouseDown(button, null); MainForm.IsModified = true; }); menu.Items.Add(item); menu.Items.Add(new ToolStripSeparator()); item = new ToolStripMenuItem("Smart copy..."); item.Click += new EventHandler(delegate(object sender2, EventArgs e2) { SmartCopyForm form = new SmartCopyForm("Smart copy of " + element.DisplayNameEl, element, Model.Report); form.ShowDialog(); if (form.IsReportModified) { MainForm.IsModified = true; MainForm.CannotRenderAnymore(); ElementsToPanels(); } }); menu.Items.Add(item); } //Display context menu menu.Show(button, e.Location); } }
/// <summary> /// Constructor with parameters</summary> /// <param name="data">System.Windows.Forms.IDataObject that contains the data associated with this event</param> /// <param name="keyState">Current state of the Shift, Ctrl, and Alt keys</param> /// <param name="x">X-coordinate of mouse pointer</param> /// <param name="y">Y-coordinate of mouse pointer</param> /// <param name="allowedEffect">>Drag and drop operations allowed by the originator (or source) of the drag and drop event</param> /// <param name="effect">Drag and drop operations allowed by the target of the drag and drop event</param> public DragEventArgs(object data, int keyState, int x, int y, DragDropEffects allowedEffect, DragDropEffects effect) { this.data = data; this.keyState = keyState; this.x = x; this.y = y; this.allowedEffect = allowedEffect; this.effect = effect; }
/// <summary> /// See IDragSource documentation /// </summary> /// <param name="dragObject"></param> /// <param name="effect"></param> public virtual void EndDrag(Object dragObject, DragDropEffects effect) { }
private static DataPackageOperation ToDataPackageOperation(DragDropEffects wpfOp) => (DataPackageOperation)((int)wpfOp) & (DataPackageOperation.Copy | DataPackageOperation.Move | DataPackageOperation.Link);
private void SetDragCursor(DragDropEffects e) { Cursor = Cursors.Hand; }
public override void DoDragDrop(IDataObject dataObject, DragDropEffects effect) { ((ExtTreeNode)Parent).DoDragDrop(dataObject, effect); }
public async Task <DragDropEffects> DoDragDrop(PointerEventArgs triggerEvent, IDataObject data, DragDropEffects allowedEffects) { Dispatcher.UIThread.VerifyAccess(); triggerEvent.Pointer.Capture(null); if (_draggedData == null) { _draggedData = data; _lastRoot = null; _lastPosition = default(Point); _allowedEffects = allowedEffects; using (_inputManager.PreProcess.OfType <RawPointerEventArgs>().Subscribe(ProcessMouseEvents)) { using (_inputManager.PreProcess.OfType <RawKeyEventArgs>().Subscribe(ProcessKeyEvents)) { var effect = await _result.FirstAsync(); return(effect); } } } return(DragDropEffects.None); }
/// <summary> /// Initializes a new instance of the <see cref='GiveFeedbackEventArgs'/> class. /// </summary> public GiveFeedbackEventArgs(DragDropEffects effect, bool useDefaultCursors) { Effect = effect; UseDefaultCursors = useDefaultCursors; }
private static void OnMouseMove(object sender, MouseEventArgs e) { //The dragging element (should be T) FrameworkElement sourceElement = e.OriginalSource as FrameworkElement; //Debug.Assert(sourceElement.DataContext is ISupportDrag<T>); //The control, like treeview or listview FrameworkElement control = sender as FrameworkElement; if ((e.LeftButton == MouseButtonState.Pressed || e.RightButton == MouseButtonState.Pressed) && !GetIsDragging(control)) { Point position = e.GetPosition(null); if (!e.MouseDevice.DirectlyOver.Focusable) { if (isDragEnabled(control)) { _dragSource = control.DataContext as ISupportDrag <T>; if (_dragSource != null) { if ((_dragSource.SupportedDragDropEffects & DragDropEffects.Copy) != 0 || (_dragSource.SupportedDragDropEffects & DragDropEffects.Link) != 0) { if (!_startPoint.Equals(_invalidPoint)) //Bug#65 { if (Math.Abs(position.X - _startPoint.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(position.Y - _startPoint.Y) > SystemParameters.MinimumVerticalDragDistance) { try { _dataObj = new VirtualDataObject <T>(_dragSource); if (_dragSource.BeforeDrag(_dataObj.DropInfo)) { SetIsDragging(control, true); var draggingItems = from si in _dataObj.DropInfo.SelectedItems select si.EmbeddedItem; SetDraggingItems(control, draggingItems.ToArray()); ShowAdorner(control); if (_dataObj.PrepareDataObject()) { //control.QueryContinueDrag += new QueryContinueDragEventHandler(OnQueryContinueDrag); System.Windows.DragDrop.AddQueryContinueDragHandler(control, new QueryContinueDragEventHandler(OnQueryContinueDrag)); DragDropEffects de = System.Windows.DragDrop.DoDragDrop(control, _dataObj, _dataObj.DropInfo.SupportedEffects); e.Handled = true; System.Windows.DragDrop.RemoveQueryContinueDragHandler(control, new QueryContinueDragEventHandler(OnQueryContinueDrag)); } } } catch (Exception ex) { Trace.WriteLine("FileDragDropHelper.OnMouseMove Failed - " + ex.Message); } } } } }
/// <summary>Respond as appropriate to <paramref name="node"/> being dropped on this, and return true if successful.</summary> internal abstract bool AcceptDrop_OfIElementTreeNode(IElementTreeNode node, DragDropEffects effects, int insertPoint);
private void RouteListView_ItemDrag(object sender, ItemDragEventArgs e) { DragDropEffects dde = DoDragDrop(this.SelectedItems, DragDropEffects.Move); }
/// <summary> /// DragEnd event handler from DragDrop behavior. /// </summary> private void SourceDoDragDrop(ITextSelection selection, IDataObject dataObject) { // Run OLE drag-drop process. It will eat all user input until the drop DragDropEffects allowedDragDropEffects = DragDropEffects.Copy; if (!_textEditor.IsReadOnly) { allowedDragDropEffects |= DragDropEffects.Move; } DragDropEffects resultingDragDropEffects = DragDropEffects.None; try { resultingDragDropEffects = DragDrop.DoDragDrop( // _textEditor.UiScope, // dragSource, dataObject, // allowedDragDropEffects); } // Ole32's DoDragDrop can return E_UNEXCEPTED, which comes to us as a COMException, // if something unexpected happened during the drag and drop operation, // e.g. the application receiving the drop failed. In this case we should // not fail, we should catch the exception and act as if the drop wasn't allowed. catch (COMException ex) when(ex.HResult == NativeMethods.E_UNEXPECTED) { } // Remove source selection if (!_textEditor.IsReadOnly && // resultingDragDropEffects == DragDropEffects.Move && // _dragSourceTextRange != null && !_dragSourceTextRange.IsEmpty) { // Normally we delete the source selection from OnDrop event, // unless source and target TextBoxes are different. // In this case the source selection is still not empty, // which means that target was in a different TextBox. // So we still need to delete the selected content in the source one. // This will create an undo unit different from a dropping one, // which is ok, because it will be in different TextBox's undo stack. using (selection.DeclareChangeBlock()) { // This is end of Move - we need to delete source content _dragSourceTextRange.Text = String.Empty; } } // Clean up the text range. _dragSourceTextRange = null; // Check the data binding expression and update the source and target if the drag source // has the binding expression. Without this, data binding is broken after complete the // drag-drop operation because Drop() paste the object then set the focus to the target. // The losting focus invoke the data binding expression's Update(), but the source isn't // updated yet before complete DoDragDrop. if (!_textEditor.IsReadOnly) { BindingExpressionBase bindingExpression = BindingOperations.GetBindingExpressionBase( _textEditor.UiScope, TextBox.TextProperty); if (bindingExpression != null) { bindingExpression.UpdateSource(); bindingExpression.UpdateTarget(); } } }
/// <summary> /// Prepare for and begin a drag operation. /// Hook the events needed by the data provider. /// </summary> private DragDropEffects DoDragDrop_Start(MouseEventArgs e) { DragDropEffects resultEffects = DragDropEffects.None; DataObject data = new DataObject(); this._dragDropObject.SetData(ref data); bool hookQueryContinueDrag = false; bool hookGiveFeedback = false; if ((this._dragDropObject.DataProviderActions & DataProviderActions.QueryContinueDrag) != 0) { hookQueryContinueDrag = true; } if ((this._dragDropObject.DataProviderActions & DataProviderActions.GiveFeedback) != 0) { hookGiveFeedback = true; } if (this._dragDropObject.AddAdorner) { hookGiveFeedback = true; } QueryContinueDragEventHandler queryContinueDrag = null; GiveFeedbackEventHandler giveFeedback = null; if (hookQueryContinueDrag) { queryContinueDrag = new QueryContinueDragEventHandler(DragSource_QueryContinueDrag); this._dragSource.QueryContinueDrag += queryContinueDrag; } if (hookGiveFeedback) { giveFeedback = new GiveFeedbackEventHandler(DragSource_GiveFeedback); this._dragSource.GiveFeedback += giveFeedback; } try { // NOTE: Set 'dragSource' to desired value (dragSource or item being dragged) // 'dragSource' is passed to QueryContinueDrag as Source and OriginalSource DependencyObject dragSource; dragSource = this._dragSource; //dragSource = this._dragDropObject.Item; resultEffects = DragDrop.DoDragDrop(dragSource, data, this._dragDropObject.AllowedEffects); } catch { Debug.WriteLine("DragDrop.DoDragDrop threw an exception"); } if (queryContinueDrag != null) { this._dragSource.QueryContinueDrag -= queryContinueDrag; } if (giveFeedback != null) { this._dragSource.GiveFeedback -= giveFeedback; } return(resultEffects); }
void StartDrag() { // prevent nested StartDrag calls mode = SelectionMode.Drag; // mouse capture and Drag'n'Drop doesn't mix textArea.ReleaseMouseCapture(); DataObject dataObject = textArea.Selection.CreateDataObject(textArea); DragDropEffects allowedEffects = DragDropEffects.All; var deleteOnMove = textArea.Selection.Segments.Select(s => new AnchorSegment(textArea.Document, s)).ToList(); foreach (ISegment s in deleteOnMove) { ISegment[] result = textArea.GetDeletableSegments(s); if (result.Length != 1 || result[0].Offset != s.Offset || result[0].EndOffset != s.EndOffset) { allowedEffects &= ~DragDropEffects.Move; } } object dragDescriptor = new object(); this.currentDragDescriptor = dragDescriptor; DragDropEffects resultEffect; using (textArea.AllowCaretOutsideSelection()) { var oldCaretPosition = textArea.Caret.Position; try { Debug.WriteLine("DoDragDrop with allowedEffects=" + allowedEffects); resultEffect = DragDrop.DoDragDrop(textArea, dataObject, allowedEffects); Debug.WriteLine("DoDragDrop done, resultEffect=" + resultEffect); } catch (COMException ex) { // ignore COM errors - don't crash on badly implemented drop targets Debug.WriteLine("DoDragDrop failed: " + ex.ToString()); return; } if (resultEffect == DragDropEffects.None) { // reset caret if drag was aborted textArea.Caret.Position = oldCaretPosition; } } this.currentDragDescriptor = null; if (deleteOnMove != null && resultEffect == DragDropEffects.Move && (allowedEffects & DragDropEffects.Move) == DragDropEffects.Move) { bool draggedInsideSingleDocument = (dragDescriptor == textArea.Document.UndoStack.LastGroupDescriptor); if (draggedInsideSingleDocument) { textArea.Document.UndoStack.StartContinuedUndoGroup(null); } textArea.Document.BeginUpdate(); try { foreach (ISegment s in deleteOnMove) { textArea.Document.Remove(s.Offset, s.Length); } } finally { textArea.Document.EndUpdate(); if (draggedInsideSingleDocument) { textArea.Document.UndoStack.EndUndoGroup(); } } } }
/// <summary> /// Begin a new drag operation with the given data and effects /// </summary> /// <param name="data">The data for the drag operation</param> /// <param name="allowedEffects">Effects allowed on the given data</param> public VirtualTreeStartDragData(object data, DragDropEffects allowedEffects) { myData = data; myAllowedEffects = allowedEffects; }
/// <summary> /// Provide drop feedback /// </summary> /// <param name="screenPoint">screen-point</param> /// <param name="keyState">key-state</param> /// <param name="supportedEffects">supported effects</param> /// <returns>actual effect</returns> public override DragDropEffects ProvideDragFeedback(Point screenPoint, int keyState, DragDropEffects supportedEffects) { // update insertion point try { currentCaretLocation = EditorContext.MoveCaretToScreenPoint(screenPoint); //move the caret markup pointer to the new caret location currentCaretLocation.MoveMarkupPointerToCaret(caretPointer.PointerRaw); //determine if this location is content editable, if not provide None feedback //since that is not a valid drop location IHTMLElement3 element = (IHTMLElement3)caretPointer.CurrentScope; bool visible = false; currentCaretLocation.IsVisible(out visible); if (!element.isContentEditable || !visible) { return(DragDropEffects.None); } } catch (Exception ex) { if (ex is COMException) { int errorCode = ((COMException)ex).ErrorCode; if (errorCode == IE_CTL_E.INVALIDLINE || errorCode == IE_CTL_E.UNPOSITIONEDELEMENT || errorCode == IE_CTL_E.UNPOSITIONEDPOINTER) { return(DragDropEffects.None); } } Trace.Fail("Exception thrown while providing drag feedback: " + ex); //bug fix 1115: eat the exception if one is thrown while placing the caret. //this can occur when attempting to move the caret into an HTML control (such as an image or table) return(DragDropEffects.None); } // provide feedback depending upon what we are processing switch (dragType) { case DragType.ExternalHtml: if (!EditorContext.CanDrop(caretPointer.CurrentScope, DataMeister)) { return(DragDropEffects.None); } // for external html provide move and copy (prefer move -- this allows // us to smoothly handle the moving of images around the document) return(ProvideMoveAsDefaultWithCopyOverride(keyState, supportedEffects)); default: return(DragDropEffects.None); } }
internal virtual DragDropEffects StartDrag(IntPtr handle, object data, DragDropEffects allowedEffects) { Console.Error.WriteLine("Drag and Drop is currently " + "not supported on this platform"); return(DragDropEffects.None); }
public override DragDropEffects GetDragDropEffect(IDataObject dataObject, DragDropEffects proposedEffect) { return(((ExtTreeNode)Parent).GetDragDropEffect(dataObject, proposedEffect)); }