public static int Query(int width, int height, string title, string message, params string [] buttons) { var d = new Dialog (width, height, title); int clicked = -1, count = 0; foreach (var s in buttons){ int n = count++; var b = new Button (s); b.Clicked += delegate { clicked = n; d.Running = false; }; d.AddButton (b); } if (message != null){ var l = new Label ((width - 4 - message.Length)/2, 0, message); d.Add (l); } Application.Run (d); return clicked; }
public ProgressInteraction(string title, int fileCount, double? byteCount) : base(title) { Count = fileCount; ByteCount = byteCount; Add (new Label (3, 2, "File")); Add ((filePct = new Label (30, 2, ""))); if (Count > 1){ Add (new Label (3, 3, "Count")); Add ((countPct = new Label (30, 3, ""))); } if (byteCount.HasValue){ Add (new Label (3, 4, "Bytes")); Add ((bytesPct = new Label (30, 4, ""))); } AddButton (new Button (10, 7, "Cancel")); }
void SetupGUI() { left = Panel.Create (this, "left", 4); right = Panel.Create (this, "right", 4); bar = new ButtonBar (bar_labels); menu = new MenuBar (mc_menu); prompt = new Label (0, Application.Lines-2, "bash$ ") { Color = Application.ColorBasic }; entry = new Entry (prompt.Text.Length, Application.Lines-2, Application.Cols - prompt.Text.Length, "") { Color = Application.ColorBasic, CanFocus = false, }; bar.Action += delegate (int n) { switch (n) { case 5: CurrentPanel.Copy (OtherPanel.CurrentPath); break; case 9: menu.Activate (0); break; case 10: var r = MessageBox.Query (56, 7, "Midnight Commander NG", "Do you really want to quit?", "Yes", "No"); if (r == 0) Running = false; break; default: break; } }; Add (left); Add (right); Add (bar); Add (menu); Add (prompt); Add (entry); SetFocus (left); }
void SetupGUI() { var height = Application.Lines - 4; left = Panel.Create (this, "left", 4); right = Panel.Create (this, "right", 4); bar = new ButtonBar (bar_labels); menu = new MenuBar (mc_menu); prompt = new Label (0, Application.Lines-2, "bash$ acción ") { Color = Application.ColorBasic }; entry = new Entry (prompt.Text.Length, Application.Lines-2, Application.Cols - prompt.Text.Length, "") { Color = Application.ColorBasic, CanFocus = false, }; bar.Action += delegate (int n){ switch (n){ case 3: var selected = CurrentPanel.SelectedNode; if (selected is Listing.DirNode) CurrentPanel.ChangeDir (selected as Listing.DirNode); else { Stream stream; try { stream = File.OpenRead (CurrentPanel.SelectedPath); } catch (IOException ioe) { Message.Error (ioe, "Could not open file", CurrentPanel.SelectedPath); return; } FullView.Show (stream); stream.Dispose (); } break; case 5: CurrentPanel.Copy (OtherPanel.CurrentPath); break; case 9: menu.Activate (0); break; case 10: var r = MessageBox.Query (56, 7, "Midnight Commander NG", "Do you really want to quit?", "Yes", "No"); if (r == 0) Running = false; break; default: break; } }; Add (left); Add (right); Add (bar); Add (menu); Add (prompt); Add (entry); SetFocus (left); }