Пример #1
0
 private void OpenChatItem_Click(object sender, RoutedEventArgs e)
 {
     Windows.ChatWindow chatWindow = ManageChatWindows.GetChatWindow(((MenuItem)sender).Tag.ToString());
     if (chatWindow != null)
     {
         chatWindow.Focus();
     }
 }
Пример #2
0
 public void OpenChatWindow(UserInfo userInfo)
 {
     Windows.ChatWindow chatWindow = ManageChatWindows.GetChatWindow(userInfo.id);
     if (chatWindow != null)
     {
         chatWindow.Focus();
     }
 }
Пример #3
0
        public override void PostLoginAction(object packet)
        {
            base.PostLoginAction(packet);

            mainWindow.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)(() =>
            {
                ManageChatWindows.ReceiveMessage((Message)packet);
            }));
        }
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (!isWindowClosing)
            {
                isWindowClosing = true;

                ManageChatWindows.RemoveChatWindow(this);
            }
        }
Пример #5
0
        public void RemoveContact(string userID)
        {
            lock (contactListView)
            {
                for (int i = 0; i < contactListView.Items.Count; i++)
                {
                    if (contactListView.Items[i].GetType() == typeof(RichTextBox))
                    {
                        if (((RichTextBox)contactListView.Items[i]).Tag.ToString() == userID)
                        {
                            ManageChatWindows.RemoveChatWindow(userID);

                            contactListView.Items.Remove(((RichTextBox)contactListView.Items[i]));
                            UpdateContactCount();

                            ContactListEntryData contactListData = null;
                            UserInfo             user            = null;
                            foreach (ContactListEntryData contactData in listContacts)
                            {
                                if (contactData.richTextBox.Tag.ToString() == userID)
                                {
                                    contactListData = contactData;
                                    break;
                                }
                            }

                            foreach (UserInfo userData in Personal.USER_CONTACTS)
                            {
                                if (userData.id == userID)
                                {
                                    user = userData;
                                    break;
                                }
                            }

                            if (user != null)
                            {
                                lock (Personal.USER_CONTACTS)
                                {
                                    Personal.USER_CONTACTS.Remove(user);
                                }
                            }

                            if (contactListData != null)
                            {
                                lock (listContacts)
                                {
                                    listContacts.Remove(contactListData);
                                }
                            }

                            UpdateContactCount();
                        }
                    }
                }
            }
        }
        public void CloseWindow()
        {
            if (!isWindowClosing)
            {
                isWindowClosing = true;

                ManageChatWindows.RemoveChatWindow(this);

                this.Close();
            }
        }
Пример #7
0
        private void menuItemArrowExit_Click(object sender, RoutedEventArgs e)
        {
            ManageChatWindows.CloseAllOpenChatWindows();

            Environment.Exit(0);
        }
Пример #8
0
        public void UpdateContact(UserInfo userInfo)
        {
            lock (Personal.USER_CONTACTS)
            {
                UserInfo userFound = Personal.USER_CONTACTS.FirstOrDefault(p => p.id == userInfo.id.Trim());

                if (userFound == null)
                {
                    Personal.USER_CONTACTS.Add(userInfo);
                    AddContactToList(userInfo);
                }
                else
                {
                    bool userJustLoggedOn  = false;
                    bool userJustLoggedOff = false;

                    ManageChatWindows.UpdateChatWindowUser(userInfo);

                    if (userFound.status != userInfo.status & userFound.status == Convert.ToInt16(UserStatus.Offline)
                        & userInfo.status != Convert.ToInt16(UserStatus.Offline))
                    {
                        userJustLoggedOn = true;
                    }

                    if (userFound.status != userInfo.status & userFound.status != Convert.ToInt16(UserStatus.Offline)
                        & userInfo.status == Convert.ToInt16(UserStatus.Offline))
                    {
                        userJustLoggedOff = true;
                    }

                    userFound.name    = userInfo.name;
                    userFound.status  = userInfo.status;
                    userFound.avatar  = userInfo.avatar;
                    userFound.comment = userInfo.comment;

                    userFound = userInfo;

                    foreach (ContactListEntryData contact in listContacts)
                    {
                        if (contact.richTextBox.ToolTip.ToString() == userFound.id.ToString())
                        {
                            contact.image.Source = LoadResource.GetSmallIconFromStatus((UserStatus)userInfo.status);
                            if (userInfo.comment.Length == 0)
                            {
                                contact.name.Text = userInfo.name;
                            }
                            else
                            {
                                contact.name.Text = userInfo.name + " - ";
                            }


                            if (userJustLoggedOn)
                            {
                                contactListView.Items.Remove(contact.richTextBox);
                                contactListView.Items.Insert(0, contact.richTextBox);
                            }

                            if (userJustLoggedOff)
                            {
                                contactListView.Items.Remove(contact.richTextBox);
                                contactListView.Items.Insert(contactListView.Items.Count, contact.richTextBox);
                            }

                            contact.comment.Text = userInfo.comment;

                            TextParser.ParseText(contact.name, false);
                            TextParser.ParseText(contact.comment, true);

                            break;
                        }
                    }

                    if (userJustLoggedOn & Personal.USER_INFO.status == Convert.ToInt16(UserStatus.Available) & !userInfo.blocked)
                    {
                        Notification.NotificationManager.Showpopup(userInfo.name, "has just signed in.", null);

                        Resource.Sounds.Player.PlaySound(Resource.Sounds.Identifiers.ONLINE);
                    }
                }
            }

            UpdateContactCount();
        }
Пример #9
0
        public void UpdatePersonalInformation()
        {
            txtName.Text   = Personal.USER_INFO.name;
            txtStatus.Text = "(" + ((UserStatus)Personal.USER_INFO.status).ToString() + ")";

            if (Personal.USER_INFO.comment.Length != 0)
            {
                txtQuickMessage.Text = Personal.USER_INFO.comment;
            }
            else
            {
                txtQuickMessage.Text = "Share a quick message";
            }

            imagePartnerFrame.Source = LoadResource.GetAvatarFrameFromStatus((UserStatus)Personal.USER_INFO.status, AvatarSize.Small);

            if (Personal.USER_INFO.avatar != "")
            {
                BitmapImage image = LoadResource.GetAvatar(Personal.USER_INFO.avatar);

                if (image != null)
                {
                    imagePartnerAvatar.Source = LoadResource.Resize(image, 50, 50, BitmapScalingMode.HighQuality);
                }
                else
                {
                    imagePartnerAvatar.Source = LoadResource.Resize(LoadResource.GetDefaultAvatarImage(), 50, 50, BitmapScalingMode.HighQuality);
                }
            }
            else
            {
                imagePartnerAvatar.Source = LoadResource.Resize(LoadResource.GetDefaultAvatarImage(), 50, 50, BitmapScalingMode.HighQuality);
            }

            Window mainWindow = Application.Current.MainWindow;

            if (Personal.USER_INFO.status == 0) // Offline
            {
                mainWindow.Icon = new BitmapImage(new Uri(Resource.Images.Identifiers.APP_ICON_STATUS_OFFLINE, UriKind.Absolute));
            }

            if (Personal.USER_INFO.status == 1) // Busy
            {
                mainWindow.Icon = new BitmapImage(new Uri(Resource.Images.Identifiers.APP_ICON_STATUS_BUSY, UriKind.Absolute));
            }

            if (Personal.USER_INFO.status == 2) // Away
            {
                mainWindow.Icon = new BitmapImage(new Uri(Resource.Images.Identifiers.APP_ICON_STATUS_AWAY, UriKind.Absolute));
            }

            if (Personal.USER_INFO.status == 3) // Available
            {
                mainWindow.Icon = new BitmapImage(new Uri(Resource.Images.Identifiers.APP_ICON_STATUS_AVAILABLE, UriKind.Absolute));
            }

            TextParser.ParseText(txtQuickMessage, false);
            TextParser.ParseText(txtName, false);

            ManageChatWindows.UpdateChatWindowPersonal();
        }