Beispiel #1
0
        private void BtnChat_Click(object sender, RoutedEventArgs e)
        {
            Chat chat = new Chat(Sender, Resiver);

            chat.Left = Left;
            chat.Top  = Top;
            chat.Show();
        }
Beispiel #2
0
 public void setChatWindow()
 {
     chat                         = new Chat();
     chat.send.Click             += send_Click;
     chat.message.KeyUp          += enter_Input;
     chat.disconnectButton.Click += disconnect_Click;
     chat.Show();
 }
 //Opens chat
 public void OpenChat()
 {
     if (C.Visibility != Visibility.Visible)
     {
         ElementHost.EnableModelessKeyboardInterop(C);
         C.Show();
     }
 }
Beispiel #4
0
 public void CreatTalking(object _text)
 {
     string text = _text.ToString();
     int indexof = text.IndexOf(";");
     string fromuser = text.Substring(0, indexof);
     string message = text.Substring(indexof + 1);
     Chat talk = new Chat(message);
     talk.UserName = Username;
     talk.ToName = fromuser;
     talk.ToIP = GetIP(fromuser);
     TalkList.Add(talk);
     talk.Show();
 }
        private void btn_submit_Click(object sender, EventArgs e)
        {
            string username = textBox_username.Text;
            string password = textBox_password.Text;


            if (VerifyLogin(username, password))
            {
                Form Chat = new Chat(username);
                Chat.Show();
            }
            else
            {
                MessageBox.Show("Apresenta Credênciais Erradas !! \nOu então não está Registado !!");
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            String username = textbox1.Text.ToString();
            String password = textbox2.Text.ToString();

            if (ClientService.login(username, password) == false)
            {
                MessageBox.Show("Nume sau parola gresita");
            }
            else
            {
                //Chat win2 = new Chat(ClientService.getClient());
                Chat win2 = new Chat(communication, username);

                win2.Show();
                this.Close();
            }
        }
Beispiel #7
0
        private void friendLis_DoubleClick(object sender, EventArgs e)
        {
            //是否有选中项
            if (friendLis.SelectedItems.Count > 0)
            {
                //聊天窗体是否为空
                if (chatForm == null)
                {
                    chatForm          = new Chat();//创建聊天窗体对象
                    friend            = PublicFun.GetFriend(friendLis.SelectedItems[0].Name);
                    chatForm.nickName = friend.NickName;
                    chatForm.friendID = friend.ID;

                    chatForm.Show();
                    chatForm = null;
                }
            }
        }
Beispiel #8
0
        private void connectButton_Click(object sender, System.EventArgs e)
        {
            try
            {
                ipTB.Text   = ipTB.Text.TrimEnd(' ');
                portTB.Text = portTB.Text.TrimEnd(' ');
                var ipChecker =
                    new Regex(
                        @"((?<=\s)|^)((\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])\.){3}(\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])(\s|$)");
                if (!ipChecker.IsMatch(ipTB.Text))
                {
                    throw new ArgumentException();
                }

                if (!int.TryParse(portTB.Text, out var port) && (port <= 0 || port > 65535))
                {
                    throw new ArgumentException();
                }

                _parrent.Connect(nameBox.Text, ipTB.Text, portTB.Text);
            }
            catch (ArgumentException)
            {
                MessageBox.Show("Wrong IP or port format.");
                return;
            }
            catch (EndpointNotFoundException)
            {
                MessageBox.Show("Wrong IP or port. Unable to connect.");
                return;
            }
            catch (Exception)
            {
                MessageBox.Show("Something wrong.");
                _parrent.Close();
                return;
            }

            _parrent.Show();

            Hide();
        }
Beispiel #9
0
        private void OkButton1_Click(object sender, EventArgs e)
        {
            string ip       = IpTextBox1.Text;
            int    port     = (int)PortUpDown.Value;
            string UserName = NickNametextBox2.Text;
            //send to clientSide?
            ClientSide Client = new ClientSide(ip, port, ClientColor, UserName);
            //       chatting = new Chat(Client, ClientColor, NickNametextBox2.Text);
            bool res = Client.Connect(ip, port);

            Client.sendMessageToServer(UserName);
            if (!res)
            {
                MessageBox.Show("Cant connect to server");
                return;
            }
            //     ConnectedClients f = new ConnectedClients(ClientColor, UserName.Text, client);
            this.Hide();
            chatting.Show();
        }
Beispiel #10
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            string IP   = "127.0.0.1";
            int    port = 8000;
            string nick = textBox_Nick.Text;

            chat_Window = new Chat(IP, port, nick);

            try
            {
                chat_Window.Location      = this.Location;
                chat_Window.StartPosition = FormStartPosition.Manual;
                chat_Window.FormClosing  += delegate { this.Close(); };
                chat_Window.Show();
                this.Hide();
            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message,
                                "Connection error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Beispiel #11
0
 private void ContactListView_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     if (ContactListView.SelectedItem == null)
         return;
     UserContact contact = new UserContact((UserContact)ContactListView.SelectedItem);
     string login = contact.Nickname;
     foreach (var cont in Contacts)
     {
         if (cont.Nickname == login)
         {
             var chat = new Chat(CurrentUserId, cont.Id, cont.Nickname, this);
             ChatStartedGuids.Add(cont.Id);
             chat.Uid = cont.Id.ToString();
             ChatWindows.Add(chat);
             chat.Show();
             ContactListView.SelectedItem = null;
             break;
         }
     }
 }
Beispiel #12
0
        // Chat Room
        private void btnChatRoom_Click(object sender, EventArgs e)
        {
            chat = new Chat
                                 {
                                     ReceiveName = "PUBLIC",
                                     Text = @"广播: " + UserName + @" -> all",
                                     ChatType = ChatType.Public,
                                     Stream = Stream,
                                     UserName = UserName
                                 };
            DisableChatButton();

            chat.Show();
        }
Beispiel #13
0
        // Talk
        private void btnChat_Click(object sender, EventArgs e)
        {
            if (lbxOnline.SelectedItem == null)
            {
                MessageBox.Show("请选择一个接收者!", "发送消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            chat = new Chat
                                {
                                    ChatType = ChatType.Private,
                                    Text = @"聊天: " + UserName + @" -> " + lbxOnline.SelectedItem,
                                    ReceiveName = lbxOnline.SelectedItem.ToString(),
                                    Stream = Stream,
                                    UserName = UserName
                                };

            DisableChatButton();

            chat.Show();
        }
Beispiel #14
0
 private void btnChat_Click(object sender, EventArgs e)
 {
     Hide();
     newChat = new Chat(socketClient);
     newChat.Show();
 }
Beispiel #15
0
 private void listView1_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     if (this.listView1.SelectedItems.Count > 0)
     {
         ListViewItem lvitem = this.listView1.SelectedItems[0];
         string toname = lvitem.Text;
         string toips = lvitem.Tag.ToString();
         Chat t = isHaveTalk(toname);
         if (t != null)
         {
             t.Focus();
         }
         else
         {
             Chat talk = new Chat();
             talk.UserName = Username;
             talk.ToName = toname;
             talk.ToIP = toips;
             TalkList.Add(talk);
             talk.Show();
         }
     }
 }