public override async Task <IScriptCommand> ExecuteAsync(ParameterDic pm) { IWindowManager wm = pm.GetValue <IWindowManager>(WindowManagerKey) ?? new WindowManager(); IEventAggregator events = pm.GetValue <IEventAggregator>(EventAggregatorKey) ?? new EventAggregator(); TabbedExplorerViewModel tevm = new TabbedExplorerViewModel(wm, events); pm.SetValue(DestinationKey, tevm); tevm.Initializer = new ScriptCommandInitializer() { StartupParameters = pm, WindowManager = wm, Events = events, OnModelCreated = ScriptCommands.Run(OnModelCreatedKey), OnViewAttached = ScriptCommands.Run(OnViewAttachedKey) }; if (pm.HasValue(OnTabExplorerCreatedKey)) { await tevm.Commands.ExecuteAsync(pm.GetValue <IScriptCommand>(OnTabExplorerCreatedKey)); } tevm.OnTabExplorerAttachedKey = OnTabExplorerAttachedKey; object enableTabsWhenOneTab = pm.GetValue("{EnableTabsWhenOneTab}"); tevm.EnableTabsWhenOneTab = !(enableTabsWhenOneTab is bool) || (bool)enableTabsWhenOneTab; logger.Info(String.Format("Showing {0}", tevm)); wm.ShowWindow(tevm); return(NextCommand); }
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); }
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); }
public override IScriptCommand Execute(ParameterDic pm) { if (SkipIfExists && pm.HasValue(DestinationKey)) { return(NextCommand); } IUIDragInput dragInp = pm.GetValue <IUIDragInput>(base.InputKey); if (dragInp != null) { pm.SetValue(DestinationKey, dragInp.Data, SkipIfExists); } return(NextCommand); }
public override IScriptCommand Execute(ParameterDic pm) { Point pos1 = pm.GetValue <Point>(Position1Key); if (pm.HasValue(Position2Key)) { Point pos2 = pm.GetValue <Point>(Position2Key); Value = new Rect(pos1, pos2); } else { Size size = pm.GetValue <Size>(SizeKey); Value = new Rect(pos1, size); } return(base.Execute(pm)); }
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); }
protected override IScriptCommand executeInner(ParameterDic pm, Control sender, RoutedEventArgs evnt, IUIInput input, IList <IUIInputProcessor> inpProcs) { if (!pm.HasValue <ParameterDic>("{DragDrop}")) { ScriptCommands.AssignGlobalParameterDic("{DragDrop}", false).Execute(pm); } if (!pm.HasValue <Point>(CurrentPositionAdjustedKey)) { HubScriptCommands.ObtainPointerPosition().Execute(pm); } logger.Debug(State.ToString()); switch (State) { case DragDropLiteState.StartLite: case DragDropLiteState.StartCanvas: string mode = State == DragDropLiteState.StartLite ? "Lite" : "Canvas"; if (dragStart(pm, input, mode)) { foreach (var item in pm.GetValue <IEnumerable <IDraggable> >(DragDropDraggingItemsKey) .Where(i => (State == DragDropLiteState.StartLite) || i is IPositionAware)) { item.IsDragging = true; } return(NextCommand); } else { return(FailCommand); } case DragDropLiteState.EndLite: case DragDropLiteState.EndCanvas: case DragDropLiteState.CancelCanvas: //foreach (var item in pm.GetValue<IEnumerable<IDraggable>>(DragDropDraggingItemsKey)) // item.IsDragging = true; if (pm.HasValue <Point>(DragDropStartPositionKey)) { Point currentPosition = pm.GetValue <Point>(CurrentPositionAdjustedKey); Point startPosition = pm.GetValue <Point>(DragDropStartPositionKey); Vector movePt = currentPosition - startPosition; var items = pm.GetValue <IEnumerable <IDraggable> >(DragDropDraggingItemsKey); foreach (var item in items) { item.IsDragging = false; } if (State == DragDropLiteState.EndCanvas) { foreach (var posAwareItem in items.Cast <IPositionAware>()) { posAwareItem.OffsetPosition(movePt); } } } dragEnd(pm); return(NextCommand); default: return(ResultCommand.Error(new NotSupportedException(State.ToString()))); } }
public override bool CanExecute(ParameterDic pm) { return(pm.HasValue(TabbedExplorerKey)); }