예제 #1
0
        private static void HandleMessage(string MessageString)
        {
            string Sender  = AuxiliaryClientWorker.GetElement(MessageString, "-U ", " -Content");
            string Message = AuxiliaryClientWorker.GetElement(MessageString, "-Content ", ".");

            MainWindowController.MainWindow.Dispatcher.Invoke(() =>
            {
                #region Profile picture before the text
                System.Windows.Shapes.Ellipse ImageToShowFrame = new System.Windows.Shapes.Ellipse();
                ImageToShowFrame.Height               = 30;
                ImageToShowFrame.Width                = 30;
                ImageToShowFrame.Stroke               = System.Windows.Media.Brushes.Black;
                ImageToShowFrame.StrokeThickness      = 1.5;
                ImageBrush ImageToShowBrush           = new ImageBrush(AuxiliaryClientWorker.BitmapToBitmapImage(ProfilePictures[Usernames.IndexOf(Sender)]));
                ImageToShowFrame.Fill                 = ImageToShowBrush;
                ImageToShowFrame.MouseLeftButtonDown += This;
                #endregion
                MainWindowController.ChatParagraph.Inlines.Add(ImageToShowFrame);

                #region Text to add after the profile picture
                System.Windows.Controls.Label TextToShow = new System.Windows.Controls.Label();
                TextToShow.FontSize   = 16;
                TextToShow.Foreground = System.Windows.Media.Brushes.Black;
                TextToShow.Content    = "[" + Sender + "]: " + Message;
                #endregion
                MainWindowController.ChatParagraph.Inlines.Add(TextToShow);
                MainWindowController.ChatParagraph.Inlines.Add(Environment.NewLine);
                MainWindowController.ChatDocument.Blocks.Add(MainWindowController.ChatParagraph);
                MainWindowController.MainPage.ClientChatTextBox.Document = MainWindowController.ChatDocument;
            });
        }
예제 #2
0
        internal static void GetCurrentProfilePicture(string CurrentUser)
        {
            Bitmap CurrentProfilePicture = new Bitmap(ProfilePictures[Usernames.IndexOf(CurrentUser)]);

            CurrentProfilePicture.Save(AppDomain.CurrentDomain.BaseDirectory + "CurrentProfilePicture.png", ImageFormat.Png);
            MainWindowController.MainWindow.Dispatcher.Invoke(() =>
            {
                ImageBrush ProfilePictureBrush = new ImageBrush(AuxiliaryClientWorker.BitmapToBitmapImage(CurrentProfilePicture));
                ProfilePictureBrush.Stretch    = Stretch.UniformToFill;
                MainWindowController.MainPage.UserProfilePicture.Fill = ProfilePictureBrush;
            });
        }
예제 #3
0
 internal static void UpdateUserProfilePicture(string UserToUpdate, byte[] Data)
 {
     byte[] DataToUse = Data;
     ProfilePictures[Usernames.IndexOf(UserToUpdate)] = AuxiliaryClientWorker.GetBitmapFromBytes(Data);
     if (UserToUpdate == LoginClientWorker.CurrentUser)
     {
         MainWindowController.MainWindow.Dispatcher.Invoke(() =>
         {
             ImageBrush NewProfilePictureBrush = new ImageBrush(AuxiliaryClientWorker.BitmapToBitmapImage(AuxiliaryClientWorker.GetBitmapFromBytes(DataToUse)));
             MainWindowController.MainPage.UserProfilePicture.Fill = NewProfilePictureBrush;
         });
     }
 }