private void backToType(object sender, NavigationEventArgs e) { TypePage tp = mainFrame.Content as TypePage; Grid grid = tp.Content as Grid; var ch = grid.Children; string pageName = type + "Canvas"; foreach (var c in ch) { Canvas can = c as Canvas; if (can.Name.Equals(pageName)) { can.Background = Brushes.LightGreen; break; } } mainFrame.Navigated -= backToType; }
private async void Button_Click(object sender, RoutedEventArgs e) { if (mainFrame.Source.ToString().Split('/')[2].Equals(typePage.ToString())) { TypePage tp = mainFrame.Content as TypePage; var grid = tp.Content as Grid; var ch = grid.Children; foreach (var can in ch) { Canvas c = can as Canvas; if (c.Background == Brushes.LightGreen) { type = c.Name.Substring(0, c.Name.Length - 6); mainFrame.Source = sizePage; mainFrame.Navigated += goToSize; return; } } } else if (mainFrame.Source.ToString().Split('/')[2].Equals(sizePage.ToString())) { SizePage sp = mainFrame.Content as SizePage; var grid = sp.Content as Grid; var ch = grid.Children; foreach (var can in ch) { Canvas c = can as Canvas; if (c.Background == Brushes.LightGreen) { size = c.Name.Substring(0, c.Name.Length - 6); mainFrame.Source = sidePage; mainFrame.Navigated += goToSide; break; } } } else if (mainFrame.Source.ToString().Split('/')[2].Equals(sidePage.ToString())) { SidePage sp = mainFrame.Content as SidePage; var grid = sp.Content as Grid; var ch = grid.Children; sideIds.Clear(); foreach (var can in ch) { Canvas c = can as Canvas; if (c.Background == Brushes.LightGreen) { sideIds.Add(Int32.Parse(c.Uid)); } } mainFrame.Source = drinkPage; mainFrame.Navigated += goToDrink; } else if (mainFrame.Source.ToString().Split('/')[2].Equals(drinkPage.ToString())) { DrinkPage dp = mainFrame.Content as DrinkPage; var grid = dp.Content as Grid; var ch = grid.Children; drinkIds.Clear(); foreach (var can in ch) { Canvas c = can as Canvas; if (c.Background == Brushes.LightGreen) { drinkIds.Add(Int32.Parse(c.Uid)); } } mainFrame.Source = locationPage; mainFrame.Navigated += goToLocation; nextButton.Content = Application.Current.FindResource("Finish") as string; } else if (nextButton.Content.Equals(Application.Current.FindResource("Finish").ToString())) { LocationPage lp = mainFrame.Content as LocationPage; var grid = lp.Content as Grid; var ch = grid.Children; foreach (var can in ch) { Canvas c = can as Canvas; if (c.Background == Brushes.LightGreen) { location = c.Name.Substring(0, c.Name.Length - 6); OrderModel om = new OrderModel() { drinkIds = new List <int>(drinkIds), location = location, sideIds = new List <int>(sideIds), size = size, type = type, staffId = currentlyLogged.id, }; //Thread t = new Thread(() => addOrder(om)); //t.SetApartmentState(ApartmentState.STA); //t.Start(); nextButton.Content = Application.Current.FindResource("Next") as string; mainFrame.Source = typePage; size = null; type = null; location = null; drinkIds.Clear(); sideIds.Clear(); var scheduler = TaskScheduler.FromCurrentSynchronizationContext(); Task <Grid> t = addOrder(om); t.Start(scheduler); Grid g = await t; myStackPanel.Children.Add(g); return; } } } }