Example #1
0
        /// <inheritdoc />
        public virtual async Task <DetermineDirectoryResult> DetermineDirectoryAsync(DetermineDirectoryContext context)
        {
            Argument.IsNotNull(nameof(context), context);

            var browserDialog = new FolderBrowserDialog();

            browserDialog.Description         = context.Title;
            browserDialog.ShowNewFolderButton = context.ShowNewFolderButton;

            var initialDirectory = context.InitialDirectory;

            if (!string.IsNullOrEmpty(initialDirectory))
            {
                browserDialog.SelectedPath = IO.Path.AppendTrailingSlash(initialDirectory);
            }
            else
            {
                browserDialog.RootFolder = System.Environment.SpecialFolder.MyComputer;
            }

            var result = new DetermineDirectoryResult
            {
                Result        = browserDialog.ShowDialog() == DialogResult.OK,
                DirectoryName = browserDialog.SelectedPath
            };

            return(result);
        }
        /// <inheritdoc />
        public virtual async Task <DetermineDirectoryResult> DetermineDirectoryAsync(DetermineDirectoryContext context)
        {
            Argument.IsNotNull(nameof(context), context);

            var folderPicker = new FolderPicker();

            folderPicker.FileTypeFilter.Add(context.Filter);

            var folder = await folderPicker.PickSingleFolderAsync();

            var result = new DetermineDirectoryResult
            {
                Result        = folder != null,
                Directory     = folder,
                DirectoryName = folder?.Path
            };

            return(result);
        }