private void ShowSelectedChatView() { if (lstChats.SelectedItem != null) { BitChatPanel chatPanel = lstChats.SelectedItem.Tag as BitChatPanel; chatPanel.BringToFront(); } }
private void ShowChatListContextMenu(Point location) { if (lstChats.SelectedItem != null) { BitChatPanel chatPanel = lstChats.SelectedItem.Tag as BitChatPanel; mnuChat.Show(lstChats, location); } else { mnuPlus.Show(lstChats, location); } }
private void RemoveSelectedChatView() { if (lstChats.SelectedItem != null) { ChatListItem itm = lstChats.SelectedItem as ChatListItem; BitChatPanel chatPanel = itm.Tag as BitChatPanel; lstChats.RemoveItem(itm); mainContainer.Panel2.Controls.Remove(chatPanel); chatPanel.SettingsModified -= chatPanel_SettingsModified; chatPanel.BitChat.LeaveChat(); } }
private void mnuProperties_Click(object sender, EventArgs e) { if (lstChats.SelectedItem != null) { ChatListItem itm = lstChats.SelectedItem as ChatListItem; BitChatPanel chatPanel = itm.Tag as BitChatPanel; using (frmChatProperties frm = new frmChatProperties(chatPanel.BitChat)) { frm.Text = chatPanel.BitChat.NetworkName + " - Properties"; frm.ShowDialog(this); } } }
private void ReadUISettingsFrom(Stream s) { BinaryReader bR = new BinaryReader(s); byte version = bR.ReadByte(); switch (version) //version { case 1: case 2: //form location this.Location = new Point(bR.ReadInt32(), bR.ReadInt32()); //form size this.Size = new Size(bR.ReadInt32(), bR.ReadInt32()); //form maximized if (Convert.ToBoolean(bR.ReadByte())) { this.WindowState = FormWindowState.Maximized; } //form main container splitter position if (version > 1) { mainContainer.SplitterDistance = mainContainer.Width - bR.ReadInt32(); } //first chat panel settings if (Convert.ToBoolean(bR.ReadByte())) { foreach (Control ctrl in mainContainer.Panel2.Controls) { BitChatPanel panel = ctrl as BitChatPanel; if (panel != null) { panel.ReadSettingsFrom(bR); break; } } } break; default: throw new Exception("Settings format version not supported."); } }
private void ShowSelectedChatView() { if (lstChats.SelectedItem != null) { if (_currentChatPanel != null) { _currentChatPanel.TrimMessageList(); } BitChatPanel chatPanel = (lstChats.SelectedItem as ChatListItem).ChatPanel; chatPanel.BringToFront(); chatPanel.SetFocusMessageEditor(); _currentChatPanel = chatPanel; } }
private void chatPanel_SettingsModified(object sender, EventArgs e) { BitChatPanel senderPanel = sender as BitChatPanel; using (MemoryStream mS = new MemoryStream()) { senderPanel.WriteSettingsTo(mS); foreach (Control ctrl in mainContainer.Panel2.Controls) { BitChatPanel panel = ctrl as BitChatPanel; if ((panel != null) && !panel.Equals(sender)) { mS.Position = 0; panel.ReadSettingsFrom(mS); } } } }
private void AddChatView(BitChat chat) { string title; if (chat.NetworkType == BitChatClient.Network.BitChatNetworkType.PrivateChat) { if (chat.NetworkName == null) { title = chat.PeerEmailAddress.Address; } else { title = chat.NetworkName; } } else { title = chat.NetworkName; } ChatListItem itm = new ChatListItem(title); BitChatPanel chatPanel = new BitChatPanel(chat, itm); chatPanel.Dock = DockStyle.Fill; chatPanel.SettingsModified += chatPanel_SettingsModified; chatPanel.MessageNotification += chatPanel_MessageNotification; mainContainer.Panel2.Controls.Add(chatPanel); itm.Tag = chatPanel; lstChats.AddItem(itm); if (lstChats.Controls.Count == 1) { ShowSelectedChatView(); } }
private void WriteUISettingsTo(Stream s) { BinaryWriter bW = new BinaryWriter(s); bW.Write((byte)2); //version //form location bW.Write(this.Location.X); bW.Write(this.Location.Y); //form size bool maximized = this.WindowState == FormWindowState.Maximized; Size size; if (maximized) { size = new Size(960, 540); } else { size = this.Size; } bW.Write(size.Width); bW.Write(size.Height); //form maximized if (maximized) { bW.Write((byte)1); } else { bW.Write((byte)0); } //form main container splitter position bW.Write(mainContainer.Width - mainContainer.SplitterDistance); //write first chat panel settings bool panelFound = false; foreach (Control ctrl in mainContainer.Panel2.Controls) { BitChatPanel panel = ctrl as BitChatPanel; if (panel != null) { bW.Write((byte)1); panel.WriteSettingsTo(bW); panelFound = true; break; } } if (!panelFound) { bW.Write((byte)0); } }