public void AddObject(IChatObject obj) { ChatCollection.Add(obj); if (obj is IGroupObject) { OnPropertyChanged(() => Groups); OnPropertyChanged(() => AnyGroupExists); } }
public void SortObject(IChatObject obj) { //this procedure may seem silly but will be better performance-wise compared to calling RearrangeChatCollection all day var tempColl = new ObservableCollection <IChatObject>( ChatCollection.OrderBy(chat => chat is IFriendObject ? GetStatusPriority(((IFriendObject)chat).IsOnline, ((IFriendObject)chat).UserStatus) : 0). ThenBy(chat => chat.Name) ); int oldIndex = ChatCollection.IndexOf(obj); int newIndex = tempColl.IndexOf(obj); if (oldIndex != newIndex) { ChatCollection.Move(oldIndex, newIndex); } }
public bool RemoveObject(IChatObject obj) { var item = ChatCollection.FirstOrDefault(); if (item != null) { MainWindowView.CurrentView = item.ConversationView; } else { MainWindowView.CurrentView = new AddFriendViewModel(); } bool success = ChatCollection.Remove(obj); if (success && obj is IGroupObject) { OnPropertyChanged(() => Groups); OnPropertyChanged(() => AnyGroupExists); } return(success); }
public void SelectObject(IChatObject obj) { SelectedChat = obj; }
private void MessageAlertClear(IChatObject chat) { chat.HasNewMessage = false; chat.NewMessageCount = 0; }
private void MessageAlertIncrement(IChatObject chat) { if (!chat.Selected) { chat.HasNewMessage = true; chat.NewMessageCount++; } if (config.EnableAudioNotifications && call == null) { if (WindowState == WindowState.Normal && config.AlwaysNotify && !chat.Selected) { Winmm.PlayMessageNotify(); } else if (WindowState == WindowState.Minimized || !IsActive) { Winmm.PlayMessageNotify(); } } }