Inheritance: System.EventArgs
Exemplo n.º 1
0
        /// <summary>
        /// Fired when the markdown is changed.
        /// </summary>
        /// <param name="newMarkdown"></param>
        private void OnMarkdownChanged(string newMarkdown)
        {
            OnMarkdownReadyArgs args = new OnMarkdownReadyArgs();

            // Clear the current content
            CleanUpTextBlock();

            // Make sure we have something to parse.
            if (!String.IsNullOrWhiteSpace(newMarkdown))
            {
                try
                {
                    // Try to parse the markdown.
                    Markdown markdown = new Markdown();
                    markdown.Parse(newMarkdown);

                    // Now try to display it
                    RenderToRichTextBlock rendner = new RenderToRichTextBlock(ui_richTextBox, this);
                    rendner.Render(markdown);
                }
                catch (Exception e)
                {
                    DebuggingReporter.ReportCriticalError("Error while parsing and rendering: " + e.Message);
                    args.WasError  = true;
                    args.Exception = e;
                }
            }

            // #todo indicate if ready
            m_onMarkdownReady.Raise(this, args);
        }
 /// <summary>
 /// Hide the loading text when the markdown is done.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void MarkdownBox_OnMarkdownReady(object sender, OnMarkdownReadyArgs e)
 {
     if(e.WasError)
     {
         m_host.ShowError();
         App.BaconMan.TelemetryMan.ReportUnExpectedEvent(this, "FailedToShowMarkdown", e.Exception);
     }
     else
     {
         // Hide loading
         m_host.HideLoading();
     }
 }
 private void MarkdownTextBlock_OnMarkdownReady(object sender, OnMarkdownReadyArgs e)
 {
     ErrorContainer.Visibility = e.Exception != null ? Visibility.Visible : Visibility.Collapsed;
     if (e.Exception != null)
         ErrorText.Text = e.Exception.ToString();
 }
 /// <summary>
 /// Hide the loading text when the markdown is done.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void MarkdownBox_OnMarkdownReady(object sender, OnMarkdownReadyArgs e)
 {
     if (e.WasError)
     {
         m_base.FireOnFallbackToBrowser();
         App.BaconMan.TelemetryMan.ReportUnExpectedEvent(this, "FailedToShowMarkdown", e.Exception);
     }
     else
     {
         // Hide loading
         m_base.FireOnLoading(false);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Fired when the value of a DependencyProperty is changed.
        /// </summary>
        /// <param name="d"></param>
        /// <param name="prop"></param>
        private void OnPropertyChanged(DependencyObject d, DependencyProperty prop)
        {
            // Make sure we have something to parse.
            if (Markdown == null)
            {
                return;
            }

            // Disconnect from OnClick handlers.
            UnhookListeners();

            var args = new OnMarkdownReadyArgs();

            try
            {
                // Try to parse the markdown.
                MarkdownDocument markdown = new MarkdownDocument();
                markdown.Parse(Markdown);

                // Now try to display it
                var renderer = new XamlRenderer(markdown, this);
                renderer.Background             = Background;
                renderer.BorderBrush            = BorderBrush;
                renderer.BorderThickness        = BorderThickness;
                renderer.CharacterSpacing       = CharacterSpacing;
                renderer.FontFamily             = FontFamily;
                renderer.FontSize               = FontSize;
                renderer.FontStretch            = FontStretch;
                renderer.FontStyle              = FontStyle;
                renderer.FontWeight             = FontWeight;
                renderer.Foreground             = Foreground;
                renderer.IsTextSelectionEnabled = IsTextSelectionEnabled;
                renderer.Padding                 = Padding;
                renderer.CodeBackground          = CodeBackground;
                renderer.CodeBorderBrush         = CodeBorderBrush;
                renderer.CodeBorderThickness     = CodeBorderThickness;
                renderer.CodeForeground          = CodeForeground;
                renderer.CodeFontFamily          = CodeFontFamily;
                renderer.CodePadding             = CodePadding;
                renderer.CodeMargin              = CodeMargin;
                renderer.Header1FontSize         = Header1FontSize;
                renderer.Header1FontWeight       = Header1FontWeight;
                renderer.Header1Margin           = Header1Margin;
                renderer.Header2FontSize         = Header2FontSize;
                renderer.Header2FontWeight       = Header2FontWeight;
                renderer.Header2Margin           = Header2Margin;
                renderer.Header3FontSize         = Header3FontSize;
                renderer.Header3FontWeight       = Header3FontWeight;
                renderer.Header3Margin           = Header3Margin;
                renderer.Header4FontSize         = Header4FontSize;
                renderer.Header4FontWeight       = Header4FontWeight;
                renderer.Header4Margin           = Header4Margin;
                renderer.Header5FontSize         = Header5FontSize;
                renderer.Header5FontWeight       = Header5FontWeight;
                renderer.Header5Margin           = Header5Margin;
                renderer.Header6FontSize         = Header6FontSize;
                renderer.Header6FontWeight       = Header6FontWeight;
                renderer.Header6Margin           = Header6Margin;
                renderer.HorizontalRuleBrush     = HorizontalRuleBrush;
                renderer.HorizontalRuleMargin    = HorizontalRuleMargin;
                renderer.HorizontalRuleThickness = HorizontalRuleThickness;
                renderer.ListMargin              = ListMargin;
                renderer.ListGutterWidth         = ListGutterWidth;
                renderer.ListBulletSpacing       = ListBulletSpacing;
                renderer.ParagraphMargin         = ParagraphMargin;
                renderer.QuoteBackground         = QuoteBackground;
                renderer.QuoteBorderBrush        = QuoteBorderBrush;
                renderer.QuoteBorderThickness    = QuoteBorderThickness;
                renderer.QuoteForeground         = QuoteForeground;
                renderer.QuoteMargin             = QuoteMargin;
                renderer.QuotePadding            = QuotePadding;
                renderer.TableBorderBrush        = TableBorderBrush;
                renderer.TableBorderThickness    = TableBorderThickness;
                renderer.TableCellPadding        = TableCellPadding;
                renderer.TableMargin             = TableMargin;
                renderer.TextWrapping            = TextWrapping;
                Content = renderer.Render();
            }
            catch (Exception ex)
            {
                DebuggingReporter.ReportCriticalError("Error while parsing and rendering: " + ex.Message);
                args.WasError  = true;
                args.Exception = ex;
            }

            // #todo indicate if ready
            m_onMarkdownReady.Raise(this, args);
        }
        /// <summary>
        /// Fired when the markdown is changed. 
        /// </summary>
        /// <param name="newMarkdown"></param>
        private void OnMarkdownChanged(string newMarkdown)
        {
            OnMarkdownReadyArgs args = new OnMarkdownReadyArgs();

            // Clear the current content
            CleanUpTextBlock();

            // Make sure we have something to parse.
            if (!String.IsNullOrWhiteSpace(newMarkdown))
            {
                try
                {
                    // Try to parse the markdown.
                    Markdown markdown = new Markdown();
                    markdown.Parse(newMarkdown);

                    // Now try to display it
                    RenderToRichTextBlock rendner = new RenderToRichTextBlock(ui_richTextBox, this);
                    rendner.Render(markdown);
                }
                catch (Exception e)
                {
                    DebuggingReporter.ReportCriticalError("Error while parsing and rendering: " + e.Message);
                    args.WasError = true;
                    args.Exception = e;
                }
            }

            // #todo indicate if ready
            m_onMarkdownReady.Raise(this, args);            
        }
        /// <summary>
        /// Fired when the value of a DependencyProperty is changed.
        /// </summary>
        /// <param name="d"></param>
        /// <param name="prop"></param>
        private void OnPropertyChanged(DependencyObject d, DependencyProperty prop)
        {
            // Make sure we have something to parse.
            if (Markdown == null)
                return;

            // Disconnect from OnClick handlers.
            UnhookListeners();

            var args = new OnMarkdownReadyArgs();
            try
            {
                // Try to parse the markdown.
                MarkdownDocument markdown = new MarkdownDocument();
                markdown.Parse(Markdown);

                // Now try to display it
                var renderer = new XamlRenderer(markdown, this);
                renderer.Background = Background;
                renderer.BorderBrush = BorderBrush;
                renderer.BorderThickness = BorderThickness;
                renderer.CharacterSpacing = CharacterSpacing;
                renderer.FontFamily = FontFamily;
                renderer.FontSize = FontSize;
                renderer.FontStretch = FontStretch;
                renderer.FontStyle = FontStyle;
                renderer.FontWeight = FontWeight;
                renderer.Foreground = Foreground;
                renderer.IsTextSelectionEnabled = IsTextSelectionEnabled;
                renderer.Padding = Padding;
                renderer.CodeBackground = CodeBackground;
                renderer.CodeBorderBrush = CodeBorderBrush;
                renderer.CodeBorderThickness = CodeBorderThickness;
                renderer.CodeForeground = CodeForeground;
                renderer.CodeFontFamily = CodeFontFamily;
                renderer.CodePadding = CodePadding;
                renderer.CodeMargin = CodeMargin;
                renderer.Header1FontSize = Header1FontSize;
                renderer.Header1FontWeight = Header1FontWeight;
                renderer.Header1Margin = Header1Margin;
                renderer.Header2FontSize = Header2FontSize;
                renderer.Header2FontWeight = Header2FontWeight;
                renderer.Header2Margin = Header2Margin;
                renderer.Header3FontSize = Header3FontSize;
                renderer.Header3FontWeight = Header3FontWeight;
                renderer.Header3Margin = Header3Margin;
                renderer.Header4FontSize = Header4FontSize;
                renderer.Header4FontWeight = Header4FontWeight;
                renderer.Header4Margin = Header4Margin;
                renderer.Header5FontSize = Header5FontSize;
                renderer.Header5FontWeight = Header5FontWeight;
                renderer.Header5Margin = Header5Margin;
                renderer.Header6FontSize = Header6FontSize;
                renderer.Header6FontWeight = Header6FontWeight;
                renderer.Header6Margin = Header6Margin;
                renderer.HorizontalRuleBrush = HorizontalRuleBrush;
                renderer.HorizontalRuleMargin = HorizontalRuleMargin;
                renderer.HorizontalRuleThickness = HorizontalRuleThickness;
                renderer.ListMargin = ListMargin;
                renderer.ListGutterWidth = ListGutterWidth;
                renderer.ListBulletSpacing = ListBulletSpacing;
                renderer.ParagraphMargin = ParagraphMargin;
                renderer.QuoteBackground = QuoteBackground;
                renderer.QuoteBorderBrush = QuoteBorderBrush;
                renderer.QuoteBorderThickness = QuoteBorderThickness;
                renderer.QuoteForeground = QuoteForeground;
                renderer.QuoteMargin = QuoteMargin;
                renderer.QuotePadding = QuotePadding;
                renderer.TableBorderBrush = TableBorderBrush;
                renderer.TableBorderThickness = TableBorderThickness;
                renderer.TableCellPadding = TableCellPadding;
                renderer.TableMargin = TableMargin;
                renderer.TextWrapping = TextWrapping;
                Content = renderer.Render();
            }
            catch (Exception ex)
            {
                DebuggingReporter.ReportCriticalError("Error while parsing and rendering: " + ex.Message);
                args.WasError = true;
                args.Exception = ex;
            }

            // #todo indicate if ready
            m_onMarkdownReady.Raise(this, args);
        }