Example #1
0
 private void rtf_output_MouseLeave(object sender, MouseEventArgs e)
 {
     SlideFade.CreateProfileImgAnimationOut(profile_image);
 }
Example #2
0
        public void StartChattingWith(Contact contact)
        {
            if (ChattingWith != null)
            {
                if (ChattingWith.ID == contact.ID)
                {
                    return;
                }
            }

            if (Uploads.Count > 0)
            {
                NotificationWindow.ShowNotification("Upload In Progress", string.Format("Unable to start chatting with {0} since you are currently uploading files.", contact.FullName));
                return;
            }

            new Thread(new ThreadStart(delegate
            {
                this.Dispatcher.Invoke((App.MethodInvoker) delegate
                {
                    rtf_input.IsEnabled = false;
                }, null);

                this.Dispatcher.Invoke((App.MethodInvoker) delegate
                {
                    ChattingWith = contact;

                    LastMessageFrom = "";

                    profile_image_source.ImageSource   = new System.Windows.Media.Imaging.BitmapImage(new Uri(contact.ProfileImage));
                    profile_image.BorderBrush          = (SolidColorBrush) new BrushConverter().ConvertFromString(contact.status.GetColor());
                    txt_chattingwith_nickname.Text     = contact.FullName;
                    txt_chattingwith_statusupdate.Text = contact.StatusUpdate;

                    rtf_output.SelectAll();
                    rtf_output.Selection.Text = "";
                }, null);

                this.Dispatcher.Invoke((App.MethodInvoker) delegate
                {
                    SlideFade.CreateProfileImgAnimationOut(profile_image);
                    App.Instance.Contacts[contact.ID].LastMessage = DateTime.Now;
                }, null);

                var Messages       = contact.Messages;
                int MessagesToLoad = 50;
                if (Messages.Count > MessagesToLoad)
                {
                    Messages.Reverse();
                    Messages.RemoveRange(MessagesToLoad - 1, Messages.Count - MessagesToLoad);
                    Messages.Reverse();
                }

                foreach (Message msg in Messages)
                {
                    if ((msg.SendTime - DateTime.Now).Days > 7)
                    {
                        continue;
                    }

                    this.Dispatcher.Invoke((App.MethodInvoker) delegate
                    {
                        HandleMessage(msg.From, msg.Msg, true);
                    }, null);
                }

                this.Dispatcher.Invoke((App.MethodInvoker) delegate
                {
                    rtf_input.IsEnabled = true;
                    rtf_output.ScrollToEnd();
                    SubscribeAll();
                }, null);
            })).Start();
        }