Exemple #1
0
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     if (!string.IsNullOrEmpty(msg.Text))
     {
         provider.AddMsg(msg.Text, UserInLog.id);
         client.SendMsg(UserInLog, msg.Text, TypeMsg.Message, UserInLog.id);
         msg.Text = "";
     }
 }
Exemple #2
0
 private void tbMessage_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         if (client != null)
         {
             client.SendMsg(tbMessage.Text, Id);
             tbMessage.Text = string.Empty;
         }
     }
 }
 // Метод отправки сообщения всем
 private void btnToAll_Click(object sender, RoutedEventArgs e)
 {
     // Если строка не пустая, отправляем сообщение сервису, указав свой ИД
     if (String.IsNullOrWhiteSpace(tbMessage.Text))
     {
         return;
     }
     if (IsConnected)
     {
         client.SendMsg(tbMessage.Text, id, 0);
         tbMessage.Text = "";
     }
 }
Exemple #4
0
 private void button_Click(object sender, RoutedEventArgs e)
 {
     if (client != null)
     {
         client.SendMsg(textBox.Text, ID);
         textBox.Text = string.Empty;
     }
 }
Exemple #5
0
 private void textBox1_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         if (client != null)
         {
             client.SendMsg(textBox1.Text, ID);
             textBox1.Text = string.Empty;
         }
     }
 }
Exemple #6
0
 private void Window_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         if (client != null)
         {
             client.SendMsg(tbMassage.Text, ID);
         }
         tbMassage.Text = string.Empty;
     }
 }
Exemple #7
0
 private void textBox2_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         if (client != null)
         {
             client.SendMsg(textBox2.Text, ID);
             client.NewMsg(ID, textBox2.Text, DateTime.Now.ToString());
             textBox2.Text = "";
         }
     }
 }
Exemple #8
0
 private void tbMessage_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         if (client != null)
         {
             string msg = Converts.BinaryToString(serpent.Encrypt(tbMessage.Text, Convert.FromBase64String(KeyToSerpent)));
             msg += KeyToSerpent;
             client.SendMsg(msg, ID);
             tbMessage.Text = string.Empty;
         }
     }
 }
        //переробити на find user
        private void tbMessage_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                if (client != null)
                {
                    client.SendMsg(tbMessage.Text, userId, currentUser); // відправити ід отримувача
                    Button b = new Button();
                    b.Name    = "a";
                    b.Content = DateTime.Now.ToShortTimeString() + ", Me : " + tbMessage.Text;
                    lbChat.Items.Add(b);
                    lbChat.ScrollIntoView(lbChat.Items[lbChat.Items.Count - 1]);

                    tbMessage.Text = string.Empty;
                }
            }
        }
Exemple #10
0
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     client.SendMsg(Message.Text, _LoginFirst, _LoginSecond);
     Message.Text = null;
 }
Exemple #11
0
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                return;
            }
            client = new ServiceChatClient(new System.ServiceModel.InstanceContext(new Program()));
            id     = client.Connect(args[0]);



            while (true)
            {
                PrintMenu();
                Console.WriteLine("Input option");
                char key = Console.ReadKey().KeyChar;
                Console.WriteLine();
                switch (key)
                {
                case 'w':
                {
                    int    receiverId;
                    string mes;
                    lock (locker)
                    {
                        Console.WriteLine("Write receiver Id");
                        if (!Int32.TryParse(Console.ReadLine(), out receiverId))
                        {
                            Console.WriteLine("Wrong input!");
                            continue;
                        }
                        Console.WriteLine("Write message");
                        mes = Console.ReadLine();
                    }
                    client.SendMsg(mes, receiverId, id);
                }; break;

                case 'u':
                {
                    Console.WriteLine("Users ID: ");
                    var usersId = client.GetServerUsers();
                    for (int i = 0; i < usersId.Length; i++)
                    {
                        Console.Write(usersId[i] + " ");
                    }
                    Console.WriteLine();
                }; break;

                case 'i':
                {
                    Console.WriteLine("Your data:\n" +
                                      $"\tID - {id}\n" +
                                      $"\tNickName - {args[0]}"
                                      );
                }; break;

                case 'e':
                {
                    client.Disconnect(id);
                    Console.WriteLine("Disconnect...");
                    return;
                }

                default:
                {
                    Console.WriteLine("Wrong command!");
                    continue;
                }
                }
            }
        }