示例#1
0
        private void btnSendPrivate_Click(object sender, RoutedEventArgs e)
        {
            User[] userToSend = new User[lstClients.SelectedItems.Count];
            int    i          = 0;

            foreach (User user in lstClients.SelectedItems)
            {
                userToSend[i++] = user;
            }
            if (userToSend.Length > 0)
            {
                Message msg = new Message();
                msg.From = user;
                msg.To   = userToSend;
                if (ErrorControls.NotEmptyTextBox(tbMsg))
                {
                    msg.Msg = tbMsg.Text;
                    try
                    {
                        parent.Proxy.SendPrivateMessage(msg);
                        MyMessages(user.Name + ": " + tbMsg.Text);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    tbMsg.Text = "";
                }
            }
            else
            {
                MessageBox.Show("Выберите пользователя");
            }
        }
示例#2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            bool check = ErrorControls.NotEmptyTextBox(tbName);

            if (check)
            {
                ReplyNewUser newUser = null;
                try
                {
                    // connect to the server ...
                    handler = new CallbackHandler();
                    site    = new InstanceContext(handler);
                    proxy   = new ConnectionClient(site);
                    // logging
                    newUser = proxy.Join(tbName.Text);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                if (newUser != null)
                {
                    ClientWindow client = new ClientWindow(newUser);
                    client.Owner = this;
                    client.Show();
                    this.Hide();
                }
            }
        }
示例#3
0
 private void btnSendAll_Click(object sender, RoutedEventArgs e)
 {
     if (ErrorControls.NotEmptyTextBox(tbMsg))
     {
         try
         {
             parent.Proxy.SendMessageToAll(user.Name + ": " + tbMsg.Text, this.user);
             MyMessages(user.Name + ": " + tbMsg.Text);
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
         tbMsg.Text = "";
     }
 }