예제 #1
0
 private List <string> AddFolder()
 {
     _folderBrowserDialog.CheckFolderExists = true;
     if (_folderBrowserDialog.ShowDialog() && !string.IsNullOrWhiteSpace(_folderBrowserDialog.SelectedPath))
     {
         return new List <string> {
                    _folderBrowserDialog.SelectedPath
         }
     }
     ;
     _folderBrowserDialog.Reset();
     return(null);
 }
        bool IFolderBrowserDialogService.ShowDialog()
        {
            Dialog.Description         = Description;
            Dialog.RootFolder          = RootFolder;
            Dialog.ShowNewFolderButton = ShowNewFolderButton;
            if (RestorePreviouslySelectedDirectory && !string.IsNullOrEmpty(resultPath))
            {
                Dialog.SelectedPath = resultPath;
            }
            else
            {
                Dialog.SelectedPath = StartPath;
            }
            var res = Dialog.ShowDialog();

            resultPath = Dialog.SelectedPath;
            if (res == DialogResult.OK)
            {
                return(true);
            }
            if (res == DialogResult.Cancel)
            {
                return(false);
            }
            throw new InvalidOperationException();
        }
예제 #3
0
        /// <summary>
        /// Display a <see cref="IFolderBrowserDialog"/> and return the selected path.
        /// </summary>
        /// <param name="initialDirectory">The directory location to start browsing</param>
        /// <param name="title">The dialog title</param>
        /// <returns>The user selected path, or an empty string if no directory was selected</returns>
        public string FolderBrowserDialog(string initialDirectory, string title = "Select folder")
        {
            _folderBrowserDialog.Title            = title;
            _folderBrowserDialog.InitialDirectory = initialDirectory;
            _folderBrowserDialog.ShowDialog();

            return(_folderBrowserDialog.SelectedPath);
        }
예제 #4
0
 private void SelectFolder()
 {
     if (_folderBrowserDialog.ShowDialog() == true)
     {
         this.FolderPath = _folderBrowserDialog.SelectedPath;
         RunProcessCommand.RaiseCanExecuteChanged();
     }
 }
예제 #5
0
 private void BrowseDownloadLocation()
 {
     folderBrowserDialog.SelectedPath        = DownloadLocation;
     folderBrowserDialog.ShowNewFolderButton = true;
     if (folderBrowserDialog.ShowDialog() == true)
     {
         DownloadLocation = folderBrowserDialog.SelectedPath;
     }
 }
        private bool TryGetFolderPath(out string path)
        {
            FolderBrowserDialog.Reset();
            FolderBrowserDialog.CheckFolderExists = true;
            var result = FolderBrowserDialog.ShowDialog();

            path = FolderBrowserDialog.SelectedPath;
            return(result);
        }
예제 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConfigurationWrapper" /> class that is to manage the sever configuration file.
 /// </summary>
 /// <param name="file">The file containing the configuration.</param>
 /// <param name="configurationEditor">The server configuration editor main interface.</param>
 /// <param name="userInterface">The user interface that provides basic functionality to implement user interactivity.</param>
 /// <exception cref="System.ArgumentNullException">
 /// The server configuration editor main interface cannot be null
 /// or
 /// userInterface
 /// </exception>
 public ConfigurationWrapper(FileInfo file, IConfiguration configurationEditor, IGraphicalUserInterface userInterface)
 {
     if (configurationEditor == null)
     {
         throw new System.ArgumentNullException("The server configuration editor main interface cannot be null");
     }
     if (userInterface == null)
     {
         throw new System.ArgumentNullException($"The {nameof(userInterface)} cannot be null");
     }
     m_ServerConfiguration = configurationEditor;
     m_userInterface       = userInterface;
     if (file != null)
     {
         ConfigurationFile = file;
     }
     else
     {
         ConfigurationFile = FindConfigurationFile();
     }
     if (ConfigurationFile != null)
     {
         file = ConfigurationFile;
         Read(file);
     }
     else
     {
         m_userInterface.MessageBoxShowExclamation(Resources.ConfigurationWrapper_NoConfigurationFileSelectedInfo, Resources.ConfigurationWrapper_NoConfigurationFileSelectedHeader);
         string selectedPath = String.Empty;
         using (IFolderBrowserDialog _fbd = m_userInterface.OpenFolderBrowserDialogFunc())
         {
             if (_fbd.ShowDialog())
             {
                 selectedPath = _fbd.SelectedPath;
             }
         }
         if (string.IsNullOrEmpty(selectedPath))
         {
             m_userInterface.MessageBoxShowExclamation(Resources.ConfigurationWrapperNoFolderSelectedInfo, Resources.ConfigurationWrapperNoFolderSelectedHeader);
             selectedPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
         }
         configurationEditor.CreateDefaultConfiguration();
         try
         {
             file = new FileInfo(Path.Combine(selectedPath, configurationEditor.DefaultFileName));
         }
         catch (Exception exception)
         {
             m_userInterface.MessageBoxShowError(Resources.ConfigurationWrapperProblemWithOpeningOfTheFileInfo + exception.Message, Resources.ConfigurationWrapperProblemWithOpeningOfTheFileHeader);
         }
         configurationEditor.SaveConfiguration(String.Empty, file);
         Read(file);
     }
 }
예제 #8
0
 /// <summary/>
 public DialogResult ShowDialog()
 {
     return(m_dlg.ShowDialog());
 }