public UserDefinedFunctionNodeViewModel(
     CosmosUserDefinedFunction udf,
     IContainerContext context,
     NonLeafTreeNodeViewModel parent,
     ScriptCommands <CosmosUserDefinedFunction> commands,
     IMessenger messenger)
     : base(udf, context, parent, commands, messenger)
 {
 }
Exemplo n.º 2
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)));
        }
        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)));
        }
        public IExplorerViewModel OpenTab(IEntryModel model = null)
        {
            var initializer = _initializer.Clone();

            if (initializer is ExplorerInitializer)
            {
                ExplorerInitializer eInit = initializer as ExplorerInitializer;
                if (model != null)
                {
                    eInit.Initializers.Add(ExplorerInitializers.StartupDirectory(model));
                }
            }
            else
            if (initializer is ScriptCommandInitializer)
            {
                ScriptCommandInitializer sInit = initializer as ScriptCommandInitializer;

                sInit.OnViewAttached = (model != null) ?
                                       ScriptCommands.Assign("{StartupPath}", model.FullPath, false,
                                                             UIScriptCommands.ExplorerGotoStartupPathOrFirstRoot()) :
                                       UIScriptCommands.ExplorerGotoStartupPathOrFirstRoot();

                sInit.OnModelCreated = ScriptCommands.Assign("{TabbedExplorer}", this, false,
                                                             UIScriptCommands.ExplorerAssignScriptParameters("{Explorer}", "{TabbedExplorer}",
                                                                                                             sInit.OnModelCreated));
            }


            ExplorerViewModel expvm = new ExplorerViewModel(_windowManager, _events)
            {
                Initializer = initializer
            };

            //expvm.Commands.ParameterDicConverter.AddAdditionalParameters(new ParameterDic()
            //    {
            //        {"TabbedExplorer", this }
            //    });
            expvm.DropHelper = new TabDropHelper <IExplorerViewModel>(expvm, this);

            //expvm.FileList.Commands.CommandDictionary.CloseTab =
            //    UIScriptCommands.TabExplorerCloseTab("{TabbedExplorer}", "{Explorer}");
            ////ScriptCommands.ReassignToParameter("{Explorer}", TabbedExplorer.CloseTab(this));
            expvm.FileList.Commands.CommandDictionary.OpenTab =
                ScriptCommands.Assign("{TabbedExplorer}", this, false,
                                      FileList.AssignSelectionToParameter(
                                          UIScriptCommands.TabExplorerNewTab("{TabbedExplorer}", "{Parameter}", null)));
            expvm.DirectoryTree.Commands.CommandDictionary.OpenTab =
                ScriptCommands.Assign("{TabbedExplorer}", this, false,
                                      DirectoryTree.AssignSelectionToParameter(
                                          UIScriptCommands.TabExplorerNewTab("{TabbedExplorer}", "{Parameter}", null)));

            ActivateItem(expvm);
            checkTabs();

            return(expvm);
        }
Exemplo n.º 5
0
        public void Test_ExecuteFunc()
        {
            IParameterDic pm = new ParameterDic();

            Assert.IsTrue(runCommand(
                              ScriptCommands.Assign("{utcNow}", DateTime.UtcNow,
                                                    ScriptCommands.ExecuteFunc("{utcNow}", "AddDays",
                                                                               new object[] { 10 }, "{utcNow10}")), pm));
            Assert.AreNotEqual(pm.Get("{utcNow.Day}"), pm.Get("{utcNow10.Day}"));
        }
        /// <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))));
        }
Exemplo n.º 7
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)));
        }
        public static IScriptCommand SetDependencyPropertyValue <T>(string elementVariable,
                                                                    DependencyProperty property, T value, IScriptCommand nextCommand = null)
        {
            string propertyVariable = ParameterDic.CombineVariable(elementVariable, "Property");
            string valueVariable    = ParameterDic.CombineVariable(elementVariable, "Value");

            return(ScriptCommands.Assign(propertyVariable, property, false,
                                         ScriptCommands.Assign(valueVariable, value, false,
                                                               SetDependencyProperty(elementVariable, propertyVariable, valueVariable, nextCommand))));
        }
        /// <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>
        /// Obtain DataObject (IDataObject) and assign to a variable, or assign null if not found.
        /// </summary>
        /// <param name="mode"></param>
        /// <param name="iSupportDropVariable"></param>
        /// <param name="destinationVariable"></param>
        /// <param name="nextCommand"></param>
        /// <returns></returns>
        public static IScriptCommand QueryDataObjectFromDraggables(
            string iSupportDragVariable = "{ISupportDrag}", string draggablesVariable = "{Draggables}",
            string destinationVariable  = "{DataObj}", bool skipIfExists = false, IScriptCommand nextCommand = null)
        {
            IScriptCommand cmd = ScriptCommands.ExecuteFunc(iSupportDragVariable,
                                                            (ISupportDrag isd) => isd.GetDraggables(),
                                                            new object[] { }, destinationVariable, nextCommand);

            return(skipIfExists ? ScriptCommands.IfNotAssigned(destinationVariable, cmd) : cmd);
        }
        protected override Script.IScriptCommand onEvent(RoutedEvent eventId)
        {
            switch (eventId.Name)
            {
            case "MouseMove":
            case "TouchMove":
                return
                    (ScriptCommands.AssignGlobalParameterDic("{CanvasResize}", false,
                                                             ScriptCommands.IfTrue("{CanvasResize.IsResizing}",
                                                                                   HubScriptCommands.AssignCursorPosition(PositionRelativeToType.Panel, "{CanvasResize.CurrentPosition}", false,
                                                                                                                          HubScriptCommands.UpdateResizeItemAdorner("{CanvasResize.ResizeItemAdorner}",
                                                                                                                                                                    "{CanvasResize.ResizeMode}", "{CanvasResize.StartPosition}", "{CanvasResize.CurrentPosition}")))));

            //case "MouseDrag":
            //case "TouchDrag":
            case "PreviewTouchDown":
            case "PreviewMouseDown":
                return
                    (ScriptCommands.AssignGlobalParameterDic("{CanvasResize}", false,
                                                             HubScriptCommands.SetRoutedEventHandled(
                                                                 ScriptCommands.Assign("{CanvasResize.IsResizing}", true, false,
                                                                                       HubScriptCommands.AssignCursorPosition(PositionRelativeToType.Panel, "{CanvasResize.StartPosition}", false,
                                                                                                                              //Assign Source's Name (e.g. N, NW) to CanvasResize.ResizeMode.
                                                                                                                              ScriptCommands.Assign("{CanvasResize.ResizeMode}", "{EventArgs.Source.Name}", false,
                                                                                                                                                    HubScriptCommands.CaptureMouse(CaptureMouseMode.UIElement)))))));


            case "PreviewTouchUp":
            case "PreviewMouseUp":
                return
                    (ScriptCommands.Assign("{CanvasResize.ResizeItemAdorner.OffsetX}", 0, false,
                                           ScriptCommands.Assign("{CanvasResize.ResizeItemAdorner.OffsetY}", 0, false,
                                                                 ScriptCommands.AssignGlobalParameterDic("{CanvasResize}", false,
                                                                                                         ScriptCommands.Assign("{CanvasResize.IsResizing}", false, false,
                                                                                                                               HubScriptCommands.SetRoutedEventHandled(
                                                                                                                                   HubScriptCommands.CaptureMouse(CaptureMouseMode.Release,
                                                                                                                                                                  ScriptCommands.Subtract("{CanvasResize.CurrentPosition.X}", "{CanvasResize.StartPosition.X}", "{DiffX}",
                                                                                                                                                                                          ScriptCommands.Subtract("{CanvasResize.CurrentPosition.Y}", "{CanvasResize.StartPosition.Y}", "{DiffY}",
                                                                                                                                                                                                                  ScriptCommands.Switch <string>("{CanvasResize.ResizeMode}",
                                                                                                                                                                                                                                                 new Dictionary <string, IScriptCommand>()
                {
                    { "N", resizeNorthCommand },
                    { "NE", ScriptCommands.RunSequence(resizeNorthCommand, resizeEastCommand) },
                    { "E", resizeEastCommand },
                    { "SE", ScriptCommands.RunSequence(resizeSouthCommand, resizeEastCommand) },
                    { "S", resizeSouthCommand },
                    { "SW", ScriptCommands.RunSequence(resizeSouthCommand, resizeWestCommand) },
                    { "W", resizeWestCommand },
                    { "NW", ScriptCommands.RunSequence(resizeNorthCommand, resizeWestCommand) },
                },
                                                                                                                                                                                                                                                 ScriptCommands.PrintConsole("Not supported : {CanvasResize.ResizeMode}, {DiffX},{DiffY}")))))))))));
            }
            return(base.onEvent(eventId));
        }
Exemplo n.º 12
0
        public static IScriptCommand IfHasDataContext(
            string sourceElementVariable = "{EventArgs.OriginalSource}",
            DataContextType type         = DataContextType.SupportDrag,
            IScriptCommand nextCommand   = null, IScriptCommand otherwiseCommand = null)
        {
            string destVariable    = "{Temp_DataContextDest}";
            string destEleVariable = "{Temp_DataContextDestEle}";

            return(AssignDataContext(sourceElementVariable, type, destVariable, destEleVariable, false,
                                     ScriptCommands.IfAssigned(destVariable, nextCommand, otherwiseCommand)));
        }
Exemplo n.º 13
0
        public void Test_SubString()
        {
            IParameterDic pm  = new ParameterDic();
            string        str = "onceuponatime";

            Assert.IsTrue(runCommand(
                              ScriptCommands.Assign("{str}", str,
                                                    ScriptCommands.Substring("{str}", 4, "{outputStr}",
                                                                             ScriptCommands.Substring("{str}", 4, 4, "{outputStr2}"))), pm));
            Assert.AreEqual("uponatime", pm.Get("{outputStr}"));
            Assert.AreEqual("upon", pm.Get("{outputStr2}"));
        }
Exemplo n.º 14
0
        public void Test_GetProperty()
        {
            IParameterDic pm = new ParameterDic();

            Assert.IsTrue(runCommand(
                              ScriptCommands.Assign("{utcNow}", DateTime.UtcNow,
                                                    ScriptCommands.GetProperty("{utcNow}", "Ticks", "{ticks1}",
                                                                               ScriptCommands.Reassign("{utcNow.Ticks}", null, "{ticks2}"))), pm));
            Assert.AreNotEqual(0, pm.Get("{ticks1}"));
            Assert.AreEqual(pm.Get <long>("{ticks1}"),
                            pm.Get <long>("{ticks2}"));
        }
Exemplo n.º 15
0
        public void Test_GetArrayItem()
        {
            IParameterDic pm = new ParameterDic();

            int[] array = new[] { 1, 3, 5 };
            Assert.IsTrue(runCommand(
                              ScriptCommands.Assign("{array}", array,
                                                    ScriptCommands.GetArrayItem("{array}", 1, "{item1}",
                                                                                ScriptCommands.Reassign("{array[1]}", null, "{item2}"))), pm));
            Assert.AreEqual(3, pm.Get("{item1}"));
            Assert.AreEqual(3, pm.Get("{item2}"));
        }
Exemplo n.º 16
0
        public void Test_AssignValueFunc()
        {
            IParameterDic pm = new ParameterDic();
            DateTime      utcNow;

            bool success = runCommand(ScriptCommands.AssignValueFunc("{utcNow}",
                                                                     () => DateTime.UtcNow), pm);

            Assert.IsTrue(success);
            utcNow = pm.Get("{utcNow}", DateTime.MinValue);

            Assert.AreNotEqual(DateTime.MinValue, utcNow);
        }
 /// <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))));
 }
Exemplo n.º 18
0
 public TriggersFolderNodeViewModel(
     IContainerContext containerContext,
     NonLeafTreeNodeViewModel parent,
     ScriptCommands <CosmosTrigger> commands,
     IViewModelFactory viewModelFactory)
     : base("Triggers", containerContext, parent, viewModelFactory)
 {
     Commands = new[]
     {
         new CommandViewModel($"New trigger", commands.CreateCommand, this),
         CommandViewModel.Separator(),
         new CommandViewModel("Refresh", RefreshCommand)
     };
 }
Exemplo n.º 19
0
 public StoredProceduresFolderNodeViewModel(
     IContainerContext context,
     NonLeafTreeNodeViewModel parent,
     ScriptCommands <CosmosStoredProcedure> commands,
     IViewModelFactory viewModelFactory)
     : base("Stored procedures", context, parent, viewModelFactory)
 {
     Commands = new[]
     {
         new CommandViewModel($"New stored procedure", commands.CreateCommand, this),
         CommandViewModel.Separator(),
         new CommandViewModel("Refresh", RefreshCommand)
     };
 }
Exemplo n.º 20
0
 public DiskProfileBase(IEventAggregator events, params IConverterProfile[] converters)
     : base(events, converters)
 {
     MetadataProvider = new MetadataProviderBase(new BasicMetadataProvider(), new FileBasedMetadataProvider());
     CommandProviders.Add(new FileBasedCommandProvider());                                                                                                                            //Open, Cut, Copy, Paste etc
     DeleteCommand =
         ScriptCommands.AssignProperty("{DeleteEntries}", "Length", "{DeleteEntries-Length}",                                                                                         //Assign DeleteEntries Length
                                       ScriptCommands.IfValue <int>(ComparsionOperator.GreaterThanOrEqual, "{DeleteEntries.Length}", 1,                                               //If DeleteEntries Length >= 1
                                                                    UIScriptCommands.MessageBoxYesNo("FileExplorer", "Delete {DeleteEntries[0]} and {DeleteEntries-Length} Item(s)?", //IfTrue
                                                                                                     CoreScriptCommands.DiskDeleteMultiple("{DeleteEntries}", true))));
     CreateFolderCommand =
         CoreScriptCommands.DiskCreateFolder("{BaseFolder.Profile}", "{BaseFolder.FullPath}\\{FolderName}",
                                             "{CreatedFolder}", NameGenerationMode.Rename);
 }
Exemplo n.º 21
0
 public UserDefinedFunctionsFolderNodeViewModel(
     IContainerContext containerContext,
     NonLeafTreeNodeViewModel parent,
     ScriptCommands <CosmosUserDefinedFunction> commands,
     IViewModelFactory viewModelFactory)
     : base("User-defined functions", containerContext, parent, viewModelFactory)
 {
     Commands = new[]
     {
         new CommandViewModel($"New user-defined function", commands.CreateCommand, this),
         CommandViewModel.Separator(),
         new CommandViewModel("Refresh", RefreshCommand),
     };
 }
Exemplo n.º 22
0
        public void Test_ParameterDic_Not_Altered()
        {
            IParameterDic pm = new ParameterDic();

            pm.Set("{var1}", 1);
            ScriptRunner.RunScript(pm, false, //Not Cloned
                                   ScriptCommands.Assign("{var1}", 2));
            Assert.AreEqual(2, pm.Get <int>("{var1}", -1));

            pm.Set("{var1}", 1);
            ScriptRunner.RunScript(pm, true, //Cloned
                                   ScriptCommands.Assign("{var1}", 2));
            Assert.AreEqual(1, pm.Get <int>("{var1}", -1));
        }
Exemplo n.º 23
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            var vm      = DataContext as AddBookmarksViewModel;
            var rootDir = new IEntryModel[] { vm.Profile.RootModel };

            expFolderPicker.ViewModel.Initializer =
                new ScriptCommandInitializer()
            {
                OnModelCreated = UIScriptCommands.ExplorerDefault(),
                OnViewAttached = ScriptCommands.Assign("{StartupDir}", vm.CurrentBookmarkDirectory, false,
                                                       ScriptCommands.Assign("{StartupPath}", "{StartupDir.FullPath}", false,
                                                                             UIScriptCommands.ExplorerGotoStartupPathOrFirstRoot())),
                RootModels        = rootDir,
                StartupParameters = new ParameterDic()
                {
                    { "Profiles", vm.Profile },
                    { "RootDirectories", rootDir },
                    //{  "StartupPath", vm.CurrentBookmarkDirectory.FullPath },
                    //{ "StartupPath", _selectedPath },
                    //{ "FilterString", _filterStr },
                    { "ViewMode", "List" },
                    { "ItemSize", 16 },
                    { "EnableDrag", true },
                    { "EnableDrop", true },
                    { "EnableMap", false },
                    { "FileListNewWindowCommand", NullScriptCommand.Instance },      //Disable NewWindow Command.
                    { "EnableMultiSelect", true },
                    { "ShowToolbar", false },
                    { "ShowGridHeader", false }
                }
            };

            expFolderPicker.ViewModel.FileList.PropertyChanged += (o, e) =>
            {
                if (e.PropertyName == "CurrentDirectory")
                {
                    vm.CurrentBookmarkDirectory = expFolderPicker.ViewModel.FileList.CurrentDirectory;
                }
            };
            vm.PropertyChanged += (o, e) =>
            {
                if (e.PropertyName == "CurrentBookmarkDirectory")
                {
                    expFolderPicker.ViewModel.FileList.CurrentDirectory = vm.CurrentBookmarkDirectory;
                }
            };
        }
Exemplo n.º 24
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)));
 }
Exemplo n.º 25
0
        public void Test_SetProperty()
        {
            IParameterDic pm  = new ParameterDic();
            testClass     obj = new testClass()
            {
                val1 = 1, val2 = 2
            };

            Assert.IsTrue(runCommand(
                              ScriptCommands.Assign("{obj}", obj,
                                                    ScriptCommands.SetProperty("{obj}", "val1", "{obj.val2}",
                                                                               ScriptCommands.Assign("{obj.val2}", 1))), pm));
            Assert.AreEqual(2, pm.Get <int>("{obj.val1}"));
            Assert.AreEqual(1, pm.Get <int>("{obj.val2}"));
        }
        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.º 27
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            //Assign commands in run time.

            //RootVM is defined in ParameterDicConverter, where Parameter is from ICommand.CommandParameter.
            _rvm.Commands.AddRandom =
                ScriptCommands.AssignMethodResult("{RootVM}", "AddRandomNumber", null, "{Output}",
                                                  ScriptCommands.PrintDebug("{Output} Added."));
            //-> thus _rvm.Commands.AddRandomCommand is Bindable RelayCommand.
            _rvm.Commands.Add =
                ScriptCommands.ExecuteMethod("{RootVM}", "AddNumber", new object[] { "{Parameter}" },
                                             ScriptCommands.PrintDebug("{Parameter} Added."));
            //Not necessary use ExecuteMethod, as one can define their own commands.
        }
Exemplo n.º 28
0
 public static IScriptCommand ExplorerNewMdiWindow(WPF.MDI.MdiContainer container,
                                                   IProfile[] profiles, IEntryModel[] rootDirectories,
                                                   string explorerVariable = "{Explorer}", IScriptCommand nextCommand = null)
 {
     return(ScriptCommands.Assign(new Dictionary <string, object>()
     {
         { "{MdiContainer}", container },
         { "{Profiles}", profiles },
         { "{RootDirectories}", rootDirectories },
         { "{OnModelCreated}", ScriptCommands.RunSequence(null,
                                                          TestAppCommands.MdiExplorer_Initialize_Default,
                                                          UIScriptCommands.ExplorerAssignScriptParameters("{Explorer}", "{MdiContainer},{RootDirectories}")) },
         { "{OnViewAttached}", UIScriptCommands.ExplorerGotoStartupPathOrFirstRoot() }
     }, false,
                                  TestAppCommands.ExplorerNewMdiWindow("{MdiContainer}", "{WindowManager}", "{GlobalEvents}", "{Explorer}", nextCommand)));
 }
Exemplo n.º 29
0
        public void Test_ArithmeticCommands()
        {
            IParameterDic pm = new ParameterDic();
            int           val1 = 1; int val2 = 2;

            //Assert.IsTrue(runCommand(
            //    ScriptCommands.Assign(val1,
            //        ScriptCommands.Assign(val2,
            //          ScriptCommands.Add("{val1}", "{val2}", "{outputVal}"))), pm));
            Assert.IsTrue(runCommand(
                              ScriptCommands.AssignMulti(
                                  ScriptCommands.Add("{val1}", "{val2}", "{outputVal}"),
                                  () => val1,
                                  () => val2), pm));
            Assert.AreEqual(3, pm.Get("{outputVal}"));
        }
Exemplo n.º 30
0
        public void Test_ForEach()
        {
            int[]         array = new int[] { 1, 3, 5 };
            IParameterDic pm    = new ParameterDic();
            int           sum;

            bool success = runCommand(
                ScriptCommands.Assign("{array}", array,
                                      ScriptCommands.ForEach("{array}", "{i}",
                                                             ScriptCommands.Add("{i}", "{sum}", "{sum}"))), pm);

            Assert.IsTrue(success);
            sum = pm.Get <int>("{sum}");

            Assert.AreEqual(9, sum);
        }
Exemplo n.º 31
0
        public MapScriptLine(String line)
        {
            if (line.Length < 1)
                return;

            StringParameter = line.Split(' ');
            switch (StringParameter[0])
            {
                case "fog":
                    Command = ScriptCommands.Fog;
                    IntParameter = Convert.ToInt32(StringParameter[1]);
                    break;
                case "water":
                    Command = ScriptCommands.Water;
                    IntParameter = Convert.ToInt32(StringParameter[1]);
                    break;

                case "monster":
                    Command = ScriptCommands.Monster;
                    Vector2Parameter = new Vector2(
                        Convert.ToSingle(StringParameter[2]),
                        Convert.ToSingle(StringParameter[3])
                        );
                    break;
                case "makebucket":
                    Command = ScriptCommands.MakeBucket;
                    IntParameter = Convert.ToInt32(StringParameter[1]);
                    break;
                case "addbucket":
                    Command = ScriptCommands.AddBucket;
                    Vector2Parameter = new Vector2(Convert.ToSingle(StringParameter[2]),
                        Convert.ToSingle(StringParameter[3]));
                    break;
                case "ifnotbucketgoto":
                    Command = ScriptCommands.IfNotBucketGoto;
                    break;

                case "wait":
                    Command = ScriptCommands.Wait;
                    IntParameter = Convert.ToInt32(StringParameter[1]);
                    break;

                case "setflag":
                    Command = ScriptCommands.SetFlag;
                    break;
                case "iftruegoto":
                    Command = ScriptCommands.IfTrueGoto;
                    break;
                case "iffalsegoto":
                    Command = ScriptCommands.IfFalseGoto;
                    break;

                case "setglobalflag":
                    Command = ScriptCommands.SetGlobalFlag;
                    break;
                case "ifglobaltruegoto":
                    Command = ScriptCommands.IfGlobalTrueGoto;
                    break;
                case "ifglobalfalsegoto":
                    Command = ScriptCommands.IfGlobalFalseGoto;
                    break;

                case "stop":
                    Command = ScriptCommands.Stop;
                    break;
                case "tag":
                    Command = ScriptCommands.Tag;
                    break;

                case "setleftexit":
                    Command = ScriptCommands.SetLeftExit;
                    break;
                case "setleftentrance":
                    Command = ScriptCommands.SetLeftEntrance;
                    Vector2Parameter = new Vector2(Convert.ToSingle(StringParameter[1]),
                        Convert.ToSingle(StringParameter[2]));
                    break;
                case "setrightexit":
                    Command = ScriptCommands.SetRightExit;
                    break;
                case "setrightentrance":
                    Command = ScriptCommands.SetRightEntrance;
                    Vector2Parameter = new Vector2(Convert.ToSingle(StringParameter[1]),
                        Convert.ToSingle(StringParameter[2]));
                    break;
                case "setintroentrance":
                    Command = ScriptCommands.SetIntroEntrance;
                    Vector2Parameter = new Vector2(Convert.ToSingle(StringParameter[1]),
                        Convert.ToSingle(StringParameter[2]));
                    break;
                default:
                    break;
            }
        }