private void LoadFile(object sender, EventArgs e) { //show the file browser FileChooserDialog dialogBox = new FileChooserDialog ("Choose the file to open", this, FileChooserAction.Open, "Cancel",ResponseType.Cancel, "Open",ResponseType.Accept); dialogBox.Show (); if (dialogBox.Run() == (int)ResponseType.Accept) { Console.WriteLine ("accept response from dialog box"); //check to make sure the file is valid //if it is not notify the user to try again if (!FileParser.FileParser.ParseFileGrammar (dialogBox.Filename, true)) { Console.WriteLine ("bad file grammar"); InvalidFilePopup badFilePrompt = new InvalidFilePopup (); badFilePrompt.makeAppear (); } //else all is well else { Console.WriteLine ("We will repaint the home window with the" + "new data given."); parentWindow.Repaint (); } dialogBox.Destroy(); this.Destroy (); } }
/** * Wil open a file browser to locate a file on the system * */ private void OpenFileTree(object sender, EventArgs e) { bool openedSuccessfully = false; Console.WriteLine ("Opening a file tree"); //show the file browser dialogBox = new FileChooserDialog ("Choose the file to open", this, FileChooserAction.Open, "Cancel",ResponseType.Cancel, "Open",ResponseType.Accept); dialogBox.Show (); if (dialogBox.Run () == (int)ResponseType.Accept) { Console.WriteLine ("accept response from dialog box"); //check to make sure the file is valid //if it is not notify the user to try again if (!FileParser.FileParser.ParseFileGrammar (dialogBox.Filename, false)) { Console.WriteLine ("bad file grammar"); InvalidFilePopup badFilePrompt = new InvalidFilePopup (); badFilePrompt.makeAppear (); } //else all is well else { Console.WriteLine ("going to main window"); MainWindow homeScreen = new MainWindow (); homeScreen.makeAppear (); openedSuccessfully = true; } dialogBox.Destroy (); if (openedSuccessfully) this.Destroy (); } else dialogBox.Destroy (); }