AvalonStudio.Controls.Standard.SolutionExplorer.ProjectItemViewModel.Create C# (CSharp) Method

Create() public static method

public static Create ( IProjectItem item ) : ProjectItemViewModel
item IProjectItem
return ProjectItemViewModel
        public static ProjectItemViewModel Create(IProjectItem item)
        {
            ProjectItemViewModel result = null;

            if (item is IProjectFolder)
            {
                result = new ProjectFolderViewModel(item as IProjectFolder);
            }

            if (item is ISourceFile)
            {
                result = new SourceFileViewModel(item as ISourceFile);
            }

            if (item is IReferenceFolder)
            {
                result = new ReferenceFolderViewModel(item as IReferenceFolder);
            }

            return result;
        }
    }

Usage Example

Example #1
0
        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);
            });
        }
All Usage Examples Of AvalonStudio.Controls.Standard.SolutionExplorer.ProjectItemViewModel::Create
ProjectItemViewModel