Esempio n. 1
0
        private void MessagesOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs args)
        {
            if (args.Action == NotifyCollectionChangedAction.Add)
            {
                foreach (string message in args.NewItems.OfType <string>())
                {
                    MessagesTextBox.AppendText(message + Environment.NewLine);
                }

                Window window = Window.GetWindow(this);
                if (window == null)
                {
                    return;
                }

                if (window.IsActive && window.WindowState != WindowState.Minimized)
                {
                    MessagesTextBox.ScrollToEnd();
                    return;
                }

                Task.Run(new Action(FlashWhileMinimized));
                window.StartFlashing();
            }
        }
Esempio n. 2
0
 /// <summary>
 /// An event raised by the messagesTimer that responsible for updating the messages textbox in the UI
 /// </summary>
 private void UpdateMessagesTextBox(object sender, ElapsedEventArgs e)
 {
     this.Dispatcher.Invoke(() =>
     {
         MessagesTextBox.Text = simulator.SimulationMessages;
         MessagesTextBox.ScrollToEnd();
     });
 }
Esempio n. 3
0
        private void OnViewModelPropChanged(object sender, PropertyChangedEventArgs e)
        {
            var vm = DataContext as GameSurfaceViewModel;

            if (vm == null)
            {
                return;
            }

            // TODO No scrolljacking if user manually scrolled.
            if (e.PropertyName == nameof(GameSurfaceViewModel.Messages))
            {
                MessagesTextBox.ScrollToEnd();
            }
        }
Esempio n. 4
0
 private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
 {
     MessagesTextBox.Focus();
     MessagesTextBox.CaretIndex = MessagesTextBox.Text.Length;
     MessagesTextBox.ScrollToEnd();
 }
Esempio n. 5
0
 private void InputDevice_ChannelMessageReceived(object sender, ChannelMessageEventArgs e)
 {
     MessagesTextBox.Text += $"Channel: {e.Message.Message}\n";
     MessagesTextBox.ScrollToEnd();
 }