public NewOrOpenSessionTemplateCollectionViewModel(IViewModelServiceProvider serviceProvider, IModalDialog dialog)
            : base(serviceProvider)
        {
            this.dialog = dialog;
            rootGroup   = new TemplateDescriptionGroupViewModel(serviceProvider, "New project");

            // Add a default General group
            var defaultGroup = new TemplateDescriptionGroupViewModel(rootGroup, "General");

            foreach (TemplateDescription template in TemplateManager.FindTemplates(TemplateScope.Session))
            {
                var viewModel = new PackageTemplateViewModel(serviceProvider, template);
                var group     = ProcessGroup(rootGroup, template.Group) ?? defaultGroup;
                group.Templates.Add(viewModel);
            }

            recentGroup = new TemplateDescriptionGroupViewModel(serviceProvider, "Recent projects");
            foreach (var file in EditorViewModel.Instance.RecentFiles)
            {
                var viewModel = new ExistingProjectViewModel(ServiceProvider, file.FilePath, RemoveExistingProjects);
                recentGroup.Templates.Add(viewModel);
            }

            Location = InternalSettings.TemplatesWindowDialogLastNewSessionTemplateDirectory.GetValue();
            if (string.IsNullOrWhiteSpace(Location))
            {
                Location = UPath.Combine <UDirectory>(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Stride Projects");
            }

            BrowseForExistingProjectCommand = new AnonymousTaskCommand(serviceProvider, BrowseForExistingProject);
            SelectedGroup = recentGroup.Templates.Count == 0 ? rootGroup : recentGroup;
        }
        public UpdatePackageTemplateCollectionViewModel(SessionViewModel session)
            : base(session.SafeArgument(nameof(session)).ServiceProvider)
        {
            if (session == null)
            {
                throw new ArgumentNullException(nameof(session));
            }
            this.session = session;

            var rootGroup = new TemplateDescriptionGroupViewModel(ServiceProvider, "All templates");

            foreach (TemplateDescription template in session.FindTemplates(TemplateScope.Package))
            {
                var viewModel = new PackageTemplateViewModel(ServiceProvider, template, session);
                rootGroup.Templates.Add(viewModel);
            }

            Location = session.SolutionPath?.GetFullDirectory() ?? InternalSettings.TemplatesWindowDialogLastNewSessionTemplateDirectory.GetValue();
            if (string.IsNullOrWhiteSpace(Location))
            {
                Location = UPath.Combine <UDirectory>(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Stride Projects");
            }

            SelectedGroup = rootGroup;
        }
        public NewProjectTemplateCollectionViewModel(IViewModelServiceProvider serviceProvider, SessionViewModel session)
            : base(serviceProvider)
        {
            if (session == null)
            {
                throw new ArgumentNullException(nameof(session));
            }
            Session = session;

            rootGroup = new TemplateDescriptionGroupViewModel(serviceProvider, "All templates");

            // Add a default General group
            var defaultGroup = new TemplateDescriptionGroupViewModel(rootGroup, "General");

            foreach (TemplateDescription template in session.FindTemplates(TemplateScope.Session))
            {
                if (!IsAssetsOnlyTemplate(template))
                {
                    continue;
                }

                var viewModel = new PackageTemplateViewModel(serviceProvider, template, session);
                var group     = ProcessGroup(rootGroup, template.Group) ?? defaultGroup;
                group.Templates.Add(viewModel);
            }

            Location = session.SolutionPath.GetFullDirectory() ?? InternalSettings.TemplatesWindowDialogLastNewSessionTemplateDirectory.GetValue();
            if (string.IsNullOrWhiteSpace(Location))
            {
                Location = UPath.Combine <UDirectory>(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Stride Projects");
            }

            SelectedGroup = rootGroup;
        }
        protected static TemplateDescriptionGroupViewModel ProcessGroup(TemplateDescriptionGroupViewModel rootGroup, string groupPath)
        {
            if (string.IsNullOrWhiteSpace(groupPath))
            {
                return(null);
            }

            var groupDirectories = groupPath.Split("/\\".ToCharArray());

            return(groupDirectories.Aggregate(rootGroup, (current, groupDirectory) => current.SubGroups.FirstOrDefault(x => x.Name == groupDirectory) ?? new TemplateDescriptionGroupViewModel(current, groupDirectory)));
        }
 public AddItemTemplateCollectionViewModel(IViewModelServiceProvider serviceProvider) : base(serviceProvider)
 {
     RootGroup = new TemplateDescriptionGroupViewModel(serviceProvider, "All templates");
 }