protected override void OnPaint(ITerminal terminal) { terminal = terminal[TermColor.White, TermColor.DarkGray]; terminal.Clear(); // write the instruction terminal[0, 0][TermColor.LightGray].Write("Enter a number:"); if (mReplacing) { terminal[16, 0][TermColor.Black, TermColor.Yellow].Write(mText); } else { terminal[16, 0][TermColor.Yellow].Write(mText); terminal[16 + mText.Length, 0][TermColor.Black, TermColor.Yellow].Write(" "); } Stack <KeyInstruction> instructions = new Stack <KeyInstruction>(); instructions.Push(new KeyInstruction("Increment", new KeyInfo(Key.Up), new KeyInfo(Key.Down))); instructions.Push(new KeyInstruction("Min/Max", new KeyInfo(Key.Left), new KeyInfo(Key.Right))); instructions.Push(new KeyInstruction("Enter Digit", new KeyInfo(Key.Digit0), new KeyInfo(Key.Dash), new KeyInfo(Key.Digit9))); instructions.Push(new KeyInstruction("Cancel", new KeyInfo(Key.Escape))); instructions.Push(new KeyInstruction("Accept", new KeyInfo(Key.Enter))); // write the keys from right to left int x = terminal.Size.X; while (instructions.Count > 0) { KeyInstruction instruction = instructions.Pop(); // write the text x -= instruction.Instruction.Length; terminal[x, 0].Write(instruction.Instruction); // write the glyphs x--; for (int j = instruction.Keys.Length - 1; j >= 0; j--) { Glyph[] glyphs = instruction.Keys[j].DisplayGlyphs; for (int i = glyphs.Length - 1; i >= 0; i--) { x--; terminal[x, 0][TermColor.Yellow].Write(glyphs[i]); } } // put some space between each instruction x -= 2; } }
protected override void OnPaint(ITerminal terminal) { terminal = terminal[TermColor.White, TermColor.DarkGray]; terminal.Clear(); // write the instruction terminal[0, 0][TermColor.LightGray].Write(Title); if (mValue) { terminal[Title.Length + 1, 0][TermColor.Yellow].Write("Yes"); } else { terminal[Title.Length + 1, 0][TermColor.Yellow].Write("No"); } Stack <KeyInstruction> instructions = new Stack <KeyInstruction>(); instructions.Push(new KeyInstruction("Yes", new KeyInfo(Key.Y, true))); instructions.Push(new KeyInstruction("No", new KeyInfo(Key.N, true))); instructions.Push(new KeyInstruction("Cancel", new KeyInfo(Key.Escape))); instructions.Push(new KeyInstruction("Accept", new KeyInfo(Key.Enter))); // write the keys from right to left int x = terminal.Size.X; while (instructions.Count > 0) { KeyInstruction instruction = instructions.Pop(); // write the text x -= instruction.Instruction.Length; terminal[x, 0].Write(instruction.Instruction); // write the glyphs x--; for (int j = instruction.Keys.Length - 1; j >= 0; j--) { Glyph[] glyphs = instruction.Keys[j].DisplayGlyphs; for (int i = glyphs.Length - 1; i >= 0; i--) { x--; terminal[x, 0][TermColor.Yellow].Write(glyphs[i]); } } // put some space between each instruction x -= 2; } }
protected override void OnPaint(ITerminal terminal) { terminal = terminal[TermColor.White, TermColor.DarkGray]; terminal.Clear(); // write the instruction string instruction = Screen.UI.Title; IFocusable focus = Screen.FocusControl; if (focus != null) { instruction = focus.Instruction; } else if (!String.IsNullOrEmpty(Screen.UI.CurrentScreen.Title)) { instruction = Screen.UI.CurrentScreen.Title; } terminal[0, 0][TermColor.LightGray].Write(instruction); Stack <KeyInstruction> instructions = new Stack <KeyInstruction>(); // get the focused control key instructions IInputHandler input = Screen.FocusControl as IInputHandler; if (input != null) { foreach (KeyInstruction keyInstruction in input.KeyInstructions) { instructions.Push(keyInstruction); } } else { foreach (Control control in Screen.Controls) { input = control as IInputHandler; if (input != null) { foreach (KeyInstruction keyInstruction in input.KeyInstructions) { instructions.Push(keyInstruction); } } } } // get the screen control keys IInputHandler screen = Screen as IInputHandler; if (screen != null) { foreach (KeyInstruction keyInstruction in screen.KeyInstructions) { instructions.Push(keyInstruction); } } // write the keys from right to left int x = terminal.Size.X; while (instructions.Count > 0) { KeyInstruction keyInstruction = instructions.Pop(); // write the text x -= keyInstruction.Instruction.Length; terminal[x, 0].Write(keyInstruction.Instruction); // write the glyphs x--; for (int j = keyInstruction.Keys.Length - 1; j >= 0; j--) { Glyph[] glyphs = keyInstruction.Keys[j].DisplayGlyphs; for (int i = glyphs.Length - 1; i >= 0; i--) { x--; terminal[x, 0][TermColor.Yellow].Write(glyphs[i]); } } // put some space between each instruction x -= 2; } }