/// <summary> /// This needs improvement badly /// </summary> /// <param name="windowclose"></param> public static void CloseThisWindow(object windowclose) //Gets the window that calls this method as object. { string whatWindow = windowclose.GetType().ToString(); //Gets the string of the type of the object that was sent by calling the method. string mainMenuWindow = "Layout.Windows.MainMenu"; string loginWindow = "Layout.MainWindow"; string collectionWindow = "Layout.Windows.CollectionWindow"; string addInfoWindow = "DialogWindows.AddInfo"; if (whatWindow == mainMenuWindow) //Checks if its the MainMenu that called the method. { Windows.MainMenu mainMenu = (Windows.MainMenu)windowclose; //Cast the object sent with the method call into the MainMenu object so i can call the visibility property. mainMenu.Visibility = Visibility.Collapsed; } else if (whatWindow == loginWindow) //Checks if its the LoginWindow that called the method. { MainWindow main = (MainWindow)windowclose; main.Visibility = Visibility.Collapsed; } else if (whatWindow == collectionWindow) { Windows.CollectionWindow collWindow = (Windows.CollectionWindow)windowclose; collWindow.Visibility = Visibility.Collapsed; } else if (whatWindow == addInfoWindow) { DialogWindows.AddInfo addWindow = (DialogWindows.AddInfo)windowclose; addWindow.Visibility = Visibility.Collapsed; } }
private void SaveBtn_Click(object sender, RoutedEventArgs e) { if (userEmail.Text != string.Empty) { var currentUser = db.Users.FirstOrDefault(u => u.Username == Classes.Session.sessionUserName); currentUser.Email = userEmail.Text; try { db.SaveChanges(); this.Visibility = Visibility.Collapsed; Windows.MainMenu main = new Windows.MainMenu(); main.Visibility = Visibility.Visible; } catch { MessageBox.Show("Error updating the email"); } } else { MessageBox.Show("Please enter a valid email adress"); } if (BasicRadioBtn.IsChecked == true || AdvancedRadioBtn.IsChecked == true || RadioBtn.IsChecked == true) { } else { MessageBox.Show("Please select the kind of user you wish to be"); } }
public static void OpenMainMenuWindow() { Windows.MainMenu mainMenu = new Windows.MainMenu(); mainMenu.Visibility = Visibility.Visible; }