public void SetSupportedDragDropEffects(DragDropEffectsEx effects, DragDropEffectsEx defaultEffect = DragDropEffectsEx.Copy) { ContextMenu.Items.Clear(); foreach (var e in Enum.GetValues(typeof(DragDropEffectsEx))) { DragDropEffectsEx curEffect = (DragDropEffectsEx)e; if (curEffect != DragDropEffectsEx.None && effects.HasFlag(curEffect)) { var header = new TextBlock() { Text = curEffect.ToString() }; if (curEffect.Equals(defaultEffect)) { header.FontWeight = FontWeights.Bold; ContextMenu.Items.Insert(0, new MenuItem() { Tag = e, Header = header }); } else { ContextMenu.Items.Add(new MenuItem() { Tag = e, Header = header }); } } } }
private void init(IDataObject dataObject, DragDropEffectsEx allowedEffects, Action <DragDropEffectsEx> effectSetFunc) { Data = dataObject; AllowedEffects = allowedEffects; _effectSetFunc = effectSetFunc; }
protected override IScriptCommand executeInner(ParameterDic pm, UIElement sender, RoutedEventArgs evnt, IUIInput input, IList <IUIInputProcessor> inpProcs) { DragEventArgs devnt = evnt as DragEventArgs; ISupportDrop dropTarget = pm.GetValue <ISupportDrop>(DropTargetKey); IEnumerable <IDraggable> draggables = pm.GetValue <IEnumerable <IDraggable> >(DraggablesKey); DragDropEffectsEx allowedEffects = pm.HasValue(AllowedEffectsKey) ? pm.GetValue <DragDropEffectsEx>(AllowedEffectsKey) : devnt != null ? (DragDropEffectsEx)devnt.AllowedEffects : DragDropEffectsEx.All; if (dropTarget != null && draggables != null) { QueryDropEffects queryDropEffect = QueryDropEffects.None; if (devnt != null) { queryDropEffect = dropTarget.QueryDrop(draggables, allowedEffects); devnt.Effects = (DragDropEffects)queryDropEffect.SupportedEffects; } else { queryDropEffect = dropTarget.QueryDrop(draggables, allowedEffects); } pm.SetValue(DestinationKey, queryDropEffect, SkipIfExists); } return(NextCommand); }
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); }
public override QueryDropEffects QueryDrop(IEnumerable <T> models, DragDropEffectsEx allowedEffects) { if (models.Count() > 0) { return(QueryDropEffects.CreateNew(DragDropEffectsEx.Move)); } _tcvm.SelectedItem = _tvm; return(QueryDropEffects.None); }
public void OnDragCompleted(IEnumerable <IDraggable> draggables, DragDropEffectsEx effect) { if (effect == DragDropEffectsEx.Move) { foreach (var item in Items.Where(i => i.IsSelected).ToList()) { Items.Remove(item); } } }
public void OnDragCompleted(IEnumerable <IDraggable> draggables, DragDropEffectsEx effect) { if (effect == DragDropEffectsEx.Move) { foreach (var item in draggables.Cast <DragDropItemViewModel>()) { if (Items.Contains(item)) { Items.Remove(item); } } } }
public void SetFileDropData(IFileDropItem[] fileDrops, DragDropEffectsEx effects = DragDropEffectsEx.Copy) { _fileDrops = fileDrops; string[] _fileNames = (from fd in _fileDrops select fd.FileSystemPath).ToArray(); SetData(DataFormats.FileDrop, _fileNames); SetData(ShellClipboardFormats.CFSTR_PREFERREDDROPEFFECT, effects); IsVirtual = fileDrops.Any(fd => fd.IsVirtual); if (IsVirtual) { SetData(ShellClipboardFormats.CFSTR_INDRAGLOOP, 1); } }
public QueryDropEffects QueryDrop(IEnumerable <IDraggable> draggables, DragDropEffectsEx allowedEffects) { if (draggables.Count() == 0) { return(QueryDropEffects.None); } foreach (var dm in draggables.Cast <DragDropItemViewModel>()) { if (dm.Value == this.Value) { return(QueryDropEffects.None); } } return(QueryDropEffects.CreateNew(DragDropEffectsEx.Move | DragDropEffectsEx.Copy, DragDropEffectsEx.Move)); }
public override void OnDragCompleted(IEnumerable <IDraggable> draggables, DragDropEffectsEx effect) { if (effect == DragDropEffectsEx.Move) { foreach (var b in draggables.Where(d => d is BookmarkModel).Cast <BookmarkModel>()) { BookmarkModel parentModel = b.Parent as BookmarkModel; if (parentModel != null) { parentModel.Remove(b.Label); } (parentModel.Profile as BookmarkProfile).RaiseEntryChanged( new EntryChangedEvent(ChangeType.Deleted, b.FullPath)); } } }
public override DragDropEffectsEx Drop(IEnumerable <IDraggable> draggables, DragDropEffectsEx allowedEffects) { foreach (var e in draggables.Where(d => d is IEntryModel).Cast <IEntryModel>()) { BookmarkModel be = e as BookmarkModel; if (be != null) { add(be, _dropTarget as BookmarkModel); } else { _dropTarget.AddLink(e.Label, e.FullPath); } } return(allowedEffects); }
protected override IScriptCommand executeInner(ParameterDic pm, UIElement sender, RoutedEventArgs evnt, IUIInput input, IList <IUIInputProcessor> inpProcs) { DragEventArgs devnt = evnt as DragEventArgs; ISupportDrag dragSource = pm.GetValue <ISupportDrag>(DragSourceKey); ISupportDrop dropTarget = pm.GetValue <ISupportDrop>(DropTargetKey); IEnumerable <IDraggable> draggables = pm.GetValue <IEnumerable <IDraggable> >(DraggablesKey).ToList(); if (dropTarget != null && draggables != null) { DragDropEffectsEx effect = pm.HasValue <DragDropEffectsEx>(DropEffectKey) ? pm.GetValue <DragDropEffectsEx>(DropEffectKey) : devnt != null ? (DragDropEffectsEx)devnt.AllowedEffects : DragDropEffectsEx.All; DragDropEffectsEx resultEffect = DragDropEffectsEx.None; var dataObj = pm.GetValue <IDataObject>(DataObjectKey); if (effect != DragDropEffectsEx.None) { if (dropTarget is ISupportShellDrop) { resultEffect = (dropTarget as ISupportShellDrop).Drop(draggables, dataObj, effect); } else { resultEffect = dropTarget.Drop(draggables, effect); } } if (devnt != null) { devnt.Effects = (DragDropEffects)resultEffect; } pm.SetValue(DestinationKey, resultEffect, SkipIfExists); if (dragSource != null) { dragSource.OnDragCompleted(draggables, resultEffect); } } return(NextCommand); }
//public IEnumerable<IDraggable> QueryDropDraggables(IDataObject da) //{ // if (da.GetDataPresent(Format_DragDropItem)) // { // var data = da.GetData(Format_DragDropItem) as int[]; // for (int i = 0; i < data.Length; i++) // yield return new DragDropItemViewModel(data[i], IsChildDroppable, IsChildDroppable); // } //} public DragDropEffectsEx Drop(IEnumerable <IDraggable> draggable, DragDropEffectsEx allowedEffects) { if (allowedEffects.HasFlag(DragDropEffectsEx.Move) || allowedEffects.HasFlag(DragDropEffectsEx.Copy)) { var draggableViewModels = draggable.Cast <DragDropItemViewModel>(); if (draggableViewModels.Any()) { int idx = 0; foreach (var d in draggableViewModels) { Items.Insert(idx++, d); } } return(DragDropEffectsEx.Move); } else { return(DragDropEffectsEx.None); } }
public DragDropEffectsEx OnDropCompleted(IEnumerable <IEntryModel> entries, IDataObject da, IEntryModel destDir, DragDropEffectsEx allowedEffects) { string fileName = PathEx.GetFileName(destDir.FullPath); if (fileName == null) { fileName = destDir.FullPath; } if (entries.Count() == 0) { return(DragDropEffectsEx.None); } if (entries.Any(e => e.Equals(destDir) || e.Parent.Equals(destDir))) { return(DragDropEffectsEx.None); } //if (MessageBox.Show( // String.Format("[OnDropCompleted] ({2}) {0} entries to {1}", // entries.Count(), fileName, allowedEffects), "FileBasedDragDropHandler.OnDropCompleted", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { DragDropEffectsEx effect = allowedEffects.HasFlag(DragDropEffectsEx.Copy) ? DragDropEffectsEx.Copy : allowedEffects.HasFlag(DragDropEffectsEx.Move) ? DragDropEffectsEx.Move : DragDropEffectsEx.None; if (effect == DragDropEffectsEx.None) { return(DragDropEffectsEx.None); } ScriptRunner.RunScriptAsync( WPFScriptCommands.ShowProgress(effect.ToString(), IOScriptCommands.DiskTransfer(entries.ToArray(), destDir, effect == DragDropEffectsEx.Move, true), true)); return(effect); }; return(DragDropEffectsEx.None); }
public override IScriptCommand Execute(ParameterDic pm) { DragAdorner dragAdorner = pm.GetValue <DragAdorner>(AdornerKey); DragDropEffectsEx supportedEffects = pm.GetValue <DragDropEffectsEx>(SupportedEffectsKey, DragDropEffectsEx.All); DragDropEffectsEx defaultEffect = pm.GetValue <DragDropEffectsEx>(DefaultEffectKey, DragDropEffectsEx.Copy); RoutedEventHandler ContextMenu_Closed = null; ContextMenu_Closed = (o, e) => { dragAdorner.ContextMenu.RemoveHandler(ContextMenu.ClosedEvent, ContextMenu_Closed); pm.SetValue(ResultEffectKey, dragAdorner.DragDropEffect); ScriptRunner.RunScriptAsync(pm, OnCloseCommand); }; dragAdorner.SetSupportedDragDropEffects(supportedEffects, defaultEffect); dragAdorner.ContextMenu.AddHandler(ContextMenu.ClosedEvent, ContextMenu_Closed); dragAdorner.ContextMenu.IsOpen = true; return(NextCommand); }
public override DragDropEffectsEx Drop(IEnumerable <IDraggable> sourceDraggable, IDataObject da, DragDropEffectsEx allowedEffects) { var sourceVM = sourceDraggable.FirstOrDefault() as T; if (sourceVM != null) { int thisIdx = _tcvm.GetTabIndex(_tvm); int srcIdx = _tcvm.GetTabIndex(sourceVM); if (srcIdx != -1 && thisIdx != -1) { int destIdx = thisIdx > srcIdx ? thisIdx - 1 : thisIdx; if (destIdx != -1 && srcIdx != destIdx) { _tcvm.MoveTab(srcIdx, destIdx); return(DragDropEffectsEx.Move); } } } return(DragDropEffectsEx.None); }
public void OnDragCompleted(IEnumerable <IDraggable> draggables, DragDropEffectsEx effect) { }
public DragInput(IUIInput sourceInput, IDataObject dataObject, DragDropEffectsEx allowedEffects, Action <DragDropEffectsEx> effectSetFunc) { _sourceInput = sourceInput; init(dataObject, allowedEffects, effectSetFunc); }
public DragDropEffectsEx Drop(IEnumerable <IDraggable> draggables, DragDropEffectsEx allowedEffects) { return(Drop(Convert(draggables, true), allowedEffects)); }
public abstract void OnDragCompleted(IEnumerable <IDraggable> draggables, IDataObject da, DragDropEffectsEx effect);
public DragDropEffectsEx Drop(IEnumerable <IDraggable> draggables, DragDropEffectsEx allowedEffects) { return(DragDropEffectsEx.None); }
public void OnDragCompleted(IEnumerable <IDraggable> draggables, IDataObject da, DragDropEffectsEx effect) { if (_dragCompletedAction == null) { throw new ArgumentException(); } var entryModels = draggables.Select(d => _convertBackFunc(d)); _dragCompletedAction(entryModels, da, effect); }
public override DragDropEffectsEx Drop(IEnumerable <IDraggable> draggables, IDataObject da, DragDropEffectsEx allowedEffects) { return(DragDropEffectsEx.None); }
public override DragDropEffectsEx Drop(IEnumerable <IDraggable> draggables, DragDropEffectsEx allowedEffects) { return(Drop(draggables, null, allowedEffects)); }
public abstract DragDropEffectsEx Drop(IEnumerable <IDraggable> draggables, IDataObject da, DragDropEffectsEx allowedEffects);
public override void OnDragCompleted(IEnumerable <IDraggable> draggables, DragDropEffectsEx effect) { OnDragCompleted(draggables, null, effect); }
public override DragDropEffectsEx Drop(IEnumerable <M> models, DragDropEffectsEx allowedEffects) { return(_dropFunc(models, allowedEffects)); }
public abstract DragDropEffectsEx Drop(IEnumerable <M> models, DragDropEffectsEx allowedEffects);
public override QueryDropEffects QueryDrop(IEnumerable <IDraggable> draggables, DragDropEffectsEx allowedEffects) { return(QueryDropEffects.None); }
public override void OnDragCompleted(IEnumerable <M> models, IDataObject da, DragDropEffectsEx effect) { _onDragCompletedAction(models, da, effect); }