Example #1
0
        /// <summary>
        /// Creates the rich text box in the background thread.
        /// </summary>
        /// <param name="action">The action.</param>
        /// <param name="contentControl">The content control.</param>
        public static void CreateRichTextBox(Action action, RichToolTip contentControl)
        {
            var bw = new BackgroundWorker();
            DoWorkEventHandler runWorkerAction = (s, e) => contentControl.Dispatcher.BeginInvoke(
            () =>
                {
                    richTextBox = new RadRichTextBox
                    {
                        IsReadOnly = true,
                        IsSelectionEnabled = false,
                        Background = new SolidColorBrush(Colors.Transparent),
                        IsSpellCheckingEnabled = false,
                        AcceptsTab = false,
                        AcceptsReturn = false,
                        IsContextMenuEnabled = false,
                        IsImageMiniToolBarEnabled = false,
                        IsSelectionMiniToolBarEnabled = false,
                        IsTabStop = false,
                        BorderThickness = new Thickness(0),
                        Cursor = Cursors.Hand,
                        MaxWidth = 400
                    };
                });
            RunWorkerCompletedEventHandler runWOrkerComplitedHandler = null;
            runWOrkerComplitedHandler = (s, e) =>
            {
                bw.DoWork -= runWorkerAction;
                bw.RunWorkerCompleted -= runWOrkerComplitedHandler;
                action();
            };

            bw.DoWork += runWorkerAction;
            bw.RunWorkerCompleted += runWOrkerComplitedHandler;
            bw.RunWorkerAsync(richTextBox);
        }
Example #2
0
        /// <summary>
        /// Shows the richtext box.
        /// </summary>
        /// <param name="contentControl">The content control.</param>
        private static void ShowRichtextBox(RichToolTip contentControl)
        {
            if (htmlDataProvider == null)
                htmlDataProvider = new HtmlDataProvider
                {
                    RichTextBox = richTextBox,
                };

            htmlDataProvider.Html = contentControl.Tooltip;

            if (richTextBox.Parent != null && richTextBox.Parent != contentControl._popupContent)
            {
                var control = richTextBox.Parent as ContentControl;
                if (control != null)
                {
                    control.Content = null;
                }
            }
            contentControl._popupContent.ContentTemplate = null;
            contentControl._popupContent.Content = richTextBox;
            loadingContent = false;
        }
Example #3
0
 /// <summary>
 /// Loads and show the simple content. <seealso cref="IsRichText"/>
 /// </summary>
 /// <param name="richToolTipInstance">The rich tool tip instance.</param>
 private static void LoadAndShowSimpleContent(RichToolTip richToolTipInstance)
 {
     var textBlock = new TextBlock { Text = richToolTipInstance.Tooltip, TextWrapping = TextWrapping.Wrap, MaxWidth = 400 };
     if (richToolTipInstance._popupContent != null)
     {
         richToolTipInstance._popupContent.ContentTemplate = null;
         richToolTipInstance._popupContent.Content = textBlock;
     }
 }
Example #4
0
        /// <summary>
        /// Loads and show rich content. <seealso cref="IsRichText"/>
        /// </summary>
        /// <param name="contentControl">The content control.</param>
        private static void LoadAndShowRichContent(RichToolTip contentControl)
        {
            if (richTextBox == null)
            {
                if (contentControl.BusyTemplate == null)
                {
                    contentControl._popupContent.Content = new TextBlock { Text = "Loading..." };
                }
                else
                {
                    contentControl._popupContent.ContentTemplate = contentControl.BusyTemplate;
                }

                loadingContent = true;

                CreateRichTextBox(() => ShowRichtextBox(contentControl), contentControl);
            }
            else
            {
                ShowRichtextBox(contentControl);
            }
        }
 public void PropertiesTest()
 {
     var classUnderTest = new RichToolTip();
     TestsHelper.TestPublicDeclaredPropertiesGetSet(classUnderTest);
     classUnderTest.IsRichText = true;
     TestsHelper.TestPublicDeclaredPropertiesGetSet(classUnderTest);
 }