public void update_all_items(int[] filterArray) { //MessageBox.Show("Update all Items called"); num_of_category = myParser.getNums(); item_summary = myParser.getInfo(); double temp = Math.Ceiling(((double)(num_of_category[8])) / 2); menu_all.Children.Clear(); menu_all.ColumnDefinitions.Clear(); int local_counter = 0; for (int i = 0; i < myParser.item_summary.GetLength(0); i++) { filter = myParser.item_summary[i, 6]; if (filter == "veggie" && filterArray[0] == 1) { local_counter++; } else if (filter == "vegan" && filterArray[1] == 1) { local_counter++; } else if (filter == "chicken" && filterArray[2] == 1) { local_counter++; } else if (filter == "beef" && filterArray[3] == 1) { local_counter++; } else if (filter == "seafood" && filterArray[4] == 1) { local_counter++; } else if (filter == "peanut" && filterArray[5] == 1) { local_counter++; } else if (filter == "none") { local_counter++; } } double counter_temp = (double)local_counter; double temp2 = counter_temp / 2; //MessageBox.Show(Math.Ceiling(temp2).ToString()); for (int i = 0; i < Math.Ceiling(temp2); i++) { ColumnDefinition cd = new ColumnDefinition(); cd.Width = new GridLength(350); this.menu_all.ColumnDefinitions.Add(cd); } int row = 0; int col = 0; for (int i = 0; i < myParser.item_summary.GetLength(0); i++) { name = myParser.item_summary[i, 0]; description = myParser.item_summary[i, 1]; price = Math.Round(Double.Parse(myParser.item_summary[i, 2]), 2); ingredients = myParser.item_summary[i, 3]; category = myParser.item_summary[i, 4]; allergy = myParser.item_summary[i, 5]; filter = myParser.item_summary[i, 6]; item_image = myParser.item_summary[i, 7]; menuItem_template item_info = new menuItem_template(mWin, this, name, description, price, ingredients, category, allergy, filter, item_image); if (filter == "veggie" && filterArray[0] == 1) { this.menu_all.Children.Add(item_info); Grid.SetRow(item_info, row); Grid.SetColumn(item_info, col); if (row == 1) { row = 0; col++; } else { row++; } } else if (filter == "vegan" && filterArray[1] == 1) { this.menu_all.Children.Add(item_info); Grid.SetRow(item_info, row); Grid.SetColumn(item_info, col); if (row == 1) { row = 0; col++; } else { row++; } } else if (filter == "chicken" && filterArray[2] == 1) { this.menu_all.Children.Add(item_info); Grid.SetRow(item_info, row); Grid.SetColumn(item_info, col); if (row == 1) { row = 0; col++; } else { row++; } } else if (filter == "beef" && filterArray[3] == 1) { this.menu_all.Children.Add(item_info); Grid.SetRow(item_info, row); Grid.SetColumn(item_info, col); if (row == 1) { row = 0; col++; } else { row++; } } else if (filter == "seafood" && filterArray[4] == 1) { this.menu_all.Children.Add(item_info); Grid.SetRow(item_info, row); Grid.SetColumn(item_info, col); if (row == 1) { row = 0; col++; } else { row++; } } else if (filter == "peanut" && filterArray[5] == 1) { this.menu_all.Children.Add(item_info); Grid.SetRow(item_info, row); Grid.SetColumn(item_info, col); if (row == 1) { row = 0; col++; } else { row++; } } else if (filter == "none") { this.menu_all.Children.Add(item_info); Grid.SetRow(item_info, row); Grid.SetColumn(item_info, col); if (row == 1) { row = 0; col++; } else { row++; } } } }
public void search_items(string keyword) { tabcontrol_Main.SelectedIndex = 8; num_of_category = myParser.getNums(); item_summary = myParser.getInfo(); double temp = Math.Ceiling(((double)(num_of_category[8])) / 2); menu_all.Children.Clear(); menu_all.ColumnDefinitions.Clear(); int local_counter = 0; for (int i = 0; i < myParser.item_summary.GetLength(0); i++) { name = myParser.item_summary[i, 0]; if (name.ToLower().Contains(keyword.ToLower())) { local_counter++; } } double counter_temp = (double)local_counter; double temp2 = counter_temp / 2; //MessageBox.Show(Math.Ceiling(temp2).ToString()); for (int i = 0; i < Math.Ceiling(temp2); i++) { ColumnDefinition cd = new ColumnDefinition(); cd.Width = new GridLength(350); this.menu_all.ColumnDefinitions.Add(cd); } int row = 0; int col = 0; for (int i = 0; i < myParser.item_summary.GetLength(0); i++) { name = myParser.item_summary[i, 0]; description = myParser.item_summary[i, 1]; price = Math.Round(Double.Parse(myParser.item_summary[i, 2]), 2); ingredients = myParser.item_summary[i, 3]; category = myParser.item_summary[i, 4]; allergy = myParser.item_summary[i, 5]; filter = myParser.item_summary[i, 6]; item_image = myParser.item_summary[i, 7]; menuItem_template item_info = new menuItem_template(mWin, this, name, description, price, ingredients, category, allergy, filter, item_image); if (name.ToLower().Contains(keyword.ToLower())) { this.menu_all.Children.Add(item_info); Grid.SetRow(item_info, row); Grid.SetColumn(item_info, col); if (row == 1) { row = 0; col++; } else { row++; } } } }
public mainMenu(MainWindow mWindow) { InitializeComponent(); for (int i = 0; i < filter_array.Length; i++) { filter_array[i] = 1; } Orders = new ObservableCollection <aOrder>(); listbox_order.DataContext = Orders; item_summary = myParser.getInfo(); num_of_category = myParser.getNums(); mWin = mWindow; int col_all = 0; int col_special = 0; int col_beverage = 0; int col_appetizer = 0; int col_salad = 0; int col_pizza = 0; int col_burger = 0; int col_poutine = 0; int col_dessert = 0; int row_all = 0; int row_special = 0; int row_beverage = 0; int row_appetizer = 0; int row_salad = 0; int row_pizza = 0; int row_burger = 0; int row_poutine = 0; int row_dessert = 0; //double numOfCols = (double)(myParser.item_summary.GetLength(0) / 2); for (int i = 0; i < num_of_category.Length; i++) { for (int j = 0; j < Math.Ceiling(((double)(num_of_category[i])) / 2); j++) { ColumnDefinition cd = new ColumnDefinition(); cd.Width = new GridLength(350); if (i == 0) { menu_specials.ColumnDefinitions.Add(cd); } else if (i == 1) { menu_beverages.ColumnDefinitions.Add(cd); } else if (i == 2) { menu_appetizers.ColumnDefinitions.Add(cd); } else if (i == 3) { menu_salads.ColumnDefinitions.Add(cd); } else if (i == 4) { menu_pizza.ColumnDefinitions.Add(cd); } else if (i == 5) { menu_burgers.ColumnDefinitions.Add(cd); } else if (i == 6) { menu_poutine.ColumnDefinitions.Add(cd); } else if (i == 7) { menu_desserts.ColumnDefinitions.Add(cd); } else if (i == 8) { menu_all.ColumnDefinitions.Add(cd); } } } for (int i = 0; i < myParser.item_summary.GetLength(0); i++) { name = myParser.item_summary[i, 0]; description = myParser.item_summary[i, 1]; price = Math.Round(Double.Parse(myParser.item_summary[i, 2]), 2); ingredients = myParser.item_summary[i, 3]; category = myParser.item_summary[i, 4]; allergy = myParser.item_summary[i, 5]; filter = myParser.item_summary[i, 6]; item_image = myParser.item_summary[i, 7]; menuItem_template item_info = new menuItem_template(mWin, this, name, description, price, ingredients, category, allergy, filter, item_image); this.menu_all.Children.Add(item_info); Grid.SetRow(item_info, row_all); Grid.SetColumn(item_info, col_all); if (row_all == 1) { row_all = 0; col_all++; } else { row_all++; } } for (int i = 0; i < myParser.item_summary.GetLength(0); i++) { name = myParser.item_summary[i, 0]; description = myParser.item_summary[i, 1]; price = Math.Round(Double.Parse(myParser.item_summary[i, 2]), 2); ingredients = myParser.item_summary[i, 3]; category = myParser.item_summary[i, 4]; allergy = myParser.item_summary[i, 5]; filter = myParser.item_summary[i, 6]; item_image = myParser.item_summary[i, 7]; menuItem_template item_info = new menuItem_template(mWin, this, name, description, price, ingredients, category, allergy, filter, item_image); if (category.Contains("special")) { this.menu_specials.Children.Add(item_info); Grid.SetRow(item_info, row_special); Grid.SetColumn(item_info, col_special); if (row_special == 1) { row_special = 0; col_special++; } else { row_special++; } } else if (category.Contains("beverage")) { this.menu_beverages.Children.Add(item_info); Grid.SetRow(item_info, row_beverage); Grid.SetColumn(item_info, col_beverage); if (row_beverage == 1) { row_beverage = 0; col_beverage++; } else { row_beverage++; } } else if (category.Contains("appetizer")) { this.menu_appetizers.Children.Add(item_info); Grid.SetRow(item_info, row_appetizer); Grid.SetColumn(item_info, col_appetizer); if (row_appetizer == 1) { row_appetizer = 0; col_appetizer++; } else { row_appetizer++; } } else if (category.Contains("salad")) { this.menu_salads.Children.Add(item_info); Grid.SetRow(item_info, row_salad); Grid.SetColumn(item_info, col_salad); if (row_salad == 1) { row_salad = 0; col_salad++; } else { row_salad++; } } else if (category.Contains("pizza")) { this.menu_pizza.Children.Add(item_info); Grid.SetRow(item_info, row_pizza); Grid.SetColumn(item_info, col_pizza); if (row_pizza == 1) { row_pizza = 0; col_pizza++; } else { row_pizza++; } } else if (category.Contains("burger")) { this.menu_burgers.Children.Add(item_info); Grid.SetRow(item_info, row_burger); Grid.SetColumn(item_info, col_burger); if (row_burger == 1) { row_burger = 0; col_burger++; } else { row_burger++; } } else if (category.Contains("poutine")) { this.menu_poutine.Children.Add(item_info); Grid.SetRow(item_info, row_poutine); Grid.SetColumn(item_info, col_poutine); if (row_poutine == 1) { row_poutine = 0; col_poutine++; } else { row_poutine++; } } else if (category.Contains("dessert")) { this.menu_desserts.Children.Add(item_info); Grid.SetRow(item_info, row_dessert); Grid.SetColumn(item_info, col_dessert); if (row_dessert == 1) { row_dessert = 0; col_dessert++; } else { row_dessert++; } } } }