Пример #1
0
 public void setSubCategory(FeatureSampleCategory currentSampleCategories, SampleInfo sample)
 {
     if (currentSampleCategories.AllSampleCategory != null && currentSampleCategories.AllSampleCategory.ContainsKey(sample.SampleCategory))
     {
         var FeatureSamples = currentSampleCategories.AllSampleCategory[sample.SampleCategory];
         FeatureSamples.AllSamples.Add(sample);
     }
     else
     {
         FeatureSampleCollection newSamples = new FeatureSampleCollection();
         newSamples.Name       = sample.Header;
         newSamples.AllSamples = new List <SampleInfo>();
         newSamples.AllSamples.Add(sample);
         currentSampleCategories.AllSampleCategory.Add(sample.SampleCategory, newSamples);
     }
 }
Пример #2
0
        public ViewModel()
        {
            ShowcaseSamples      = new List <SampleInfo>();
            SearchCollection     = new List <Search>();
            SearchViewCollection = new List <SampleInfo>();
            WhatsNewSamples      = new List <SampleInfo>();
            Tiles           = new List <GroupInfoList <ITileItem> >();
            FeaturedSamples = new List <SampleInfo>();

            ShowcaseVisibility  = WhatsNewVisibility = Visibility.Collapsed;
            WhatsNewDescription = "The following new samples have been added in the Volume 4 2019 release.";

            Categories = new ObservableCollection <Category>();

            foreach (var sample in SampleHelper.SampleViews)
            {
                if (sample.SampleType == SampleType.Showcase)
                {
                    ShowcaseSamples.Add(sample);
                    ShowcaseVisibility = Visibility.Visible;
                }
                else
                {
                    FeaturedSamples.Add(sample);

                    SearchCollection.Add(new Search()
                    {
                        ProductName = sample.Product,
                        SampleName  = sample.Header,
                        SearchName  = sample.Category + sample.Header
                    });

                    SearchViewCollection.Add(new SampleInfo()
                    {
                        Product        = sample.Product,
                        Header         = sample.Header,
                        SampleView     = sample.SampleView,
                        SampleCategory = sample.SampleCategory,
                        SampleType     = sample.SampleType,
                        Description    = sample.Description,
                        DesktopImage   = sample.DesktopImage,
                        HasOptions     = sample.HasOptions,
                        Category       = sample.Category,
                        Tag            = sample.Tag,
                        MobileImage    = sample.MobileImage,
                        SearchKeys     = new string[] { sample.Category.ToString(), sample.Header, sample.Product }
                    });

                    if (sample.Tag == Tags.NewWithWhatsNew || sample.Tag == Tags.PreviewWithWhatsNew || sample.Tag == Tags.UpdatedWithWhatsNew)
                    {
                        WhatsNewSamples.Add(sample);
                        WhatsNewVisibility = Visibility.Visible;
                    }
                }
            }


            if (ShowcaseVisibility == Visibility.Collapsed && this.WhatsNewVisibility == Visibility.Collapsed)
            {
                this.SidePanelVisibility = Visibility.Collapsed;
            }

            MainCollection = new AllProductsCategory();

            AllProductsCategories = new Dictionary <string, Products>();
            foreach (var sample in FeaturedSamples)
            {
                if (AllProductsCategories != null && AllProductsCategories.ContainsKey(categName(sample.Category.ToString())))
                {
                    var currentProduct = AllProductsCategories[categName(sample.Category.ToString())];
                    GetProducts(currentProduct, sample);
                }
                else
                {
                    var newProducts = new Products();
                    newProducts.Name        = sample.Product;
                    newProducts.AllProducts = new Dictionary <string, FeatureSampleCategory>();
                    GetProducts(newProducts, sample);


                    AllProductsCategories.Add(categName(sample.Category.ToString()), newProducts);
                }
            }

            WhatNewCategories = new Dictionary <string, FeatureSampleCollection>();
            foreach (var sample in WhatsNewSamples)
            {
                if (WhatNewCategories != null && WhatNewCategories.ContainsKey(sample.Product))
                {
                    var currentProduct = WhatNewCategories[sample.Product];
                    currentProduct.Name = sample.Header;
                    currentProduct.AllSamples.Add(sample);
                }
                else
                {
                    var newSamples = new FeatureSampleCollection();
                    newSamples.Name       = sample.Header;
                    newSamples.AllSamples = new List <SampleInfo>();
                    newSamples.AllSamples.Add(sample);
                    WhatNewCategories.Add(sample.Product, newSamples);
                }
            }
        }