public async Task AddAsync(TemplateOrigin templateOrigin, TemplateInfoViewModel template, string layoutName = null, bool isReadOnly = false) { if (template.IsGroupExclusiveSelection) { var collection = GetCollection(template.TemplateType); var exclusiveSelectionAddedTemplates = collection.Where(f => f.Group == template.Group).ToList(); foreach (var exclusiveFeature in exclusiveSelectionAddedTemplates) { await RemoveAsync(exclusiveFeature); } } foreach (var dependency in template.Template.Dependencies) { var dependencyTemplate = MainViewModel.Instance.GetTemplate(dependency); if (dependencyTemplate == null) { // Case of hidden templates, it's not found on templat lists dependencyTemplate = new TemplateInfoViewModel(dependency, _platform, _projectTypeName, _frameworkName); } await AddAsync(templateOrigin, dependencyTemplate); } template.IncreaseSelection(); var savedTemplate = new SavedTemplateViewModel(template, templateOrigin, isReadOnly); var focus = false; if (!IsTemplateAdded(template) || template.MultipleInstance) { if (!string.IsNullOrEmpty(layoutName)) { savedTemplate.SetName(layoutName, true); } else { savedTemplate.SetName(ValidationService.InferTemplateName(template.Name, template.ItemNameEditable, template.ItemNameEditable), true); if (savedTemplate.ItemNameEditable) { focus = true; } } AddToGroup(template.TemplateType, savedTemplate); UpdateHasItemsAddedByUser(); BuildLicenses(); if (focus) { savedTemplate.IsTextSelected = true; } } }
public void Add(TemplateOrigin templateOrigin, TemplateInfoViewModel template, string layoutName = null) { var dependencies = GenComposer.GetAllDependencies(template.Template, _frameworkName); foreach (var dependency in dependencies) { var dependencyTemplate = MainViewModel.Instance.GetTemplate(dependency); if (dependencyTemplate == null) { // Case of hidden templates, it's not found on templat lists dependencyTemplate = new TemplateInfoViewModel(dependency, _frameworkName); } Add(TemplateOrigin.Dependency, dependencyTemplate); } template.IncreaseSelection(); var savedTemplate = new SavedTemplateViewModel(template, templateOrigin); var focus = false; if (!IsTemplateAdded(template) || template.MultipleInstance) { if (!string.IsNullOrEmpty(layoutName)) { savedTemplate.Name = layoutName; } else { savedTemplate.Name = ValidationService.InferTemplateName(template.Name, template.ItemNameEditable, template.ItemNameEditable); if (savedTemplate.ItemNameEditable) { focus = true; } } AddToCollection(GetCollection(template.TemplateType), savedTemplate); RaiseCollectionChanged(template.TemplateType); UpdateHasItemsAddedByUser(); BuildLicenses(); if (focus) { savedTemplate.Focus(); } } }
public async Task AddAsync(TemplateOrigin templateOrigin, TemplateInfoViewModel template, string layoutName = null, bool isReadOnly = false) { if (template.Exclusions.Count() > 0) { var exlusionsTemplateNames = AllTemplates.Where(t => template.Exclusions.Select(e => e.Identity).Contains(t.Identity)).Select(t => t.Template.Name).Distinct(); if (exlusionsTemplateNames.Count() > 0) { await ShowAddTemplateExclusionsNotificationAsync(template.Name, exlusionsTemplateNames); return; } } if (template.Requirements.Count() > 0) { if (!AllTemplates.Any(t => template.Requirements.Select(r => r.Identity).Contains(t.Identity))) { await ShowAddTemplateWithRequirementNotificationAsync(template.Name, template.Requirements.Select(r => r.Name)); return; } } if (template.IsGroupExclusiveSelection) { var collection = GetCollection(template.TemplateType); var exclusiveSelectionAddedTemplates = collection.Where(f => f.Group == template.Group).ToList(); foreach (var exclusiveFeature in exclusiveSelectionAddedTemplates) { await RemoveAsync(exclusiveFeature); } } foreach (var dependency in template.Template.Dependencies) { var dependencyTemplate = MainViewModel.Instance.GetTemplate(dependency); if (dependencyTemplate == null) { // Case of hidden templates, it's not found on templat lists dependencyTemplate = new TemplateInfoViewModel(dependency, _platform, _projectTypeName, _frameworkName); } await AddAsync(templateOrigin, dependencyTemplate); } template.IncreaseSelection(); var savedTemplate = new SavedTemplateViewModel(template, templateOrigin, isReadOnly); var focus = false; if (!IsTemplateAdded(template) || template.MultipleInstance) { if (!string.IsNullOrEmpty(layoutName)) { savedTemplate.SetName(layoutName, true); } else { if (template.ItemNameEditable) { savedTemplate.SetName(ValidationService.InferTemplateName(template.Name)); focus = true; } else { savedTemplate.SetName(template.Template.DefaultName); } } AddToGroup(template.TemplateType, savedTemplate); UpdateHasItemsAddedByUser(); BuildLicenses(); CheckForMissingVersions(); if (focus) { savedTemplate.IsTextSelected = true; } } }