private void newDirectory_Click(object sender, RoutedEventArgs e) { // let the user select a directory, then open it var dialog = new FolderBrowserDialog(); var result = dialog.ShowDialog(); // unfortunately there is a namespace collision here if I'm not this specific if (result == System.Windows.Forms.DialogResult.OK) { var pastDir = PastDirectory.create(dialog.SelectedPath); if (pastDir != null) { addPastDirectory(pastDir); openDirectory(pastDir.directory); } else if (PastDirectory.hasDirectory(dialog.SelectedPath)) { openDirectory(new DirectoryInfo(dialog.SelectedPath)); } else { Alert.showDialog("Cannot access the specified folder", App.NAME); } } }
public MainWindow() { InitializeComponent(); // load all past directories and throw 'em into the content StackPanel try { var pastDirs = PastDirectory.load(); foreach (var dir in pastDirs) { addPastDirectory(dir); } } catch (Exception ex) { Alert.showMoreInfoDialog("There was a problem loading your directory history", ex.Message, App.NAME); } }
/// <summary> /// Adds a <see cref="PastDirectory"/> control to the <see cref="content"/> StackPanel /// </summary> /// <param name="pastDir"><see cref="PastDirectory"/> control to add</param> private void addPastDirectory(PastDirectory pastDir) { pastDir.click += pastDirectory_click; content.Children.Add(pastDir); }
private void Window_Closing(object sender, CancelEventArgs e) { // write all past opened directories to their file PastDirectory.save(); }