• 大小: 91KB
    文件类型: .zip
    金币: 2
    下载: 1 次
    发布日期: 2021-05-19
  • 语言: Html/CSS
  • 标签: HTML  XAML  

资源简介

HTML与XAML转换源码,里面涉及到多种转换,HTML to XAML, HTML to RTF, RTF to HTML

资源截图

代码片段和文件信息

//---------------------------------------------------------------------------
// 
// File: HtmlXamlConverter.cs
//
// Copyright (C) Microsoft Corporation.  All rights reserved.
//
// Description: Prototype for Html - Xaml conversion 
//
//---------------------------------------------------------------------------

namespace MarkupConverter
{
    using System;
    using System.xml;
    using System.Diagnostics;
    using System.Collections;
    using System.Collections.Generic;
    using System.Text;
    using System.IO;

    using System.Windows; // DependencyProperty
    using System.Windows.Documents; // TextElement
  
    internal static class HtmlCssParser
    {
        // .................................................................
        //
        // Processing CSS Attributes
        //
        // .................................................................

        internal static void GetElementPropertiesFromCssAttributes(xmlElement htmlElement string elementName Cssstylesheet stylesheet Hashtable localProperties ListlElement> sourceContext)
        {
            string styleFromstylesheet = stylesheet.Getstyle(elementName sourceContext);

            string styleInline = HtmlToXamlConverter.GetAttribute(htmlElement “style“);

            // Combine styles from stylesheet and from inline attribute.
            // The order is important - the latter styles will override the former.
            string style = styleFromstylesheet != null ? styleFromstylesheet : null;
            if (styleInline != null)
            {
                style = style == null ? styleInline : (style + “;“ + styleInline);
            }

            // Apply local style to current formatting properties
            if (style != null)
            {
                string[] styleValues = style.Split(‘;‘);
                for (int i = 0; i < styleValues.Length; i++)
                {
                    string[] styleNameValue;

                    styleNameValue = styleValues[i].Split(‘:‘);
                    if (styleNameValue.Length == 2)
                    {
                        string styleName = styleNameValue[0].Trim().ToLower();
                        string styleValue = HtmlToXamlConverter.UnQuote(styleNameValue[1].Trim()).ToLower();
                        int nextIndex = 0;

                        switch (styleName)
                        {
                            case “font“:
                                ParseCssFont(styleValue localProperties);
                                break;
                            case “font-family“:
                                ParseCssFontFamily(styleValue ref nextIndex localProperties);
                                break;
                            case “font-size“:
                                ParseCssSize(styleValue ref nextIndex localProperties “font-size“ /*mustBeNonNegative:*/true);
                

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件       26160  2014-06-06 06:53  description.html
     文件        1670  2014-06-06 06:53  description\offline.js
     文件           0  2014-06-06 06:53  description\Combined.css
     文件           0  2014-06-06 06:53  description\67b74b86-a273-4ad7-9ed5-0f97276412eaCombined.css
     文件       10457  2014-06-06 06:53  description\Galleries.css
     文件        1727  2014-06-06 06:53  description\Layout.css
     文件       71647  2014-06-06 06:53  description\Brand.css
     文件        3369  2014-06-06 06:53  description\iframedescription.css
     文件       14808  2014-06-06 06:53  license.rtf
     文件       48011  2014-06-06 06:53  C#\MarkupConverter\htmlcssparser.cs
     文件       23221  2014-06-06 06:53  C#\MarkupConverter\htmlfromxamlconverter.cs
     文件       32002  2014-06-06 06:53  C#\MarkupConverter\htmllexicalanalyzer.cs
     文件       28125  2014-06-06 06:53  C#\MarkupConverter\htmlparser.cs
     文件       36651  2014-06-06 06:53  C#\MarkupConverter\htmlschema.cs
     文件         782  2014-06-06 06:53  C#\MarkupConverter\htmltokentype.cs
     文件        1912  2014-06-06 06:53  C#\MarkupConverter\HtmlToRtfConverter.cs
     文件      127492  2014-06-06 06:53  C#\MarkupConverter\htmltoxamlconverter.cs
     文件         998  2014-06-06 06:53  C#\MarkupConverter\MarkupConverter.cs
     文件        3861  2014-06-06 06:53  C#\MarkupConverter\MarkupConverter.csproj
     文件        2023  2014-06-06 06:53  C#\MarkupConverter\RtfToHtmlConverter.cs
     文件         296  2014-06-06 06:53  C#\MarkupConverterTester\App.xaml
     文件         317  2014-06-06 06:53  C#\MarkupConverterTester\App.xaml.cs
     文件        6271  2014-06-06 06:53  C#\MarkupConverterTester\MarkupConverterTester.csproj
     目录           0  2014-06-06 06:53  C#\MarkupConverterTester\Properties\
     文件        2314  2014-06-06 06:53  C#\MarkupConverterTester\Properties\AssemblyInfo.cs
     文件        2868  2014-06-06 06:53  C#\MarkupConverterTester\Properties\Resources.Designer.cs
     文件        5612  2014-06-06 06:53  C#\MarkupConverterTester\Properties\Resources.resx
     文件        1102  2014-06-06 06:53  C#\MarkupConverterTester\Properties\Settings.Designer.cs
     文件         201  2014-06-06 06:53  C#\MarkupConverterTester\Properties\Settings.settings
     文件        3748  2014-06-06 06:53  C#\MarkupConverterTester\Window1.xaml
     文件        1878  2014-06-06 06:53  C#\MarkupConverterTester\Window1.xaml.cs
............此处省略1个文件信息

评论

共有 条评论