Esempio n. 1
0
        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);
        }
        /// <summary>
        /// Update DragAdorner's Text to Move xyz.txt to Dest, syntax =
        /// [queryDropResult.supported/PreferredEffects] ([draggables.length] Items/draggables[0].DisplayName) to [isd.DisplayName]
        /// </summary>
        public static IScriptCommand UpdateAdornerText(string adornerVariable         = "{DragDrop.Adorner}",
                                                       string dragMethodVariable      = "{DragDrop.DragMethod}",
                                                       string draggablesVariable      = "{DragDrop.Draggables}",
                                                       string queryDropResultVariable = "{DragDrop.QueryDropResult}",
                                                       string ISupportDropVariable    = "{ISupportDrop}", IScriptCommand nextCommand = null)
        {
            string adornerTextVariable = ParameterDic.CombineVariable(adornerVariable, ".Text", false);
            string queryDropSupportedEffectsVariable = ParameterDic.CombineVariable(queryDropResultVariable, ".SupportedEffects", false);
            string queryDropPreferredEffectVariable  = ParameterDic.CombineVariable(queryDropResultVariable, ".PreferredEffect", false);
            string draggablesLengthVariable          = ParameterDic.CombineVariable(draggablesVariable, ".Count()", false);
            string draggablesFirstLabelVariable      = ParameterDic.CombineVariable(draggablesVariable, ".First().DisplayName", false);
            string iSupportDropLabelVariable         = ParameterDic.CombineVariable(ISupportDropVariable, ".DropTargetLabel", false);
            string iSupportDropDisplayNameVariable   = ParameterDic.CombineVariable(ISupportDropVariable, ".DisplayName", false);

            return
                (ScriptCommands.RunSequence(nextCommand,
                                            ScriptCommands.IfEquals(draggablesLengthVariable, 1,
                                                                    ScriptCommands.FormatText("{ItemLabel}", draggablesFirstLabelVariable),
                                                                    ScriptCommands.FormatText("{ItemLabel}", draggablesLengthVariable + " items")),
                                            ScriptCommands.IfEquals(dragMethodVariable, DragMethod.Menu,
                                                                    ScriptCommands.Assign("{MethodLabel}", queryDropSupportedEffectsVariable),
                                                                    ScriptCommands.Assign("{MethodLabel}", queryDropPreferredEffectVariable)),

                                            ScriptCommands.IfEquals(queryDropResultVariable, QueryDropEffects.None,
                                                                    ScriptCommands.FormatText(adornerTextVariable, "{ItemLabel}"),
                                                                    ScriptCommands.IfAssigned(iSupportDropLabelVariable,
                                                                                              ScriptCommands.FormatText(adornerTextVariable, iSupportDropLabelVariable),
                                                                                              ScriptCommands.SetProperty(adornerTextVariable, iSupportDropDisplayNameVariable)
                                                                                              ))
                                            ));
        }
        public static IScriptCommand SetDependencyProperty(string elementVariable,
                                                           DependencyProperty property, string valueVariable, IScriptCommand nextCommand = null)
        {
            string propertyVariable = ParameterDic.CombineVariable(elementVariable, "Property");

            return(ScriptCommands.Assign(propertyVariable, property, false,
                                         SetDependencyProperty(elementVariable, propertyVariable, valueVariable, nextCommand)));
        }
        public static IScriptCommand GetDependencyProperty(string elementVariable,
                                                           DependencyProperty property, string destinationVariable, IScriptCommand nextCommand)
        {
            string propertyVariable = ParameterDic.CombineVariable(elementVariable, "Property");

            return(ScriptCommands.Assign(propertyVariable, property, false,
                                         GetDependencyProperty(elementVariable, propertyVariable, destinationVariable, nextCommand)));
        }
Esempio n. 5
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)));
        }
Esempio n. 6
0
        /// <summary>
        /// Set Control.Commands(CommandManager).Commands(DynamicDictionary[IScriptCommand])
        /// </summary>
        /// <param name="?"></param>
        /// <returns></returns>
        public static IScriptCommand SetScriptCommand(string controlVariable      = "{FileList}", string target      = "Open",
                                                      IScriptCommand valueCommand = null, IScriptCommand nextCommand = null)
        {
            string valueVarable = ParameterDic.CombineVariable(controlVariable, "Value");

            return(ScriptCommands.Assign(valueVarable, valueCommand, false,
                                         SetScriptCommand(controlVariable, target, valueVarable, nextCommand)));
        }
Esempio n. 7
0
        /// <summary>
        /// Serializable, shortcut method for [AssignValueConverter], which a specific item from an array from a variable and assign to another variable.
        /// </summary>
        /// <param name="arrayVariable"></param>
        /// <param name="id"></param>
        /// <param name="destinationVariable"></param>
        /// <param name="nextCommand"></param>
        /// <returns></returns>
        public static IScriptCommand AssignArrayItem(string arrayVariable       = "{Array}", int id = 0,
                                                     string destinationVariable = "{Destination}", IScriptCommand nextCommand = null)
        {
            string valueConverterVariable = ParameterDic.CombineVariable(arrayVariable, "Converter");

            return(AssignValueConverter(ValueConverterType.GetArrayItem, valueConverterVariable,
                                        ScriptCommands.Reassign(arrayVariable, valueConverterVariable,
                                                                destinationVariable, false, nextCommand), id));
        }
Esempio n. 8
0
        public static IScriptCommand FileListIfSelectionLength(string fileListVariable    = "{FileList}",
                                                               ComparsionOperator op      = ComparsionOperator.Equals, int value  = 1,
                                                               IScriptCommand thenCommand = null, IScriptCommand otherwiseCommand = null)
        {
            string fileListSelectionVariable = ParameterDic.CombineVariable(fileListVariable, "Selection");

            return(UIScriptCommands.FileListAssignSelection(fileListSelectionVariable,
                                                            ScriptCommands.IfArrayLength(op, fileListSelectionVariable, value, thenCommand, otherwiseCommand)));
        }
Esempio n. 9
0
        /// <summary>
        /// Given an array filter using IfValue, and store matched item to destination variable.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="sourceArrayVariable"></param>
        /// <param name="property"></param>
        /// <param name="op"></param>
        /// <param name="value"></param>
        /// <param name="destinationArrayVariable"></param>
        /// <param name="nextCommand"></param>
        /// <returns></returns>
        public static IScriptCommand FilterArray <T>(string sourceArrayVariable      = "{SourceArray}", string property   = "Property",
                                                     ComparsionOperator op           = ComparsionOperator.Equals, T value = default(T),
                                                     string destinationArrayVariable = "{DestinationArray}", IScriptCommand nextCommand = null)
        {
            string valueVariable = ParameterDic.CombineVariable(sourceArrayVariable, "ValueCompare");

            return(Assign(valueVariable, value, false,
                          FilterArray(sourceArrayVariable, property, op, valueVariable, destinationArrayVariable, nextCommand)));
        }
Esempio n. 10
0
        /// <summary>
        /// Iterate an IEnumeration and return true if anyone's property equals to the value.
        /// <example>
        /// IScriptCommand iterateCommand2 =
        ///      ScriptCommands.ForEachIfAnyValue<DateTime>("{Items}", null, ComparsionOperator.Equals, DateTime.Today,
        ///	    ScriptCommands.PrintDebug("True"), ScriptCommands.PrintDebug("False"));
        /// </example>
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="itemsVariable"></param>
        /// <param name="property"></param>
        /// <param name="op"></param>
        /// <param name="value"></param>
        /// <param name="nextCommand"></param>
        /// <param name="otherwiseCommand"></param>
        /// <returns></returns>
        public static IScriptCommand ForEachIfAnyValue <T>(string itemsVariable       = "{Items}", string property            = null,
                                                           ComparsionOperator op      = ComparsionOperator.Equals, T value    = default(T),
                                                           IScriptCommand nextCommand = null, IScriptCommand otherwiseCommand = null)
        {
            string compareVariable = ParameterDic.CombineVariable(itemsVariable.Replace(".", ""), "Compare");

            return(Assign(compareVariable, value, false,
                          ForEachIfAnyValue(itemsVariable, property, op, compareVariable, nextCommand, otherwiseCommand)));
        }
        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)));
        }
Esempio n. 12
0
        ///// <summary>
        ///// Add variables (using Expression) to destination.
        ///// </summary>
        ///// <param name="sourceObjectVariable"></param>
        ///// <param name="addValues"></param>
        ///// <param name="destinationVariable"></param>
        ///// <param name="nextCommand"></param>
        ///// <returns></returns>
        //public static IScriptCommand Add(string sourceObjectVariable = "{Source}",
        //    object[] addValues = null,
        //    string destinationVariable = "{Destination}", IScriptCommand nextCommand = null)
        //{
        //    string valueConverterVariable = ParameterDic.CombineVariable(sourceObjectVariable, "Converter");
        //    return AssignValueConverter(ValueConverterType.AddValue, valueConverterVariable,
        //        ScriptCommands.Reassign(sourceObjectVariable, valueConverterVariable,
        //            destinationVariable, false, nextCommand), addValues);
        //}


        /// <summary>
        /// Concat array to destination
        /// </summary>
        /// <param name="sourceObjectVariable"></param>
        /// <param name="addValues"></param>
        /// <param name="destinationVariable"></param>
        /// <param name="nextCommand"></param>
        /// <returns></returns>
        public static IScriptCommand ConcatArray(string sourceObjectVariable = "{Source}",
                                                 object[] addValues          = null,
                                                 string destinationVariable  = "{Destination}", IScriptCommand nextCommand = null)
        {
            string valueConverterVariable = ParameterDic.CombineVariable(sourceObjectVariable, "Converter");

            return(AssignValueConverter(ValueConverterType.ConcatArray, valueConverterVariable,
                                        ScriptCommands.Reassign(sourceObjectVariable, valueConverterVariable,
                                                                destinationVariable, false, nextCommand), addValues));
        }
        /// <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))));
        }
Esempio n. 14
0
        public static IScriptCommand IfExistsVisualParent(string elementVariable       = "{Sender}",
                                                          FindMethodType method        = FindMethodType.Name,
                                                          string findparameterVariable = "{Parameter}",
                                                          IScriptCommand trueCommand   = null, IScriptCommand otherwiseCommand = null)
        {
            string destinationVariable = ParameterDic.CombineVariable(elementVariable, "Destination");

            return(FindVisualParent(elementVariable, method, findparameterVariable, destinationVariable,
                                    ScriptCommands.IfAssigned(destinationVariable, trueCommand, otherwiseCommand)));
        }
Esempio n. 15
0
        /// <summary>
        /// Set property of an object in ParameterDic to another object in ParameterDic.
        /// <example>
        /// ScriptCommands.SetProperty("{PSI}", "FileName", "{Value}")
        /// </example>
        /// </summary>
        /// <param name="sourceObjectVariable"></param>
        /// <param name="propertyName"></param>
        /// <param name="valueVariable"></param>
        /// <param name="nextCommand"></param>
        /// <returns></returns>
        public static IScriptCommand SetProperty(string sourceObjectVariable = "{Source}",
                                                 string propertyName         = "Property",
                                                 string valueVariable        = "{Value}", IScriptCommand nextCommand = null)
        {
            string valueConverterVariable = ParameterDic.CombineVariable(sourceObjectVariable, "Converter");

            return(AssignValueConverter(ValueConverterType.SetProperty, valueConverterVariable,
                                        ScriptCommands.Reassign(sourceObjectVariable, valueConverterVariable,
                                                                valueVariable, false, nextCommand), propertyName));
        }
Esempio n. 16
0
        /// <summary>
        /// Serializable, Use Reassign to obtain a property of a vaiable in ParameterDic and use IfEquals to compare, and run different command based on result.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="variable"></param>
        /// <param name="propertyName"></param>
        /// <param name="value"></param>
        /// <param name="trueCommand"></param>
        /// <param name="otherwiseCommand"></param>
        /// <returns></returns>
        public static IScriptCommand IfPropertyEquals <T>(string variable                 = "{variable}", string propertyName = "Property",
                                                          T value                         = default(T),
                                                          IScriptCommand trueCommand      = null,
                                                          IScriptCommand otherwiseCommand = null)
        {
            string variableProperty = ParameterDic.CombineVariable(variable, propertyName);
            string valueProperty    = "{IfPropertyEquals-Value}";

            return(AssignProperty(variable, propertyName, valueProperty,
                                  IfEquals <T>(valueProperty, value, trueCommand, otherwiseCommand)));
        }
Esempio n. 17
0
 private void dragEnd(ParameterDic pm)
 {
     pm.SetValue <object>(DragDropModeKey, null);
     pm.SetValue <object>(DragDropDeviceKey, null);
     pm.SetValue <object>(DragDropDraggingItemsKey, null);
     pm.SetValue <object>(DragDropEffectsKey, null);
     pm.SetValue(ParameterDic.CombineVariable(DragDropDragSourceKey, ".IsDraggingFrom", false), false);
     pm.SetValue <object>(DragDropDragSourceKey, null);
     pm.SetValue <object>(DragDropDropTargetKey, null);
     pm.SetValue <object>(DragDropStartPositionKey, null);
 }
Esempio n. 18
0
        /// <summary>
        /// Given an array filter using IfValue, and store matched item to destination variable.
        /// </summary>
        /// <param name="sourceArrayVariable"></param>
        /// <param name="property"></param>
        /// <param name="op"></param>
        /// <param name="valueVariable"></param>
        /// <param name="destinationArrayVariable"></param>
        /// <param name="nextCommand"></param>
        /// <returns></returns>
        public static IScriptCommand FilterArray(string sourceArrayVariable      = "{SourceArray}", string property                 = "Property",
                                                 ComparsionOperator op           = ComparsionOperator.Equals, string valueVariable  = "{Value}",
                                                 string destinationArrayVariable = "{DestinationArray}", IScriptCommand nextCommand = null)
        {
            string currentItemVariable     = ParameterDic.CombineVariable(sourceArrayVariable, "Current");
            string currentPropertyVariable = ParameterDic.CombineVariable(sourceArrayVariable, "Current" +
                                                                          (property == null ? "" : "." + property));
            string tempArrayVariable = ParameterDic.CombineVariable(sourceArrayVariable, "Temp");

            return(ForEach(sourceArrayVariable, currentItemVariable,
                           IfValue(op, currentPropertyVariable, valueVariable,
                                   ConcatArray(tempArrayVariable, new object[] { currentItemVariable }, tempArrayVariable)),
                           Assign(destinationArrayVariable, tempArrayVariable, false, nextCommand)));
        }
Esempio n. 19
0
        /// <summary>
        /// Serializable, If {StartupPath} is defined, goto the path, otherwise go to first root directory and expand it.
        /// Used to initialize Explorer onViewAttached.
        /// </summary>
        /// <param name="explorerVariable"></param>
        /// <param name="profilesVariable"></param>
        /// <param name="rootDirectoriesVariable"></param>
        /// <param name="startupPathVariable"></param>
        /// <param name="nextCommand"></param>
        /// <returns></returns>
        public static IScriptCommand ExplorerGotoStartupPathOrFirstRoot(string explorerVariable        = "{Explorer}",
                                                                        string profilesVariable        = "{Profiles}",
                                                                        string rootDirectoriesVariable = "{RootDirectories}",
                                                                        string startupPathVariable     = "{StartupPath}", IScriptCommand nextCommand = null)
        {
            string firstRootDirectoriesVariable = ParameterDic.CombineVariable(rootDirectoriesVariable, "[0]");

            return
                (ScriptCommands.RunSequence(nextCommand,
                                            ScriptCommands.IfAssignedAndNotEmptyString(startupPathVariable,
                                                                                       UIScriptCommands.ExplorerParseAndGoTo(explorerVariable, profilesVariable, startupPathVariable),
                                                                                       UIScriptCommands.ExplorerGoTo(explorerVariable, firstRootDirectoriesVariable,
                                                                                                                     UIScriptCommands.DirectoryTreeToggleExpand(firstRootDirectoriesVariable)))));
        }
Esempio n. 20
0
        /// <summary>
        /// Iterate an IEnumeration and return true if anyone's property equals to the specified variable.
        /// </summary>
        /// <example>
        /// IScriptCommand iterateCommand2 =
        ///    ScriptCommands.ForEachIfAnyValue<DateTime>("{Items}", "Day", ComparsionOperator.Equals, "Today.Day",
        ///	   ScriptCommands.PrintDebug("True"), ScriptCommands.PrintDebug("False"));
        /// </example>
        /// <param name="itemsVariable"></param>
        /// <param name="property"></param>
        /// <param name="op"></param>
        /// <param name="compareVariable"></param>
        /// <param name="nextCommand"></param>
        /// <param name="otherwiseCommand"></param>
        /// <returns></returns>
        public static IScriptCommand ForEachIfAnyValue(string itemsVariable       = "{Items}", string property = null,
                                                       ComparsionOperator op      = ComparsionOperator.Equals, string compareVariable = "{Variable}",
                                                       IScriptCommand nextCommand = null, IScriptCommand otherwiseCommand             = null)
        {
            string currentItemVariable     = ParameterDic.CombineVariable(itemsVariable.Replace(".", ""), "Current");
            string currentPropertyVariable = ParameterDic.CombineVariable(itemsVariable.Replace(".", ""), "Current" +
                                                                          ((property == null) ? "" : "." + property));
            string resultVariable = ParameterDic.CombineVariable(itemsVariable.Replace(".", ""), "Result");

            return
                (Assign(resultVariable, false, false,
                        ForEach(itemsVariable, currentItemVariable, resultVariable,
                                IfValue(op, currentPropertyVariable, compareVariable,
                                        Assign(resultVariable, true, false)),
                                IfTrue(resultVariable, nextCommand, otherwiseCommand))));
        }
Esempio n. 21
0
        /// <summary>
        /// Serializable, shortcut method for [AssignValueConverter], which obtains method result of a property from a variable and assign to another variable.
        /// </summary>
        /// <param name="sourceObjectVariable"></param>
        /// <param name="methodName"></param>
        /// <param name="parameters"></param>
        /// <param name="destinationVariable"></param>
        /// <param name="nextCommand"></param>
        /// <returns></returns>
        public static IScriptCommand ExecuteFunc(string sourceObjectVariable = "{Source}",
                                                 string methodName           = "Method", object[] parameters = null,
                                                 string destinationVariable  = "{Destination}", IScriptCommand nextCommand = null)
        {
            string valueConverterVariable = ParameterDic.CombineVariable(sourceObjectVariable, "Converter");

            List <object> methodParams = new List <object>();

            methodParams.Add(methodName);
            if (parameters != null)
            {
                methodParams.AddRange(parameters);
            }

            return(AssignValueConverter(ValueConverterType.ExecuteMethod, valueConverterVariable,
                                        ScriptCommands.Reassign(sourceObjectVariable, valueConverterVariable,
                                                                destinationVariable, false, nextCommand), methodParams.ToArray()));
        }