/*** public TCPEchoClient() * * Constructor: * * Puts up the TCPEchoClient Windows Form * * Put the selection at the end of the text to send and have echo'ed * * By default this is set to go to 192.168.1.190:190 for the echo server * Hitting a return in the form defaults to hitting the Send button * ------------------------------------------------------------ */ public TCPEchoClient() { DPrintText = PrintText; AssemblyName asmName = Assembly.GetExecutingAssembly().GetName(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(""); InitializeComponent(); AcceptButton = Send; SendText.Select(); SendText.SelectionStart = SendText.Text.Length; SendText.SelectionLength = 0; PrintText(asmName.Name + " Version " + asmName.Version.ToString(), Color.Black); PrintText("Digilent, Copyright 2011", Color.Black); }
/*** public UDPEchoClient() * * Constructor: * * Puts up the UDPEchoClient Windows Form * * Put the selection at the end of the text to send and have echo'ed * * By default this is set to go to 192.168.1.190:1200 for the echo server * Hitting a return in the form defaults to hitting the Send button * ------------------------------------------------------------ */ public UDPEchoClient() { DPrintText = PrintText; AssemblyName asmName = Assembly.GetExecutingAssembly().GetName(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(""); InitializeComponent(); AcceptButton = Send; SendText.Select(); SendText.SelectionStart = SendText.Text.Length; SendText.SelectionLength = 0; PrintText(asmName.Name + " Version " + asmName.Version.ToString(), Color.Black); PrintText("Digilent, Copyright 2011", Color.Black); }
/// <summary> /// Writes a message to the center of the screen, accepts a delegate object, /// redirecting execution to the appropriate method for printing the text /// in an appropriate colour. /// </summary> /// <param name="message">The message to be printed to the screen.</param> /// <param name="printTextDelegate">The function that will actually print the message to the screen</param> /// <param name="printFormattedTextDelegate">Used for recursive declaration of text formatting/styles.</param> public static void PrintMessageCenter(string message, PrintTextDelegate printTextDelegate, PrintFormattedTextDelegate printFormattedTextDelegate) { // Obtain the left side/left edge of the text we are going to write. int consolePointer = (Console.WindowWidth - message.Length) / 2; // Check/resolve text overflow possibilities. if (consolePointer < 0) { consolePointer = 0; } // Set the cursor position to our new left edge. Console.SetCursorPosition(consolePointer, Console.CursorTop); // Call our delegate to print the message. printFormattedTextDelegate(message, printTextDelegate); // Restore the left side/left edge pointer position. Console.SetCursorPosition(0, Console.CursorTop); }
/// <summary> /// Writes a message to the center of the screen, accepts a delegate object, /// redirecting execution to the appropriate method for printing the text /// in an appropriate colour. /// </summary> /// <param name="message">The message to be printed to the screen.</param> /// <param name="printTextDelegate">The function that will actually print the message to the screen</param> public static void PrintMessageCenter(string message, PrintTextDelegate printTextDelegate) { // If the message is multi-line, split it into a string array and call self to print // message to the center to the screen. if (message.Contains("\n")) { // Lines to print string[] lines = Regex.Split(message, "\n"); // Call self to print lines. foreach (string line in lines) { PrintMessageCenter(line, printTextDelegate); } // Early exit return; } // Obtain the left side/left edge of the text we are going to write. int consolePointer = (Console.WindowWidth - message.Length) / 2; // Check/resolve text overflow possibilities. if (consolePointer < 0) { consolePointer = 0; } // Set the cursor position to our new left edge. Console.SetCursorPosition(consolePointer, Console.CursorTop); // Call our delegate to print the message. printTextDelegate(message); // Restore the left side/left edge pointer position. Console.SetCursorPosition(0, Console.CursorTop); }
/// <summary> /// Writes a message to the with the current time to the screen, accepts a delegate object, /// redirecting execution to the appropriate method for printing the text /// in an appropriate colour. /// </summary> /// <param name="message">The message to be printed to the screen.</param> /// <param name="printTextDelegate">The function that will actually print the message to the screen</param> /// <param name="printFormattedTextDelegate">Used for recursive declaration of text formatting/styles.</param> public static void PrintMessageWithTime(string message, PrintTextDelegate printTextDelegate, PrintFormattedTextDelegate printFormattedTextDelegate) { // Call our passed in delegate with message. printFormattedTextDelegate(GetCurrentTime() + message, printTextDelegate); }
/// <summary> /// Writes a message to the with the current time to the screen, accepts a delegate object, /// redirecting execution to the appropriate method for printing the text /// in an appropriate colour. /// </summary> /// <param name="message">The message to be printed to the screen.</param> /// <param name="printTextDelegate">The function that will actually print the message to the screen</param> public static void PrintMessageWithTime(string message, PrintTextDelegate printTextDelegate) { // Call our delegate to print the message. printTextDelegate(GetCurrentTime() + message); }