private void LoggingIn(object sender, EventArgs args) { if (((LoginAck)args).message) { if (chatWindow.InvokeRequired) { chatWindow.Invoke(new Action <object, EventArgs>(LoggingIn), new object[] { sender, args }); return; } username = ClientDriver.globalUsername; chatWindow.SetUserName(username); string key = ((LoginAck)args).key; int NumberChars = key.Length; personalKey = new byte[NumberChars / 2]; for (int i = 0; i < NumberChars; i += 2) { personalKey[i / 2] = System.Convert.ToByte(key.Substring(i, 2), 16); } logCrypto.SetNewKey(personalKey); fileManager.cyptoMessage.SetNewKey(personalKey); Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + @"\" + username); popup = new PopupNotifier(); popup.Image = new Bitmap(Properties.Resources.logo, new Size(100, 100)); popup.Click += new EventHandler(OnPopupClick); new Thread(() => chatWindow.ShowDialog()).Start(); } }
public void UpdateGraphicalOnlineList(List <Contact> contactList) { if (chatWindow.InvokeRequired) { chatWindow.Invoke(new Action <List <Contact> >(UpdateGraphicalOnlineList), new object[] { contactList }); return; } for (int n = chatWindow.contactListBox.Items.Count - 1; n >= 0; --n) { chatWindow.contactListBox.Items.RemoveAt(n); } foreach (Contact contact in contactList) { if (contact.isOnline) { chatWindow.contactListBox.Items.Add(contact.name); } else { chatWindow.contactListBox.Items.Add(contact.name + " (offline)"); } } chatWindow.contactListBox.Update(); }