Example #1
0
        /// <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);
        }
Example #2
0
        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();
        }