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");
            var mru = EditorViewModel.Instance.MRU;

            foreach (var file in mru.MostRecentlyUsedFiles)
            {
                var viewModel = new ExistingProjectViewModel(ServiceProvider, file.FilePath);
                recentGroup.Templates.Add(viewModel);
            }

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

            BrowseForExistingProjectCommand = new AnonymousTaskCommand(serviceProvider, BrowseForExistingProject);
            SelectedGroup = rootGroup;
        }
        private async Task BrowseForExistingProject()
        {
            var filePath = await EditorDialogHelper.BrowseForExistingProject(ServiceProvider);

            if (filePath != null)
            {
                SelectedTemplate = new ExistingProjectViewModel(ServiceProvider, filePath);
                dialog?.RequestClose(DialogResult.Ok);
            }
        }
Ejemplo n.º 3
0
        private void RemoveExistingProjects(ExistingProjectViewModel item)
        {
            if (item == null)
            {
                return;
            }

            EditorViewModel.Instance.RemoveRecentFile(item.Path);
            SelectedGroup.Templates.Remove(item);
            UpdateTemplateList();
        }