Пример #1
0
 private void AddTemplate(TemplateInfoViewModel selectedTemplate)
 {
     if (selectedTemplate.MultipleInstance || !UserSelection.IsTemplateAdded(selectedTemplate))
     {
         UserSelection.Add(TemplateOrigin.UserSelection, selectedTemplate);
     }
 }
 private async Task AddTemplateAsync(TemplateInfoViewModel selectedTemplate)
 {
     if (selectedTemplate.MultipleInstance || !UserSelection.IsTemplateAdded(selectedTemplate))
     {
         await UserSelection.AddAsync(TemplateOrigin.UserSelection, selectedTemplate);
     }
 }
Пример #3
0
 private async Task AddTemplateAsync(TemplateInfoViewModel selectedTemplate)
 {
     if (!selectedTemplate.Disabled && selectedTemplate.CanBeAdded)
     {
         await UserSelection.AddAsync(TemplateOrigin.UserSelection, selectedTemplate);
     }
 }
        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 override async Task ProcessItemAsync(object item)
 {
     if (item is ProjectTypeMetaDataViewModel projectTypeMetaData)
     {
         ProjectType.Selected = projectTypeMetaData;
     }
     else if (item is FrameworkMetaDataViewModel frameworkMetaData)
     {
         Framework.Selected = frameworkMetaData;
     }
     else if (item is TemplateInfoViewModel template)
     {
         _selectedTemplate = template;
         await AddTemplateAsync(template);
     }
 }
Пример #6
0
        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();
                }
            }
        }
Пример #7
0
 public override void ProcessItem(object item)
 {
     if (item is MetadataInfoViewModel metadata)
     {
         if (metadata.MetadataType == MetadataType.ProjectType)
         {
             ProjectType.Selected = metadata;
         }
         else if (metadata.MetadataType == MetadataType.Framework)
         {
             Framework.Selected = metadata;
         }
     }
     else if (item is TemplateInfoViewModel template)
     {
         _selectedTemplate = template;
         AddTemplate(template);
     }
 }
Пример #8
0
        public override async Task ProcessItemAsync(object item)
        {
            if (WizardStatus.HasValidationErrors)
            {
                return;
            }

            if (item is ProjectTypeMetaDataViewModel projectTypeMetaData)
            {
                ProjectType.Selected = projectTypeMetaData;
            }
            else if (item is FrameworkMetaDataViewModel frameworkMetaData)
            {
                Framework.Selected = frameworkMetaData;
            }
            else if (item is TemplateInfoViewModel template)
            {
                _selectedTemplate = template;
                await AddTemplateAsync(template);
            }
        }
Пример #9
0
 public bool IsTemplateAdded(TemplateInfoViewModel template) => GetCollection(template.TemplateType).Any(t => t.Equals(template));
Пример #10
0
        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;
                }
            }
        }