📄 stylesheetparser.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 + -