public static IScriptCommand DetachDragDropAdorner(string adornerLayerVariable = "{AdornerLayer}", string adornerVariable = "{DragDropAdorner}",
                                                    IScriptCommand nextCommand  = null)
 {
     return(ScriptCommands.IfAssigned(adornerVariable,
                                      AssignAdornerLayer("PART_DragDropAdorner", adornerLayerVariable, false,
                                                         HubScriptCommands.DetachAdorner(adornerLayerVariable, adornerVariable))));
 }
Exemplo n.º 2
0
        /// <summary>
        /// Store position minus offset (Point) to destination.
        /// </summary>
        /// <param name="positionVariable"></param>
        /// <param name="offsetVariable"></param>
        /// <param name="destinationVariable"></param>
        /// <param name="nextCommand"></param>
        /// <returns></returns>
        public static IScriptCommand OffsetPositionNeg(string positionVariable    = "{Position}", string offsetVariable      = "{Offset}",
                                                       string destinationVariable = "{Position}", IScriptCommand nextCommand = null)
        {
            string offsetNegVariable = ParameterDic.CombineVariable(offsetVariable, "Neg", true);

            return(HubScriptCommands.NegativePosition(offsetVariable, offsetNegVariable,
                                                      HubScriptCommands.OffsetPosition(positionVariable, offsetNegVariable, destinationVariable, nextCommand)));
        }
        public static IScriptCommand IfDependencyProperty <T>(string elementVariable      = "{Sender}",
                                                              DependencyProperty property = null, ComparsionOperator op           = ComparsionOperator.Equals, T value = default(T),
                                                              IScriptCommand trueCommand  = null, IScriptCommand otherwiseCommand = null)
        {
            string destinationVariable = ParameterDic.CombineVariable(elementVariable, property.ToString() + "Value");

            return(HubScriptCommands.GetDependencyProperty(elementVariable, property, destinationVariable,
                                                           ScriptCommands.IfValue(op, destinationVariable, value, trueCommand, otherwiseCommand)));
        }
Exemplo n.º 4
0
        public static IScriptCommand IfMouseGesture(MouseGesture gesture,
                                                    IScriptCommand nextCommand = null, IScriptCommand otherwiseCommand = null)
        {
            string MouseGestureVariable = "{IfMouseGesture-Gesture}";

            return
                (ScriptCommands.Assign(MouseGestureVariable, gesture, false,
                                       HubScriptCommands.IfMouseGesture(MouseGestureVariable, nextCommand, otherwiseCommand)));
        }
        /// <summary>
        /// Get the property and compare if it's equal to value before setting.
        /// </summary>
        /// <param name="elementVariable"></param>
        /// <param name="property"></param>
        /// <param name="value"></param>
        /// <param name="ifChanged"></param>
        /// <param name="ifUnchanged"></param>
        /// <returns></returns>
        public static IScriptCommand SetDependencyPropertyIfDifferentValue(string elementVariable,
                                                                           DependencyProperty property, object value, IScriptCommand ifChanged, IScriptCommand ifUnchanged = null)
        {
            string valueVariable = ParameterDic.CombineVariable(elementVariable, "Value");

            return(HubScriptCommands.GetDependencyProperty(elementVariable, property, valueVariable,
                                                           ScriptCommands.IfEquals(valueVariable, value,
                                                                                   ifUnchanged,
                                                                                   SetDependencyPropertyValue(elementVariable, property, value, ifChanged))));
        }
        /// <summary>
        /// Update the DragAdorner's PointerPosition so selected Items will be shown at the spot.
        /// </summary>
        public static IScriptCommand UpdateAdornerPointerPosition(string adornerVariable = "{DragDrop.Adorner}", IScriptCommand nextCommand = null)
        {
            string cursorPositionVariable = "{DragDrop.CursorPosition}";

            return(HubScriptCommands.AssignCursorPosition(PositionRelativeToType.Window, cursorPositionVariable, false,
                                                          ScriptCommands.RunSequence(null,
                                                                                     ScriptCommands.IfEquals(DragDropLiteCommand.DragDropDeviceKey, UIInputType.Touch,
                                                                                                             HubScriptCommands.OffsetPositionValue("{DragDrop.CursorPosition}", new Point(-100, -100), "{DragDrop.CursorPosition}")),
                                                                                     ScriptCommands.SetProperty(adornerVariable, (DragAdorner a) => a.PointerPosition, cursorPositionVariable, nextCommand))));
        }
 public static IScriptCommand AttachDragDropAdorner(string adornerLayerVariable = "{AdornerLayer}", string adornerVariable = "{DragDropAdorner}",
                                                    IScriptCommand nextCommand  = null)
 {
     return(AssignAdornerLayer("PART_DragDropAdorner", adornerLayerVariable, false,
                               new AssignDragDropAdorner()
     {
         AdornerKey = adornerVariable,
         AdornerLayerKey = adornerLayerVariable,
         NextCommand = (ScriptCommandBase)HubScriptCommands.AttachAdorner(adornerLayerVariable, adornerVariable, nextCommand),
     }));
 }
Exemplo n.º 8
0
 public static IScriptCommand EndLiteDrag(string dragSourceVariable  = "{ISupportDrag}",
                                          IScriptCommand nextCommand = null, IScriptCommand failCommand = null)
 {
     return
         (HubScriptCommands.AssignDragMethod(QueryDrag.DragMethodKey,
                                             new DragDropLiteCommand()
     {
         State = DragDropLiteState.EndLite,
         DragSourceKey = dragSourceVariable,
         NextCommand = (ScriptCommandBase)nextCommand,
         FailCommand = (ScriptCommandBase)failCommand
     }));
 }
 /// <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))));
 }
        public static IScriptCommand AttachAdorner(string adornerLayerVariable = "{DragDrop.AdornerLayer}",
                                                   string adornerVariable      = "{DragDrop.Adorner}",
                                                   string iSupportDropVariable = "{ISupportDrop}",
                                                   string dragMethodVariable   = "{DragDrop.DragMethod}",
                                                   string draggablesVariable   = "{DragDrop.Draggables}",

                                                   IScriptCommand nextCommand = null)
        {
            return(DragDropScriptCommands.DetachAdorner(adornerLayerVariable, adornerVariable,
                                                        HubScriptCommands.AttachDragDropAdorner(adornerLayerVariable, adornerVariable,
                                                                                                HubScriptCommands.SetDependencyPropertyValue(adornerVariable, DragAdorner.IsDraggingProperty, true,
                                                                                                                                             DragDropScriptCommands.UpdateAdorner(adornerVariable, iSupportDropVariable,
                                                                                                                                                                                  dragMethodVariable, draggablesVariable, nextCommand)))));
        }
Exemplo n.º 11
0
 /// <summary>
 /// Assumed {FindSelectionMode} is assigned (use DetermineFindSelectionMode())
 /// find selected items and assign to {SelectedList} and {SelectedIdList}
 /// </summary>
 /// <param name="nextCommand"></param>
 /// <returns></returns>
 public static IScriptCommand FindSelectedItems(IScriptCommand nextCommand = null)
 {
     return
         (HubScriptCommands.DetermineFindSelectionMode("{FindSelectionMode}",
                                                       ScriptCommands.Switch("{FindSelectionMode}",
                                                                             new Dictionary <FindSelectionMode, IScriptCommand>()
     {
         { FindSelectionMode.IChildInfo,
           HubScriptCommands.FindSelectedItemsUsingIChildInfo() },
         { FindSelectionMode.GridView,
           HubScriptCommands.FindSelectedItemsUsingGridView() }
     },
                                                                             HubScriptCommands.FindSelectedItemsUsingHitTest(),
                                                                             nextCommand)));
 }
        public static IScriptCommand StartShellDrag(string iShellDragVariable = "{DragDrop.SupportDrag}", IScriptCommand nextCommand = null)
        {
            return
                //If CanDrag (ItemUnderMouse is selected), Check and set IsDraggingProperty to true.
                (ScriptCommands.SetPropertyValue(iShellDragVariable, (ISupportDrag d) => d.IsDraggingFrom, true,
                                                 HubScriptCommands.AssignDragMethod(QueryDrag.DragMethodKey,

                                                                                    //Initialize shell based drag drop
                                                                                    HubScriptCommands.QueryDrag(iShellDragVariable, "{DragResult}",
                                                                                    //Reset IsDragging property.
                                                                                                                ScriptCommands.SetPropertyValue(iShellDragVariable, (ISupportDrag d) => d.IsDraggingFrom, false,
                                                                                    //Reset IShellDrag variable.
                                                                                                                                                ScriptCommands.Assign(iShellDragVariable, null, false,
                                                                                                                                                                      nextCommand))))));
        }
Exemplo n.º 13
0
 /// <summary>
 /// Assign destination to DragMethod.Menu if Mouse action is right click, otherwise DragMethod.Normal.
 /// </summary>
 /// <returns></returns>
 public static IScriptCommand AssignDragMethod(string variable, IScriptCommand nextCommand = null)
 {
     return
         (ScriptCommands.RunSequence(nextCommand,
                                     HubScriptCommands.IfMouseGesture(new MouseGesture()
     {
         MouseAction = MouseAction.RightClick
     },
                                                                      ScriptCommands.Assign(variable, DragMethod.Menu),
                                                                      HubScriptCommands.IfTouchGesture(new TouchGesture()
     {
         TouchAction = UITouchGesture.Drag
     },
                                                                                                       ScriptCommands.Assign(variable, DragMethod.Menu),
                                                                                                       ScriptCommands.Assign(variable, DragMethod.Normal))
                                                                      )));
 }
 /// <summary>
 /// Obtain DataObject, Draggables and DropEffects, by calling AssignDataObject, QuerryDraggablesFromDataObject
 /// and QueryDropEffects() script commands.
 /// </summary>
 /// <param name="iSupportDropVariable"></param>
 /// <param name="destinationDataObjectVariable"></param>
 /// <param name="destinationVariable"></param>
 /// <param name="skipIfExists"></param>
 /// <param name="nextCommand"></param>
 /// <returns></returns>
 public static IScriptCommand QueryShellDragInfo(
     string iSupportDropVariable = "{ISupportDrop}", string destinationDataObjectVariable = "{DataObj}",
     string destinationVariable  = "{Draggables}", string queryDropResultVariable         = "{QueryDropResult}",
     bool skipIfExists           = false, IScriptCommand successCommand = null, IScriptCommand otherwiseCommand = null)
 {
     return(HubScriptCommands.AssignDataObject(destinationDataObjectVariable, false,
                                               HubScriptCommands.QueryDraggablesFromDataObject(iSupportDropVariable, destinationDataObjectVariable, destinationVariable, false,
                                                                                               //And if there's draggables,
                                                                                               ScriptCommands.IfAssigned("{DragDrop.Draggables}",
                                                                                                                         ScriptCommands.IfNotEquals("{DragDrop.Draggables.Count()}", 0,
                                                                                                                                                    //Call ISupportDrop.QueryDropEffects() to get QueryDropEffect.
                                                                                                                                                    HubScriptCommands.QueryDropEffects(iSupportDropVariable, destinationVariable, destinationDataObjectVariable, null,
                                                                                                                                                                                       queryDropResultVariable, false,
                                                                                                                                                                                       ScriptCommands.IfEquals(queryDropResultVariable, FileExplorer.Defines.QueryDropEffects.None,
                                                                                                                                                                                                               otherwiseCommand,
                                                                                                                                                                                                               successCommand)), otherwiseCommand), otherwiseCommand))));
 }
        public static IScriptCommand UpdateAdorner(string adornerVariable      = "{DragDrop.Adorner}",
                                                   string iSupportDropVariable = "{ISupportDrop}",
                                                   string dragMethodVariable   = "{DragDrop.DragMethod}",
                                                   string draggablesVariable   = "{DragDrop.Draggables}",
                                                   IScriptCommand nextCommand  = null)
        {
            string queryDropResultVariable = "{DragDrop.QueryDropResult}";

            return(DragDropScriptCommands.UpdateAdornerPointerPosition(adornerVariable,
                                                                       DragDropScriptCommands.UpdateAdornerDraggables(adornerVariable, draggablesVariable,
                                                                                                                      HubScriptCommands.QueryDropEffects(iSupportDropVariable, draggablesVariable, null, null, queryDropResultVariable, false,
                                                                                                                                                         DragDropScriptCommands.UpdateAdornerText(adornerVariable, dragMethodVariable, draggablesVariable,
                                                                                                                                                                                                  queryDropResultVariable, iSupportDropVariable, nextCommand)))));
        }
Exemplo n.º 16
0
        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 static IScriptCommand DetachAdorner(string adornerLayerVariable = "{DragDrop.AdornerLayer}",
                                            string adornerVariable      = "{DragDrop.Adorner}", IScriptCommand nextCommand = null)
 {
     return(HubScriptCommands.DetachAdorner(adornerLayerVariable, adornerVariable,
                                            ScriptCommands.Reset(nextCommand, adornerVariable, adornerLayerVariable)));
 }