/// <summary> /// 새로운 대화메시지 수신시 대화창 생성 /// </summary> /// <param name="ar">d|formkey|id/id/...|name|메시지내용</param> private void OpenNewChatFormOnMsgReceived(object sender, CustomEventArgs e) //ar = d|formkey|id/id/...|name|메시지내용 { try { ChatObj chatObj = (ChatObj)e.GetItem; ChatForm chatForm = new ChatForm(connection, miscCtrl, chatObj); } 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()); } }
/// <summary> /// 1. 채팅창에 user상태 변경 /// 2. login: user가 속한 채팅창의 user정보 활성화. /// 3. logout: 반대로 처리 /// </summary> /// <param name="userId"></param> /// <param name="status"></param> private void SetChatFormKeyUpdate(ChatForm chatForm, string newFormKey, string oldFormKey) { lock (ChatFormList) { chatForm.SetFormKey(newFormKey); ChatFormList.Remove((string)oldFormKey); ChatFormList[(string)newFormKey] = chatForm; } }
/// <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(); } } }
/// <summary> /// 工具栏点击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolBar_ButtonClick(object sender, ToolBarButtonClickEventArgs e) { if (e.Button == toolBarButtonPushScreen) { if (toolBarButtonPushScreen.Text == "推送桌面") { SendControl("PushScreen"); pushScreen.Start(); toolBarButtonPushScreen.Text = "停止推送"; } else { toolBarButtonPushScreen.Text = "推送桌面"; SendControl("PushScreen Closed"); pushScreen.Stop(); } } else if (controlConnected) { if (e.Button == toolBarButtonRemote) { ScreenForm screenForm = new ScreenForm(); screenForm.ShowDialog(); } else if (e.Button == toolBarButtonVideo) { VideoForm videoForm = new VideoForm(); videoForm.ShowDialog(); } else if (e.Button == toolBarButtonCommand) { CommandForm commandForm = new CommandForm(); commandForm.ShowDialog(); } else if (e.Button == toolBarButtonFileManage) { if (!Clients.isThread_FileManageStarted) { Clients.thread_FileMange = new Thread(FileManagementConnection); Clients.thread_FileMange.Start(); Clients.isThread_FileManageStarted = true; } tabControl.SelectedTab = this.tabPageFileManage; } else if (e.Button == toolBarButtonChat) { ChatForm chatForm = new ChatForm(); chatForm.ShowDialog(); } } else { MessageBox.Show("请先连接远程主机"); } }
static void MainForm_TypingStateChanged(object sender, ChatForm.TypingEvent e) { BBConversation convers = sender as BBConversation; // Create istyping message BBMessage msg = new BBMessage(); msg.MsgTypingMsg(e.isTyping); msg.Conversation = convers; // Send it. Client.SendMessage(msg.GetNetMessage(), NetChannel.ReliableUnordered); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //PList = new PlayerList(); MainForm = new ChatForm(); AppConfig = new Configuration(); IsAppHidden = AppConfig.RunMinimized; // Create a configuration for the client Program.ChatApplicationBusiness.Config = new NetAppConfiguration("BBTcpTest"); // enable encryption; this key was generated using the 'GenerateEncryptionKeys' application Config.EnableEncryption( "AQABwV1rQ1NDWzkkhUsYtMiRGjyxSn/zI13tros2RlXHlW6PA7Cvw2nOyMhDmweM+" + "T/+FWzssAWLh8qd+YHaMCCFskVdaZfRzquZlNOs9mX/vtxkLrXgBUaJQD/XOuBeJF" + "o3RfAKA4uhrEr7Bk1iB3zJQW1bSHK7KmmEWzMErk6iA7c=", null); Log = new NetLog(); Log.IgnoreTypes = NetLogEntryTypes.Verbose; // Verbose; Log.IsOutputToFileEnabled = false; Log.OutputFileName = "clientlog.html"; // uncomment this if you want to start multiple instances of this process on the same computer //Log.OutputFileName = "clientlog" + System.Diagnostics.Process.GetCurrentProcess().Id + ".html"; //Log.LogEvent += new EventHandler<NetLogEventArgs>(Log_LogEvent); Client = new NetClient(Config, Log); Client.StatusChanged += new EventHandler<NetStatusEventArgs>(Client_StatusChanged); Application.Idle += new EventHandler(ApplicationLoop); MainForm.TypingStateChanged += new EventHandler<ChatForm.TypingEvent>(MainForm_TypingStateChanged); CreateNotificationIcon(); Application.Run(MainForm); if (Client != null) Client.Shutdown("Application exiting"); if (notifyIconNA != null) notifyIconNA.Visible = false; }
/// <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()); } }
/// <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()); } }
private string[] GetChattersID(ChatForm form) { string[] chatters = null; try { if (form.ChattersTree.Nodes.Count != 0) { chatters = new string[form.ChattersTree.Nodes.Count]; for (int i = 0; i < form.ChattersTree.Nodes.Count; i++) { chatters[i] = (string)form.ChattersTree.Nodes[i].Tag; } } } catch (Exception exception) { logWrite(exception.ToString()); } return chatters; }
/// <summary> /// ���ڰ� ä���� ��ȭâ�� ���� �������� �˸� /// </summary> /// <param name="id"></param> /// <param name="form"></param> public void DelChatter(string id, ChatForm form) { TreeNode[] node = form.ChattersTree.Nodes.Find(id, false); form.chatBox.AppendText("\r\n###" + node[0].Text + "���� â�� �ݰ� ��ȭ�� �����Ͽ����ϴ�.." + "\r\n\r\n"); node[0].Remove(); }
//msg(d|Formkey|id/id/...|�߽���name|���� private void Addmsg(string msg, ChatForm form) { string [] temp = msg.Split('|'); string sendername = temp[0]; RichTextBox box = form.chatBox; string sendermsg = sendername + " ���� �� :"; int lines = box.Lines.Length; box.AppendText(sendermsg + "\r\n"); int findnum = box.Find(sendermsg, RichTextBoxFinds.Reverse); box.SelectionBackColor = Color.White; box.Select(findnum, sendermsg.Length); box.SelectionColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); box.SelectionFont = new Font("����", 9.0f, FontStyle.Bold); sendermsg = temp[1]; lines = box.Lines.Length; box.AppendText("�� " + sendermsg + " (" + DateTime.Now.ToString() + ")" + "\r\n\r\n"); findnum = box.Find(sendermsg, RichTextBoxFinds.Reverse); box.SelectionBackColor = Color.White; box.Select(findnum, sendermsg.Length); box.SelectionFont = new Font("����", 9.0f, FontStyle.Regular); box.ScrollToCaret(); form.chatBox.ScrollToCaret(); }
private void Addchatter(string id, string name, ChatForm form) { TreeNode[] nodearray=form.ChattersTree.Nodes.Find(id, false); if (nodearray != null && nodearray.Length != 0) { foreach (TreeNode anode in nodearray) { if (!id.Equals(anode.Tag.ToString())) { TreeNode node = form.ChattersTree.Nodes.Add(id, name + "(" + id + ")"); node.Tag = id; node.ImageIndex = 0; node.SelectedImageIndex = 0; form.Text += "/" + name; form.chatBox.AppendText("\r\n\r\n" + node.Text + "���� ��ȭ�ڷ� �߰��߽��ϴ�.\r\n\r\n"); } } } else { TreeNode node = form.ChattersTree.Nodes.Add(id, name + "(" + id + ")"); node.Tag = id; node.ImageIndex = 0; node.SelectedImageIndex = 0; form.Text += "/" + name; form.chatBox.AppendText("\r\n\r\n" + node.Text + "���� ��ȭ�ڷ� �߰��߽��ϴ�.\r\n\r\n"); } }
/// <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="ar">d|formkey|id/id/...|name|메시지내용</param> private void NewChatForm(string[] ar) //ar = d|formkey|id/id/...|name|메시지내용 { try { ChatForm chatForm = new ChatForm(myid); chatForm.SetCustomFont(custom_color, custom_font); chatForm.SetFormKey(ChatUtils.GetFormKey(ar[1], myid)); ChatFormList[chatForm.GetFormKey()] = chatForm; string[] tempidar = ar[2].Split('/'); //첫번째가 대화메시지 띄운 사람. foreach (string tempId in tempidar) { if (!this.myid.Equals(tempId)) { UserObject userObj = ChatUtils.FindUserObjectTagFromTreeNodes(memTree.Nodes, tempId); chatForm.SetChatterOnFormOpening(userObj); } } 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.WindowState = FormWindowState.Minimized; //chatForm.Show(); chatForm.PostUserMessage(tempidar[0], ar[3]/*user name*/, ar[4]/*user msg*/); } catch (Exception exception) { logWrite(exception.ToString()); } }
/// <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()); } }
/// <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()); } }
//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()); } }
public ChatCallback(ChatForm _f) { f = _f; }
private string[] GetChattersID(ChatForm form) { string[] chatters = null; try { if (form.ChattersTree.Nodes.Count != 0) { chatters = ChatUtils.GetLoggedInIdFromNodeTag(form.ChattersTree.Nodes); } } catch (Exception exception) { logWrite(exception.ToString()); } return chatters; }