private static void LoginForm_FormComplete(ConsoleForm sender, FormCompleteEventArgs e) { if (e.Cancel || sender.Textboxes["txtServer"].Text == null) { ConsoleUtils.UOut(ConsoleColor.Yellow, "K, bye!"); return; } LoginResult loginResult = HandleLogin(sender.Textboxes["txtServer"].Text, sender.Textboxes["txtUser"].Text, sender.Textboxes["txtPass"].Text); if (loginResult.Success == false) { DisplayLoginForm(); } else { Console.ResetColor(); Console.Clear(); Console.Out.Flush(); EnterMainLoop(); } }
/// <summary> /// Method to be called when a new <see cref="ConsoleForm">ConsoleForm</see> is /// needed to be deserialized from disk. /// </summary> /// <param name="path">A string with the fully qualified path to the /// form definition file on disk. If the path starts with ".\", the function /// will replace the "." with the path of the executing assembly.</param> /// <returns>A new instance of a console form.</returns> public static ConsoleForm GetFormInstance(string path) { ConsoleForm form = new ConsoleForm(); XmlSerializer ser = new XmlSerializer(form.GetType()); if (path.IndexOf(".\\") == 0) path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + path.Substring(1); using (StreamReader sr = new StreamReader(path)) { form = (ConsoleForm) ser.Deserialize(sr); sr.Close(); } return form; }
private static void LoginForm_FormCancelled(ConsoleForm sender, EventArgs e) { Console.ResetColor(); Console.Clear(); ConsoleUtils.UOut(ConsoleColor.Yellow, "K, bye!"); }