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 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();
        }
示例#3
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);
        }