/// <inheritdoc />
        public bool?ShowDialog(Window owner)
        {
            if (owner == null)
            {
                throw new ArgumentNullException(nameof(owner));
            }

            using (var dialog = new FolderBrowserDialog())
            {
                var sync = new FolderBrowserDialogSettingsSync(dialog, settings);

                // Update dialog
                sync.ToDialog();

                DialogResult result = dialog.ShowDialog(new Win32Window(owner));

                // Update settings
                sync.ToSettings();

                switch (result)
                {
                case DialogResult.OK:
                case DialogResult.Yes:
                    return(true);

                case DialogResult.No:
                case DialogResult.Abort:
                    return(false);

                default:
                    return(null);
                }
            }
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        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);
 }