Ejemplo n.º 1
0
        public MainMenuViewModel()
        {
            SaveCommand = ReactiveCommand.Create();
            SaveCommand.Subscribe(_ => { ShellViewModel.Instance.Save(); });

            SaveAllCommand = ReactiveCommand.Create();
            SaveAllCommand.Subscribe(_ => { ShellViewModel.Instance.SaveAll(); });

            CleanProjectCommand = ReactiveCommand.Create();
            CleanProjectCommand.Subscribe(_ => { ShellViewModel.Instance.Clean(); });

            BuildProjectCommand = ReactiveCommand.Create();
            BuildProjectCommand.Subscribe(_ => { ShellViewModel.Instance.Build(); });

            PackagesCommand = ReactiveCommand.Create();
            PackagesCommand.Subscribe(o => { ShellViewModel.Instance.ShowPackagesDialog(); });

            ProjectPropertiesCommand = ReactiveCommand.Create();
            ProjectPropertiesCommand.Subscribe(o => { ShellViewModel.Instance.ShowProjectPropertiesDialog(); });

            NewProjectCommand = ReactiveCommand.Create();
            NewProjectCommand.Subscribe(o =>
            {
                // ShellViewModel.Instance.ShowNewProjectDialog();
            });

            ExitCommand = ReactiveCommand.Create();
            ExitCommand.Subscribe(o => { ShellViewModel.Instance.ExitApplication(); });
        }
Ejemplo n.º 2
0
        public void CanCreateNewProjectWithNullFacade()
        {
            Func<string, IDisposable> timerFunc = s => new MockDisposable();

            var command = new NewProjectCommand(null, timerFunc);
            Assert.IsFalse(command.CanExecute(null));
        }
Ejemplo n.º 3
0
 public void SetUp()
 {
     projectController  = MockRepository.GenerateStub <IProjectController>();
     commandFactory     = MockRepository.GenerateStub <ICommandFactory>();
     loadPackageCommand = MockRepository.GenerateStub <ICommand>();
     commandFactory.Stub(cf => cf.CreateLoadPackageCommand()).Return(loadPackageCommand);
     command = new NewProjectCommand(projectController, commandFactory);
 }
Ejemplo n.º 4
0
 private void RegisterCommands()
 {
     NewProjectCommand = new NewProjectCommand(this);
     NewProjectFromStructureCommand = new NewProjectFromStructureCommand(this);
     AddStructureToProjectCommand   = new AddStructureToProjectCommand(this);
     LoadProjectCommand             = new LoadProjectCommand(this);
     SaveProjectCommand             = new SaveProjectCommand(this);
     LoadProjectCodeCommand         = new LoadProjectCodeCommand(this);
     CreateProjectCodeCommand       = new CreateProjectCodeCommand(this);
 }
Ejemplo n.º 5
0
        public void CanCreateNewProjectWithFacadeUnableToCreate()
        {
            var project = new Mock<ILinkToProjects>();
            {
                project.Setup(p => p.CanCreateNewProject())
                    .Returns(false);
            }

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

            var command = new NewProjectCommand(project.Object, timerFunc);
            Assert.IsFalse(command.CanExecute(null));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Initalize the values.
        /// </summary>
        public ProjectViewModel()
            : base("Projects")
        {
            // Set Event Aggregator
            _events = IoC.Get <IEventAggregator>();

            // New Project command
            NewProjectCommand = ReactiveCommand.Create();
            NewProjectCommand.Subscribe(_ => NewProject());

            // Load Project command
            LoadProjectCommand = ReactiveCommand.Create();
            LoadProjectCommand.Subscribe(_ => LoadProject());
        }
        public ProjectsPageViewModel()
        {
            NewProjectCommand  = new NewProjectCommand(this);
            AddTaskCommand     = new AddTaskCommand(this);
            RemoveTaskCommand  = new RemoveTaskCommand(this);
            SaveProjectCommand = new SaveProjectCommand(this);
            OpenProjectCommand = new OpenProjectCommand(this);

            EnumList = new List <Stage>();
            foreach (Stage stage in Enum.GetValues(typeof(Stage)))
            {
                EnumList.Add(stage);
            }
        }
Ejemplo n.º 8
0
        private void SubscribeCommands()
        {
            ProjectSettingCommand.Subscribe(x => OpenProjectSetting());

            NewProjectCommand.PublishTask(x => Editor.Value.NewProjectAsync(),
                                          e => ShowError(e, "プロジェクトの作成に失敗しました。"));
            OpenProjectCommand.PublishTask(x => Editor.Value.OpenAsync(),
                                           e => ShowError(e, "データを読み込めませんでした。"));
            SaveCommand.PublishTask(x => Editor.Value.SaveAsync(),
                                    e => ShowError(e, "保存を中止し、以前のファイルに復元しました。"));
            SaveAsCommand.PublishTask(x => Editor.Value.SaveAsAsync(),
                                      e => ShowError(e, "保存を中止しました。"));
            CloseCanceledCommand.PublishTask(x => Editor.Value.CloseProjectAsync(),
                                             e => ShowError(e, "ウィンドウを閉じることができませんでした。"));
        }
Ejemplo n.º 9
0
        public void CreateNewProject()
        {
            var project = new Mock<ILinkToProjects>();
            {
                project.Setup(p => p.NewProject())
                    .Verifiable();
            }

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

            var command = new NewProjectCommand(project.Object, timerFunc);
            command.Execute(null);

            project.Verify(p => p.NewProject(), Times.Once());
        }
        /// <summary>
        /// Creates a new instance of <see cref="VisualDropStartScreen"/>.
        /// </summary>
        /// <param name="openProjectCommandFactory">A factory that provides an instance of <see cref="OpenProjectCommand"/>.</param>
        /// <param name="newProjectCommandFactory">A factory that provides an instance of <see cref="NewProjectCommand"/>.</param>
        public VisualDropStartScreen(
            Func <OpenProjectCommand> openProjectCommandFactory,
            Func <OpenTemplateCommand> openTemplateCommandFactory,
            Func <NewProjectCommand> newProjectCommandFactory)
        {
            _openProjectCommand  = openProjectCommandFactory();
            _openTemplateCommand = openTemplateCommandFactory();
            _newProjectCommand   = newProjectCommandFactory();
            PopulateTargetSpectrumValues();

            for (int i = 0; i < _targetSpectrumLogoValues.Count; i++)
            {
                SpectrumLogoValues.Add(_targetSpectrumLogoValues[i]);
            }

            GenerateAnimationFrames();
        }
Ejemplo n.º 11
0
        private void InitializeCommands()
        {
            NewProjectCommand              = new NewProjectCommand(this);
            SaveChangesCommand             = new SaveChangesCommand(this);
            RemoveSelectedNewActionCommand = new RemoveSelectedNewActionCommand(this);
            OpenFileCommand             = new OpenFileCommand(this);
            ExecuteActionCommand        = new ExecuteActionCommand(this);
            OpenAddActionDialogCommand  = new OpenAddActionDialogCommand(this);
            CloseAddActionDialogCommand = new CloseAddActionDialogCommand(this);

            RegisterCommand(NewProjectCommand);
            RegisterCommand(SaveChangesCommand);
            RegisterCommand(RemoveSelectedNewActionCommand);
            RegisterCommand(OpenFileCommand);
            RegisterCommand(ExecuteActionCommand);
            RegisterCommand(OpenAddActionDialogCommand);
            RegisterCommand(CloseAddActionDialogCommand);

            RaiseCanExecuteCommandChanged();
        }
Ejemplo n.º 12
0
        public SolutionViewModel(ISolution model) : base(model)
        {
            shell = IoC.Get <IShell>();

            Projects   = new ObservableCollection <ProjectViewModel>();
            IsExpanded = true;

            Projects.BindCollections(model.Projects, p => { return(ProjectViewModel.Create(this, p)); },
                                     (pvm, p) => pvm.Model == p);

            NewProjectCommand = ReactiveCommand.Create();
            NewProjectCommand.Subscribe(o =>
            {
                shell.ModalDialog = new NewProjectDialogViewModel(model);
                shell.ModalDialog.ShowDialog();
            });

            AddExistingProjectCommand = ReactiveCommand.Create();
            AddExistingProjectCommand.Subscribe(async o =>
            {
                var dlg   = new OpenFileDialog();
                dlg.Title = "Open Project";

                var extensions = new List <string>();

                foreach (var projectType in shell.ProjectTypes)
                {
                    extensions.AddRange(projectType.Extensions);
                }

                dlg.Filters.Add(new FileDialogFilter {
                    Name = "AvalonStudio Project", Extensions = extensions
                });
                dlg.InitialFileName  = string.Empty;
                dlg.InitialDirectory = Model.CurrentDirectory;
                dlg.AllowMultiple    = false;

                var result = await dlg.ShowAsync();

                if (result != null && result.Length == 1)
                {
                    var proj = Solution.LoadProjectFile(model, result[0]);

                    if (proj != null)
                    {
                        model.AddProject(proj);
                        model.Save();
                    }
                }
            });

            OpenInExplorerCommand = ReactiveCommand.Create();
            OpenInExplorerCommand.Subscribe(o => { Platform.OpenFolderInExplorer(model.CurrentDirectory); });

            ConfigurationCommand = ReactiveCommand.Create();
            ConfigurationCommand.Subscribe(o =>
            {
                //Workspace.Instance.ModalDialog = new SolutionConfigurationDialogViewModel(Workspace.Instance.SolutionExplorer.Model);
                //Workspace.Instance.ModalDialog.ShowDialog();
            });

            BuildSolutionCommand = ReactiveCommand.Create();
            BuildSolutionCommand.Subscribe(o => { BuildSolution(); });

            CleanSolutionCommand = ReactiveCommand.Create();
            CleanSolutionCommand.Subscribe(o => { CleanSolution(); });

            RebuildSolutionCommand = ReactiveCommand.Create();
            RebuildSolutionCommand.Subscribe(o =>
            {
                CleanSolution();

                BuildSolution();
            });

            RunAllTestsCommand = ReactiveCommand.Create();
            RunAllTestsCommand.Subscribe(o => { RunTests(); });
        }
Ejemplo n.º 13
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();
            };
        }
Ejemplo n.º 14
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];
                }
            };
        }
Ejemplo n.º 15
0
        public async Task <ActionResult <ProjectDto> > NewProject(NewProjectCommand newProject)
        {
            var createdProject = await Mediator.Send(newProject);

            return(Ok(createdProject));
        }