Beispiel #1
0
        public Task <string[]> ShowFileDialogAsync(FileDialog dialog, IWindowBaseImpl parent)
        {
            var events = new SystemDialogEvents();

            if (dialog is OpenFileDialog ofd)
            {
                _native.OpenFileDialog((parent as WindowImpl)?.Native,
                                       events, ofd.AllowMultiple,
                                       ofd.Title ?? "",
                                       ofd.InitialDirectory ?? "",
                                       ofd.InitialFileName ?? "",
                                       string.Join(";", dialog.Filters.SelectMany(f => f.Extensions)));
            }
            else
            {
                _native.SaveFileDialog((parent as WindowImpl)?.Native,
                                       events,
                                       dialog.Title ?? "",
                                       dialog.InitialDirectory ?? "",
                                       dialog.InitialFileName ?? "",
                                       string.Join(";", dialog.Filters.SelectMany(f => f.Extensions)));
            }

            return(events.Task.ContinueWith(t => { events.Dispose(); return t.Result; }));
        }
        public Task <string[]> ShowFileDialogAsync(FileDialog dialog, Window parent)
        {
            var events = new SystemDialogEvents();

            var nativeParent = GetNativeWindow(parent);

            if (dialog is OpenFileDialog ofd)
            {
                _native.OpenFileDialog(nativeParent,
                                       events, ofd.AllowMultiple.AsComBool(),
                                       ofd.Title ?? "",
                                       ofd.Directory ?? "",
                                       ofd.InitialFileName ?? "",
                                       string.Join(";", dialog.Filters.SelectMany(f => f.Extensions)));
            }
            else
            {
                _native.SaveFileDialog(nativeParent,
                                       events,
                                       dialog.Title ?? "",
                                       dialog.Directory ?? "",
                                       dialog.InitialFileName ?? "",
                                       string.Join(";", dialog.Filters.SelectMany(f => f.Extensions)));
            }

            return(events.Task.ContinueWith(t => { events.Dispose(); return t.Result; }));
        }
Beispiel #3
0
        public Task <string> ShowFolderDialogAsync(OpenFolderDialog dialog, IWindowBaseImpl parent)
        {
            var events = new SystemDialogEvents();

            _native.SelectFolderDialog((parent as WindowImpl)?.Native, events, dialog.Title ?? "", dialog.InitialDirectory ?? "");

            return(events.Task.ContinueWith(t => { events.Dispose(); return t.Result.FirstOrDefault(); }));
        }
Beispiel #4
0
        public Task <string> ShowFolderDialogAsync(OpenFolderDialog dialog, Window parent)
        {
            var events = new SystemDialogEvents();

            var nativeParent = GetNativeWindow(parent);

            _native.SelectFolderDialog(nativeParent, events, dialog.Title ?? "", dialog.InitialDirectory ?? "");

            return(events.Task.ContinueWith(t => { events.Dispose(); return t.Result.FirstOrDefault(); }));
        }
        public override async Task <IReadOnlyList <IStorageFolder> > OpenFolderPickerAsync(FolderPickerOpenOptions options)
        {
            using var events = new SystemDialogEvents();

            var suggestedDirectory = options.SuggestedStartLocation?.TryGetUri(out var suggestedDirectoryTmp) == true
                ? suggestedDirectoryTmp.LocalPath : string.Empty;

            _native.SelectFolderDialog((IAvnWindow)_window.Native, events, options.AllowMultiple.AsComBool(), options.Title ?? "", suggestedDirectory);

            var result = await events.Task.ConfigureAwait(false);

            return(result?.Select(f => new BclStorageFolder(new DirectoryInfo(f))).ToArray()
                   ?? Array.Empty <IStorageFolder>());
        }
        public override async Task <IStorageFile?> SaveFilePickerAsync(FilePickerSaveOptions options)
        {
            using var events = new SystemDialogEvents();

            var suggestedDirectory = options.SuggestedStartLocation?.TryGetUri(out var suggestedDirectoryTmp) == true
                ? suggestedDirectoryTmp.LocalPath : string.Empty;

            _native.SaveFileDialog((IAvnWindow)_window.Native,
                                   events,
                                   options.Title ?? string.Empty,
                                   suggestedDirectory,
                                   options.SuggestedFileName ?? string.Empty,
                                   PrepareFilterParameter(options.FileTypeChoices));

            var result = await events.Task.ConfigureAwait(false);

            return(result.FirstOrDefault() is string file
                ? new BclStorageFile(new FileInfo(file))
                : null);
        }