//換頁按鈕觸發以及顯示頁數 public void ClickPageButton(int buttonIndex, Label pageNumberLabel, MealButtonList mealList) { if (buttonIndex == 0 && _currentPage > 1) { _currentPage--; ControlButtonVisible(mealList); pageNumberLabel.Text = PAGE_STRING + Convert.ToSingle(_currentPage) + SLASH + Convert.ToString(_totalPage); } else if (buttonIndex == 1 && _currentPage < _totalPage) { _currentPage++; ControlButtonVisible(mealList); pageNumberLabel.Text = PAGE_STRING + Convert.ToSingle(_currentPage) + SLASH + Convert.ToString(_totalPage); } }
//初始化meal按鈕 private void InitialMealButton() { _meal = new MealButtonList(); for (int mealIndex = 0; mealIndex < TOTAL_MEAL; mealIndex++) { _meal.AddMeal(_mealData.GetMeal(mealIndex).GetName(), _mealData.GetMeal(mealIndex).GetPrice(), _mealData.GetMeal(mealIndex).GetDescription()); } }
//初始化點餐按鈕(判斷哪些按鈕需要顯示) void ControlButtonVisible(MealButtonList mealList) { int maxButtonIndex; int minButtonIndex; int buttonIndex; minButtonIndex = (_currentPage - 1) * _perPageButtonNumber; maxButtonIndex = _currentPage * _perPageButtonNumber; for (buttonIndex = 0; buttonIndex < _totalButtonNumber; buttonIndex++) { if (minButtonIndex <= buttonIndex && buttonIndex < maxButtonIndex) { mealList.GetMealButton(buttonIndex).Visible = true; } else mealList.GetMealButton(buttonIndex).Visible = false; } }
//初始化點餐按鈕 public void InitialMealButton(MealButtonList mealList) { ControlButtonVisible(mealList); }