/// <summary> /// Action to be taken when the OK button is pressed /// </summary> private void Ok() { if (string.IsNullOrEmpty(selectedFolder)) { EditorUtility.DisplayDialog("No folder selected!", "The selected folder cannot be blank", "OK"); return; } OnFolderSelected.SafeInvoke(this, new EventArgs <string>() { Value = selectedFolder }); okClicked = true; Close(); }
public override void Execute() { if (!CanExecute()) { throw new CannotExecuteCommandException(GetType()); } var openFolderDialog = new CommonOpenFileDialog { IsFolderPicker = true, EnsurePathExists = true, Multiselect = false }; var result = openFolderDialog.ShowDialog(); if (result != CommonFileDialogResult.Ok) { return; } var directoryPath = openFolderDialog.FileNames.Single(); OnFolderSelected?.Invoke(directoryPath); }
protected override void OnInitialized() { base.OnInitialized(); Root.Padding = "5px"; Root.Layout = Layout.LayoutType.Column; Root.Children = new List <Component>() { new Label("Wybierz folder") { Margin = "5px" }, new TreeView() { Width = "100%", Expand = true, Name = "treeview", Children = new List <Component>() { new TreeViewRoot("Computer") { Name = "computer_node", Icon = Icons.Desktop } } }, new Component() { Width = "100%", MarginTop = "5px", AutosizeY = true, Children = new List <Component>() { new Button("Nowy folder") { Action = () => CreateNewFolder() }, new Spacer(), new Button("Anuluj") { Action = () => Hide() }, new Button("Ok") { Appearance = Button.ButtonStyle.Filled, MarginLeft = "5px", Action = () => { TreeViewNode node = (Root.FindChild("treeview") as TreeView).GetSelectedNode(); if (node != null && node is TreeViewDirectory) { OnFolderSelected?.Invoke(this, (node as TreeViewDirectory).Path); } Hide(); } }, } } }; string[] drives = Directory.GetLogicalDrives(); TreeViewNode computerNode = Root.FindChild("computer_node") as TreeViewNode; foreach (var drive in drives) { computerNode.Children.Add(new TreeViewDirectory(drive) { Icon = Icons.Hdd }); } }