public HomePage()
 {
     InitializeComponent();
     SizeChanged += HomePage_SizeChanged;
     recipeList.LoadAll();
     searchResultList = recipeList;
 }
 private void ChangeBindingList(RecipesList input)
 {
     try
     {
         SkipButton.Children.Clear();
         var number      = NumberOfRecipePerPage();
         var bindingList = input.GetByPage(1, number).GetBindingData();
         dataListView.ItemsSource = bindingList;
         int len          = input.Recipes.Count;
         int numberOfPage = len / number + (len % number == 0 ? 0 : 1);
         maxPage = numberOfPage;
         if (numberOfPage != 0)
         {
             int temp = numberOfPage < maxButtonPerPage ? numberOfPage : maxButtonPerPage;
             ChangeListButton(1, temp);
         }
         else
         {
             TextBlock nofication = new TextBlock();
             nofication.Text     = "Empty!!!";
             nofication.FontSize = 40;
             StackPanel panel = new StackPanel();
             panel.HorizontalAlignment = HorizontalAlignment.Center;
             panel.Children.Add(nofication);
             GridLayout.VerticalAlignment = VerticalAlignment.Center;
             GridLayout.Children.Add(panel);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 private void PreButton_Click(object sender, RoutedEventArgs e)
 {
     if (currentPage > 1)
     {
         var number = NumberOfRecipePerPage();
         currentPage = currentPage - 1;
         RecipesList toShow = _favoriteList.GetByPage(currentPage, number);
         if ((currentPage) % maxButtonPerPage == 0 && currentPage - 1 < maxPage)
         {
             int temp = currentPage + 1 - maxButtonPerPage;
             ChangeListButton(temp, currentPage);
         }
         foreach (Button button in SkipButton.Children)
         {
             if (button.Content.ToString() == (currentPage).ToString())
             {
                 BrushConverter bc = new BrushConverter();
                 button.Background = (Brush)bc.ConvertFrom("#ed81a1");
             }
             else
             {
                 button.Background = Brushes.White;
             }
         }
         ;
         dataListView.ItemsSource = toShow.GetBindingData();
     }
 }
        //public FavouritePage()
        //{
        //    InitializeComponent();
        //    SizeChanged += FavouritePage_SizeChanged;
        //}

        public FavouritePage(RecipesList favoriteList)
        {
            InitializeComponent();
            SizeChanged  += FavouritePage_SizeChanged;
            _favoriteList = favoriteList;
            recipeList    = favoriteList;
            _favoriteList = _favoriteList.SearchFavoriteRecipes();
        }
 private void ChangeBindingList(RecipesList input)
 {
     try
     {
         dataListView.ItemsSource = input.GetCategoryBindingData();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemple #6
0
        public SettingPage(RecipesList list)
        {
            InitializeComponent();

            var config = ConfigurationManager.OpenExeConfiguration(
                ConfigurationUserLevel.None);
            var state      = config.AppSettings.Settings["ShowSplashScreen"].Value;
            var showSplash = bool.Parse(state);

            ToggleSwitch1.IsChecked = showSplash;
            recipeList   = list;
            SizeChanged += SettingPage_SizeChanged;
        }
Exemple #7
0
        private void ChangeBindingList(RecipesList input)
        {
            SkipButton.Children.Clear();
            var number      = NumberOfRecipePerPage();
            var bindingList = input.GetByPage(1, number).GetBindingData();

            dataListView.ItemsSource = bindingList;
            int len          = input.Recipes.Count;
            int numberOfPage = len / number + (len % number == 0 ? 0 : 1);

            maxPage = numberOfPage;
            int temp = numberOfPage < maxButtonPerPage ? numberOfPage : maxButtonPerPage;

            ChangeListButton(1, temp);
        }
        private void PackIcon_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            var icon = sender as PackIcon;

            icon.Foreground = Brushes.Pink;
            Debug.WriteLine(temp.FoodName);
            foreach (var recipe in categoryList)
            {
                if (recipe.FoodName == temp.FoodName)
                {
                    recipe.ToggleFavorite();
                    categoryList = categoryList.SearchFavoriteRecipes();
                }
            }
        }
Exemple #9
0
        private void SearchBox_PreviewKeyUp(object sender, KeyEventArgs e)
        {
            string key = (sender as TextBox).Text;

            if (key == "")
            {
                //searchResultList = recipeList.SearchNameContains_NoneUtf(key);

                ChangeBindingList(recipeList);
            }
            else
            {
                searchResultList = recipeList.SearchNameContains_NoneUtf(key);
                ChangeBindingList(searchResultList);
                //MessageBox.Show(key);
            }
        }
        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 #11
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;
            }
            }
        }
        private void PageNumber_Click(object sender, RoutedEventArgs e)
        {
            var number = NumberOfRecipePerPage();

            string[] separator  = new string[] { "_" };
            string   pageNumber = (sender as Button).Name;

            foreach (Button button in SkipButton.Children)
            {
                button.Background = Brushes.White;
            }
            ;
            BrushConverter bc = new BrushConverter();

            (sender as Button).Background = (Brush)bc.ConvertFrom("#ed81a1");
            var tokens   = pageNumber.Split(separator, StringSplitOptions.None);
            int nextPage = int.Parse(tokens[1]);

            RecipesList toShow = _favoriteList.GetByPage(nextPage, number);

            dataListView.ItemsSource = toShow.GetBindingData();
        }
Exemple #14
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;
            }
            }
        }
Exemple #15
0
 private void NextButton_Click(object sender, RoutedEventArgs e)
 {
     if (currentPage < maxPage)
     {
         var number = NumberOfRecipePerPage();
         currentPage = currentPage + 1;
         RecipesList toShow = recipeList.GetByPage(currentPage, number);
         if ((currentPage - 1) % maxButtonPerPage == 0 && currentPage - 1 < maxPage)
         {
             int temp = currentPage + maxButtonPerPage;
             if (temp > nearestNumberDivideByFive(temp) && temp <= maxPage)
             {
                 temp = nearestNumberDivideByFive(temp);
                 ChangeListButton(currentPage, temp);
             }
             else
             {
                 ChangeListButton(currentPage, maxPage);
             }
         }
         foreach (Button button in SkipButton.Children)
         {
             if (button.Content.ToString() == (currentPage).ToString())
             {
                 BrushConverter bc = new BrushConverter();
                 button.Background = (Brush)bc.ConvertFrom("#ed81a1");
             }
             else
             {
                 button.Background = Brushes.White;
             }
         }
         ;
         dataListView.ItemsSource = toShow.GetBindingData();
     }
 }
 public CategoryPage(RecipesList recipesList)
 {
     InitializeComponent();
     SizeChanged += CategoryPage_SizeChanged;
     categoryList = recipesList;
 }
Exemple #17
0
 public AddRecipePage(RecipesList recipes)
 {
     InitializeComponent();
     recipeList   = recipes;
     SizeChanged += AddRecipePage_SizeChanged;
 }
Exemple #18
0
 public CategoryWindow(Recipe foodTemp, RecipesList foodList)
 {
     InitializeComponent();
     food       = foodTemp;
     recipeList = foodList.GetCategoryBindingList(foodTemp.Category);
 }