public StandardProjectViewModel(ISolutionParentViewModel parent, IProject model) : base(parent, model) { if (model.Solution.StartupProject == model) { this.VisitParents(parentVm => { parentVm.IsExpanded = true; }); IsExpanded = true; } NewFileCommand = ReactiveCommand.Create(async() => { var observable = Items.ObserveNewItems().OfType <SourceFileViewModel>().FirstOrDefaultAsync(); using (var subscription = observable.Subscribe(item => { item.InEditMode = true; })) { File.CreateText(Path.Combine(model.CurrentDirectory, "NewFile1")); await observable; } }); }
public StandardProjectViewModel(ISolutionParentViewModel parent, IProject model) : base(parent, model) { if (model.Solution.StartupProject == model) { this.VisitParents(parentVm => { parentVm.IsExpanded = true; }); IsExpanded = true; } }
public static SolutionItemViewModel Create(ISolutionParentViewModel parent, ISolutionItem item) { SolutionItemViewModel result = null; if (item is ISolutionFolder folder) { result = new SolutionFolderViewModel(parent, folder); } else if (item is IProject project) { result = new StandardProjectViewModel(parent, project); } else { throw new Exception("Unrecognised model type"); } return(result); }
public ProjectViewModel(ISolutionParentViewModel parent, IProject model) : base(parent, model) { shell = IoC.Get <IShell>(); Items = new ObservableCollection <ProjectItemViewModel>(); Items.BindCollections(model.Items, p => { return(ProjectItemViewModel.Create(p)); }, (pivm, p) => pivm.Model == p); ConfigureCommand = ReactiveCommand.Create(() => { if (configuration == null) { configuration = new ProjectConfigurationDialogViewModel(model, () => { configuration = null; }); shell.AddDocument(configuration); } else { shell.SelectedDocument = configuration; } //shell.ModalDialog.ShowDialog(); }); DebugCommand = ReactiveCommand.Create(() => { //shell.Debug(model); }); BuildCommand = ReactiveCommand.Create(() => shell.Build(model)); CleanCommand = ReactiveCommand.Create(() => shell.Clean(model)); ManageReferencesCommand = ReactiveCommand.Create(() => { }); SetProjectCommand = ReactiveCommand.Create(() => { model.Solution.StartupProject = model; model.Solution.Save(); shell.InvalidateCodeAnalysis(); var root = this.FindRoot(); if (root != null) { root.VisitChildren(solutionItem => { solutionItem.RaisePropertyChanged(nameof(FontWeight)); }); } }); OpenInExplorerCommand = ReactiveCommand.Create(() => Platform.OpenFolderInExplorer(Model.CurrentDirectory)); NewItemCommand = ReactiveCommand.Create(() => { shell.ModalDialog = new NewItemDialogViewModel(model); shell.ModalDialog.ShowDialog(); }); RemoveCommand = ReactiveCommand.Create(() => { shell.CloseDocumentsForProject(Model); Model.Solution.RemoveItem(Model); Model.Solution.Save(); }); DevConsoleCommand = ReactiveCommand.Create(() => { PlatformSupport.LaunchShell(Model.CurrentDirectory, Model.ToolChain?.BinDirectory, Model.Debugger2?.BinDirectory); }); }
public SolutionParentViewModel(ISolutionParentViewModel parent, T model) : base(parent, model) { Items = new ObservableCollection <SolutionItemViewModel>(); Items.BindCollections(Model.Items, p => { return(SolutionItemViewModel.Create(this, p)); }, (pvm, p) => pvm.Model == p); AddNewFolderCommand = ReactiveCommand.Create(() => { Model.Solution.AddItem(SolutionFolder.Create("New Folder"), null, Model); Model.Solution.Save(); }); AddExistingProjectCommand = ReactiveCommand.Create(async() => { var dlg = new OpenFileDialog(); dlg.Title = "Open Project"; var shell = IoC.Get <IShell>(); foreach (var projectType in shell.ProjectTypes) { var projectTypeMetadata = projectType.Metadata; var extensions = new List <string>(); extensions.Add(projectTypeMetadata.DefaultExtension); extensions.AddRange(projectTypeMetadata.PossibleExtensions); dlg.Filters.Add(new FileDialogFilter() { Name = projectTypeMetadata.Description, Extensions = extensions }); } dlg.InitialDirectory = Model.Solution.CurrentDirectory; dlg.AllowMultiple = false; var result = await dlg.ShowAsync(); if (result != null && !string.IsNullOrEmpty(result.FirstOrDefault())) { var projectTypeGuid = ProjectUtils.GetProjectTypeGuidForProject(result[0]); if (projectTypeGuid.HasValue) { var proj = await ProjectUtils.LoadProjectFileAsync(Model.Solution, projectTypeGuid.Value, result[0]); if (proj != null) { Model.Solution.AddItem(proj, projectTypeGuid, Model); Model.Solution.Save(); } } else { IoC.Get <Utils.IConsole>().WriteLine( $"The project '{result[0]}' isn't supported by any installed project type!"); } } }); AddNewProjectCommand = ReactiveCommand.Create(() => { var shell = IoC.Get <IShell>(); shell.ModalDialog = new NewProjectDialogViewModel(Model); shell.ModalDialog.ShowDialog(); }); RemoveCommand = ReactiveCommand.Create(() => { Model.Solution.RemoveItem(Model); Model.Solution.Save(); }); }
public SolutionFolderViewModel(ISolutionParentViewModel parent, ISolutionFolder folder) : base(parent, folder) { _folderIcon = "FolderIcon".GetIcon(); _folderOpenIcon = "FolderOpenIcon".GetIcon(); }
public SolutionParentViewModel(ISolutionParentViewModel parent, T model) : base(parent, model) { Items = new ObservableCollection <SolutionItemViewModel>(); Items.BindCollections(Model.Items, p => { return(SolutionItemViewModel.Create(this, p)); }, (pvm, p) => pvm.Model == p); AddNewFolderCommand = ReactiveCommand.Create(() => { Model.Solution.AddItem(SolutionFolder.Create("New Folder"), Model); Model.Solution.Save(); }); AddExistingProjectCommand = ReactiveCommand.Create(async() => { var dlg = new OpenFileDialog(); dlg.Title = "Open Project"; var extensions = new List <string>(); var shell = IoC.Get <IShell>(); foreach (var projectType in shell.ProjectTypes) { extensions.AddRange(projectType.Extensions); } dlg.Filters.Add(new FileDialogFilter { Name = "AvalonStudio Project", Extensions = extensions }); dlg.InitialDirectory = Model.Solution.CurrentDirectory; dlg.AllowMultiple = false; var result = await dlg.ShowAsync(); if (result != null && !string.IsNullOrEmpty(result.FirstOrDefault())) { var proj = await Project.LoadProjectFileAsync(Model.Solution, result[0]); if (proj != null) { Model.Solution.AddItem(proj, Model); Model.Solution.Save(); } } }); AddNewProjectCommand = ReactiveCommand.Create(() => { var shell = IoC.Get <IShell>(); shell.ModalDialog = new NewProjectDialogViewModel(Model); shell.ModalDialog.ShowDialog(); }); RemoveCommand = ReactiveCommand.Create(() => { Model.Solution.RemoveItem(Model); Model.Solution.Save(); }); }
public SolutionItemViewModel(ISolutionParentViewModel parent, T model) : base(parent) { Model = model; }
public SolutionItemViewModel(ISolutionParentViewModel parent) { Parent = parent; }