/// <summary> /// Refreshes status text being displayed on the screen. /// </summary> /// <param name="updateType">Type of update for the new status message received from backend service.</param> /// <param name="message">Actual message received from the backend service.</param> private void RefreshStatusText(UpdateType updateType, string message) { Run run; if (updateType == UpdateType.Information) { run = new Run(); run.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255)); run.Text = message; } else if (updateType == UpdateType.Warning) { run = new Run(); run.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 255, 0)); run.Text = message; } else { run = new Run(); run.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 10, 10)); run.Text = message; } TextBlockServiceStatus.Inlines.Add(run); if (TextBlockServiceStatus.Inlines.Count > m_numberOfMessages) { TextBlockServiceStatus.Inlines.Remove(TextBlockServiceStatus.Inlines.FirstInline); } TextBlockServiceStatus.UpdateLayout(); ScrollViewerMonitor.UpdateLayout(); //this is require to keep scroll-bar at the bottom. ScrollViewerMonitor.ScrollToVerticalOffset(TextBlockServiceStatus.ActualHeight * 2); }
void m_duplexClient_SendToClientReceived(object sender, SendToClientReceivedEventArgs e) { if (e.msg is ServiceUpdateMessage) { string message = ((ServiceUpdateMessage)e.msg).ServiceUpdate; if (((ServiceUpdateMessage)e.msg).ServiceUpdateType == UpdateType.Information) { // TextBoxServiceStatus.Text += ((ServiceUpdateMessage)e.msg).ServiceUpdate; Run run = new Run(); run.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255)); run.Text = message; TextBoxServiceStatus.Inlines.Add(run); } else if (((ServiceUpdateMessage)e.msg).ServiceUpdateType == UpdateType.Warning) { Run run = new Run(); run.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 255, 0)); run.Text = message; TextBoxServiceStatus.Inlines.Add(run); } else { Run run = new Run(); run.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 10, 10)); run.Text = message; TextBoxServiceStatus.Inlines.Add(run); } } if (TextBoxServiceStatus.Inlines.Count > m_numberOfMessagesOnMonitor) { TextBoxServiceStatus.Inlines.RemoveAt(0); } if (m_activityWindow != null) { m_activityWindow.Close(); } ScrollViewerMonitor.UpdateLayout(); //this is required to keep scroll-bar at the bottom. ScrollViewerMonitor.ScrollToVerticalOffset(TextBoxServiceStatus.ActualHeight * 2); //ScrollViewerMonitor.ScrollToBottom(); }
public void Initialize(ScrollIntoViewTestControl control) { // Setup initial conditions. control.Width = 300; control.Height = 350; scrollViewer = control.scrollViewer; itemsControl = control.itemsControl; // Populate collection. PopulateCollection(10); // Setup binding. control.itemsControl.ItemsSource = items; // Setup the scroll-viewer-monitor. scrollViewerMonitor = new ScrollViewerMonitor<Placeholder>(scrollViewer); scrollViewerMonitor.TopElementChanged += delegate { Debug.WriteLine("!! TopElementChanged: " + scrollViewerMonitor.TopElement.Text); }; }