private static void AddComplexProperty(XmlTextReader xamlReader, StringBuilder inlineStyle, List <string> xamlAncestors, List <string> htmlAncestors)
 {
     if (inlineStyle != null && xamlReader.Name.EndsWith(".TextDecorations"))
     {
         HtmlFromXamlConverter.WriteElementContent(xamlReader, null, inlineStyle, xamlAncestors, htmlAncestors);
         return;
     }
     HtmlFromXamlConverter.WriteElementContent(xamlReader, null, null, xamlAncestors, htmlAncestors);
 }
        private static bool WriteFlowDocument(XmlTextReader xamlReader, XmlTextWriter htmlWriter)
        {
            if (!HtmlFromXamlConverter.ReadNextToken(xamlReader))
            {
                return(false);
            }
            if (xamlReader.NodeType != XmlNodeType.Element || xamlReader.Name != "FlowDocument")
            {
                return(false);
            }
            StringBuilder inlineStyle = new StringBuilder();

            htmlWriter.WriteStartElement("HTML");
            htmlWriter.WriteStartElement("BODY");
            HtmlFromXamlConverter.WriteFormattingProperties(xamlReader, htmlWriter, inlineStyle, "BODY");
            HtmlFromXamlConverter.WriteElementContent(xamlReader, htmlWriter, inlineStyle, new List <string>(), new List <string>());
            htmlWriter.WriteEndElement();
            htmlWriter.WriteEndElement();
            return(true);
        }
        private static void WriteElement(XmlTextReader xamlReader, XmlTextWriter htmlWriter, StringBuilder inlineStyle, List <string> xamlAncestors, List <string> htmlAncestors)
        {
            if (htmlWriter == null)
            {
                if (inlineStyle != null && xamlReader.Name == "TextDecoration")
                {
                    string attribute = xamlReader.GetAttribute("Location");
                    string a;
                    if ((a = attribute) != null)
                    {
                        if (!(a == "Underline"))
                        {
                            if (!(a == "OverLine"))
                            {
                                if (a == "Strikethrough")
                                {
                                    inlineStyle.Append("text-decoration:line-through;");
                                }
                            }
                            else
                            {
                                inlineStyle.Append("text-decoration:overline;");
                            }
                        }
                        else
                        {
                            inlineStyle.Append("text-decoration:underline;");
                        }
                    }
                }
                HtmlFromXamlConverter.WriteElementContent(xamlReader, null, null, xamlAncestors, htmlAncestors);
                return;
            }
            string name;
            string text;

            switch (name = xamlReader.Name)
            {
            case "Run":
            case "Span":
                text = "SPAN";
                goto IL_38A;

            case "InlineUIContainer":
                text = "SPAN";
                goto IL_38A;

            case "Bold":
                text = "B";
                goto IL_38A;

            case "Italic":
                text = "I";
                goto IL_38A;

            case "Paragraph":
                if (xamlAncestors.Count > 0 && xamlAncestors[xamlAncestors.Count - 1] == "ListItem")
                {
                    text = "SPAN";
                    goto IL_38A;
                }
                text = "P";
                goto IL_38A;

            case "BlockUIContainer":
                text = "DIV";
                goto IL_38A;

            case "Section":
                text = "DIV";
                goto IL_38A;

            case "Table":
                text = "TABLE";
                goto IL_38A;

            case "Table.Columns":
                text = "COLGROUP";
                goto IL_38A;

            case "TableColumn":
                text = "COL";
                goto IL_38A;

            case "TableRowGroup":
                text = "TBODY";
                goto IL_38A;

            case "TableRow":
                text = "TR";
                goto IL_38A;

            case "TableCell":
                text = "TD";
                goto IL_38A;

            case "List":
            {
                string attribute2 = xamlReader.GetAttribute("MarkerStyle");
                if (attribute2 == null || attribute2 == "Disc" || attribute2 == "Circle" || attribute2 == "Square" || attribute2 == "Box")
                {
                    text = "UL";
                    goto IL_38A;
                }
                if (attribute2 == null || attribute2 == "None")
                {
                    text = "DL";
                    goto IL_38A;
                }
                text = "OL";
                goto IL_38A;
            }

            case "ListItem":
                if (htmlAncestors.Count > 0 && htmlAncestors[htmlAncestors.Count - 1] == "DL")
                {
                    text = "DD";
                    goto IL_38A;
                }
                text = "LI";
                goto IL_38A;

            case "LineBreak":
                text = "BR";
                goto IL_38A;

            case "Hyperlink":
                text = "A";
                goto IL_38A;

            case "Image":
                text = "IMG";
                goto IL_38A;
            }
            text = null;
IL_38A:
            xamlAncestors.Add(xamlReader.Name);
            if (text != null)
            {
                htmlAncestors.Add(text);
            }
            if (htmlWriter != null && text != null)
            {
                htmlWriter.WriteStartElement(text);
                HtmlFromXamlConverter.WriteFormattingProperties(xamlReader, htmlWriter, inlineStyle, text);
                if (text == "IMG")
                {
                    string attribute3 = xamlReader.GetAttribute("Width");
                    if (!string.IsNullOrEmpty(attribute3))
                    {
                        htmlWriter.WriteAttributeString("WIDTH", attribute3);
                    }
                    string attribute4 = xamlReader.GetAttribute("Height");
                    if (!string.IsNullOrEmpty(attribute4))
                    {
                        htmlWriter.WriteAttributeString("HEIGHT", attribute4);
                    }
                }
                else
                {
                    if (text == "COL")
                    {
                        inlineStyle.Length = 0;
                        string attribute5 = xamlReader.GetAttribute("Width");
                        if (!string.IsNullOrEmpty(attribute5))
                        {
                            htmlWriter.WriteAttributeString("WIDTH", attribute5);
                        }
                    }
                }
                HtmlFromXamlConverter.WriteElementContent(xamlReader, htmlWriter, inlineStyle, xamlAncestors, htmlAncestors);
                htmlWriter.WriteEndElement();
            }
            else
            {
                HtmlFromXamlConverter.WriteElementContent(xamlReader, null, null, xamlAncestors, htmlAncestors);
            }
            xamlAncestors.RemoveAt(xamlAncestors.Count - 1);
            if (text != null)
            {
                htmlAncestors.RemoveAt(htmlAncestors.Count - 1);
            }
        }