Example #1
0
        private void SendButton_Click(object sender, EventArgs e)
        {
            if (UserList.SelectedIndex >= 0 && MessageTextBox.Text != "")
            {
                Thread waiting_thread = new Thread(new ThreadStart(new Action(() =>
                {
                    WaitingForm form = new WaitingForm("Отправка...");
                    form.ShowDialog();
                })));
                waiting_thread.Start();

                ActionResult result = client.SendMessage(user_name, UserList.SelectedItem.ToString(), MessageTextBox.Text);

                try { waiting_thread.Abort(); }
                catch (Exception ex) { }

                if (!result.Result)
                {
                    MessageBox.Show(result.Data, ErrorMessages.ERR_ERROR,
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    AddMessage(user_name, UserList.SelectedItem.ToString(), MessageTextBox.Text);
                    MessageTextBox.Clear();
                }
            }
            else
            {
                MessageBox.Show("Вы не выбрали получателя либо не ввели текст сообщения!", "Предупреждение",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Example #2
0
        private void RegisterButton_Click(object sender, EventArgs e)
        {
            if (!client.is_connected)
            {
                InitListenThread();
            }

            if (client.is_connected)
            {
                WaitingForm waiting     = null;
                Thread      wait_thread = new Thread(new ThreadStart(new Action(() =>
                {
                    waiting = new WaitingForm("Запрос к серверу...");
                    waiting.ShowDialog();
                })));

                wait_thread.Start();
                ActionResult res = client.RegisterUser(LoginBox.Text, PasswordBox.Text);
                try { wait_thread.Abort(); }
                catch (Exception ex) { }

                if (!res.Result)
                {
                    MessageBox.Show(res.Data, ErrorMessages.ERR_ERROR,
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show(res.Data, InfoMessages.INF_INFORMATION,
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Example #3
0
        private void LoginButton_Click(object sender, EventArgs e)
        {
            if (!client.is_connected)
            {
                InitListenThread();
            }

            Thread.Sleep(10);

            if (client.is_connected)
            {
                WaitingForm waiting     = null;
                Thread      wait_thread = new Thread(new ThreadStart(new Action(() =>
                {
                    waiting = new WaitingForm("Запрос к серверу...");
                    waiting.ShowDialog();
                })));

                wait_thread.Start();
                ActionResult res = client.LoginUser(LoginBox.Text, PasswordBox.Text);
                try { wait_thread.Abort(); }
                catch (Exception ex) { }

                if (!res.Result)
                {
                    MessageBox.Show(res.Data, ErrorMessages.ERR_ERROR,
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MainForm app = new MainForm(client, LoginBox.Text);
                    client.AddMessage = app.AddMessage;
                    client.user_name  = LoginBox.Text;
                    app.Show();

                    this.ShowInTaskbar = false;
                    this.Hide();
                }
            }
        }