protected override Task OnVisibilityChanged() { if (ChannelSession.Chat.BotClient != null) { this.SendChatAsComboBox.ItemsSource = new List <string>() { "Streamer", "Bot" }; this.SendChatAsComboBox.SelectedIndex = 1; } else { this.SendChatAsComboBox.ItemsSource = new List <string>() { "Streamer" }; this.SendChatAsComboBox.SelectedIndex = 0; } ScrollViewer scrollViewer = VisualTreeHelpers.GetVisualChild <ScrollViewer>(this.ChatList); if (scrollViewer != null && scrollViewer.VerticalOffset == scrollViewer.ScrollableHeight) { this.updateScrollingToLatest = true; } return(Task.FromResult(0)); }
private void ChatList_LayoutUpdated(object sender, EventArgs e) { if (this.updateScrollingToLatest && this.MessageControls.Count > 0) { ScrollViewer scrollViewer = VisualTreeHelpers.GetVisualChild <ScrollViewer>(this.ChatList); scrollViewer.ScrollToEnd(); this.updateScrollingToLatest = false; } }
private void DataGridRow_PreviewMouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { DataGridRow row = sender as DataGridRow; CommandButtonsControl commandButtonsControl = VisualTreeHelpers.GetVisualChild <CommandButtonsControl>(row); if (commandButtonsControl != null) { RemoteCommand command = commandButtonsControl.GetCommandFromCommandButtons <RemoteCommand>(); if (command != null) { this.CurrentlySelectedCommand = command; } } }
private async Task AddMessage(ChatMessageViewModel message) { await messageUpdateLock.WaitAsync(); ScrollViewer scrollViewer = VisualTreeHelpers.GetVisualChild <ScrollViewer>(this.ChatList); if (scrollViewer.VerticalOffset == scrollViewer.ScrollableHeight) { this.updateScrollingToLatest = true; } ChatMessageControl messageControl = new ChatMessageControl(message); this.totalMessages++; this.MessageControls.Add(messageControl); while (this.MessageControls.Count > ChannelSession.Settings.MaxMessagesInChat) { this.MessageControls.RemoveAt(0); } messageUpdateLock.Release(); }