/// <summary> /// Find ISelectable under cursor over element's datacontext, if it's ISelectable.IsSelected, /// assign canDragKey to true, otherwise false. /// </summary> /// <param name="canDragKey"></param> /// <returns></returns> public static IScriptCommand IfItemUnderMouseIsSelected(IScriptCommand trueCommand = null, IScriptCommand otherwiseCommand = null) { return //Calculate a number of positions. (HubScriptCommands.ObtainPointerPosition( //Assign the datacontext item of the UIelement that's undermouse to {ItemUnderMouse} HubScriptCommands.AssignItemUnderMouse("{ItemUnderMouse}", false, //And If it's exists and selected, ScriptCommands.IfAssigned("{ItemUnderMouse}", ScriptCommands.IfNotAssigned("{ItemUnderMouse.IsSelected}", trueCommand, ScriptCommands.IfTrue("{ItemUnderMouse.IsSelected}", trueCommand, otherwiseCommand)), otherwiseCommand)))); }
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()))); } }