private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            string condition = ((ComboBoxItem)(sender as ComboBox).SelectedItem).ToString();

            Debug.WriteLine(condition);
            var tokens = condition.Split(new string[] { ": " }, StringSplitOptions.None);

            switch (tokens[tokens.Length - 1])
            {
            case "Order by name A-Z":
            {
                _favoriteList = _favoriteList.SortByName();
                ChangeBindingList(_favoriteList);
                break;
            }

            case "Order by name Z-A":
            {
                _favoriteList = _favoriteList.SortByNameDescending();
                ChangeBindingList(_favoriteList);
                break;
            }

            case "Order by date descending":
            {
                _favoriteList = _favoriteList.SortByDateDescending();
                ChangeBindingList(_favoriteList);
                break;
            }

            case "Order by date ascending":
            {
                _favoriteList = _favoriteList.SortByDate();
                ChangeBindingList(_favoriteList);
                break;
            }
            }
            var config = ConfigurationManager.OpenExeConfiguration(
                ConfigurationUserLevel.None);

            config.AppSettings.Settings["DisplayOptionFavPage"].Value = tokens[tokens.Length - 1];
            config.Save(ConfigurationSaveMode.Minimal);
        }
Exemple #2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            categoryText.Text = food.Category;
            var config = ConfigurationManager.OpenExeConfiguration(
                ConfigurationUserLevel.None);
            var option = config.AppSettings.Settings["DisplayOption"].Value;

            switch (option)
            {
            case "Order by name A-Z":
            {
                AtoZ.IsSelected = true;
                recipeList      = recipeList.SortByName();
                ChangeBindingList(recipeList);
                break;
            }

            case "Order by name Z-A":
            {
                ZtoA.IsSelected = true;
                recipeList      = recipeList.SortByNameDescending();
                ChangeBindingList(recipeList);
                break;
            }

            case "Order by date descending":
            {
                DateDescending.IsSelected = true;
                recipeList = recipeList.SortByDateDescending();
                ChangeBindingList(recipeList);
                break;
            }

            case "Order by date ascending":
            {
                DateAscending.IsSelected = true;
                recipeList = recipeList.SortByDate();
                ChangeBindingList(recipeList);
                break;
            }
            }
            ChangeBindingList(recipeList);
        }
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            var config = ConfigurationManager.OpenExeConfiguration(
                ConfigurationUserLevel.None);
            var option = config.AppSettings.Settings["DisplayOption"].Value;

            Console.WriteLine(option);
            switch (option)
            {
            case "Sort By Name A-Z":
            {
                AtoZ.IsSelected = true;
                recipeList      = recipeList.SortByName();
                ChangeBindingList(recipeList);
                break;
            }

            case "Sort By Name Z-A":
            {
                ZtoA.IsSelected = true;
                recipeList      = recipeList.SortByNameDescending();
                ChangeBindingList(recipeList);
                break;
            }

            case "Sort By Date Descending":
            {
                DateDescending.IsSelected = true;
                recipeList = recipeList.SortByDateDescending();
                ChangeBindingList(recipeList);
                break;
            }

            case "Sort By Date Ascending":
            {
                DateAscending.IsSelected = true;
                recipeList = recipeList.SortByDate();
                ChangeBindingList(recipeList);
                break;
            }
            }
        }
Exemple #4
0
        private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            string condition = ((ComboBoxItem)(sender as ComboBox).SelectedItem).ToString();

            Debug.WriteLine(condition);
            var tokens = condition.Split(new string[] { ": " }, StringSplitOptions.None);

            switch (tokens[tokens.Length - 1])
            {
            case "Order by name A-Z":
            {
                recipeList = recipeList.SortByName();
                ChangeBindingList(recipeList);
                break;
            }

            case "Order by name Z-A":
            {
                recipeList = recipeList.SortByNameDescending();
                ChangeBindingList(recipeList);
                break;
            }

            case "Order by date descending":
            {
                recipeList = recipeList.SortByDateDescending();
                ChangeBindingList(recipeList);
                break;
            }

            case "Order by date ascending":
            {
                recipeList = recipeList.SortByDate();
                ChangeBindingList(recipeList);
                break;
            }
            }
        }