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(); }));
        }