private void OpenWindow(object targetUser)
 {
     App.Current.Dispatcher.Invoke((Action) delegate
     {
         PersonalChatWindow personalWindow = new PersonalChatWindow(this.client, targetUser.ToString());
         PersonalWindows.Add(targetUser.ToString(), personalWindow);
         personalWindow.Show();
     });
 }
 private void CreatePersonalWindow(string target, Package Packet) // Create personal window, when a personal message is received and a chat with the sender is not open
 {
     App.Current.Dispatcher.Invoke((Action) delegate
     {
         PersonalChatWindow personalWindow = new PersonalChatWindow(this.client, target);
         PersonalWindows.Add(target, personalWindow);
         if (Packet is ImagePacket imgPacket)
         {
             personalWindow.AddImage(imgPacket);
             Application.Current.Properties["personalWindows"] = PersonalWindows;
             personalWindow.Show();
         }
         else if (Packet is MessagePacket Message)
         {
             personalWindow.AddMessage(Message);
             Application.Current.Properties["personalWindows"] = PersonalWindows;
             personalWindow.Show();
         }
     });
        public void CreatePersonalWindow(string target, object Packet)
        {
            App.Current.Dispatcher.Invoke((Action) delegate
            {
                PersonalChatWindow personalWindow = new PersonalChatWindow(this.client, target);
                PersonalWindows.Add(target, personalWindow);
                if (Packet is ImagePacket imgPacket)
                {
                    BitmapToImageConverter converter = new BitmapToImageConverter();
                    var receivedImage = converter.Convert(imgPacket.Imagebmp);

                    personalWindow.AddImage((BitmapImage)receivedImage);
                    Application.Current.Properties["personalWindows"] = PersonalWindows;
                    personalWindow.Show();
                }
                else if (Packet is MessagePacket Message)
                {
                    personalWindow.AddMessage(Message.message);
                    Application.Current.Properties["personalWindows"] = PersonalWindows;
                    personalWindow.Show();
                }
            });