Example #1
0
 // move to register form
 private void SignUpLabel_Click(object sender, EventArgs e)
 {
     InvokeIfNeeded(delegate()
     {
         if (r == null)
         {
             r = new register(Client, this, f1);
         }
         this.Hide();
         r.setTextBoxesToDefault();
         r.Show();
     });
 }
Example #2
0
        //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;
                }
            }
        }