/// <summary> /// Отображает или убирает кнопку "Вниз" /// </summary> /// <param name="isVisible"></param> public async void ShowButtonToBottomAsync(bool isVisible) { IsFocus = false; if (_cache.IndexLevel == 0 && CountNewMessages == 0 && !_haveNewMessage) { IsVisibleButtonToBottom = isVisible; await Task.Run(() => _serverWorker.GetUpdate(!IsVisibleButtonToBottom)); if (IsVisibleButtonToBottom) { GetFlickerAsync(); } else { CountNewMessages = 0; } _countClickButtonToBottom = 0; IsFocus = true; } else if (_cache.IndexLevel > 0 && _isGoToBottom == false) { _isGoToBottom = true; Application.Current.Dispatcher.Invoke(LoadFromCache, DispatcherPriority.Background); _countClickButtonToBottom = 0; IsFocus = true; } else if (_cache.IndexLevel > 0) { _isGoToBottom = false; IsFocus = true; } else if (CountNewMessages > 0 && _isGoToBottom == false) { if (CountNewMessages > 100) { await Task.Run(() => _serverWorker.GetMessages(Messages[Messages.Count - 1].Id, "New messages")); } else { CountNewMessages = 0; var mapper = new MapperConfiguration(cfg => cfg.CreateMap <Message, ChatMessageDTO>()).CreateMapper(); await Task.Run(() => _serverWorker.GetMessages(mapper.Map <Message, ChatMessageDTO>(MessagesContainer.GetMessage()))); } _countClickButtonToBottom = 0; } else { _isGoToBottom = false; } }