static void Test_filesystemdlg() { var frm = new Form(0, 0, Console.WindowWidth, Console.WindowHeight) { Title = "Filesystem Dialog" }; frm.AddChild(new Label(2, 2, "Path to open dialog on: ")); frm.AddChild(new TextLine(26, 2, 20) { Text = "../..", Name = "txtPath" }); frm.AddChild(new Option(26, 3, 20, "Directories only") { Name = "optDirsOnly" }); frm.AddChild(new Option(26, 4, 20, "Allow new name") { Name = "optNewFileOrFoldername" }); frm.AddChild(new Listbox(50, 2, 20, 20) { Name = "lbSelected", TabIndex = -1, BackgroundColor = ConsoleColor.DarkGray }); frm.AddChild(new Button(26, 5, 10, "Open...") { OnPressed = (s, e) => { var fsdlg = new FilesystemDialog(frm.Child <TextLine>("txtPath").Text) { ListDirectoriesOnly = frm.Child <Option>("optDirsOnly").Selected, AllowNewFileOrFoldername = frm.Child <Option>("optNewFileOrFoldername").Selected }; var selection = BashForms.OpenModal(fsdlg); frm.Child <Listbox>("lbSelected").Clear(); frm.Child <Listbox>("lbSelected").AddRange(selection.Select(fn => new Listbox.Item(fn))); } }); frm.AddChild(new Button(26, 7, 10, "Close") { OnPressed = (s, e) => BashForms.Close() }); BashForms.Open(frm); }
public Task Edit(Task task) { if (task == null) { task = new Task(); _dlg.Title = "Edit new task"; } Bind(); if (!BashForms.OpenModal(_dlg)) { return(null); } Retrieve(); return(task); void Bind() { _txtSubject.Text = task.Subject; _txtDescription.Text = task.Description; _txtDueDate.Text = task.DueAt.Date == DateTime.MaxValue.Date ? "" : task.DueAt.ToString("d"); _cboPriority.Text = task.Priority == TaskPriorities.No ? "" : task.Priority.ToString(); _txtTags.Text = String.Join(",", task.Tags); } void Retrieve() { task.Subject = _txtSubject.Text; task.Description = _txtDescription.Text; task.DueAt = _txtDueDate.Text != "" ? DateTime.Parse(_txtDueDate.Text) : DateTime.MaxValue; if (!Enum.TryParse(_cboPriority.Text, true, out task.Priority)) { task.Priority = TaskPriorities.No; } task.Tags = _txtTags.Text.Split(new[] { ',', ';', '#', ' ' }, StringSplitOptions.RemoveEmptyEntries); } }