📄 general.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.IO;
namespace San7GeneralScreen
{
public class CommonDefine
{
public static List<INIValue> SanGuoColumns = new List<INIValue>();
public static string GetColumnName(string _name)
{
foreach (INIValue iv in CommonDefine.SanGuoColumns)
{
_name = _name.Replace(iv.Name, iv.Value);
}
return _name;
}
/// <summary>
/// 加载XML文件
/// </summary>
/// <param name="xmlFilePath"></param>
/// <returns></returns>
public static XmlDocument LoadXmlFromFile(string xmlFilePath)
{
if (File.Exists(xmlFilePath))
{
string context = "";
string line = "";
System.IO.StreamReader sr = new System.IO.StreamReader(xmlFilePath, Encoding.Default);
while ((line = sr.ReadLine()) != null)
{
context += line + System.Environment.NewLine;
}
sr.Close();
sr.Dispose();
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(context);
return xmlDoc;
}
else
{
return null;
}
}
}
public struct General
{
public string No;
public string Name;
public List<City> City;
}
public struct INIValue
{
public string Name;
public string Value;
public INIValue(string line)
{
Name = "";
Value = "";
string[] str = line.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
if (str.Length > 0)
{
Name = str[0];
}
if (str.Length > 1)
{
Value = str[1];
}
}
public INIValue(string _name, string _value)
{
Name = _name;
Value = _value;
}
}
public class City
{
public string CityID;
public string Status;
public string CityName;
public string Display;
public City(string strLine)
{
CityID = "";
Status = "";
CityName = "";
Display = "";
string[] strArr = strLine.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
if (strArr.Length > 1)
{
if (strArr[1].Trim() != "")
{
string[] strCityInfo = strArr[1].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
if (strCityInfo.Length > 1)
{
CityID = strCityInfo[0].Trim();
Status = strCityInfo[1].Substring(0, 1);
CityName = strCityInfo[1].Remove(0, 1).Replace(";", "").Trim();
Display = CityID + "," + Status ;
Display = Display.PadRight(15, ' ') + ";" + CityName;
}
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -