protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            user = e?.Parameter as Wardrobe;
            Step = 1;
            Step1Grid.Visibility = Visibility.Visible;
            Step2Grid.Visibility = Visibility.Collapsed;

            // Paint elements with user profile color
            DataContext = user;

            // Fill type combobox
            var types = Enum.GetValues(typeof(ClothingType)).OfType <ClothingType>()
                        .Select(t => new TypeWrapper
            {
                Type = t.ToString()
            });

            TypeComboBox.ItemsSource   = types;
            TypeComboBox.SelectedIndex = 0;

            // Fill purchase date fields
            var seasons = new string[]
            {
                "Winter", "Spring",
                "Summer", "Autumn"
            };
            var resources = ResourceLoader.GetForCurrentView();

            SeasonComboBox.ItemsSource = seasons.Select(s => new SeasonWrapper
            {
                Season = s
            });

            // Fill color grid
            GarmentColorGrid.ItemsSource = ClothingColors.All()
                                           .Select(c => new ColorWrapper
            {
                Color = c
            });

            // Fill style grid
            GarmentStyleGrid.ItemsSource = ClothingStyles.All()
                                           .Select(s => new StyleWrapper
            {
                Style = s
            });
        }
Beispiel #2
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            (wardrobe, garment) = ((Wardrobe, string))e?.Parameter;
            var clothing = wardrobe.Garments.First(g => g.ID.Equals(garment, StringComparison.InvariantCulture));

            oldName = clothing.Name;

            Step = 1;
            Step1Grid.Visibility = Visibility.Visible;
            Step2Grid.Visibility = Visibility.Collapsed;

            // Paint elements with user profile color
            DataContext = wardrobe;

            // -------- Fill elements with current values --------
            // Garment name
            NameTextBox.Text = clothing.Name;

            // Garment type
            var types = Enum.GetValues(typeof(ClothingType)).OfType <ClothingType>();

            TypeComboBox.ItemsSource = types.Select(t => new TypeWrapper
            {
                Type = t.ToString()
            });
            TypeComboBox.SelectedIndex = types.ToList().IndexOf(clothing.Type);

            // Purchase date
            var seasons = new string[]
            {
                "Winter", "Spring",
                "Summer", "Autumn"
            };
            var resources = ResourceLoader.GetForCurrentView();

            SeasonComboBox.ItemsSource = seasons.Select(s => new SeasonWrapper
            {
                Season = s
            });
            SeasonComboBox.SelectedIndex = seasons.ToList().IndexOf(clothing.PurchaseDate.Season.ToString());
            YearTextBox.Text             = clothing.PurchaseDate.Year.ToString(CultureInfo.InvariantCulture);

            // Garment colors
            GarmentColorGrid.ItemsSource = ClothingColors.All()
                                           .Select(c => new ColorWrapper
            {
                Color = c
            });
            var indices = ClothingColors.All()
                          .Select(c => new
            {
                Index = ClothingColors.All().ToList().IndexOf(c),
                Color = c
            })
                          .Where(c => clothing.ColorTags.Contains(c.Color))
                          .Select(c => c.Index);

            foreach (var index in indices)
            {
                GarmentColorGrid.SelectRange(new ItemIndexRange(index, 1));
            }

            // Garment styles
            GarmentStyleGrid.ItemsSource = ClothingStyles.All()
                                           .Select(s => new StyleWrapper
            {
                Style = s
            });
            indices = ClothingStyles.All()
                      .Select(s => new
            {
                Index = ClothingStyles.All().ToList().IndexOf(s),
                Style = s
            })
                      .Where(s => clothing.StyleTags.Contains(s.Style))
                      .Select(s => s.Index);
            foreach (var index in indices)
            {
                GarmentStyleGrid.SelectRange(new ItemIndexRange(index, 1));
            }
        }