Beispiel #1
0
        /// <summary>
        /// create a chat form
        /// </summary>
        /// <param name="type">type1: create form by sender, other: create form by receiver</param>
        /// <param name="senderId">SenderId</param>
        /// <param name="receiverId">ReceiverId</param>
        /// <returns>ChatForm</returns>
        public ChatForm CreateChatForm(int type, string senderId, string receiverId)
        {
            string senderName   = m_UserDictionary[senderId].DisplayName;
            string receiverName = m_UserDictionary[receiverId].DisplayName;

            ChatForm c = new ChatForm(HubProxy);

            //set value for ChatForm
            if (type == 1)
            {
                c.Text       = receiverName;
                c.senderId   = senderId;
                c.receiverId = receiverId;
                c.ownerName  = senderName;
            }
            else
            {
                c.Text       = senderName;
                c.senderId   = receiverId;
                c.receiverId = senderId;
                c.ownerName  = receiverName;
            }


            c.Show();


            return(c);
        }
Beispiel #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            Form f2 = new ChatForm();

            f2.Show(this);
            this.Hide();
        }
Beispiel #3
0
        public void Register()//发送注册信息
        {
            byte[] data = new byte[100];
            data = Encoding.UTF8.GetBytes("REGISTER|REGISTER");
            int i = UsrInfo.NewClient.Send(data);

            data = Encoding.UTF8.GetBytes(Account.Text + "|" + Password.Text);
            i    = UsrInfo.NewClient.Send(data);

            byte[] temp       = new byte[100];
            int    recv       = UsrInfo.NewClient.Receive(temp);
            string stringdata = Encoding.UTF8.GetString(temp, 0, recv);

            if (stringdata == "YES")
            {
                this.Hide();//隐藏注册界面
                UsrInfo.Account = Account.Text;
                ChatForm ChatForm = new ChatForm();
                ChatForm.Show();
            }
            else
            {
                tip.Text      = "该账号已被注册,请再次尝试";
                Account.Text  = "";
                Password.Text = "";
            }
        }
Beispiel #4
0
        private void Sign_Click(object sender, EventArgs e)
        {
            ChatForm chat = new ChatForm(textBox1.Text);

            _host = textBox1.Text;
            chat.Show();
        }
Beispiel #5
0
        public void Check_Account()//发送账号信息,验证账号
        {
            byte[] data = new byte[100];
            data = Encoding.UTF8.GetBytes("LOGIN|LOGIN");
            int i = UsrInfo.NewClient.Send(data);

            data = Encoding.UTF8.GetBytes(Account.Text + "|" + Password.Text);
            i    = UsrInfo.NewClient.Send(data);

            byte[] temp       = new byte[100];
            int    recv       = UsrInfo.NewClient.Receive(temp);
            string stringdata = Encoding.UTF8.GetString(temp, 0, recv);

            if (stringdata == "YES")
            {
                this.Hide();//隐藏登陆界面
                UsrInfo.Account = Account.Text;
                ChatForm ChatForm = new ChatForm();
                ChatForm.Show();
            }
            else
            {
                tip.Text      = "账号或密码错误";
                Account.Text  = "";
                Password.Text = "";
            }
        }
Beispiel #6
0
        public void buttonChat_Click(object sender, EventArgs e)
        {
            try
            {
                bool     flag     = false;
                bool     exsit    = false;
                string   aim      = listOnl.SelectedItem.ToString();
                ChatForm chatForm = null;

                if (aim.EndsWith("*"))
                {
                    flag = true;
                    //chatForm.ricTexReceive.Text += Addbuff + "\n";
                    aim = aim.Substring(0, aim.Length - 1);
                    listOnl.Items[listOnl.Items.IndexOf(listOnl.SelectedItem)] = aim;
                }
                foreach (var temp in chatList)
                {
                    if (temp.chat.aim == aim)
                    {
                        MessageBox.Show("对话框已存在", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                        exsit = true;
                    }
                }
                if (exsit == false)
                {
                    chatForm            = new ChatForm();
                    chatForm.fatherWind = this;
                    chatList.Add(chatForm);
                    chatForm.chat.startIP = client;
                    chatForm.chat.aim     = aim;
                    chatForm.Show();
                }
                if (flag == true)
                {
                    /*
                     * foreach (var temp in listOnl.Items)
                     * {
                     *  if (temp.ToString() == aim)
                     *      ans = n;
                     *  n++;
                     * }
                     * listOnl.Items[ans] = aim;
                     */
                    chatForm.ricTexReceive.Text += Addbuff;
                    SocketTcp.SaveLog(client.name, aim, Addbuff);
                    Addbuff = "";
                }
            }
            catch (Exception)
            {
                MessageBox.Show("请选择聊天对象", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
            }
        }
Beispiel #7
0
 /// <summary>
 /// 사용자가 다수의 상대방과 대화하기를 요청했을 경우 대화창 생성
 /// </summary>
 /// <param name="groupList">대화선택목록</param>
 /// <param name="chatIdList">대화가능자 조합 키값(myid/id/id..)</param>
 private void MakeChatForm(List <MemberObj> groupList, string chatIdList)
 {
     try
     {
         ChatForm chatForm = new ChatForm(connection, miscCtrl, groupList);
         chatForm.Show();
     }
     catch (Exception exception)
     {
         Logger.error(exception.ToString());
     }
 }
 /// <summary>
 /// 사용자가 대화하기를 선택시 대화창 생성
 /// </summary>
 /// <param name="chatter"></param>
 /// <param name="ids"></param>
 private void MakeChatForm(MemberObj userObj)
 {
     try
     {
         if (userObj.Id == null || userObj.Id == "")
             return;
         ChatForm chatForm = new ChatForm(connection, miscCtrl, userObj);
         chatForm.Show();
     }
     catch (Exception exception)
     {
         Logger.error(exception.ToString());
     }
 }
Beispiel #9
0
 /// <summary>
 /// 사용자가 대화하기를 선택시 대화창 생성
 /// </summary>
 /// <param name="chatter"></param>
 /// <param name="ids"></param>
 private void MakeChatForm(MemberObj userObj)
 {
     try
     {
         if (userObj.Id == null || userObj.Id == "")
         {
             return;
         }
         ChatForm chatForm = new ChatForm(connection, miscCtrl, userObj);
         chatForm.Show();
     }
     catch (Exception exception)
     {
         Logger.error(exception.ToString());
     }
 }
Beispiel #10
0
        //打开聊天窗口
        private void it1_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count <= 0)
            {
                return;
            }
            List <Object> listTwoInfo = new List <object>();

            listTwoInfo.Add(Ip);                                                     //自己的ip
            listTwoInfo.Add(Port);                                                   //自己的port
            listTwoInfo.Add(listView1.SelectedItems[0].SubItems[1].Text.ToString()); //对方ip
            listTwoInfo.Add(listView1.SelectedItems[0].SubItems[2].Text.ToString()); //对方port
            ChatForm chatform = new ChatForm();

            chatform.Tag = listTwoInfo;
            chatform.Show(this);
        }
        /// <summary>
        /// 사용자가 대화하기를 선택시 대화창 생성
        /// </summary>
        /// <param name="chatter"></param>
        /// <param name="ids"></param>
        private void MakeChatForm(UserObject userObj) {
        
            try {
                if (userObj.Id == null || userObj.Id == "")
                    return;
                ChatForm chatForm = new ChatForm(myid);

                chatForm.SetCustomFont(custom_color, custom_font);
                chatForm.SetFormKey(ChatUtils.GetFormKey(userObj.Id, this.myid)); //DateTime.Now.ToString() +"!"+ this.myid;
                ChatFormList[chatForm.GetFormKey()] = chatForm;

                chatForm.SetChatterOnFormOpening(userObj);//대화창에 참가자 노드 추가(key=id, text=name)
                logWrite("Formkey 생성 : <" + chatForm.GetFormKey() + ">");
                
                chatForm.ChatMessageAdded += ChatMessageAdded;
                
                chatForm.BtnAddChatter.MouseClick += new MouseEventHandler(BtnAddChatter_Click);
                chatForm.chatSendFile.MouseClick += new MouseEventHandler(chatSendFile_Click);
                chatForm.FormClosing += new FormClosingEventHandler(chatForm_FormClosing);

                chatForm.txtbox_exam.ForeColorChanged += new EventHandler(txtbox_exam_Changed);
                chatForm.txtbox_exam.FontChanged += new EventHandler(txtbox_exam_Changed);
                chatForm.Show();
                chatForm.ReBox.Focus();

            } catch (Exception exception) {
                logWrite(exception.ToString());
            }
        }
        /// <summary>
        /// 사용자가 다수의 상대방과 대화하기를 요청했을 경우 대화창 생성
        /// </summary>
        /// <param name="chattersName">대화가능한 상대방의 이름열</param>
        /// <param name="nonchatters">대화불가능한 상대방의 이름열</param>
        /// <param name="ids">대화가능자의 id</param>
        private void MakeChatForm(List<UserObject> groupList, string chatIdList)
        {
            try {
                ChatForm chatForm = new ChatForm(myid);

                chatForm.SetCustomFont(custom_color, custom_font);
                chatForm.SetFormKey(ChatUtils.GetFormKey(chatIdList, this.myid));//DateTime.Now.ToString() + this.myid;
                logWrite("Formkey 생성 : " + chatForm.GetFormKey());

                foreach (UserObject userObj in groupList) {
                    if (userObj.Status != MsgrUserStatus.LOGOUT) {
                        chatForm.SetChatterOnFormOpening(userObj);
                    } else {
                        chatForm.PostCanNotJoinMessage(userObj.Name);
                    }
                }

                chatForm.ChatMessageAdded += ChatMessageAdded;
                
                chatForm.BtnAddChatter.MouseClick += new MouseEventHandler(BtnAddChatter_Click);
                chatForm.chatSendFile.MouseClick += new MouseEventHandler(chatSendFile_Click);
                chatForm.FormClosing += new FormClosingEventHandler(chatForm_FormClosing);
                chatForm.txtbox_exam.ForeColorChanged += new EventHandler(txtbox_exam_Changed);
                chatForm.txtbox_exam.FontChanged += new EventHandler(txtbox_exam_Changed);
                ChatFormList[chatForm.GetFormKey()] = chatForm;       //ChatterList 저장(key=id/id/.. value=chatform)

                chatForm.Show();
                chatForm.ReBox.Focus();
            }
            catch (Exception exception)
            {
                logWrite(exception.ToString());
            }

        }
Beispiel #13
0
        /// <summary>
        /// double-click the user info to chat
        /// </summary>
        private void listViewOnlineUsers_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            string otherInfo = listViewOnlineUsers.SelectedItems[0].Text.Trim();
            if (otherInfo == note) return;

            Match match = Regex.Match(otherInfo, @"^(\w+)-([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}):([0-9]+)$");

            UdpUtils.Message otherProfile = new UdpUtils.Message()
            {
                FromUserName = match.Groups[1].Value,
                IpAddress = match.Groups[2].Value,
                Port = Convert.ToInt32(match.Groups[3].Value)
            };

            if (otherInfo != note)
            {
                UdpUtils.Message myProfile = new UdpUtils.Message()
                {
                    FromUserName = this.Text,
                    IpAddress = "",
                    Port = 0
                };

                ChatForm form = chatFormList.Find(f => f.Text == string.Format("{0}:{1}", this.Text, otherProfile.FromUserName));

                if (form != null) form.Activate();
                else
                {
                    ChatForm chat = new ChatForm(otherProfile, myProfile);
                    chatFormList.Add(chat);
                    chat.Show();
                }
            }
        }
Beispiel #14
0
        //ar = d|formkey|id/id/...|name|�޽�������
        /// <summary>
        /// ���ο� ��ȭ�޽��� ���Ž� ��ȭâ ����
        /// </summary>
        /// <param name="ar">d|formkey|id/id/...|name|�޽�������</param>
        private void NewChatForm(string[] ar)
        {
            try
            {
                ChatForm chatForm = new ChatForm();
                chatForm.txtbox_exam.Font = txtfont;
                chatForm.txtbox_exam.ForeColor = txtcolor;
                chatForm.Formkey.Text = ar[1];
                string[] tempidar = ar[2].Split('/');
                for (int i = 0; i < (tempidar.Length - 1); i++)
                {
                    if (!this.myid.Equals(tempidar[i]))
                    {
                        string tempid = tempidar[i];
                        string name = getName(tempid);
                        if (i == 0)
                        {
                            chatForm.Text += name;
                        }
                        else
                        {
                            chatForm.Text += "/" + name;
                        }
                        TreeNode parti = chatForm.ChattersTree.Nodes.Add(tempid, name + "(" + tempid + ")");
                        parti.Tag = tempid;
                        parti.ImageIndex = 0;
                        parti.SelectedImageIndex = 0;
                    }
                }

                chatForm.ReBox.KeyUp += new KeyEventHandler(getMsg);   //�亯 �޽��� �ڽ��� Ű�̺�Ʈ ����
                chatForm.BtnAddChatter.MouseClick += new MouseEventHandler(BtnAddChatter_Click);
                chatForm.chatSendFile.MouseClick += new MouseEventHandler(chatSendFile_Click);
                chatForm.btnSend.Click += new EventHandler(btnSend_Click);
                chatForm.FormClosing += new FormClosingEventHandler(chatForm_FormClosing);
                chatForm.txtbox_exam.ForeColorChanged += new EventHandler(txtbox_exam_Changed);
                chatForm.txtbox_exam.FontChanged += new EventHandler(txtbox_exam_Changed);
                //chatForm.WindowState = FormWindowState.Minimized;
                ChatFormList[chatForm.Formkey.Text] = chatForm;
                chatForm.Show();

                string mymsg = ar[3] + " ���� �� :";
                int lines = chatForm.chatBox.Lines.Length;
                chatForm.chatBox.AppendText(mymsg + "\r\n");
                int findnum = chatForm.chatBox.Find(mymsg, RichTextBoxFinds.Reverse);
                chatForm.chatBox.SelectionBackColor = Color.White;
                chatForm.chatBox.Select(findnum, mymsg.Length);
                chatForm.chatBox.SelectionColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
                chatForm.chatBox.SelectionFont = new Font("����", 9.0f, FontStyle.Bold);
                chatForm.chatBox.ScrollToCaret();

                mymsg = ar[4];
                lines = chatForm.chatBox.Lines.Length;
                chatForm.chatBox.AppendText("��  " + mymsg + "\r\n\r\n");
                findnum = chatForm.chatBox.Find(mymsg, RichTextBoxFinds.Reverse);
                chatForm.chatBox.SelectionBackColor = Color.White;
                chatForm.chatBox.SelectionFont = new Font("����", 9.0f, FontStyle.Regular);
                chatForm.chatBox.ScrollToCaret();
            }
            catch (Exception exception)
            {
                logWrite(exception.ToString());
            }
        }
Beispiel #15
0
        /// <summary>
        /// ����ڰ� �ټ��� ����� ��ȭ�ϱ⸦ ��û���� ��� ��ȭâ ����
        /// </summary>
        /// <param name="chattersName">��ȭ������ ������ �̸���</param>
        /// <param name="nonchatters">��ȭ�Ұ����� ������ �̸���</param>
        /// <param name="ids">��ȭ�������� id</param>
        private void MakeChatForm(string chattersName, ArrayList nonchatters, string ids)
        {
            try
            {
                ChatForm chatForm = new ChatForm();
                chatForm.Text = chattersName;
                chatForm.txtbox_exam.ForeColor = txtcolor;
                chatForm.txtbox_exam.Font = txtfont;
                chatForm.Formkey.Text = DateTime.Now.ToString() + this.myid;
                logWrite("Formkey ���� : " + chatForm.Formkey.Text);

                string[] tempidar = ids.Split('/');
                for (int i = 0; i < (tempidar.Length - 1); i++)
                {
                    if (!tempidar[i].Equals(this.myid))
                    {
                        string tempid = tempidar[i];
                        string name = getName(tempid);
                        TreeNode node = chatForm.ChattersTree.Nodes.Add(tempid, name + "(" + tempid + ")");
                        node.Tag = tempid;
                        node.ImageIndex = 1;
                        node.SelectedImageIndex = 1;
                    }
                }
                if (nonchatters.Count != 0)
                {
                    foreach (string non in nonchatters)
                    {
                        chatForm.chatBox.AppendText(non + " ���� ��ȭ�� �Ұ����� �����̹Ƿ� �������� ���߽��ϴ�.\r\n\r\n");
                    }
                }
                chatForm.Show();
                chatForm.ReBox.KeyDown += new KeyEventHandler(getMsg);    //�亯 �޽��� �ڽ��� Ű�̺�Ʈ ����
                chatForm.BtnAddChatter.MouseClick += new MouseEventHandler(BtnAddChatter_Click);
                chatForm.chatSendFile.MouseClick += new MouseEventHandler(chatSendFile_Click);
                chatForm.FormClosing += new FormClosingEventHandler(chatForm_FormClosing);
                chatForm.txtbox_exam.ForeColorChanged += new EventHandler(txtbox_exam_Changed);
                chatForm.txtbox_exam.FontChanged += new EventHandler(txtbox_exam_Changed);
                chatForm.ReBox.Focus();
                ChatFormList[chatForm.Formkey.Text] = chatForm;       //ChatterList ����(key=id/id/.. value=chatform)
            }
            catch (Exception exception)
            {
                logWrite(exception.ToString());
            }
        }
Beispiel #16
0
        /// <summary>
        /// ����ڰ� ��ȭ�ϱ⸦ ���ý� ��ȭâ ����
        /// </summary>
        /// <param name="chatter"></param>
        /// <param name="ids"></param>
        private void MakeChatForm(string chatter, string ids)
        {
            try
            {
                ChatForm chatForm = new ChatForm();
                chatForm.Text = chatter;
                chatForm.txtbox_exam.Font = txtfont;
                chatForm.txtbox_exam.ForeColor = txtcolor;
                chatForm.Formkey.Text = DateTime.Now.ToString() +"!"+ this.myid;
                logWrite("Formkey ���� : <" + chatForm.Formkey.Text + ">");
                ToolTip tip = new ToolTip();
                tip.SetToolTip(chatForm.BtnAddChatter, "��ȭ ���� �߰�");
                chatForm.KeyDown += new KeyEventHandler(chatForm_KeyDown);
                chatForm.btnSend.KeyDown += new KeyEventHandler(btnSend_KeyDown);
                chatForm.ReBox.KeyDown += new KeyEventHandler(getMsg);    //�亯 �޽��� �ڽ��� Ű�̺�Ʈ ����
                chatForm.BtnAddChatter.MouseClick += new MouseEventHandler(BtnAddChatter_Click);
                chatForm.chatSendFile.MouseClick += new MouseEventHandler(chatSendFile_Click);
                chatForm.FormClosing += new FormClosingEventHandler(chatForm_FormClosing);
                chatForm.txtbox_exam.ForeColorChanged += new EventHandler(txtbox_exam_Changed);
                chatForm.txtbox_exam.FontChanged += new EventHandler(txtbox_exam_Changed);
                chatForm.btnSend.Click += new EventHandler(btnSend_Click);
                ChatFormList[chatForm.Formkey.Text] = chatForm;
                chatForm.Show();
                chatForm.ReBox.Focus();

                if (ids != null)
                {
                    string name = getName(ids);
                    TreeNode node = chatForm.ChattersTree.Nodes.Add(ids, name + "(" + ids + ")");//��ȭâ�� ������ ��� �߰�(key=id, text=name)
                    node.Tag = ids;
                    node.ImageIndex = 0;
                    node.SelectedImageIndex = 0;
                }
            }
            catch (Exception exception)
            {
                logWrite(exception.ToString());
            }
        }
        /// <summary>
        /// 사용자가 다수의 상대방과 대화하기를 요청했을 경우 대화창 생성
        /// </summary>
        /// <param name="groupList">대화선택목록</param>
        /// <param name="chatIdList">대화가능자 조합 키값(myid/id/id..)</param>
        private void MakeChatForm(List<MemberObj> groupList, string chatIdList)
        {
            try
            {
                ChatForm chatForm = new ChatForm(connection, miscCtrl, groupList);
                chatForm.Show();
            }
            catch (Exception exception)
            {
                Logger.error(exception.ToString());
            }

        }