Esempio n. 1
0
        private async Task Build(string str)
        {
            str = str.Trim();
            var resultCode = CheckCode(str);

            if (resultCode != 0)
            {
                Message = $"line {resultCode}: Error! IncorrectCommand";
                return;
            }
            BreakPoints.Clear();
            foreach (var command in Commands)
            {
                if (command.IsBreakpointSet)
                {
                    BreakPoints.Add(command.CommandId);
                }
            }
            Commands = FromsStringtoCommands(str);
            for (int i = 0; i < Commands.Count; i++)
            {
                if (BreakPoints.Contains(Commands[i].CommandId))
                {
                    Commands[i].IsBreakpointSet = true;
                }
            }
            CurrentCommand = Commands.First();

            SaveProjectCommand.Execute("Build");
            await Task.Factory.StartNew(() => SendMessage("Sucessfully Compiled!"));

            Start();
        }
Esempio n. 2
0
        public MainWindowViewModel(MainWindow mainWindow)
        {
            MainWindow = mainWindow;
            RoutedCommand saveHotkey = new RoutedCommand();

            saveHotkey.InputGestures.Add(new KeyGesture(Key.S, ModifierKeys.Control));
            MainWindow.CommandBindings.Add(new CommandBinding(saveHotkey,
                                                              new ExecutedRoutedEventHandler((object sender, ExecutedRoutedEventArgs e) =>
            {
                SaveProjectCommand.Execute(null);
            })));
            RoutedCommand loadHotkey = new RoutedCommand();

            loadHotkey.InputGestures.Add(new KeyGesture(Key.O, ModifierKeys.Control));
            MainWindow.CommandBindings.Add(new CommandBinding(loadHotkey,
                                                              new ExecutedRoutedEventHandler((object sender, ExecutedRoutedEventArgs e) =>
            {
                LoadProjectCommand.Execute(null);
            })));
            RoutedCommand exportHotkey = new RoutedCommand();

            exportHotkey.InputGestures.Add(new KeyGesture(Key.E, ModifierKeys.Control));
            MainWindow.CommandBindings.Add(new CommandBinding(exportHotkey,
                                                              new ExecutedRoutedEventHandler((object sender, ExecutedRoutedEventArgs e) =>
            {
                ExportProjectCommand.Execute(null);
            })));
            RoutedCommand newFileHotkey = new RoutedCommand();

            newFileHotkey.InputGestures.Add(new KeyGesture(Key.N, ModifierKeys.Control));
            MainWindow.CommandBindings.Add(new CommandBinding(newFileHotkey,
                                                              new ExecutedRoutedEventHandler((object sender, ExecutedRoutedEventArgs e) =>
            {
                NewProjectCommand.Execute(null);
            })));
            RoutedCommand logWindow = new RoutedCommand();

            logWindow.InputGestures.Add(new KeyGesture(Key.F1, ModifierKeys.Control));
            MainWindow.CommandBindings.Add(new CommandBinding(logWindow,
                                                              new ExecutedRoutedEventHandler((object sender, ExecutedRoutedEventArgs e) =>
            {
                if (ConsoleLogger.IsOpened)
                {
                    ConsoleLogger.HideConsoleWindow();
                }
                else
                {
                    ConsoleLogger.ShowConsoleWindow();
                }
            })));
            RoutedCommand pasteCommand = new RoutedCommand();

            pasteCommand.InputGestures.Add(new KeyGesture(Key.V, ModifierKeys.Control));
            MainWindow.CommandBindings.Add(new CommandBinding(pasteCommand,
                                                              new ExecutedRoutedEventHandler((object sender, ExecutedRoutedEventArgs e) =>
            {
                switch (MainWindow.mainTabControl.SelectedIndex)
                {
                case 0 when CharacterTabViewModel.Character != null:         // character (condition)
                    {
                        if (ClipboardManager.TryGetObject(ClipboardManager.ConditionFormat, out var obj) && obj is Condition cond)
                        {
                            CharacterTabViewModel.Character.visibilityConditions.Add(cond);
                        }
                    }
                    break;

                case 1 when DialogueTabViewModel.Dialogue != null:         // dialogue (nothing at this moment)
                    {
                    }
                    break;

                case 2 when VendorTabViewModel.Vendor != null:         // vendor (vendor item)
                    {
                        if (ClipboardManager.TryGetObject(ClipboardManager.VendorItemFormat, out var obj) && obj is VendorItem item)
                        {
                            if (item.isBuy)
                            {
                                VendorTabViewModel.AddItemBuy(item);
                            }
                            else
                            {
                                VendorTabViewModel.AddItemSell(item);
                            }
                        }
                    }
                    break;

                case 3 when QuestTabViewModel.Quest != null:         // quest (condition, reward)
                    {
                        if (ClipboardManager.TryGetObject(ClipboardManager.ConditionFormat, out var obj) && obj is Condition cond)
                        {
                            QuestTabViewModel.AddCondition(new Controls.Universal_ItemList(cond, true));
                        }
                        else if (ClipboardManager.TryGetObject(ClipboardManager.RewardFormat, out obj) && obj is Reward rew)
                        {
                            QuestTabViewModel.AddReward(new Controls.Universal_ItemList(rew, true));
                        }
                    }
                    break;
                }
            })));
            CharacterTabViewModel = new CharacterTabViewModel();
            DialogueTabViewModel  = new DialogueTabViewModel();
            VendorTabViewModel    = new VendorTabViewModel();
            QuestTabViewModel     = new QuestTabViewModel();
            CurrencyTabViewModel  = new CurrencyTabViewModel();
            MainWindow.mainTabControl.SelectionChanged += TabControl_SelectionChanged;

            MainWindow.CurrentProject.OnDataLoaded += () =>
            {
                ResetAll();

                ProjectData proj = MainWindow.CurrentProject;
                NPCProject  data = proj.data;

                if (data.lastCharacter > -1 && data.lastCharacter < data.characters.Count)
                {
                    CharacterTabViewModel.Character = data.characters[data.lastCharacter];
                }

                if (data.lastDialogue > -1 && data.lastDialogue < data.dialogues.Count)
                {
                    DialogueTabViewModel.Dialogue = data.dialogues[data.lastDialogue];
                }

                if (data.lastVendor > -1 && data.lastVendor < data.vendors.Count)
                {
                    VendorTabViewModel.Vendor = data.vendors[data.lastVendor];
                }

                if (data.lastQuest > -1 && data.lastQuest < data.quests.Count)
                {
                    QuestTabViewModel.Quest = data.quests[data.lastQuest];
                }

                if (data.lastCurrency > -1 && data.lastCurrency < data.currencies.Count)
                {
                    CurrencyTabViewModel.Currency = data.currencies[data.lastCurrency];
                }

                UpdateAllTabs();
            };
        }
Esempio n. 3
0
        public MainWindowViewModel(MainWindow mainWindow)
        {
            MainWindow = mainWindow;
            RoutedCommand saveHotkey = new RoutedCommand();

            saveHotkey.InputGestures.Add(new KeyGesture(Key.S, ModifierKeys.Control));
            MainWindow.CommandBindings.Add(new CommandBinding(saveHotkey,
                                                              new ExecutedRoutedEventHandler((object sender, ExecutedRoutedEventArgs e) =>
            {
                SaveProjectCommand.Execute(null);
            })));
            RoutedCommand loadHotkey = new RoutedCommand();

            loadHotkey.InputGestures.Add(new KeyGesture(Key.O, ModifierKeys.Control));
            MainWindow.CommandBindings.Add(new CommandBinding(loadHotkey,
                                                              new ExecutedRoutedEventHandler((object sender, ExecutedRoutedEventArgs e) =>
            {
                LoadProjectCommand.Execute(null);
            })));
            RoutedCommand exportHotkey = new RoutedCommand();

            exportHotkey.InputGestures.Add(new KeyGesture(Key.E, ModifierKeys.Control));
            MainWindow.CommandBindings.Add(new CommandBinding(exportHotkey,
                                                              new ExecutedRoutedEventHandler((object sender, ExecutedRoutedEventArgs e) =>
            {
                ExportProjectCommand.Execute(null);
            })));
            RoutedCommand newFileHotkey = new RoutedCommand();

            newFileHotkey.InputGestures.Add(new KeyGesture(Key.N, ModifierKeys.Control));
            MainWindow.CommandBindings.Add(new CommandBinding(newFileHotkey,
                                                              new ExecutedRoutedEventHandler((object sender, ExecutedRoutedEventArgs e) =>
            {
                NewProjectCommand.Execute(null);
            })));
            RoutedCommand logWindow = new RoutedCommand();

            logWindow.InputGestures.Add(new KeyGesture(Key.F1, ModifierKeys.Control));
            MainWindow.CommandBindings.Add(new CommandBinding(logWindow,
                                                              new ExecutedRoutedEventHandler((object sender, ExecutedRoutedEventArgs e) =>
            {
                if (ConsoleLogger.IsOpened)
                {
                    ConsoleLogger.HideConsoleWindow();
                }
                else
                {
                    ConsoleLogger.ShowConsoleWindow();
                }
            })));
            CharacterTabViewModel = new CharacterTabViewModel();
            DialogueTabViewModel  = new DialogueTabViewModel();
            VendorTabViewModel    = new VendorTabViewModel();
            QuestTabViewModel     = new QuestTabViewModel();
            MainWindow.mainTabControl.SelectionChanged += TabControl_SelectionChanged;

            MainWindow.CurrentProject.OnDataLoaded += () =>
            {
                ResetAll();

                ProjectData proj = MainWindow.CurrentProject;
                NPCProject  data = proj.data;

                if (data.lastCharacter > -1)
                {
                    CharacterTabViewModel.Character = data.characters[data.lastCharacter];
                }

                if (data.lastDialogue > -1)
                {
                    DialogueTabViewModel.Dialogue = data.dialogues[data.lastDialogue];
                }

                if (data.lastVendor > -1)
                {
                    VendorTabViewModel.Vendor = data.vendors[data.lastVendor];
                }

                if (data.lastQuest > -1)
                {
                    QuestTabViewModel.Quest = data.quests[data.lastQuest];
                }
            };
        }
        public void LoadProject()
        {
            var history = new Mock<ITimeline>();
            {
                history.Setup(h => h.Mark(It.IsAny<string>()))
                    .Verifiable();
            }

            var project = new Mock<IProject>();
            {
                project.Setup(p => p.History)
                    .Returns(history.Object);
                project.Setup(p => p.Save(It.IsAny<IPersistenceInformation>()))
                    .Verifiable();
            }

            var projectFacade = new ProjectFacade(project.Object);
            var projectLink = new Mock<ILinkToProjects>();
            {
                projectLink.Setup(p => p.HasActiveProject())
                    .Returns(true);
                projectLink.Setup(p => p.ActiveProject())
                    .Returns(projectFacade);
            }

            Func<string, IDisposable> timerFunc = s => new MockDisposable();

            var command = new SaveProjectCommand(projectLink.Object, timerFunc);

            var persistence = new Mock<IPersistenceInformation>();
            command.Execute(persistence.Object);

            project.Verify(p => p.Save(It.IsAny<IPersistenceInformation>()), Times.Once());
            history.Verify(h => h.Mark(It.IsAny<string>()), Times.Once());
        }
        private void SaveProj(object sender, ExecutedRoutedEventArgs e)
        {
            var cmd = new SaveProjectCommand();

            cmd.Execute(e.Parameter);
        }
        public void Execute_should_save_the_current_test_filter()
        {
            command.Execute(NullProgressMonitor.CreateInstance());

            saveFilterCommand.AssertWasCalled(c => c.Execute(Arg <IProgressMonitor> .Is.Anything));
        }