private void AttemptLogin() { this.Hide(); CredentialManager.StoreCredentials( (Application.OpenForms["LoginForm"].Controls["textbox1"] as TextBox).Text, (Application.OpenForms["LoginForm"].Controls["textbox2"] as TextBox).Text); if (client.Login()) { this.Dispose(); this.Close(); } else { this.Show(); (Application.OpenForms["LoginForm"].Controls["textbox1"] as TextBox).Text = ""; (Application.OpenForms["LoginForm"].Controls["textbox2"] as TextBox).Text = ""; CredentialManager.ClearCredentials(); } }
public QuickGett() { // Create a tray menu trayMenu = new ContextMenu(); trayMenu.MenuItems.Add(new MenuItem("Upload...", OnMenuUpload)); trayMenu.MenuItems.Add(new MenuItem("Switch User", Configure)); trayMenu.MenuItems.Add(new MenuItem("Exit", OnExit)); trayIcon = new NotifyIcon(); trayIcon.Icon = Properties.Resources.favicon; // Add menu to tray icon and show it. trayIcon.ContextMenu = trayMenu; trayIcon.Visible = true; //create a client client = new GettClient(trayIcon); //check for user/pass credentials in settings //if missing, prompt for them. if (!CredentialManager.ValidCredentials()) { LoginForm lf = new LoginForm(client); lf.Show(); client.Notify("You need to log in to ge.tt!"); } else { //credentials exist, auto login client.Notify("Logging into ge.tt with saved credentials..."); client.Login(); } //start status updating thread running = true; Thread statusThread = new Thread(new ThreadStart(this.UpdateSysTrayStatusThread)); statusThread.Start(); }