Esempio n. 1
0
        /// <summary>
        /// Used to display messages to the user
        /// </summary>
        /// <param name="strMessage"></param>
        /// <param name="type"></param>
        public void NotifyUser(string strMessage, NotifyType type, bool clearPrevious = false)
        {
            if (!this.Dispatcher.HasThreadAccess)
            {
                var ignored = this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { NotifyUser(strMessage, type, clearPrevious); });
                return;
            }

            switch (type)
            {
            case NotifyType.StatusMessage:
                StatusBorder.Background = new SolidColorBrush(Windows.UI.Colors.Green);
                break;

            case NotifyType.ErrorMessage:
                StatusBorder.Background = new SolidColorBrush(Windows.UI.Colors.Red);
                break;
            }
            if (clearPrevious)
            {
                StatusBlock.Text = strMessage;
            }
            else
            {
                if (StatusBlock.Text != "")
                {
                    StatusBlock.Text += "\r\n";
                }
                StatusBlock.Text += strMessage;
            }
            StatusBlockScroller.ChangeView(0, StatusBlockScroller.ExtentHeight, 1);

            // Collapse the StatusBlock if it has no text to conserve real estate.
            StatusBorder.Visibility = (StatusBlock.Text != String.Empty) ? Visibility.Visible : Visibility.Collapsed;
        }
Esempio n. 2
0
        public void LogMessage(string message)
        {
            if (!this.Dispatcher.HasThreadAccess)
            {
                var ignored = this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { LogMessage(message); });
                return;
            }

            Debug.WriteLine(message);
            if (Diagnostics.Text != "")
            {
                Diagnostics.Text += "\r\n";
            }
            Diagnostics.Text += message;
            StatusBlockScroller.ChangeView(0, StatusBlockScroller.ExtentHeight, 1);
        }
Esempio n. 3
0
 private async Task LogMessageAsync(string message, bool clearPrevious = false)
 {
     Debug.WriteLine(message);
     await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         if (clearPrevious)
         {
             LogText.Text = message;
         }
         else
         {
             if (LogText.Text != "")
             {
                 LogText.Text += "\r\n";
             }
             LogText.Text += message;
         }
         StatusBlockScroller.ChangeView(0, StatusBlockScroller.ExtentHeight, 1);
     });
 }