public Task<string> ShowFolderDialogAsync(OpenFolderDialog dialog, IWindowImpl parent) { var tcs = new TaskCompletionSource<string>(); var dlg = new global::Gtk.FileChooserDialog(dialog.Title, ((WindowImpl)parent), FileChooserAction.SelectFolder, "Cancel", ResponseType.Cancel, "Select Folder", ResponseType.Accept) { }; dlg.Modal = true; dlg.Response += (_, args) => { if (args.ResponseId == ResponseType.Accept) tcs.TrySetResult(dlg.Filename); dlg.Hide(); dlg.Dispose(); }; dlg.Close += delegate { tcs.TrySetResult(null); dlg.Dispose(); }; dlg.Show(); return tcs.Task; }
private async Task GetOutputPath() { var dlg = new OpenFolderDialog(); string text = textOutputPath.Text; if (text.Length > 0) { dlg.InitialDirectory = textOutputPath.Text; } var result = await dlg.ShowAsync(); if (!string.IsNullOrWhiteSpace(result)) { textOutputPath.Text = result; } }
public OpenFolderCommandDefinition() { command = ReactiveCommand.Create(); command.Subscribe(async _ => { var shell = IoC.Get<IShell>(); var ofd = new OpenFolderDialog(); var result = await ofd.ShowAsync(); if (result != string.Empty) { //shell.CurrentSolution = RawProject.CreateRawSolution(result); } }); }
private async Task promptForDirectoryPath() { var dialog = new Avalonia.Controls.OpenFolderDialog(); // if there is allready a folder picked, then use it if it exists. If something isn't right use Desktop if (!string.IsNullOrEmpty(this.DirectoryPath) && System.IO.Directory.Exists(this.DirectoryPath)) { dialog.Directory = this.DirectoryPath; } else { dialog.Directory = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop); } var win = (Window)this.GetVisualRoot(); string result = await dialog.ShowAsync(win); if (!string.IsNullOrWhiteSpace(result)) { DirectoryPath = result; } }
public Task<string> ShowFolderDialogAsync(OpenFolderDialog dialog, IWindowImpl parent) { return Task.Factory.StartNew(() => { string result = string.Empty; var hWnd = parent?.Handle?.Handle ?? IntPtr.Zero; var frm = (IFileDialog)(new UnmanagedMethods.FileOpenDialogRCW()); uint options; frm.GetOptions(out options); options |= (uint)(UnmanagedMethods.FOS.FOS_PICKFOLDERS | UnmanagedMethods.FOS.FOS_FORCEFILESYSTEM | UnmanagedMethods.FOS.FOS_NOVALIDATE | UnmanagedMethods.FOS.FOS_NOTESTFILECREATE | UnmanagedMethods.FOS.FOS_DONTADDTORECENT); frm.SetOptions(options); if (dialog.InitialDirectory != null) { IShellItem directoryShellItem; var riid = new Guid("43826D1E-E718-42EE-BC55-A1E261C37BFE"); //IShellItem if (UnmanagedMethods.SHCreateItemFromParsingName(dialog.InitialDirectory, IntPtr.Zero, ref riid, out directoryShellItem) == (uint)UnmanagedMethods.HRESULT.S_OK) { frm.SetFolder(directoryShellItem); } } if (dialog.DefaultDirectory != null) { IShellItem directoryShellItem; var riid = new Guid("43826D1E-E718-42EE-BC55-A1E261C37BFE"); //IShellItem if (UnmanagedMethods.SHCreateItemFromParsingName(dialog.DefaultDirectory, IntPtr.Zero, ref riid, out directoryShellItem) == (uint)UnmanagedMethods.HRESULT.S_OK) { frm.SetDefaultFolder(directoryShellItem); } } if (frm.Show(hWnd) == (uint)UnmanagedMethods.HRESULT.S_OK) { IShellItem shellItem; if (frm.GetResult(out shellItem) == (uint)UnmanagedMethods.HRESULT.S_OK) { IntPtr pszString; if (shellItem.GetDisplayName(UnmanagedMethods.SIGDN_FILESYSPATH, out pszString) == (uint)UnmanagedMethods.HRESULT.S_OK) { if (pszString != IntPtr.Zero) { try { result = Marshal.PtrToStringAuto(pszString); } finally { Marshal.FreeCoTaskMem(pszString); } } } } } return result; }); }
public MainWindowViewModel() { Items = new List<TestItem>(); for (int i = 0; i < 10; ++i) { Items.Add(new TestItem($"Item {i}", $"Item {i} Value")); } Nodes = new List<TestNode> { new TestNode { Header = "Root", SubHeader = "Root Item", IsExpanded = true, Children = new[] { new TestNode { Header = "Child 1", SubHeader = "Child 1 Value", }, new TestNode { Header = "Child 2", SubHeader = "Child 2 Value", IsExpanded = false, Children = new[] { new TestNode { Header = "Grandchild", SubHeader = "Grandchild Value", }, new TestNode { Header = "Grandmaster Flash", SubHeader = "White Lines", }, } }, } } }; CollapseNodesCommand = ReactiveCommand.Create(); CollapseNodesCommand.Subscribe(_ => ExpandNodes(false)); ExpandNodesCommand = ReactiveCommand.Create(); ExpandNodesCommand.Subscribe(_ => ExpandNodes(true)); OpenFileCommand = ReactiveCommand.Create(); OpenFileCommand.Subscribe(_ => { var ofd = new OpenFileDialog(); ofd.ShowAsync(); }); OpenFolderCommand = ReactiveCommand.Create(); OpenFolderCommand.Subscribe(_ => { var ofd = new OpenFolderDialog(); ofd.ShowAsync(); }); shell = ShellViewModel.Instance; }
public Task<string> ShowFolderDialogAsync(OpenFolderDialog dialog, IWindowImpl parent) { throw new NotImplementedException(); }