WeiranZhang.Metropaper.Controls.NewHtmlBlock.AppendSpan C# (CSharp) Method

AppendSpan() private method

private AppendSpan ( HtmlNode node, System.Windows.Documents.Paragraph paragraph, System.Windows.Documents.Span span, string style ) : void
node HtmlAgilityPack.HtmlNode
paragraph System.Windows.Documents.Paragraph
span System.Windows.Documents.Span
style string
return void
        private void AppendSpan(HtmlNode node, Paragraph paragraph, Span span, string style)
        {
            Span span2 = new Span();

            switch (style.ToLower())
            {
                case "h1":
                    if (H1FontFamily != null)
                        span2.FontFamily = H1FontFamily;
                    else if (span2.FontFamily != this.FontFamily)
                        span2.FontFamily = this.FontFamily;

                    if (H1FontSize != null)
                        span2.FontSize = H1FontSize.Value;
                    else if (span2.FontSize != this.FontSize)
                        span2.FontSize = this.FontSize;

                    if (H1FontStretch != null)
                        span2.FontStretch = H1FontStretch;
                    else if (span2.FontStretch != this.FontStretch)
                        span2.FontStretch = this.FontStretch;

                    if (H1FontStyle != null)
                        span2.FontStyle = H1FontStyle;
                    else if (span2.FontStyle != this.FontStyle)
                        span2.FontStyle = this.FontStyle;

                    if (H1FontWeight != null)
                        span2.FontWeight = H1FontWeight;
                    else if (span2.FontWeight != this.FontWeight)
                        span2.FontWeight = this.FontWeight;

                    if (H1Foreground != null)
                        span2.Foreground = H1Foreground;
                    else if (span2.Foreground != this.Foreground)
                        span2.Foreground = this.Foreground;
                    break;

                case "h2":
                    if (H2FontFamily != null)
                        span2.FontFamily = H2FontFamily;
                    else if (span2.FontFamily != this.FontFamily)
                        span2.FontFamily = this.FontFamily;

                    if (H2FontSize != null)
                        span2.FontSize = H2FontSize.Value;
                    else if (span2.FontSize != this.FontSize)
                        span2.FontSize = this.FontSize;

                    if (H2FontStretch != null)
                        span2.FontStretch = H2FontStretch;
                    else if (span2.FontStretch != this.FontStretch)
                        span2.FontStretch = this.FontStretch;

                    if (H2FontStyle != null)
                        span2.FontStyle = H2FontStyle;
                    else if (span2.FontStyle != this.FontStyle)
                        span2.FontStyle = this.FontStyle;

                    if (H2FontWeight != null)
                        span2.FontWeight = H2FontWeight;
                    else if (span2.FontWeight != this.FontWeight)
                        span2.FontWeight = this.FontWeight;

                    if (H2Foreground != null)
                        span2.Foreground = H2Foreground;
                    else if (span2.Foreground != this.Foreground)
                        span2.Foreground = this.Foreground;
                    break;

                case "h3":
                    if (H3FontFamily != null)
                        span2.FontFamily = H3FontFamily;
                    else if (span2.FontFamily != this.FontFamily)
                        span2.FontFamily = this.FontFamily;

                    if (H3FontSize != null)
                        span2.FontSize = H3FontSize.Value;
                    else if (span2.FontSize != this.FontSize)
                        span2.FontSize = this.FontSize;

                    if (H3FontStretch != null)
                        span2.FontStretch = H3FontStretch;
                    else if (span2.FontStretch != this.FontStretch)
                        span2.FontStretch = this.FontStretch;

                    if (H3FontStyle != null)
                        span2.FontStyle = H3FontStyle;
                    else if (span2.FontStyle != this.FontStyle)
                        span2.FontStyle = this.FontStyle;

                    if (H3FontWeight != null)
                        span2.FontWeight = H3FontWeight;
                    else if (span2.FontWeight != this.FontWeight)
                        span2.FontWeight = this.FontWeight;

                    if (H3Foreground != null)
                        span2.Foreground = H3Foreground;
                    else if (span2.Foreground != this.Foreground)
                        span2.Foreground = this.Foreground;
                    break;
                case "title":
                    if (H2FontFamily != null)
                        span2.FontFamily = H2FontFamily;
                    else if (span2.FontFamily != this.FontFamily)
                        span2.FontFamily = this.FontFamily;

                    if (H2FontSize != null)
                        span2.FontSize = H2FontSize.Value;
                    else if (span2.FontSize != this.FontSize)
                        span2.FontSize = this.FontSize;

                    if (H2FontStretch != null)
                        span2.FontStretch = H2FontStretch;
                    else if (span2.FontStretch != this.FontStretch)
                        span2.FontStretch = this.FontStretch;

                    if (H2FontStyle != null)
                        span2.FontStyle = H2FontStyle;
                    else if (span2.FontStyle != this.FontStyle)
                        span2.FontStyle = this.FontStyle;

                    if (H2FontWeight != null)
                        span2.FontWeight = FontWeights.Normal;
                    else if (span2.FontWeight != this.FontWeight)
                        span2.FontWeight = FontWeights.Normal;

                    if (H2Foreground != null)
                        span2.Foreground = H2Foreground;
                    else if (span2.Foreground != this.Foreground)
                        span2.Foreground = this.Foreground;
                    break;
                default:
                    if (span2.FontFamily != this.FontFamily)
                        span2.FontFamily = this.FontFamily;

                    if (span2.FontSize != this.FontSize)
                        span2.FontSize = this.FontSize;

                    if (span2.FontStretch != this.FontStretch)
                        span2.FontStretch = this.FontStretch;

                    if (span2.FontStyle != this.FontStyle)
                        span2.FontStyle = this.FontStyle;

                    if (span2.FontWeight != this.FontWeight)
                        span2.FontWeight = this.FontWeight;

                    if (span2.Foreground != this.Foreground)
                        span2.Foreground = this.Foreground;
                    break;
            }

            if (span != null)
            {
                span.Inlines.Add(span2);
            }
            else if (paragraph != null)
            {
                paragraph.Inlines.Add(span2);
            }

            RenderChildren(node, paragraph, span2);
        }