private void ChatMouseBtnClicked(object sender, EventArgs arg)//탭버튼 { SButton btn = (SButton)sender; if (btn == bn_chat) { bn_profile.forChatAction(); Pn_tab.Controls.Clear(); foreach (KeyValuePair <string, Control> entry in BtnChatMemManager.getInstance().dicChatList) { if (Pn_tab.InvokeRequired) { Pn_tab.Invoke((MethodInvoker) delegate { Pn_tab.Controls.Add(entry.Value); }); } else { Pn_tab.Controls.Add(entry.Value); } } } else { bn_chat.forChatAction(); Pn_tab.Controls.Clear(); foreach (KeyValuePair <string, Control> entry in BtnChatMemManager.getInstance().dicProfileList) { Pn_tab.Controls.Add(entry.Value); } } }
public ProfileForm() { this.SuspendLayout(); QueDataSendPend = new Queue <string>(); // 친구목록 받아오기, // 오프라인 채팅 받아오기 Pn_tab = new Panel(); this.Pn_tab.Anchor = (System.Windows.Forms.AnchorStyles)(AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right); this.Pn_tab.Location = new Point(0, 60); this.Pn_tab.Name = "panelTab"; this.Pn_tab.Size = new Size(this.Size.Width, this.Size.Height - 60); this.Pn_tab.BackColor = Color.White; bn_profile = new SButton("resource\\navi_btn_friend.txt", 1, 55); bn_chat = new TbChatlstBtn("resource\\board_navi_btn_chat.txt", 46, 55); bn_chat.setforChatButton(); bn_profile.setforChatButton(); bn_profile.MouseClick += new System.Windows.Forms.MouseEventHandler(this.ChatMouseBtnClicked); bn_chat.MouseClick += new System.Windows.Forms.MouseEventHandler(this.ChatMouseBtnClicked); bn_createBTN = new Control(); //버튼 만들기 // 친구목록 // gui // 프로필사진 // 이름 // // 더블클릭시 채팅방 생성 1:1 이미 생성된채팅방이면 그 챙팅방내용으로 자식 윈도우 생성 // 채팅방 버튼 // gui // 채팅방사진(프로필)// 마지막받은메세지 // 확인했나 안했나 //채팅방 채팅로그 // db 채팅방 id 만들기 -> key // 채팅 로그 // 채팅방 유지하는 아이디숫자 // 받을사람들 목록 // 채팅 폼 // 보더리스-> 이 폼의 차일드 // 맨위에 프로필사진, 옆에 이름, 아래 팬 하나 넣어서 채팅방, 옆에 바 만들고, 아래에 채팅텍스트 박스, 옆에 전송버튼 // 버튼 테스트 // 버튼 레이블 쓰지말고 그냥 텍스트 그리는 클래스 하나 구현해야함. // this.Size = new Size(300, 500); //lstCprofile.Add(new ProFileEX(new Size(300,50), new Point(0, 0), "정으니",this)); this.FormClosing += new FormClosingEventHandler(closing); this.Controls.Add(Pn_tab); this.Controls.Add(bn_profile); this.Controls.Add(bn_chat); this.ResumeLayout(false); BtnChatMemManager.getInstance().dicFormList.Add("profileForm", this); }
public void AddButton(string key, string msg) { if (this.InvokeRequired) { this.Invoke((MethodInvoker) delegate { AddButton(key, msg); }); } else { int cnt = BtnChatMemManager.getInstance().dicChatList.Count; ChatLstButton btn = new ChatLstButton(new Size(this.Width, 50), new Point(0, 50 * cnt), key, this); BtnChatMemManager.getInstance().dicChatList.Add(key, btn); btn.getMsg(msg); } }
public void initData(string id, TcpClient tcp, string friendlist) { // 이것이 call되는 시점은 생성자call된 이후 시점. myId = id; connection = tcp; stream = tcp.GetStream(); int idx = 0; int cnt = 0; while (true) { idx = friendlist.IndexOf(' '); if (idx == -1) { break; } string name = friendlist.Substring(0, idx); friendlist = friendlist.Substring(idx); friendlist = friendlist.TrimStart(' '); BtnChatMemManager.getInstance().dicProfileList.Add(name, new ProFileEX(new Size(300, 50), new Point(0, 50 * cnt + 1), name, this)); // this.Size = new Size(300, 500); //lstCprofile.Add(new ProFileEX(new Size(300,50), new Point(0, 0), "정으니",this)); cnt++; } ByteField requestPendingMSg = new ByteField(8); TcpHeader head = new TcpHeader(); head.mode = 400; head.msgsize = 8; requestPendingMSg.setHeader(head); stream.Write(requestPendingMSg.m_field, 0, 8); Thread recv = new Thread(new ThreadStart(takeMsgFromServ)); Thread send = new Thread(new ThreadStart(sendMsgToServ)); recv.Start(); send.Start(); //test }
void onClosing(object sender, FormClosingEventArgs e) { BtnChatMemManager.getInstance().dicFormList.Remove(this.key); }
void processData() { while (getdatalength() > 8) // 메세지를 2개이상 q받았을시도 처리 { TcpHeader head = this.getheader(); if (getdatalength() < head.msgsize) { break; } string strmsg = Encoding.Unicode.GetString(m_field, m_rear + 1 + m_headsize, (int)head.msgsize - m_headsize); subData((int)head.msgsize); int indexof = strmsg.IndexOf(' '); string Id = strmsg.Substring(0, indexof); string msg = strmsg.Substring(indexof); if (head.mode == 301) { msg.TrimEnd(' '); } ProfileForm profile = (ProfileForm)BtnChatMemManager.getInstance().dicFormList["profileForm"]; if (BtnChatMemManager.getInstance().dicProfileList.ContainsKey(Id)) { if (BtnChatMemManager.getInstance().dicChatList.ContainsKey(Id)) { ChatLstButton btn = ((ChatLstButton)BtnChatMemManager.getInstance().dicChatList[Id]); if (btn.InvokeRequired) { btn.Invoke(btn.myDelegate, msg); } else { btn.getMsg(msg); } } else { if (profile.InvokeRequired) { profile.Invoke((MethodInvoker) delegate { profile.AddButton(Id, msg); }); } } } else { if (BtnChatMemManager.getInstance().dicChatList.ContainsKey(Id)) { ChatLstButton btn = ((ChatLstButton)BtnChatMemManager.getInstance().dicChatList[Id]); if (btn.InvokeRequired) { btn.Invoke(btn.myDelegate, msg); } else { btn.getMsg(msg); } } else { if (profile.InvokeRequired) { profile.Invoke((MethodInvoker) delegate { profile.AddButton(Id, msg); }); } } } profile.uncheckedMsg++; profile.refreshGui(); } }