static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ClientClass client = new ClientClass(); MainForm f1 = new MainForm("", client, "", "", "", null); signInWindow f = new signInWindow(client, f1, ""); Forms.loadingForm = new loadingForm2("", client, "", "", "", f1, f); Forms.loadingForm.setHiddenForm(true); f1.setSignInWindow(f); Application.Run(f); }
public loadingForm2(string _data, ClientClass _client, string _username, string _topic, string _password, MainForm _f1, signInWindow _signIn = null) { InitializeComponent(); hiddenForm = false; f1 = _f1; data = _data; Client = _client; userName = _username; password = _password; topic = _topic; Client.Message += client_Message; this.BackColor = Color.White; signIn = _signIn; this.FormClosed += loadingForm_FormClosed; // occurs after the closing of the form }
public register(ClientClass _client, signInWindow _signIn, MainForm _f1, string error = "") { InitializeComponent(); PasswordTextBox.isPassword = true; signIn = _signIn; client = _client; Error = error; f1 = _f1; if (Error != "") { errorLabel.Text = Error; } else { errorLabel.Text = ""; } client.Message += client_Message; }
private void client_Message(object sender, dynamic e) { if (e.Type != "108") { switch (e.Type.ToString()) { //sign in Response case "100": bool connect = e.Confirm; if (connect) { //display code form if (f1 != null) { InvokeIfNeeded(delegate() { this.Hide(); f1.Show(); }); } else { InvokeIfNeeded(delegate() { MainForm f = new MainForm("", Client, userName, topic, password, null); signInWindow signinForm = new signInWindow(Client, f, ""); f.setSignInWindow(signinForm); f.Show(); }); } } break; } } }
//Handling received messages private void client_Message(object sender, dynamic e) { bool connect; if (e.Type != "108") { switch (e.Type.ToString()) { case "100": connect = e.Confirm; if (connect && !hiddenForm) { InvokeIfNeeded(delegate() { hiddenForm = true; f1.ChangeToshowForm(); this.Hide(); f1.Show(); }); } else if (!hiddenForm) { hiddenForm = true; this.Hide(); if (signIn != null) { InvokeIfNeeded(delegate() { signIn.setTextBoxToDefault(); signIn.setErrorLabel(e.Error); signIn.Show(); }); } else { InvokeIfNeeded(delegate() { signInWindow _f = new signInWindow(Client, f1, e.Error); _f.Show(); }); } } break; case "103": if (e.Confirm) { InvokeIfNeeded(delegate() { hiddenForm = true; this.Hide(); if (signIn != null) { //signIn.setTextBoxToDefault(); signIn.setErrorLabel(e.Error); signIn.Show(); } }); } else { // if there is problem with registresion InvokeIfNeeded(delegate() { hiddenForm = true; this.Hide(); register r = new register(Client, signIn, f1, e.Error); // the user register to the system r.Show(); }); } break; case "104": if (e.checkNames) // the usernamesare valid { hiddenForm = true; InvokeIfNeeded(delegate() { f1.ChangeToshowForm(); signIn.setUsername(userName); this.Hide(); f1.Show(); }); } else { // opening craete call again frinds and write error msg } break; case "109": bool checkUserCall = false; foreach (string s in (List <string>)e.usersToAdd) { if (s == userName) { checkUserCall = true; } } if (checkUserCall && !hiddenForm) { if (MessageBox.Show("Do you want to connect to a conversation created by " + e.admin, "New call", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Client.addTosend(new GetInitText(e.callId, userName, password)); InvokeIfNeeded(delegate() { f1.setStartCall(); hiddenForm = true; f1.ChangeToshowForm(); this.Hide(); f1.Show(); }); } else { Client.addTosend(new leaveCall(userName, topic)); // the user already in the call users list } } break; } } }