///<summary> Обработчик нажатия на пункт меню учасники чата </summary>
        private void ContextMenuChatMembers_OnClick(object sender, RoutedEventArgs e)
        {
            var modelChat = ListBoxChat.SelectedItem as ModelChat;

            if (modelChat == null)
            {
                return;
            }

            //var rightWorkspaceContent = WindowMain.GetRightWorkspaceContent();
            //var existChatMessageDetail = rightWorkspaceContent != null ? rightWorkspaceContent is ViewChatMessageDetail : true;

            //var chatMessageDetail = existChatMessageDetail ? rightWorkspaceContent as ViewChatMessageDetail : null;

            //var createNewViewChatMessageDetail = chatMessageDetail != null ? chatMessageDetail.CurrentModelChat.Id != _viewModelChat.CurrentModelChat.Id: false;

            var chatMessageDetail = WindowMain.GetRightWorkspaceContent() as ViewChatMessageDetail;

            if (chatMessageDetail?.CurrentModelChat.Id != _viewModelChat.CurrentModelChat.Id)
            {
                var viewChatMessageDetail = new ViewChatMessageDetail(modelChat);
                WindowMain.ShowInRightWorkspace(viewChatMessageDetail);
                viewChatMessageDetail.OnInviteMembers_MouseClick(null, null);
            }
            else
            {
                chatMessageDetail?.OnInviteMembers_MouseClick(null, null);
            }
        }
 ///<summary> Обработчик изменения видимости приглашений и запросов </summary>
 private void ViewContactRequestInviteOnIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     if (!(WindowMain.GetRightWorkspaceContent() is ViewContactRequestInvite))
     {
         GridRequestInvite.Background = Brushes.Transparent;
     }
 }
 ///<summary> Обработчик изменения видимости поиска контактов в директории </summary>
 private void ViewContactDirectoryOnIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     if (!(WindowMain.GetRightWorkspaceContent() is ViewContactDirectory))
     {
         GridFindNewContact.Background = Brushes.Transparent;
     }
 }
Ejemplo n.º 4
0
        ///<summary> Обработчик клика по элементу звонка в ListBoxCallHistory </summary>
        private void GridCallItem_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (ListBoxCallHistory.SelectedItem != null && !(WindowMain.GetRightWorkspaceContent() is ViewCallHistoryDetail))
            {
                var modelCallHistoryPeer = (ModelCallHistoryPeer)ListBoxCallHistory.SelectedItem;

                _viewModelCallHistory.SetModelCallHistoryReaded(modelCallHistoryPeer);

                WindowMain.ShowInRightWorkspace(new ViewCallHistoryDetail(modelCallHistoryPeer));
            }
        }
        ///<summary> Удалить контакт из списока (Временный кастыль для демо !!!) </summary>
        public void DeleteContactListBoxContact(ModelContact modelContact)
        {
            var modelContactFromList = _viewModelContact.CurrentListModelContact.FirstOrDefault(obj => obj.Id == modelContact.Id);

            if (modelContactFromList != null)
            {
                _viewModelContact.ListModelContact.Remove(modelContact);
                _viewModelContact.ApplyFilter();
            }

            var userControl = WindowMain.GetRightWorkspaceContent() as ViewContactDetail;

            if (userControl != null && userControl.CurrentModelContact.Id == modelContact.Id)
            {
                WindowMain.ShowInRightWorkspace(null);
            }
        }
        ///<summary> Обработчик изменения ViewModelChat </summary>
        private void ViewModelChatOnPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName.Equals("CurrentListModelChat", StringComparison.InvariantCultureIgnoreCase))
            {
                int count;

                var viewChatMessageDetail = WindowMain.GetRightWorkspaceContent() as ViewChatMessageDetail;

                if (viewChatMessageDetail != null && viewChatMessageDetail.IsScrollAtBottom)
                {
                    var chatId = viewChatMessageDetail.CurrentModelChat.Id;

                    var list = _viewModelChat.CurrentListModelChat.Where(obj => obj.Id != chatId);

                    count = list.Sum(obj => obj.NewMessagesCount);
                }
                else
                {
                    count = _viewModelChat.CurrentListModelChat.Sum(obj => obj.NewMessagesCount);
                }

                OnCountUnreadMessageChanged(count);
            }
        }
        ///<summary> Открыть карточку контакта </summary>
        private void OpenModelContactDetail(ModelContact modelContact)
        {
            if (modelContact == null)
            {
                return;
            }

            var userControl = WindowMain.GetRightWorkspaceContent();

            if (userControl != null && (userControl as ViewContactDetail)?.CurrentModelContact.Id == modelContact.Id)
            {
                var userControlFront = WindowMain.GetRightWorkspaceFrontContent();

                // проверить на null и попробовать привести к ViewCallActive
                if (userControlFront != null && userControlFront is ViewCallActive)
                {
                    WindowMain.CloseInRightWorkspaceFront();
                }

                return;
            }

            WindowMain.ShowInRightWorkspace(new ViewContactDetail(modelContact));
        }