Ejemplo n.º 1
0
        private void fillAvailableTemplates(BuildingPresets buildingPresets)
        {
            AvailableTemplates.Clear();

            var allTemplates = new Dictionary <string, int>();

            foreach (var curBuilding in buildingPresets.Buildings)
            {
                if (string.IsNullOrWhiteSpace(curBuilding.Template))
                {
                    continue;
                }

                if (!allTemplates.ContainsKey(curBuilding.Template))
                {
                    allTemplates.Add(curBuilding.Template, 1);
                }
                else
                {
                    allTemplates[curBuilding.Template] = ++allTemplates[curBuilding.Template];
                }
            }

            var templateListOrderedByOccurrence = allTemplates.OrderByDescending(x => x.Value).ToList();
            var templateNameList = allTemplates.OrderBy(x => x.Key).Select(x => x.Key).ToList();

            foreach (var curTemplateName in templateNameList)
            {
                AvailableTemplates.Add(curTemplateName);
            }
        }
        /// <summary>
        ///     The btn remove_ click.
        /// </summary>
        /// <param name="sender">
        ///     The sender.
        /// </param>
        /// <param name="e">
        ///     The e.
        /// </param>
        private void BtnRemove_Click(object sender, EventArgs e)
        {
            Template selectedTemplate = TemplateListBox.SelectedItem as Template;

            DataSource.Templates.Remove(selectedTemplate);
            AvailableTemplates.Add(selectedTemplate);
            UpdateDataSource();
            ComboBoxSearch.Text = string.Empty;

            if (SelectedPackage.Templates != null)
            {
                SelectedPackage.Templates = DataSource.Templates;
            }
        }
Ejemplo n.º 3
0
 public void ToggleLookingForTemplateEffect()
 {
     if (TemplateListVisibility == Visibility.Visible)
     {
         TemplateListVisibility = Visibility.Hidden;
         RaisePropertyChanged("TemplateListVisibility");
         return;
     }
     AvailableTemplates.Clear();
     foreach (var availableTemplateName in availableTemplateNames)
     {
         AvailableTemplates.Add(availableTemplateName);
     }
     TemplateListVisibility = Visibility.Visible;
     RaisePropertyChanged("AvailableTemplates");
     RaisePropertyChanged("TemplateListVisibility");
 }
Ejemplo n.º 4
0
        void RefreshAvailableTemplates()
        {
            AvailableTemplates.Clear();

            if (SelectedCategory != null)
            {
                if (SelectedCategory.Name == "Starter Projects")
                {
                    foreach (var item in DataLoader.StarterProjects)
                    {
                        var viewModel = new TemplateViewModel
                        {
                            BackingData = item
                        };

                        AvailableTemplates.Add(viewModel);
                    }
                }
                else
                {
                    foreach (var item in DataLoader.EmptyProjects)
                    {
                        var viewModel = new TemplateViewModel
                        {
                            BackingData = item
                        };

                        AvailableTemplates.Add(viewModel);
                    }
                }
            }

            if (AvailableTemplates.Count != 0)
            {
                SelectedTemplate = AvailableTemplates[0];
            }
        }