/// <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 AddInfoBtn_Click(object sender, RoutedEventArgs e) //to be tested { this.Visibility = Visibility.Collapsed; DialogWindows.AddInfo AddDialog = new DialogWindows.AddInfo(); AddDialog.Visibility = Visibility.Visible; }