/// ------------------------------------------------------------------------------------ /// <summary> /// Handle the Folder browse button to locate a folder to write to. /// </summary> /// ------------------------------------------------------------------------------------ protected virtual void btnFolderBrowse_Click(object sender, System.EventArgs e) { using (var dlg = new FolderBrowserDialogAdapter()) { dlg.SelectedPath = BaseOutputFolder; dlg.Description = TeResourceHelper.GetResourceString(StidExportDlgFolderBrowserPrompt); dlg.ShowNewFolderButton = true; if (dlg.ShowDialog() == DialogResult.OK) { BaseOutputFolder = dlg.SelectedPath; m_fUserModifiedFolder = true; } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Handles the Click event of the m_btnBrowseDest control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param> /// ------------------------------------------------------------------------------------ private void m_btnBrowseDest_Click(object sender, EventArgs e) { Logger.WriteEvent("Browsing for destination folder in 'Picture Properties' dialog"); using (var dlg = new FolderBrowserDialogAdapter()) { dlg.SelectedPath = m_txtDestination.Text; dlg.Description = String.Format(FwCoreDlgs.kstidSelectLinkedFilesSubFolder, s_defaultPicturesFolder); dlg.ShowNewFolderButton = true; if (dlg.ShowDialog() == DialogResult.OK) { if (ValidateDestinationFolder(dlg.SelectedPath)) { m_txtDestination.Text = dlg.SelectedPath; } } } }
private void m_browse_Click(object sender, EventArgs e) { using (var dlg = new FolderBrowserDialogAdapter()) { dlg.Description = String.Format(FwCoreDlgs.ksDirectoryLocationForBackup); dlg.ShowNewFolderButton = true; if (String.IsNullOrEmpty(DestinationFolder) || !Directory.Exists(DestinationFolder)) { dlg.SelectedPath = FwDirectoryFinder.DefaultBackupDirectory; } else { dlg.SelectedPath = DestinationFolder; } if (dlg.ShowDialog(this) == DialogResult.OK) { DestinationFolder = dlg.SelectedPath; } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Handles the Click event of the m_btnBrowseProjectFolder control. /// It launches a FolderBrowserDialog with the initial directory being one of: /// - the folder specified in the text box, if it exists; /// - otherwise, the specified default path, if that folder exists /// - otherwise, My Computer (was C:\, but that won't work on Linux). /// </summary> /// ------------------------------------------------------------------------------------ private void m_btnBrowseProjectFolder_Click(object sender, EventArgs e) { string defaultPath = FwDirectoryFinder.ProjectsDirectory; using (var fldrBrowse = new FolderBrowserDialogAdapter()) { fldrBrowse.ShowNewFolderButton = true; fldrBrowse.Description = FwCoreDlgs.ksChooseProjectFolder; bool backupDirExists = FileUtils.DirectoryExists(m_tbProjectsFolder.Text); // if the directory exists which is typed in the text box... if (backupDirExists) { fldrBrowse.SelectedPath = m_tbProjectsFolder.Text; } else { // check the last directory used in the registry. If it exists, begin looking // here. if (FileUtils.DirectoryExists(defaultPath)) { fldrBrowse.SelectedPath = defaultPath; } else { // Otherwise, begin looking in My Computer fldrBrowse.SelectedPath = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer); } } // if directory selected, set path to it. if (fldrBrowse.ShowDialog() == DialogResult.OK) { m_tbProjectsFolder.Text = fldrBrowse.SelectedPath; } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// LinkedFiles Browse /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// ------------------------------------------------------------------------------------ private void btnLinkedFilesBrowse_Click(object sender, EventArgs e) { using (var folderBrowserDlg = new FolderBrowserDialogAdapter()) { folderBrowserDlg.Description = FwCoreDlgs.folderBrowserDlgDescription; folderBrowserDlg.RootFolder = Environment.SpecialFolder.Desktop; if (!Directory.Exists(txtExtLnkEdit.Text)) { string msg = String.Format(FwCoreDlgs.ksLinkedFilesFolderIsUnavailable, txtExtLnkEdit.Text); MessageBox.Show(msg, FwCoreDlgs.ksLinkedFilesFolderUnavailable); folderBrowserDlg.SelectedPath = m_defaultLinkedFilesFolder; } else { folderBrowserDlg.SelectedPath = txtExtLnkEdit.Text; } if (folderBrowserDlg.ShowDialog() == DialogResult.OK) { txtExtLnkEdit.Text = folderBrowserDlg.SelectedPath; } } }