Commit 1c7b883a authored by nanahira's avatar nanahira

blank

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