private void BrowseFolder() { var settings = new FolderBrowserDialogSettings { Description = "This is a description" }; bool? success = dialogService.ShowFolderBrowserDialog(this, settings); if (success == true) { Path = settings.SelectedPath; } }
/// <summary> /// Initializes a new instance of the <see cref="FolderBrowserDialogWrapper"/> class. /// </summary> /// <param name="settings">The settings for the folder browser dialog.</param> public FolderBrowserDialogWrapper(FolderBrowserDialogSettings settings) { if (settings == null) throw new ArgumentNullException(nameof(settings)); this.settings = settings; folderBrowserDialog = new FolderBrowserDialog { Description = settings.Description, SelectedPath = settings.SelectedPath, ShowNewFolderButton = settings.ShowNewFolderButton }; }
/// <summary> /// Initializes a new instance of the <see cref="FolderBrowserDialogWrapper"/> class. /// </summary> /// <param name="settings">The settings for the folder browser dialog.</param> public FolderBrowserDialogWrapper(FolderBrowserDialogSettings settings) { if (settings == null) throw new ArgumentNullException("settings"); this.settings = settings; folderBrowserDialog = new FolderBrowserDialog { Description = settings.Description, SelectedPath = settings.SelectedPath, ShowNewFolderButton = settings.ShowNewFolderButton }; }
public void ToSettings() { // Arrange var dialog = new FolderBrowserDialog(); var settings = new FolderBrowserDialogSettings(); var sync = new FolderBrowserDialogSettingsSync(dialog, settings); dialog.SelectedPath = @"C:\temp"; // Act sync.ToSettings(); // Assert Assert.That(settings.SelectedPath, Is.EqualTo(dialog.SelectedPath)); }
public void ToDialog() { // Arrange var dialog = new FolderBrowserDialog(); var settings = new FolderBrowserDialogSettings(); var sync = new FolderBrowserDialogSettingsSync(dialog, settings); settings.Description = "Some description"; settings.RootFolder = Environment.SpecialFolder.ProgramFiles; settings.SelectedPath = @"C:\temp"; settings.ShowNewFolderButton = !settings.ShowNewFolderButton; // Act sync.ToDialog(); // Assert Assert.That(dialog.Description, Is.EqualTo(settings.Description)); Assert.That(dialog.RootFolder, Is.EqualTo(settings.RootFolder)); Assert.That(dialog.SelectedPath, Is.EqualTo(settings.SelectedPath)); Assert.That(dialog.ShowNewFolderButton, Is.EqualTo(settings.ShowNewFolderButton)); }
public void SetUp() { dialog = new FolderBrowserDialog(); settings = new FolderBrowserDialogSettings(); sync = new FolderBrowserDialogSettingsSync(dialog, settings); }
public FolderBrowserDialogSettingsSync(FolderBrowserDialog dialog, FolderBrowserDialogSettings settings) { this.dialog = dialog ?? throw new ArgumentNullException(nameof(dialog)); this.settings = settings ?? throw new ArgumentNullException(nameof(settings)); }
/// <summary> /// Initializes a new instance of the <see cref="FolderBrowserDialogWrapper"/> class. /// </summary> /// <param name="settings">The settings for the folder browser dialog.</param> public FolderBrowserDialogWrapper(FolderBrowserDialogSettings settings) => this.settings = settings ?? throw new ArgumentNullException(nameof(settings));