Commit 1c7b883a authored by nanahira's avatar nanahira

blank

parent dc3a0b4b
This diff is collapsed.
This diff is collapsed.

namespace DataEditorX.Common
{
/// <summary>
/// 区域
/// </summary>
public class Area
{
public Area()
{
left = 0;
top = 0;
width = 0;
height = 0;
}
/// <summary>
/// 左
/// </summary>
public int left;
/// <summary>
/// 顶
/// </summary>
public int top;
/// <summary>
/// 宽
/// </summary>
public int width;
/// <summary>
/// 高
/// </summary>
public int height;
}
/// <summary>
/// 区域
/// </summary>
public class Area
{
public Area()
{
left = 0;
top = 0;
width = 0;
height = 0;
}
/// <summary>
/// 左
/// </summary>
public int left;
/// <summary>
/// 顶
/// </summary>
public int top;
/// <summary>
/// 宽
/// </summary>
public int width;
/// <summary>
/// 高
/// </summary>
public int height;
}
}
......@@ -112,12 +112,12 @@ public static string GetHtmlContentByUrl(string url)
(HttpWebRequest)WebRequest.Create(url);
httpWebRequest.Timeout = 15000;
using (HttpWebResponse httpWebResponse =
(HttpWebResponse)httpWebRequest.GetResponse())
(HttpWebResponse)httpWebRequest.GetResponse())
{
using (Stream stream = httpWebResponse.GetResponseStream())
{
using (StreamReader streamReader =
new StreamReader(stream, Encoding.UTF8))
new StreamReader(stream, Encoding.UTF8))
{
htmlContent = streamReader.ReadToEnd();
streamReader.Close();
......
......@@ -5,119 +5,119 @@
namespace DataEditorX.Common
{
public class ConfHelper
{
/// <summary>
/// 内容分隔符
/// </summary>
public const string SEP_LINE = " ";
/// <summary>
/// 从行获取值
/// </summary>
/// <param name="line"></param>
/// <returns></returns>
public static string getValue(string line)
{
int t = line.IndexOf('=');
if (t > 0)
return line.Substring(t + 1).Trim();
return "";
}
/// <summary>
/// 从词中获取第一个值
/// </summary>
/// <param name="word"></param>
/// <returns></returns>
public static string getValue1(string word)
{
int i = word.IndexOf(SEP_LINE);
if (i > 0)
return word.Substring(0, i);
return word;
}
/// <summary>
/// 从词中获取第二个值
/// </summary>
/// <param name="word"></param>
/// <returns></returns>
public static string getValue2(string word)
{
int i = word.IndexOf(SEP_LINE);
if (i > 0)
return word.Substring(i + SEP_LINE.Length);
return "";
}
/// <summary>
/// 获取多行值,替换\n \t
/// </summary>
/// <param name="line"></param>
/// <returns></returns>
public static string getMultLineValue(string line)
{
return getRegex(getValue(line));
}
/// <summary>
/// 替换特殊符
/// </summary>
/// <param name="word"></param>
/// <returns></returns>
public static string getRegex(string word)
{
StringBuilder sb = new StringBuilder(word);
sb.Replace("\\r", "\r");
sb.Replace("\\n", "\n");
sb.Replace("\\t", "\t");
sb.Replace("[:space:]", " ");
return sb.ToString();
}
/// <summary>
/// 获取boolean值
/// </summary>
/// <param name="line"></param>
/// <returns></returns>
public static bool getBooleanValue(string line)
{
if (getValue(line).ToLower() == "true")
return true;
else
return false;
}
/// <summary>
/// 获取int值
/// </summary>
/// <param name="line"></param>
/// <param name="defalut">失败的值</param>
/// <returns></returns>
public static int getIntegerValue(string line, int defalut)
{
int i;
try
{
i = int.Parse(getValue(line));
return i;
}
catch{}
return defalut;
}
/// <summary>
/// 从行获取内容添加到字典
/// race 0x1 xxx
/// </summary>
/// <param name="dic"></param>
/// <param name="line"></param>
public static void DicAdd(SortedList<long, string> dic, string line)
{
int i = line.IndexOf("0x");
int j = (i > 0) ? line.IndexOf(SEP_LINE, i + 1) : -1;
if (j > 0)
{
string strkey = line.Substring(i + 2, j - i - 1);
string strval = line.Substring(j + 1);
long key;
long.TryParse(strkey, NumberStyles.HexNumber, null, out key);
if (!dic.ContainsKey(key))
dic.Add(key, strval.Trim());
}
}
}
public class ConfHelper
{
/// <summary>
/// 内容分隔符
/// </summary>
public const string SEP_LINE = " ";
/// <summary>
/// 从行获取值
/// </summary>
/// <param name="line"></param>
/// <returns></returns>
public static string getValue(string line)
{
int t = line.IndexOf('=');
if (t > 0)
return line.Substring(t + 1).Trim();
return "";
}
/// <summary>
/// 从词中获取第一个值
/// </summary>
/// <param name="word"></param>
/// <returns></returns>
public static string getValue1(string word)
{
int i = word.IndexOf(SEP_LINE);
if (i > 0)
return word.Substring(0, i);
return word;
}
/// <summary>
/// 从词中获取第二个值
/// </summary>
/// <param name="word"></param>
/// <returns></returns>
public static string getValue2(string word)
{
int i = word.IndexOf(SEP_LINE);
if (i > 0)
return word.Substring(i + SEP_LINE.Length);
return "";
}
/// <summary>
/// 获取多行值,替换\n \t
/// </summary>
/// <param name="line"></param>
/// <returns></returns>
public static string getMultLineValue(string line)
{
return getRegex(getValue(line));
}
/// <summary>
/// 替换特殊符
/// </summary>
/// <param name="word"></param>
/// <returns></returns>
public static string getRegex(string word)
{
StringBuilder sb = new StringBuilder(word);
sb.Replace("\\r", "\r");
sb.Replace("\\n", "\n");
sb.Replace("\\t", "\t");
sb.Replace("[:space:]", " ");
return sb.ToString();
}
/// <summary>
/// 获取boolean值
/// </summary>
/// <param name="line"></param>
/// <returns></returns>
public static bool getBooleanValue(string line)
{
if (getValue(line).ToLower() == "true")
return true;
else
return false;
}
/// <summary>
/// 获取int值
/// </summary>
/// <param name="line"></param>
/// <param name="defalut">失败的值</param>
/// <returns></returns>
public static int getIntegerValue(string line, int defalut)
{
int i;
try
{
i = int.Parse(getValue(line));
return i;
}
catch{}
return defalut;
}
/// <summary>
/// 从行获取内容添加到字典
/// race 0x1 xxx
/// </summary>
/// <param name="dic"></param>
/// <param name="line"></param>
public static void DicAdd(SortedList<long, string> dic, string line)
{
int i = line.IndexOf("0x");
int j = (i > 0) ? line.IndexOf(SEP_LINE, i + 1) : -1;
if (j > 0)
{
string strkey = line.Substring(i + 2, j - i - 1);
string strval = line.Substring(j + 1);
long key;
long.TryParse(strkey, NumberStyles.HexNumber, null, out key);
if (!dic.ContainsKey(key))
dic.Add(key, strval.Trim());
}
}
}
}
This diff is collapsed.
......@@ -16,26 +16,26 @@ namespace System.IO
/// </summary>
public class MyPath
{
/// <summary>
/// 从相对路径获取真实路径
/// </summary>
/// <param name="dir"></param>
/// <returns></returns>
public static string GetRealPath(string dir)
{
string path = Application.StartupPath;
if (dir.StartsWith("."))
{
dir = MyPath.Combine(path, dir.Substring(2));
}
return dir;
}
/// <summary>
/// 从相对路径获取真实路径
/// </summary>
/// <param name="dir"></param>
/// <returns></returns>
public static string GetRealPath(string dir)
{
string path = Application.StartupPath;
if (dir.StartsWith("."))
{
dir = MyPath.Combine(path, dir.Substring(2));
}
return dir;
}
/// <summary>
/// 合并路径
/// </summary>
/// <param name="paths"></param>
/// <returns></returns>
public static string Combine(params string[] paths)
public static string Combine(params string[] paths)
{
if (paths.Length == 0)
{
......@@ -78,64 +78,64 @@ public static string Combine(params string[] paths)
return builder.ToString();
}
}
/// <summary>
/// 检查目录是否合法
/// </summary>
/// <param name="dir">目录</param>
/// <param name="defalut">不合法时,采取的目录</param>
/// <returns></returns>
public static string CheckDir(string dir,string defalut)
{
DirectoryInfo fo;
try
{
fo = new DirectoryInfo(MyPath.GetRealPath(dir));
}
catch{
//路径不合法
fo = new DirectoryInfo(defalut);
}
if (!fo.Exists)
fo.Create();
dir = fo.FullName;
return dir;
}
/// <summary>
/// 根据tag获取文件名
/// tag_lang.txt
/// </summary>
/// <param name="tag">前面</param>
/// <param name="lang"></param>
/// <returns></returns>
public static string getFileName(string tag,string lang)
{
return tag + "_" + lang + ".txt";
}
/// <summary>
/// 由tag和lang获取文件名
/// </summary>
/// <param name="tag"></param>
/// <param name="file"></param>
/// <returns></returns>
public static string getFullFileName(string tag, string file)
{
string name = Path.GetFileNameWithoutExtension(file);
if (!name.StartsWith(tag + "_"))
return "";
else
return name.Replace(tag + "_", "");
}
/// <summary>
/// 检查目录是否合法
/// </summary>
/// <param name="dir">目录</param>
/// <param name="defalut">不合法时,采取的目录</param>
/// <returns></returns>
public static string CheckDir(string dir,string defalut)
{
DirectoryInfo fo;
try
{
fo = new DirectoryInfo(MyPath.GetRealPath(dir));
}
catch{
//路径不合法
fo = new DirectoryInfo(defalut);
}
if (!fo.Exists)
fo.Create();
dir = fo.FullName;
return dir;
}
/// <summary>
/// 根据tag获取文件名
/// tag_lang.txt
/// </summary>
/// <param name="tag">前面</param>
/// <param name="lang"></param>
/// <returns></returns>
public static string getFileName(string tag,string lang)
{
return tag + "_" + lang + ".txt";
}
/// <summary>
/// 由tag和lang获取文件名
/// </summary>
/// <param name="tag"></param>
/// <param name="file"></param>
/// <returns></returns>
public static string getFullFileName(string tag, string file)
{
string name = Path.GetFileNameWithoutExtension(file);
if (!name.StartsWith(tag + "_"))
return "";
else
return name.Replace(tag + "_", "");
}
public static void CreateDir(string dir)
{
if (!Directory.Exists(dir))
Directory.CreateDirectory(dir);
}
public static void CreateDirByFile(string file)
{
string dir = Path.GetDirectoryName(file);
if (!Directory.Exists(dir))
Directory.CreateDirectory(dir);
}
}
public static void CreateDir(string dir)
{
if (!Directory.Exists(dir))
Directory.CreateDirectory(dir);
}
public static void CreateDirByFile(string file)
{
string dir = Path.GetDirectoryName(file);
if (!Directory.Exists(dir))
Directory.CreateDirectory(dir);
}
}
}
......@@ -10,39 +10,39 @@
namespace System
{
/// <summary>
/// Description of User32.
/// </summary>
public class User32
{
/// <summary>
/// 发送窗口消息
/// </summary>
/// <param name="hWnd"></param>
/// <param name="msg"></param>
/// <param name="wParam"></param>
/// <param name="lParam"></param>
/// <returns></returns>
[DllImport("User32.dll", EntryPoint = "SendMessage")]
public static extern int SendMessage(IntPtr hWnd, int msg, uint wParam, uint lParam);
/// <summary>
/// 设置窗口的位置
/// </summary>
/// <param name="hWnd"></param>
/// <param name="hWndInsertAfter"></param>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="Width"></param>
/// <param name="Height"></param>
/// <param name="flags"></param>
/// <returns></returns>
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int y, int Width, int Height, int flags);
/// <summary>
/// 得到当前活动的窗口
/// </summary>
/// <returns></returns>
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern System.IntPtr GetForegroundWindow();
}
/// <summary>
/// Description of User32.
/// </summary>
public class User32
{
/// <summary>
/// 发送窗口消息
/// </summary>
/// <param name="hWnd"></param>
/// <param name="msg"></param>
/// <param name="wParam"></param>
/// <param name="lParam"></param>
/// <returns></returns>
[DllImport("User32.dll", EntryPoint = "SendMessage")]
public static extern int SendMessage(IntPtr hWnd, int msg, uint wParam, uint lParam);
/// <summary>
/// 设置窗口的位置
/// </summary>
/// <param name="hWnd"></param>
/// <param name="hWndInsertAfter"></param>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="Width"></param>
/// <param name="Height"></param>
/// <param name="flags"></param>
/// <returns></returns>
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int y, int Width, int Height, int flags);
/// <summary>
/// 得到当前活动的窗口
/// </summary>
/// <returns></returns>
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern System.IntPtr GetForegroundWindow();
}
}
\ No newline at end of file
......@@ -8,53 +8,53 @@
namespace DataEditorX.Common
{
public class XMLReader
{
#region XML操作config
/// <summary>
/// 保存值
/// </summary>
/// <param name="appKey"></param>
/// <param name="appValue"></param>
public static void Save(string appKey, string appValue)
{
XmlDocument xDoc = new XmlDocument();
xDoc.Load(System.Windows.Forms.Application.ExecutablePath + ".config");
public class XMLReader
{
#region XML操作config
/// <summary>
/// 保存值
/// </summary>
/// <param name="appKey"></param>
/// <param name="appValue"></param>
public static void Save(string appKey, string appValue)
{
XmlDocument xDoc = new XmlDocument();
xDoc.Load(System.Windows.Forms.Application.ExecutablePath + ".config");
XmlNode xNode = xDoc.SelectSingleNode("//appSettings");
XmlNode xNode = xDoc.SelectSingleNode("//appSettings");
XmlElement xElem = (XmlElement)xNode.SelectSingleNode("//add[@key='" + appKey + "']");
if (xElem != null) //存在,则更新
xElem.SetAttribute("value", appValue);
else//不存在,则插入
{
XmlElement xNewElem = xDoc.CreateElement("add");
xNewElem.SetAttribute("key", appKey);
xNewElem.SetAttribute("value", appValue);
xNode.AppendChild(xNewElem);
}
xDoc.Save(System.Windows.Forms.Application.ExecutablePath + ".config");
}
/// <summary>
/// 获取值
/// </summary>
/// <param name="appKey"></param>
/// <returns></returns>
public static string GetAppConfig(string appKey)
{
XmlDocument xDoc = new XmlDocument();
xDoc.Load(System.Windows.Forms.Application.ExecutablePath + ".config");
XmlElement xElem = (XmlElement)xNode.SelectSingleNode("//add[@key='" + appKey + "']");
if (xElem != null) //存在,则更新
xElem.SetAttribute("value", appValue);
else//不存在,则插入
{
XmlElement xNewElem = xDoc.CreateElement("add");
xNewElem.SetAttribute("key", appKey);
xNewElem.SetAttribute("value", appValue);
xNode.AppendChild(xNewElem);
}
xDoc.Save(System.Windows.Forms.Application.ExecutablePath + ".config");
}
/// <summary>
/// 获取值
/// </summary>
/// <param name="appKey"></param>
/// <returns></returns>
public static string GetAppConfig(string appKey)
{
XmlDocument xDoc = new XmlDocument();
xDoc.Load(System.Windows.Forms.Application.ExecutablePath + ".config");
XmlNode xNode = xDoc.SelectSingleNode("//appSettings");
XmlNode xNode = xDoc.SelectSingleNode("//appSettings");
XmlElement xElem = (XmlElement)xNode.SelectSingleNode("//add[@key='" + appKey + "']");
XmlElement xElem = (XmlElement)xNode.SelectSingleNode("//add[@key='" + appKey + "']");
if (xElem != null)
{
return xElem.Attributes["value"].Value;
}
return string.Empty;
}
#endregion
}
if (xElem != null)
{
return xElem.Attributes["value"].Value;
}
return string.Empty;
}
#endregion
}
}
This diff is collapsed.
This diff is collapsed.
......@@ -11,81 +11,81 @@
namespace DataEditorX.Config
{
/// <summary>
/// DataEditor的数据
/// </summary>
public class DataConfig
{
public DataConfig()
{
InitMember(MyPath.Combine(Application.StartupPath, MyConfig.TAG_CARDINFO+".txt"));
}
public DataConfig(string conf)
{
InitMember(conf);
}
/// <summary>
/// 初始化成员
/// </summary>
/// <param name="conf"></param>
public void InitMember(string conf)
{
//conf = MyPath.Combine(datapath, MyConfig.FILE_INFO);
if(!File.Exists(conf))
{
dicCardRules = new Dictionary<long, string>();
dicSetnames = new Dictionary<long, string>();
dicCardTypes = new Dictionary<long, string>();
dicLinkMarkers = new Dictionary<long, string>();
dicCardcategorys = new Dictionary<long, string>();
dicCardAttributes = new Dictionary<long, string>();
dicCardRaces = new Dictionary<long, string>();
dicCardLevels = new Dictionary<long, string>();
return;
}
//提取内容
string text = File.ReadAllText(conf);
dicCardRules = DataManager.Read(text, MyConfig.TAG_RULE);
dicSetnames = DataManager.Read(text, MyConfig.TAG_SETNAME);
dicCardTypes = DataManager.Read(text, MyConfig.TAG_TYPE);
dicLinkMarkers = DataManager.Read(text, MyConfig.TAG_MARKER);
dicCardcategorys = DataManager.Read(text, MyConfig.TAG_CATEGORY);
dicCardAttributes = DataManager.Read(text, MyConfig.TAG_ATTRIBUTE);
dicCardRaces = DataManager.Read(text, MyConfig.TAG_RACE);
dicCardLevels = DataManager.Read(text, MyConfig.TAG_LEVEL);
/// <summary>
/// DataEditor的数据
/// </summary>
public class DataConfig
{
public DataConfig()
{
InitMember(MyPath.Combine(Application.StartupPath, MyConfig.TAG_CARDINFO+".txt"));
}
public DataConfig(string conf)
{
InitMember(conf);
}
/// <summary>
/// 初始化成员
/// </summary>
/// <param name="conf"></param>
public void InitMember(string conf)
{
//conf = MyPath.Combine(datapath, MyConfig.FILE_INFO);
if(!File.Exists(conf))
{
dicCardRules = new Dictionary<long, string>();
dicSetnames = new Dictionary<long, string>();
dicCardTypes = new Dictionary<long, string>();
dicLinkMarkers = new Dictionary<long, string>();
dicCardcategorys = new Dictionary<long, string>();
dicCardAttributes = new Dictionary<long, string>();
dicCardRaces = new Dictionary<long, string>();
dicCardLevels = new Dictionary<long, string>();
return;
}
//提取内容
string text = File.ReadAllText(conf);
dicCardRules = DataManager.Read(text, MyConfig.TAG_RULE);
dicSetnames = DataManager.Read(text, MyConfig.TAG_SETNAME);
dicCardTypes = DataManager.Read(text, MyConfig.TAG_TYPE);
dicLinkMarkers = DataManager.Read(text, MyConfig.TAG_MARKER);
dicCardcategorys = DataManager.Read(text, MyConfig.TAG_CATEGORY);
dicCardAttributes = DataManager.Read(text, MyConfig.TAG_ATTRIBUTE);
dicCardRaces = DataManager.Read(text, MyConfig.TAG_RACE);
dicCardLevels = DataManager.Read(text, MyConfig.TAG_LEVEL);
}
/// <summary>
/// 规则
/// </summary>
public Dictionary<long, string> dicCardRules = null;
/// <summary>
/// 属性
/// </summary>
public Dictionary<long, string> dicCardAttributes = null;
/// <summary>
/// 种族
/// </summary>
public Dictionary<long, string> dicCardRaces = null;
/// <summary>
/// 等级
/// </summary>
public Dictionary<long, string> dicCardLevels = null;
/// <summary>
/// 系列名
/// </summary>
public Dictionary<long, string> dicSetnames = null;
/// <summary>
/// 卡片类型
/// </summary>
public Dictionary<long, string> dicCardTypes = null;
/// <summary>
/// 连接标志
/// </summary>
public Dictionary<long, string> dicLinkMarkers = null;
/// <summary>
/// 效果类型
/// </summary>
public Dictionary<long, string> dicCardcategorys = null;
}
/// <summary>
/// 规则
/// </summary>
public Dictionary<long, string> dicCardRules = null;
/// <summary>
/// 属性
/// </summary>
public Dictionary<long, string> dicCardAttributes = null;
/// <summary>
/// 种族
/// </summary>
public Dictionary<long, string> dicCardRaces = null;
/// <summary>
/// 等级
/// </summary>
public Dictionary<long, string> dicCardLevels = null;
/// <summary>
/// 系列名
/// </summary>
public Dictionary<long, string> dicSetnames = null;
/// <summary>
/// 卡片类型
/// </summary>
public Dictionary<long, string> dicCardTypes = null;
/// <summary>
/// 连接标志
/// </summary>
public Dictionary<long, string> dicLinkMarkers = null;
/// <summary>
/// 效果类型
/// </summary>
public Dictionary<long, string> dicCardcategorys = null;
}
}
......@@ -14,131 +14,131 @@
namespace DataEditorX.Config
{
public class DataManager
{
/// <summary>
/// 内容开头
/// </summary>
public const string TAG_START = "##";
/// <summary>
/// 内容结尾
/// </summary>
public const string TAG_END = "#";
/// <summary>
/// 行分隔符
/// </summary>
public const char SEP_LINE = '\t';
public class DataManager
{
/// <summary>
/// 内容开头
/// </summary>
public const string TAG_START = "##";
/// <summary>
/// 内容结尾
/// </summary>
public const string TAG_END = "#";
/// <summary>
/// 行分隔符
/// </summary>
public const char SEP_LINE = '\t';
#region 根据tag获取内容
static string reReturn(string content)
{
string text = content.Replace("\r\n", "\n");
text = text.Replace("\r", "\n");
return text;
}
public static string subString(string content, string tag)
{
Regex reg = new Regex(string.Format(@"{0}{1}\n([\S\s]*?)\n{2}", TAG_START, tag, TAG_END), RegexOptions.Multiline);
Match mac = reg.Match(reReturn(content));
if (mac.Success)//把相应的内容提取出来
{
return mac.Groups[1].Value.Replace("\n",Environment.NewLine);
}
return "";
}
#endregion
#region 根据tag获取内容
static string reReturn(string content)
{
string text = content.Replace("\r\n", "\n");
text = text.Replace("\r", "\n");
return text;
}
public static string subString(string content, string tag)
{
Regex reg = new Regex(string.Format(@"{0}{1}\n([\S\s]*?)\n{2}", TAG_START, tag, TAG_END), RegexOptions.Multiline);
Match mac = reg.Match(reReturn(content));
if (mac.Success)//把相应的内容提取出来
{
return mac.Groups[1].Value.Replace("\n",Environment.NewLine);
}
return "";
}
#endregion
#region 读取
/// <summary>
/// 从字符串中,按tag来分割内容,并读取内容
/// </summary>
/// <param name="content">字符串</param>
/// <param name="tag">开始的标志</param>
/// <returns></returns>
public static Dictionary<long, string> Read(string content, string tag)
{
return Read(subString(content,tag));
}
/// <summary>
/// 从文件读取内容,按行读取
/// </summary>
/// <param name="strFile"></param>
/// <param name="encode"></param>
/// <returns></returns>
public static Dictionary<long, string> Read(string strFile, Encoding encode)
{
return Read(File.ReadAllLines(strFile, encode));
}
/// <summary>
/// 从字符串中读取内容,需要分行
/// </summary>
/// <param name="content"></param>
/// <returns></returns>
public static Dictionary<long, string> Read(string content)
{
string text = reReturn(content);
return Read(text.Split('\n'));
}
/// <summary>
/// 从行读取内容
/// </summary>
/// <param name="lines"></param>
/// <returns></returns>
public static Dictionary<long, string> Read(string[] lines)
{
Dictionary<long, string> tempDic = new Dictionary<long, string>();
long lkey;
foreach (string line in lines)
{
if (line.StartsWith("#"))
continue;
string[] words = line.Split(SEP_LINE);
if (words.Length < 2)
continue;
if (words[0].StartsWith("0x"))
long.TryParse(words[0].Replace("0x", ""), NumberStyles.HexNumber, null, out lkey);
else
long.TryParse(words[0], out lkey);
// N/A 的数据不显示
if (!tempDic.ContainsKey(lkey) && words[1] != "N/A")
tempDic.Add(lkey, words[1]);
}
return tempDic;
}
#region 读取
/// <summary>
/// 从字符串中,按tag来分割内容,并读取内容
/// </summary>
/// <param name="content">字符串</param>
/// <param name="tag">开始的标志</param>
/// <returns></returns>
public static Dictionary<long, string> Read(string content, string tag)
{
return Read(subString(content,tag));
}
/// <summary>
/// 从文件读取内容,按行读取
/// </summary>
/// <param name="strFile"></param>
/// <param name="encode"></param>
/// <returns></returns>
public static Dictionary<long, string> Read(string strFile, Encoding encode)
{
return Read(File.ReadAllLines(strFile, encode));
}
/// <summary>
/// 从字符串中读取内容,需要分行
/// </summary>
/// <param name="content"></param>
/// <returns></returns>
public static Dictionary<long, string> Read(string content)
{
string text = reReturn(content);
return Read(text.Split('\n'));
}
/// <summary>
/// 从行读取内容
/// </summary>
/// <param name="lines"></param>
/// <returns></returns>
public static Dictionary<long, string> Read(string[] lines)
{
Dictionary<long, string> tempDic = new Dictionary<long, string>();
long lkey;
foreach (string line in lines)
{
if (line.StartsWith("#"))
continue;
string[] words = line.Split(SEP_LINE);
if (words.Length < 2)
continue;
if (words[0].StartsWith("0x"))
long.TryParse(words[0].Replace("0x", ""), NumberStyles.HexNumber, null, out lkey);
else
long.TryParse(words[0], out lkey);
// N/A 的数据不显示
if (!tempDic.ContainsKey(lkey) && words[1] != "N/A")
tempDic.Add(lkey, words[1]);
}
return tempDic;
}
#endregion
#region 查找
public static List<long> GetKeys(Dictionary<long, string> dic)
{
List<long> list = new List<long>();
foreach (long l in dic.Keys)
{
list.Add(l);
}
return list;
}
public static string[] GetValues(Dictionary<long, string> dic)
{
List<string> list = new List<string>();
foreach (long l in dic.Keys)
{
list.Add(dic[l]);
}
return list.ToArray();
}
/// <summary>
/// 获取值
/// </summary>
/// <param name="dic"></param>
/// <param name="key"></param>
/// <returns></returns>
public static string GetValue(Dictionary<long, string> dic, long key)
{
if(dic.ContainsKey(key))
return dic[key].Trim();
return key.ToString("x");
}
#endregion
}
#endregion
#region 查找
public static List<long> GetKeys(Dictionary<long, string> dic)
{
List<long> list = new List<long>();
foreach (long l in dic.Keys)
{
list.Add(l);
}
return list;
}
public static string[] GetValues(Dictionary<long, string> dic)
{
List<string> list = new List<string>();
foreach (long l in dic.Keys)
{
list.Add(dic[l]);
}
return list.ToArray();
}
/// <summary>
/// 获取值
/// </summary>
/// <param name="dic"></param>
/// <param name="key"></param>
/// <returns></returns>
public static string GetValue(Dictionary<long, string> dic, long key)
{
if(dic.ContainsKey(key))
return dic[key].Trim();
return key.ToString("x");
}
#endregion
}
}
......@@ -12,63 +12,63 @@
namespace DataEditorX.Config
{
/// <summary>
/// 裁剪图片是、配置
/// </summary>
/// <summary>
/// 裁剪图片是、配置
/// </summary>
public class ImageSet
{
public ImageSet(){
Init();
Init();
}
//初始化
//初始化
void Init()
{
this.normalArea = MyConfig.readArea(MyConfig.TAG_IMAGE_OTHER);
this.normalArea = MyConfig.readArea(MyConfig.TAG_IMAGE_OTHER);
this.xyzArea = MyConfig.readArea(MyConfig.TAG_IMAGE_XYZ);
this.xyzArea = MyConfig.readArea(MyConfig.TAG_IMAGE_XYZ);
this.pendulumArea = MyConfig.readArea(MyConfig.TAG_IMAGE_PENDULUM);
this.pendulumArea = MyConfig.readArea(MyConfig.TAG_IMAGE_PENDULUM);
int[] ints = MyConfig.readIntegers(MyConfig.TAG_IMAGE_SIZE, 4);
int[] ints = MyConfig.readIntegers(MyConfig.TAG_IMAGE_SIZE, 4);
this.w = ints[0];
this.h = ints[1];
this.W = ints[2];
this.H = ints[3];
this.w = ints[0];
this.h = ints[1];
this.W = ints[2];
this.H = ints[3];
this.quilty = MyConfig.readInteger(MyConfig.TAG_IMAGE_QUILTY, 95);
this.quilty = MyConfig.readInteger(MyConfig.TAG_IMAGE_QUILTY, 95);
}
/// <summary>
/// jpeg质量
/// </summary>
/// <summary>
/// jpeg质量
/// </summary>
public int quilty;
/// <summary>
/// 小图的宽
/// </summary>
public int w;
/// <summary>
/// 小图的高
/// </summary>
public int h;
/// <summary>
/// 大图的宽
/// </summary>
public int W;
/// <summary>
/// 大图的高
/// </summary>
public int H;
/// <summary>
/// 怪兽的中间图
/// </summary>
public Area normalArea;
/// <summary>
/// xyz怪兽的中间图
/// </summary>
public Area xyzArea;
/// <summary>
/// p怪的中间图
/// </summary>
public Area pendulumArea;
/// <summary>
/// 小图的宽
/// </summary>
public int w;
/// <summary>
/// 小图的高
/// </summary>
public int h;
/// <summary>
/// 大图的宽
/// </summary>
public int W;
/// <summary>
/// 大图的高
/// </summary>
public int H;
/// <summary>
/// 怪兽的中间图
/// </summary>
public Area normalArea;
/// <summary>
/// xyz怪兽的中间图
/// </summary>
public Area xyzArea;
/// <summary>
/// p怪的中间图
/// </summary>
public Area pendulumArea;
}
}
This diff is collapsed.
......@@ -5,94 +5,94 @@
namespace DataEditorX.Config
{
public class YgoPath
{
public YgoPath(string gamepath)
{
SetPath(gamepath);
}
public void SetPath(string gamepath)
{
this.gamepath = gamepath;
picpath = MyPath.Combine(gamepath, "pics");
fieldpath = MyPath.Combine(picpath, "field");
picpath2 = MyPath.Combine(picpath, "thumbnail");
luapath = MyPath.Combine(gamepath, "script");
ydkpath = MyPath.Combine(gamepath, "deck");
replaypath = MyPath.Combine(gamepath, "replay");
public class YgoPath
{
public YgoPath(string gamepath)
{
SetPath(gamepath);
}
/// <summary>游戏目录</summary>
public string gamepath;
/// <summary>大图目录</summary>
public string picpath;
/// <summary>小图目录</summary>
public string picpath2;
/// <summary>场地图目录</summary>
public string fieldpath;
/// <summary>脚本目录</summary>
public string luapath;
/// <summary>卡组目录</summary>
public string ydkpath;
/// <summary>录像目录</summary>
public string replaypath;
public void SetPath(string gamepath)
{
this.gamepath = gamepath;
picpath = MyPath.Combine(gamepath, "pics");
fieldpath = MyPath.Combine(picpath, "field");
picpath2 = MyPath.Combine(picpath, "thumbnail");
luapath = MyPath.Combine(gamepath, "script");
ydkpath = MyPath.Combine(gamepath, "deck");
replaypath = MyPath.Combine(gamepath, "replay");
}
/// <summary>游戏目录</summary>
public string gamepath;
/// <summary>大图目录</summary>
public string picpath;
/// <summary>小图目录</summary>
public string picpath2;
/// <summary>场地图目录</summary>
public string fieldpath;
/// <summary>脚本目录</summary>
public string luapath;
/// <summary>卡组目录</summary>
public string ydkpath;
/// <summary>录像目录</summary>
public string replaypath;
public string GetImage(long id)
{
{
return GetImage(id.ToString());
}
}
public string GetImageThum(long id)
{
{
return GetImageThum(id.ToString());
}
}
public string GetImageField(long id)
{
{
return GetImageField(id.ToString());//场地图
}
}
public string GetScript(long id)
{
{
return GetScript(id.ToString());
}
public string GetYdk(string name)
{
return MyPath.Combine(ydkpath, name + ".ydk");
}
//字符串id
public string GetImage(string id)
{
return MyPath.Combine(picpath, id + ".jpg");
}
}
public string GetYdk(string name)
{
return MyPath.Combine(ydkpath, name + ".ydk");
}
//字符串id
public string GetImage(string id)
{
return MyPath.Combine(picpath, id + ".jpg");
}
public string GetImageThum(string id)
{
return MyPath.Combine(picpath2, id + ".jpg");
}
{
return MyPath.Combine(picpath2, id + ".jpg");
}
public string GetImageField(string id)
{
return MyPath.Combine(fieldpath, id+ ".png");//场地图
}
{
return MyPath.Combine(fieldpath, id+ ".png");//场地图
}
public string GetScript(string id)
{
return MyPath.Combine(luapath, "c" + id + ".lua");
}
{
return MyPath.Combine(luapath, "c" + id + ".lua");
}
public string[] GetCardfiles(long id)
{
string[] files = new string[]{
GetImage(id),//大图
GetImageThum(id),//小图
GetImageField(id),//场地图
GetScript(id)
};
return files;
}
{
string[] files = new string[]{
GetImage(id),//大图
GetImageThum(id),//小图
GetImageField(id),//场地图
GetScript(id)
};
return files;
}
public string[] GetCardfiles(string id)
{
string[] files = new string[]{
GetImage(id),//大图
GetImageThum(id),//小图
GetImageField(id),//场地图
GetScript(id)
};
return files;
}
{
string[] files = new string[]{
GetImage(id),//大图
GetImageThum(id),//小图
GetImageField(id),//场地图
GetScript(id)
};
return files;
}
}
}
......@@ -5,14 +5,14 @@
namespace DataEditorX
{
public class DFlowLayoutPanel : FlowLayoutPanel
{
public DFlowLayoutPanel()
{
SetStyle(ControlStyles.OptimizedDoubleBuffer |
ControlStyles.AllPaintingInWmPaint,
true);
UpdateStyles();
}
}
public class DFlowLayoutPanel : FlowLayoutPanel
{
public DFlowLayoutPanel()
{
SetStyle(ControlStyles.OptimizedDoubleBuffer |
ControlStyles.AllPaintingInWmPaint,
true);
UpdateStyles();
}
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -2,12 +2,12 @@
namespace DataEditorX.Controls
{
public interface IMainForm
{
void CdbMenuClear();
void LuaMenuClear();
void AddCdbMenu(ToolStripItem item);
void AddLuaMenu(ToolStripItem item);
void Open(string file);
}
public interface IMainForm
{
void CdbMenuClear();
void LuaMenuClear();
void AddCdbMenu(ToolStripItem item);
void AddLuaMenu(ToolStripItem item);
void Open(string file);
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment