⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stylesheetparser.cs

📁 一个基于 Internet Explorer 中 MSHTML 技术的 ASP.NET 服务器控件
💻 CS
字号:
using System;
using System.Collections;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using FreeTextBoxControls.Common;

namespace FreeTextBoxControls 
{
	/// <summary>
	/// Reads stylesheets for FreeTextBox
	/// </summary>
	public class StyleSheetParser 
	{
		/// <summary>
		/// Finds the stylesheet and reads in correctly formatted styles
		/// </summary>
		public static string[] ParseStyleSheet(string sheetLocation)
		{
			sheetLocation = System.Web.HttpContext.Current.Request.PhysicalApplicationPath + sheetLocation.Replace("/","\\");
			if (File.Exists(sheetLocation))
			{
				ArrayList stylesList = new ArrayList();
				StreamReader reader = File.OpenText(sheetLocation);
				string text = reader.ReadToEnd();
				reader.Close();
				string rp = @"\.(?<className>[^}]+)\s*{[^}]*}";
				Regex regex = new Regex(rp, RegexOptions.IgnoreCase);
				MatchCollection mc = regex.Matches(text);
				if (mc.Count > 0)
				{
					for (int i = 0; i < mc.Count; i++)
					{
						stylesList.Add(mc[i].Groups["className"].Value);
					}
				}
				return (string[]) stylesList.ToArray(typeof(string));
			}
			else
			{
				return new string[] {"找不到文件",sheetLocation};
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -