Пример #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(); });
        }
Пример #2
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());
        }
Пример #3
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(); });
        }