///////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Draws MdiClient background and application version info. /// </summary> /// private void DrawMdiClientWindow() { MdiClient.BorderBackColor = Color.Black; MdiClient.BorderBackColorInact = Color.Black; MdiClient.BorderForeColor = Color.DarkCyan; MdiClient.BorderForeColorInact = Color.DarkCyan; MdiClient.BackColor = Color.Black; MdiClient.ForeColor = Color.DarkCyan; MdiClient.FillRectangle(0, 0, MdiClient.Width, MdiClient.Height, ' '); ///////////////////////////////////////////////////////////////////////////////// // Display application version info. // string info = GetVerboseVersionInfo(); TaggedTextCollection lines = TaggedText.SplitTextInLines(info); int left = MdiClient.Width - 2 - lines.MaxTextLength; int top = MdiClient.Height - 1 - lines.Count; for (int i = 0; i < lines.Count; ++i) { MdiClient.At(left, top + i).Write(lines[i].Text); } // Display information about tracing, if any. // Debug.IfTracingExecute(() => { MdiClient.ForeColor = Color.DarkMagenta; MdiClient.At(2, MdiClient.Height - 3); MdiClient.Write("Tracing to: "); MdiClient.Write(System.IO.Path.GetFileName(Debug.TraceFile.Name)); MdiClient.At(2, MdiClient.Height - 2); MdiClient.Write("Trace flags: "); MdiClient.Write(Debug.TraceFlags.Verbose()); }); }
///////////////////////////////////////////////////////////////////////////////// // Constructs sample application form. // public TestClient_TUI() : base(100, 40) { this.Text = applicationTitle; this.WindowUnloaded += new EventHandler(EH_WindowUnloaded); ///////////////////////////////////////////////////////////////////////////// // Client Area default text MdiClient.Border = false; MdiClient.SetSize(Width, Height - 3); --MdiClient.Left; --MdiClient.Top; MdiClient.ForeColor = Color.DarkCyan; MdiClient.FillRectangle(0, 0, MdiClient.Width, MdiClient.Height, '▒'); MdiClient.DrawFrame(0, 0, MdiClient.Width, MdiClient.Height); MdiClient.BackColor = BackColor; MdiClient.ForeColor = ForeColor; MdiClient.SetCursorPosition(60, 3); MdiClient.WriteLine("Text User Interface Test Suite\r\n"); MdiClient.WriteLine("▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒"); MdiClient.WriteLine("ABCDEFGHIJKLMNOPQRSTUVWXYZÖÅÄÉ\r\n" + "abcdefghijklmnopqrstuvwxyzåäöé\n" + "\b\b\b«☺»" + "\r0123456789"); MdiClient.WriteLine("▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒"); MdiClient.SetColors(60, 5, 30, 5, Color.Black, Color.DarkGray); ///////////////////////////////////////////////////////////////////////////// // Application main menu Menu.MenuItems.Add(new MenuItem("-")); // test invalid separator MenuItem miEditor = new MenuItem("&Editor"); miEditor.ToolTipText = "Sets editor window in focus"; Menu.MenuItems.Add(miEditor); miEditor.Click += new EventHandler(EH_SetEditorInFocus); Menu.MenuItems.Add(new MenuItem("-")); // test invalid separator Menu.MenuItems.Add(new MenuItem("-")); // test invalid separator MenuItem miRed = new MenuItem("&Red"); miRed.ToolTipText = "Sets red window in focus."; Menu.MenuItems.Add(miRed); miRed.Click += new EventHandler(EH_SetRedInFocus); MenuItem miCyan = new MenuItem("&Cyan"); miCyan.ToolTipText = "Sets cyan window in focus."; Menu.MenuItems.Add(miCyan); miCyan.Click += new EventHandler(EH_SetCyanInFocus); MenuItem miSubmenu = new MenuItem("&Misc..."); miSubmenu.ToolTipText = "Grid test, button test and message box tests are here..."; Menu.MenuItems.Add(miSubmenu); Menu.MenuItems.Add(new MenuItem("-")); // test invalid separator ///////////////////////////////////////////////////////////////////////////// // Client window: Moveable winMoveable = new ButtonBase() { Name = "winMoveable", Left = 50, Top = 15, Width = 25, Height = 11, Border = true, BorderForeColor = Color.Yellow, BackColor = Color.DarkBlue, ForeColor = Color.Gray, }; winMoveable.DrawContents += new DrawEventHandler(EH_winMoveable_DrawContents); ///////////////////////////////////////////////////////////////////////////// // Client window: Cyan and SubCyan winCyan = new ButtonBase() { Name = "winCyan", TabStop = true, Left = 54, Top = 20, Width = 22, Height = 7, Border = true, BorderForeColor = Color.Green, BackColor = Color.DarkBlue, ForeColor = Color.Gray, Text = "Cyan Window:" }; textBoxSubCyan = new TextBox() { Name = "winSubCyan", Parent = winCyan, Multiline = false, Left = 1, Top = 2, Width = 20, Height = 1, BackColor = Color.DarkMagenta, ForeColor = Color.Cyan, ForeColorInact = Color.Gray, ToolTipText = "Cyan Window; Tests single-line text box with validation..." }; textBoxSubCyan.KeyDown += new KeyEventHandler(EH_winSubCyan_KeyDown); textBoxSubCyan.GotFocus += new EventHandler(EH_winSubCyan_GotFocus); checkBoxSubCyan = new CheckBox() { Name = "checkBoxSubCyan", Parent = winCyan, Left = 1, Top = 4, Width = 20, Height = 1, BackColor = Color.DarkMagenta, ForeColor = Color.Cyan, ForeColorInact = Color.Gray, Text = "Check box", ToolTipText = "Cyan Window; Checkbox to test..." }; checkBoxSubCyan.KeyDown += new KeyEventHandler(EH_winSubCyan_KeyDown); textBoxSubCyan.Validating += new CancelEventHandler(EH_textBoxSubCyan_Validating); ///////////////////////////////////////////////////////////////////////////// // Client window: Buffered drawBox = new MdiForm(21, 15) { Name = "winBuf", TabStop = false, Left = MdiClient.Width - 23, Top = MdiClient.Height - 17, Border = true }; drawBox.Write("Draw Box"); drawBox.ForeColor = Color.DarkMagenta; drawBox.DrawFrame(3, 3, 15, 10, BoxLines.NotJoined); drawBox.DrawFrame(3, 5, 15, 1, BoxLines.Joined); drawBox.DrawFrame(5, 3, 1, 10, BoxLines.Joined); drawBox.ForeColor = Color.Green; drawBox.CursorTop = 4; drawBox.CursorLeft = 8; drawBox.Write(" Test "); ///////////////////////////////////////////////////////////////////////////// // Client window: Red winRead = new ButtonBase() { Name = "winRed", TabStop = true, ToolTipText = "Red Window; Shift+Arrows moves only draw box, " + "Control+Arrows resizes draw box", Left = 75, Top = 18, Width = 20, Height = 10, Border = true, BackColor = Color.DarkRed, ForeColor = Color.Yellow, BackColorInact = Color.DarkRed, ForeColorInact = Color.DarkYellow, Text = "Red Window:", ForwadKeysToParent = true }; winRead.KeyDown += new KeyEventHandler(EH_winRed_KeyDown); winRead.GotFocus += new EventHandler(EH_winRed_GotFocus); winRead.LostFocus += new EventHandler(EH_winRed_LostFocus); ///////////////////////////////////////////////////////////////////////////// // Client window: Editor textBoxEditor = new TextBox() { Name = "winEditor", Multiline = true, ToolTipText = "Press F2 to load file 'VRO-test.txt' or AppKey for ListBox ...", Left = 5, Top = 5, Width = 40, Height = 15, VerticalScrollBar = true, Border = true, Caption = "TextBox as Editor", Text = "0 Editor\r\n" + "1\r\n" + "2\r\n" + "3\r\n" + "4\r\n" + "5\r\n" + "6 234567890123456789012345678901234567890123456789\r\n" + "7\r\n" + "8\r\n" + "9\r\n" + "10 sdfasdfasdfasfasfasdf1\r\n" + "11\r\n" + "12\r\n" + "1\b3 backspace\r\n" + "tabs\ta\tab\tabc\tabcd\tabcde\tabcdef\r\n" + "15\r\n" + "16\r\n" + "17\r\n" + "18\r\n" + "19\r\n" }; textBoxEditor.KeyDown += new KeyEventHandler(EH_winEditor_KeyDown); ///////////////////////////////////////////////////////////////////////////// // List box listBox = new ListBox() { Name = "listBox", Left = 5, Top = 5, Width = 40, Height = 15, VerticalScrollBar = true, Border = true, CaptionForeColor = Color.Red, Caption = "List Box (copied from TextBox)", Header = new string[] { string.Empty, " Header", string.Empty, ListBoxBase.WideDivider, }, Footer = new string [] { ListBoxBase.WideDivider, " Footer", } }; listBox.KeyDown += new KeyEventHandler(EH_listBox_KeyDown); ///////////////////////////////////////////////////////////////////////////// // Vertical submenu miSubmenu.MenuItems.Add(new MenuItem("-")); // test invalid sep. MenuItem miShowGrid = new MenuItem("Show &grid window"); miShowGrid.ToolTipText = "Shows a lots of windows in a grid..."; miSubmenu.MenuItems.Add(miShowGrid); miShowGrid.Click += new EventHandler(EH_ShowGridWindow); miSubmenu.MenuItems.Add(new MenuItem("-")); MenuItem m13 = new MenuItem("Test &Error Recovery"); m13.ToolTipText = "Throws exception"; miSubmenu.MenuItems.Add(m13); m13.Click += delegate { throw new Exception("Error Recovery Test"); }; miSubmenu.MenuItems.Add(new MenuItem("-")); MenuItem miTestButton = new MenuItem( "&&Long submenu item that && opens test &button (& multiple &&s) "); miTestButton.ToolTipText = "&&Long submenu item that && opens test &button (& multiple &&s) "; miSubmenu.MenuItems.Add(miTestButton); miTestButton.Click += new EventHandler(EH_SetTestButtonInFocus); miSubmenu.MenuItems.Add(new MenuItem("-")); // test invalid sep. ///////////////////////////////////////////////////////////////////////////// // Button buttonTest = new Button() { Name = "buttonTest", Border = true, Left = 5, Top = 10, AutoSize = true, HorizontalPadding = 2, // VerticalPadding = 1, Text = "Test Button\nwith very long line\nand the third line", ToolTipText = "Press ENTER to hide the button..." }; buttonTest.Click += new EventHandler(EH_buttonTest_Click); buttonTest2 = new Button() { Name = "buttonTest2", Border = true, Left = 5 + buttonTest.Width + 2, Top = 10, AutoSize = true, HorizontalPadding = 2, // VerticalPadding = 1, Text = "Test Button 2\nwith very long line\nand the third line", ToolTipText = "Press ENTER to hide the button...", TextAlign = TextAlign.Right }; buttonTest2.Click += new EventHandler(EH_buttonTest_Click); }