Commit 7d1cf42f authored by keyongyu's avatar keyongyu

1229

parent 981f8645
...@@ -16,14 +16,16 @@ ...@@ -16,14 +16,16 @@
using DataEditorX.Language; using DataEditorX.Language;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using DataEditorX.Core; using DataEditorX.Core;
using DataEditorX.Config;
using System.Configuration; using System.Configuration;
using DataEditorX.Controls;
namespace DataEditorX namespace DataEditorX
{ {
/// <summary> /// <summary>
/// Description of CodeEditForm. /// Description of CodeEditForm.
/// </summary> /// </summary>
public partial class CodeEditForm : DockContent public partial class CodeEditForm : DockContent, IEditForm
{ {
#region Style #region Style
SortedDictionary<long,string> cardlist; SortedDictionary<long,string> cardlist;
...@@ -36,7 +38,6 @@ public partial class CodeEditForm : DockContent ...@@ -36,7 +38,6 @@ public partial class CodeEditForm : DockContent
AutocompleteMenu popupMenu_con; AutocompleteMenu popupMenu_con;
AutocompleteMenu popupMenu_find; AutocompleteMenu popupMenu_find;
string nowFile; string nowFile;
public string NowFile { get { return nowFile; } }
string title; string title;
string oldtext; string oldtext;
Dictionary<string,string> tooltipDic; Dictionary<string,string> tooltipDic;
...@@ -76,32 +77,22 @@ void InitForm() ...@@ -76,32 +77,22 @@ void InitForm()
popupMenu_find.Items.MaximumSize = new System.Drawing.Size(200, 400); popupMenu_find.Items.MaximumSize = new System.Drawing.Size(200, 400);
popupMenu_find.Items.Width = 300; popupMenu_find.Items.Width = 300;
title=this.Text; title=this.Text;
fctb.SyntaxHighlighter=new MySyntaxHighlighter();
string fontname=ConfigurationManager.AppSettings["fontname"]; string fontname = MyConfig.readString(MyConfig.TAG_FONT_NAME);
float fontsize=0; float fontsize = MyConfig.readFloat(MyConfig.TAG_FONT_SIZE, 14);
if(float.TryParse(ConfigurationManager.AppSettings["fontsize"]
, out fontsize))
fctb.Font=new Font(fontname,fontsize); fctb.Font=new Font(fontname,fontsize);
if(ReadConfig("IME").ToLower()=="true") if(MyConfig.readBoolean(MyConfig.TAG_IME))
fctb.ImeMode=ImeMode.On; fctb.ImeMode=ImeMode.On;
if (ReadConfig("wordwrap").ToLower() == "true") if (MyConfig.readBoolean(MyConfig.TAG_WORDWRAP))
fctb.WordWrap = true; fctb.WordWrap = true;
else else
fctb.WordWrap = false; fctb.WordWrap = false;
if (ReadConfig("tabisspace").ToLower() == "true") if (MyConfig.readBoolean(MyConfig.TAG_TAB2SPACES))
tabisspaces = true; tabisspaces = true;
else else
tabisspaces = false; tabisspaces = false;
} }
string ReadConfig(string key)
{
string v = ConfigurationManager.AppSettings[key];
if (string.IsNullOrEmpty(v))
return "";
else
return v;
}
public void LoadXml(string xmlfile) public void LoadXml(string xmlfile)
{ {
fctb.DescriptionFile=xmlfile; fctb.DescriptionFile=xmlfile;
...@@ -110,7 +101,23 @@ public void LoadXml(string xmlfile) ...@@ -110,7 +101,23 @@ public void LoadXml(string xmlfile)
#endregion #endregion
#region Open #region Open
public void Open(string file) public void SetActived()
{
this.Activate();
}
public bool CanOpen(string file)
{
return YGOUtil.isScript(file);
}
public string GetOpenFile()
{
return nowFile;
}
public bool Create(string file)
{
return Open(file);
}
public bool Open(string file)
{ {
if(!string.IsNullOrEmpty(file)) if(!string.IsNullOrEmpty(file))
{ {
...@@ -126,7 +133,9 @@ public void Open(string file) ...@@ -126,7 +133,9 @@ public void Open(string file)
fctb.OpenFile(nowFile, new UTF8Encoding(false)); fctb.OpenFile(nowFile, new UTF8Encoding(false));
oldtext=fctb.Text; oldtext=fctb.Text;
SetTitle(); SetTitle();
return true;
} }
return false;
} }
void HideMenu() void HideMenu()
...@@ -323,7 +332,7 @@ bool savefile(bool saveas) ...@@ -323,7 +332,7 @@ bool savefile(bool saveas)
{ {
using (SaveFileDialog sfdlg = new SaveFileDialog()) using (SaveFileDialog sfdlg = new SaveFileDialog())
{ {
sfdlg.Filter = "Script(*.lua)|*.lua|All Files(*.*)|*.*"; sfdlg.Filter = LANG.GetMsg(LMSG.ScriptFilter);
if (sfdlg.ShowDialog() == DialogResult.OK) if (sfdlg.ShowDialog() == DialogResult.OK)
{ {
nowFile = sfdlg.FileName; nowFile = sfdlg.FileName;
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using System.Windows.Forms;
namespace DataEditorX.Common namespace DataEditorX.Common
{ {
class CodeEdit : RichTextBox public class Area
{ {
public CodeEdit() public Area()
: base()
{ {
left = 0;
top = 0;
width = 0;
height = 0;
} }
public int left;
public int top;
public int width;
public int height;
} }
} }
...@@ -7,8 +7,9 @@ ...@@ -7,8 +7,9 @@
using System.Drawing; using System.Drawing;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using DataEditorX.Common;
namespace DataEditorX namespace DataEditorX.Common
{ {
/// <summary> /// <summary>
/// Description of ImageHelper. /// Description of ImageHelper.
...@@ -44,6 +45,10 @@ public static Bitmap Zoom(Bitmap sourceBitmap, int newWidth, int newHeight) ...@@ -44,6 +45,10 @@ public static Bitmap Zoom(Bitmap sourceBitmap, int newWidth, int newHeight)
#endregion #endregion
#region 裁剪 #region 裁剪
public static Bitmap Cut(Bitmap sourceBitmap, Area area)
{
return Cut(sourceBitmap, area.left, area.top, area.width, area.height);
}
/// <summary> /// <summary>
/// 裁剪图像 /// 裁剪图像
/// </summary> /// </summary>
......
/* /*
* 由SharpDevelop创建。 * 由SharpDevelop创建。
* 用户: Acer * 用户: Acer
* 日期: 2014-10-25 * 日期: 2014-10-25
......
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Text;
using DataEditorX.Common;
namespace DataEditorX.Config
{
class MyConfig
{
public const int WM_OPEN = 0x0401;
public const int MAX_HISTORY = 0x10;
public const string TAG_DATA = "data";
public const string TAG_LANGUAGE = "language";
public const string TAG_IMAGE_OTHER = "image_other";
public const string TAG_IMAGE_XYZ = "image_xyz";
public const string TAG_IMAGE_PENDULUM = "image_pendulum";
public const string TAG_IMAGE_SIZE = "image";
public const string TAG_IMAGE_QUILTY = "image_quilty";
public const string TAG_FONT_NAME = "fontname";
public const string TAG_FONT_SIZE = "fontsize";
public const string TAG_IME = "IME";
public const string TAG_WORDWRAP = "wordwrap";
public const string TAG_TAB2SPACES = "tabisspace";
public const string TAG_SOURCE_URL = "sourceURL";
public const string TAG_UPDATE_URL = "updateURL";
public const string FILE_LANGUAGE = "language.txt";
public const string FILE_TEMP = "open.tmp";
public const string FILE_MESSAGE = "message.txt";
public const string FILE_HISTORY = "history.txt";
public static string readString(string key)
{
return ConfigurationManager.AppSettings[key];
}
public static int readInteger(string key,int def)
{
int i;
if (int.TryParse(readString(key), out i))
return i;
return def;
}
public static float readFloat(string key, float def)
{
float i;
if (float.TryParse(readString(key), out i))
return i;
return def;
}
public static int[] readIntegers(string key, int length)
{
string temp = readString(key);
int[] ints = new int[length];
string[] ws = string.IsNullOrEmpty(temp) ? null : temp.Split(',');
if (ws != null && ws.Length > 0 && ws.Length <= length)
{
for (int i = 0; i < ws.Length; i++)
{
int.TryParse(ws[i], out ints[i]);
}
}
return ints;
}
public static Area readArea(string key)
{
int[] ints = readIntegers(key, 4);
Area a = new Area();
if (ints != null)
{
a.left = ints[0];
a.top = ints[1];
a.width = ints[2];
a.height = ints[3];
}
return a;
}
public static bool readBoolean(string key)
{
if (readString(key).ToLower() == "true")
return true;
else
return false;
}
}
}
...@@ -13,14 +13,13 @@ ...@@ -13,14 +13,13 @@
namespace FastColoredTextBoxNS namespace FastColoredTextBoxNS
{ {
/// <summary>
/// Description of FastColoredTextBoxEx.
/// </summary>
public class FastColoredTextBoxEx : FastColoredTextBox public class FastColoredTextBoxEx : FastColoredTextBox
{ {
Point lastMouseCoord; Point lastMouseCoord;
string mFile;
public FastColoredTextBoxEx() : base() public FastColoredTextBoxEx() : base()
{ {
this.SyntaxHighlighter = new MySyntaxHighlighter();
} }
public new event EventHandler<ToolTipNeededEventArgs> ToolTipNeeded; public new event EventHandler<ToolTipNeededEventArgs> ToolTipNeeded;
protected override void OnMouseMove(MouseEventArgs e) protected override void OnMouseMove(MouseEventArgs e)
......
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using DataEditorX.Core;
using DataEditorX.Config;
using System.Windows.Forms;
using DataEditorX.Language;
namespace DataEditorX.Controls
{
interface IMainForm
{
void CdbMenuClear();
void LuaMenuClear();
void AddCdbMenu(ToolStripItem item);
void AddLuaMenu(ToolStripItem item);
void Open(string file);
}
class History
{
IMainForm mainForm;
string historyFile;
List<string> cdbhistory;
List<string> luahistory;
public string[] GetcdbHistory()
{
return cdbhistory.ToArray();
}
public string[] GetluaHistory()
{
return luahistory.ToArray();
}
public History(IMainForm mainForm)
{
this.mainForm = mainForm;
cdbhistory = new List<string>();
luahistory = new List<string>();
}
public void ReadHistory(string historyFile)
{
if (!File.Exists(historyFile))
return;
this.historyFile = historyFile;
string[] lines = File.ReadAllLines(historyFile);
AddHistorys(lines);
}
void AddHistorys(string[] lines)
{
luahistory.Clear();
cdbhistory.Clear();
foreach (string line in lines)
{
if (string.IsNullOrEmpty(line) || line.StartsWith("#"))
continue;
if (File.Exists(line))
{
if (YGOUtil.isScript(line))
{
if (luahistory.Count < MyConfig.MAX_HISTORY
&& luahistory.IndexOf(line) < 0)
luahistory.Add(line);
}
else
{
if (cdbhistory.Count < MyConfig.MAX_HISTORY
&& cdbhistory.IndexOf(line) < 0)
cdbhistory.Add(line);
}
}
}
}
public void AddHistory(string file)
{
List<string> tmplist = new List<string>();
//添加到开始
tmplist.Add(file);
//添加旧记录
tmplist.AddRange(cdbhistory.ToArray());
tmplist.AddRange(luahistory.ToArray());
//
AddHistorys(tmplist.ToArray());
SaveHistory();
MenuHistory();
}
void SaveHistory()
{
string texts = "# database history";
foreach (string str in cdbhistory)
{
if (File.Exists(str))
texts += Environment.NewLine + str;
}
texts += Environment.NewLine + "# script history";
foreach (string str in luahistory)
{
if (File.Exists(str))
texts += Environment.NewLine + str;
}
File.Delete(historyFile);
File.WriteAllText(historyFile, texts);
}
public void MenuHistory()
{
//cdb历史
mainForm.CdbMenuClear();
foreach (string str in cdbhistory)
{
ToolStripMenuItem tsmi = new ToolStripMenuItem(str);
tsmi.Click += MenuHistoryItem_Click;
mainForm.AddCdbMenu(tsmi);
}
mainForm.AddCdbMenu(new ToolStripSeparator());
ToolStripMenuItem tsmiclear = new ToolStripMenuItem(LANG.GetMsg(LMSG.ClearHistory));
tsmiclear.Click += MenuHistoryClear_Click;
mainForm.AddCdbMenu(tsmiclear);
//lua历史
mainForm.LuaMenuClear();
foreach (string str in luahistory)
{
ToolStripMenuItem tsmi = new ToolStripMenuItem(str);
tsmi.Click += MenuHistoryItem_Click;
mainForm.AddLuaMenu(tsmi);
}
mainForm.AddLuaMenu(new ToolStripSeparator());
ToolStripMenuItem tsmiclear2 = new ToolStripMenuItem(LANG.GetMsg(LMSG.ClearHistory));
tsmiclear2.Click += MenuHistoryClear2_Click;
mainForm.AddLuaMenu(tsmiclear2);
}
void MenuHistoryClear2_Click(object sender, EventArgs e)
{
luahistory.Clear();
MenuHistory();
SaveHistory();
}
void MenuHistoryClear_Click(object sender, EventArgs e)
{
cdbhistory.Clear();
MenuHistory();
SaveHistory();
}
void MenuHistoryItem_Click(object sender, EventArgs e)
{
ToolStripMenuItem tsmi = sender as ToolStripMenuItem;
if (tsmi != null)
{
string file = tsmi.Text;
mainForm.Open(file);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace DataEditorX.Controls
{
interface IEditForm
{
string GetOpenFile();
bool Create(string file);
bool Open(string file);
bool CanOpen(string file);
bool Save();
void SetActived();
}
}
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
*/ */
using System; using System;
using System.Configuration; using System.Configuration;
using DataEditorX.Config;
using DataEditorX.Common;
namespace DataEditorX.Core namespace DataEditorX.Core
{ {
/// <summary>
/// Description of ImageSet.
/// </summary>
public class ImageSet public class ImageSet
{ {
bool isInit; bool isInit;
...@@ -24,55 +24,25 @@ public void Init() ...@@ -24,55 +24,25 @@ public void Init()
if(isInit) if(isInit)
return; return;
isInit=true; isInit=true;
string temp=ConfigurationManager.AppSettings["image_other"]; this.normalArea = MyConfig.readArea(MyConfig.TAG_IMAGE_OTHER);
string[] ws=string.IsNullOrEmpty(temp)?null:temp.Split(',');
if(ws!=null && ws.Length==4){ this.xyzArea = MyConfig.readArea(MyConfig.TAG_IMAGE_XYZ);
int.TryParse(ws[0],out this.other_x);
int.TryParse(ws[1],out this.other_y); this.pendulumArea = MyConfig.readArea(MyConfig.TAG_IMAGE_PENDULUM);
int.TryParse(ws[2],out this.other_w);
int.TryParse(ws[3],out this.other_h); int[] ints = MyConfig.readIntegers(MyConfig.TAG_IMAGE_SIZE, 4);
}
//MyMsg.Show(string.Format("other:{0},{1},{2},{3}",other_x,other_y,other_w,other_h)); this.w = ints[0];
temp=ConfigurationManager.AppSettings["image_xyz"]; this.h = ints[1];
ws=string.IsNullOrEmpty(temp)?null:temp.Split(','); this.W = ints[2];
if(ws!=null && ws.Length==4){ this.H = ints[3];
int.TryParse(ws[0],out this.xyz_x);
int.TryParse(ws[1],out this.xyz_y); this.quilty = MyConfig.readInteger(MyConfig.TAG_IMAGE_QUILTY, 95);
int.TryParse(ws[2],out this.xyz_w);
int.TryParse(ws[3],out this.xyz_h);
}
//MyMsg.Show(string.Format("xyz:{0},{1},{2},{3}",xyz_x,xyz_y,xyz_w,xyz_h));
temp=ConfigurationManager.AppSettings["image_pendulum"];
ws=string.IsNullOrEmpty(temp)?null:temp.Split(',');
if(ws!=null && ws.Length==4){
int.TryParse(ws[0],out this.pendulum_x);
int.TryParse(ws[1],out this.pendulum_y);
int.TryParse(ws[2],out this.pendulum_w);
int.TryParse(ws[3],out this.pendulum_h);
}
//MyMsg.Show(string.Format("pendulum:{0},{1},{2},{3}",pendulum_x,pendulum_y,pendulum_w,pendulum_h));
temp=ConfigurationManager.AppSettings["image"];
ws=string.IsNullOrEmpty(temp)?null:temp.Split(',');
if(ws!=null && ws.Length==4){
int.TryParse(ws[0],out this.w);
int.TryParse(ws[1],out this.h);
int.TryParse(ws[2],out this.W);
int.TryParse(ws[3],out this.H);
}
//MyMsg.Show(string.Format("image:{0},{1},{2},{3}",w,h,W,H));
temp=ConfigurationManager.AppSettings["image_quilty"];
if(!string.IsNullOrEmpty(temp)){
int.TryParse(temp, out this.quilty);
}
//MyMsg.Show(string.Format("quilty:{0}",quilty));
} }
public int quilty; public int quilty;
public int w,h,W,H; public int w,h,W,H;
public int other_x,other_y; public Area normalArea;
public int other_w,other_h; public Area xyzArea;
public int xyz_x,xyz_y; public Area pendulumArea;
public int xyz_w,xyz_h;
public int pendulum_x,pendulum_y;
public int pendulum_w,pendulum_h;
} }
} }
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
using System.ComponentModel; using System.ComponentModel;
using DataEditorX.Language; using DataEditorX.Language;
using DataEditorX.Common;
using DataEditorX.Config;
namespace DataEditorX.Core namespace DataEditorX.Core
{ {
...@@ -72,8 +74,7 @@ public void Cancel() ...@@ -72,8 +74,7 @@ public void Cancel()
} }
public static void CheckVersion(bool showNew) public static void CheckVersion(bool showNew)
{ {
string newver = CheckUpdate.Check( string newver = CheckUpdate.Check(MyConfig.readString(MyConfig.TAG_UPDATE_URL));
ConfigurationManager.AppSettings["updateURL"]);
int iver, iver2; int iver, iver2;
int.TryParse(Application.ProductVersion.Replace(".", ""), out iver); int.TryParse(Application.ProductVersion.Replace(".", ""), out iver);
int.TryParse(newver.Replace(".", ""), out iver2); int.TryParse(newver.Replace(".", ""), out iver2);
...@@ -121,19 +122,13 @@ public void CutImages(string imgpath,bool isreplace) ...@@ -121,19 +122,13 @@ public void CutImages(string imgpath,bool isreplace)
Bitmap bp=new Bitmap(jpg); Bitmap bp=new Bitmap(jpg);
Bitmap bmp=null; Bitmap bmp=null;
if(c.IsType(CardType.TYPE_XYZ)){ if(c.IsType(CardType.TYPE_XYZ)){
bmp = MyBitmap.Cut(bp, bmp = MyBitmap.Cut(bp, imgSet.xyzArea);
imgSet.xyz_x,imgSet.xyz_y,
imgSet.xyz_w,imgSet.xyz_h);
} }
else if(c.IsType(CardType.TYPE_PENDULUM)){ else if(c.IsType(CardType.TYPE_PENDULUM)){
bmp = MyBitmap.Cut(bp, bmp = MyBitmap.Cut(bp, imgSet.pendulumArea);
imgSet.pendulum_x,imgSet.pendulum_y,
imgSet.pendulum_w,imgSet.pendulum_h);
} }
else{ else{
bmp = MyBitmap.Cut(bp, bmp = MyBitmap.Cut(bp, imgSet.normalArea);
imgSet.other_x,imgSet.other_y,
imgSet.other_w,imgSet.other_h);
} }
MyBitmap.SaveAsJPEG(bmp, savejpg, imgSet.quilty); MyBitmap.SaveAsJPEG(bmp, savejpg, imgSet.quilty);
//bmp.Save(savejpg, ImageFormat.Png); //bmp.Save(savejpg, ImageFormat.Png);
......
...@@ -20,7 +20,18 @@ public static void SetConfig(DataConfig dcfg) ...@@ -20,7 +20,18 @@ public static void SetConfig(DataConfig dcfg)
{ {
datacfg = dcfg; datacfg = dcfg;
} }
public static bool isScript(string file)
{
if (file != null && file.EndsWith(".lua", StringComparison.OrdinalIgnoreCase))
return true;
return false;
}
public static bool isDataBase(string file)
{
if (file != null && file.EndsWith(".cdb", StringComparison.OrdinalIgnoreCase))
return true;
return false;
}
public static string GetCardImagePath(string picpath,Card c) public static string GetCardImagePath(string picpath,Card c)
{ {
string jpg = MyPath.Combine(picpath, c.id + ".jpg"); string jpg = MyPath.Combine(picpath, c.id + ".jpg");
......
...@@ -17,43 +17,42 @@ ...@@ -17,43 +17,42 @@
using DataEditorX.Core; using DataEditorX.Core;
using DataEditorX.Language; using DataEditorX.Language;
using WeifenLuo.WinFormsUI.Docking; using WeifenLuo.WinFormsUI.Docking;
using DataEditorX.Controls;
using DataEditorX.Config;
namespace DataEditorX namespace DataEditorX
{ {
public partial class DataEditForm : DockContent public partial class DataEditForm : DockContent, IEditForm
{ {
#region 成员变量 #region 成员变量
TaskHelper tasker=null; TaskHelper tasker = null;
string taskname; string taskname;
string GAMEPATH="",PICPATH="",PICPATH2="",LUAPTH=""; string GAMEPATH = "", PICPATH = "", PICPATH2 = "", LUAPTH = "";
/// <summary>当前卡片</summary> /// <summary>当前卡片</summary>
Card oldCard=new Card(0); Card oldCard = new Card(0);
/// <summary>搜索条件</summary> /// <summary>搜索条件</summary>
Card srcCard=new Card(0); Card srcCard = new Card(0);
string[] strs=null; string[] strs = null;
List<string> tmpCodes; List<string> tmpCodes;
string title; string title;
string nowCdbFile=""; string nowCdbFile = "";
int MaxRow=20; int MaxRow = 20;
int page=1,pageNum=1; int page = 1, pageNum = 1;
int cardcount; int cardcount;
string undoString; string undoString;
List<Card> cardlist=new List<Card>(); List<Card> cardlist = new List<Card>();
bool[] setcodeIsedit = new bool[5]; bool[] setcodeIsedit = new bool[5];
Image m_cover; Image m_cover;
DataConfig datacfg; DataConfig datacfg;
string datapath, confcover; string datapath, confcover;
public string getNowCDB() public DataEditForm(string datapath, string cdbfile)
{
return nowCdbFile;
}
public DataEditForm(string datapath,string cdbfile)
{ {
InitPath(datapath); InitPath(datapath);
Initialize(); Initialize();
nowCdbFile=cdbfile; nowCdbFile = cdbfile;
} }
public DataEditForm(string datapath) public DataEditForm(string datapath)
...@@ -63,26 +62,45 @@ public DataEditForm(string datapath) ...@@ -63,26 +62,45 @@ public DataEditForm(string datapath)
} }
public DataEditForm() public DataEditForm()
{ {
string dir=ConfigurationManager.AppSettings["language"]; string dir = MyConfig.readString(MyConfig.TAG_LANGUAGE);
if(string.IsNullOrEmpty(dir)) if (string.IsNullOrEmpty(dir))
{ {
Application.Exit(); Application.Exit();
} }
datapath=MyPath.Combine(Application.StartupPath, dir); datapath = MyPath.Combine(Application.StartupPath, dir);
InitPath(datapath); InitPath(datapath);
Initialize(); Initialize();
} }
void Initialize() void Initialize()
{ {
datacfg=null; datacfg = null;
tmpCodes = new List<string>(); tmpCodes = new List<string>();
InitializeComponent(); InitializeComponent();
title=this.Text; title = this.Text;
nowCdbFile=""; nowCdbFile = "";
} }
#endregion #endregion
public void SetActived()
{
this.Activate();
}
public string GetOpenFile()
{
return nowCdbFile;
}
public bool CanOpen(string file)
{
return YGOUtil.isDataBase(file);
}
public bool Create(string file)
{
return Open(file);
}
public bool Save()
{
return true;
}
#region 窗体 #region 窗体
//窗体第一次加载 //窗体第一次加载
void DataEditFormLoad(object sender, EventArgs e) void DataEditFormLoad(object sender, EventArgs e)
...@@ -91,29 +109,30 @@ void DataEditFormLoad(object sender, EventArgs e) ...@@ -91,29 +109,30 @@ void DataEditFormLoad(object sender, EventArgs e)
HideMenu();//是否需要隐藏菜单 HideMenu();//是否需要隐藏菜单
SetTitle(); SetTitle();
if(datacfg==null){ if (datacfg == null)
datacfg=new DataConfig(datapath); {
datacfg = new DataConfig(datapath);
datacfg.Init(); datacfg.Init();
} }
tasker=new TaskHelper(datapath, bgWorker1, tasker = new TaskHelper(datapath, bgWorker1,
datacfg.dicCardTypes, datacfg.dicCardTypes,
datacfg.dicCardRaces); datacfg.dicCardRaces);
//设置空白卡片 //设置空白卡片
oldCard=new Card(0); oldCard = new Card(0);
SetCard(oldCard); SetCard(oldCard);
if (nowCdbFile !=null && File.Exists(nowCdbFile)) if (nowCdbFile != null && File.Exists(nowCdbFile))
Open(nowCdbFile); Open(nowCdbFile);
// CheckUpdate(false);//检查更新 // CheckUpdate(false);//检查更新
} }
//窗体关闭 //窗体关闭
void DataEditFormFormClosing(object sender, FormClosingEventArgs e) void DataEditFormFormClosing(object sender, FormClosingEventArgs e)
{ {
if(tasker!=null && tasker.IsRuning()) if (tasker != null && tasker.IsRuning())
{ {
if(!CancelTask()) if (!CancelTask())
{ {
e.Cancel=true; e.Cancel = true;
return; return;
} }
...@@ -130,19 +149,19 @@ void DataEditFormEnter(object sender, EventArgs e) ...@@ -130,19 +149,19 @@ void DataEditFormEnter(object sender, EventArgs e)
//隐藏菜单 //隐藏菜单
void HideMenu() void HideMenu()
{ {
if(this.MdiParent ==null) if (this.MdiParent == null)
return; return;
menuStrip1.Visible=false; menuStrip1.Visible = false;
menuitem_file.Visible=false; menuitem_file.Visible = false;
menuitem_file.Enabled=false; menuitem_file.Enabled = false;
//this.SuspendLayout(); //this.SuspendLayout();
this.ResumeLayout(true); this.ResumeLayout(true);
foreach(Control c in this.Controls) foreach (Control c in this.Controls)
{ {
if(c.GetType()==typeof(MenuStrip)) if (c.GetType() == typeof(MenuStrip))
continue; continue;
Point p=c.Location; Point p = c.Location;
c.Location=new Point(p.X, p.Y-25); c.Location = new Point(p.X, p.Y - 25);
} }
this.ResumeLayout(false); this.ResumeLayout(false);
//this.PerformLayout(); //this.PerformLayout();
...@@ -150,72 +169,74 @@ void HideMenu() ...@@ -150,72 +169,74 @@ void HideMenu()
//移除Tag //移除Tag
string RemoveTag(string text) string RemoveTag(string text)
{ {
int t=text.LastIndexOf(" ("); int t = text.LastIndexOf(" (");
if(t>0) if (t > 0)
{ {
return text.Substring(0,t); return text.Substring(0, t);
} }
return text; return text;
} }
//设置标题 //设置标题
void SetTitle() void SetTitle()
{ {
string str=title; string str = title;
string str2=RemoveTag(title); string str2 = RemoveTag(title);
if(!string.IsNullOrEmpty(nowCdbFile)){ if (!string.IsNullOrEmpty(nowCdbFile))
str=nowCdbFile+"-"+str; {
str2=Path.GetFileName(nowCdbFile); str = nowCdbFile + "-" + str;
str2 = Path.GetFileName(nowCdbFile);
} }
if(this.MdiParent !=null) if (this.MdiParent != null)
{
this.Text = str2;
if (tasker != null && tasker.IsRuning())
{ {
this.Text=str2; if (DockPanel.ActiveContent == this)
if(tasker!=null && tasker.IsRuning()){ this.MdiParent.Text = str;
if(DockPanel.ActiveContent == this)
this.MdiParent.Text=str;
} }
else else
this.MdiParent.Text=str; this.MdiParent.Text = str;
} }
else else
this.Text=str; this.Text = str;
} }
//按cdb路径设置目录 //按cdb路径设置目录
void SetCDB(string cdb) void SetCDB(string cdb)
{ {
this.nowCdbFile=cdb; this.nowCdbFile = cdb;
SetTitle(); SetTitle();
if(cdb.Length>0) if (cdb.Length > 0)
{ {
char SEP=Path.DirectorySeparatorChar; char SEP = Path.DirectorySeparatorChar;
int l=nowCdbFile.LastIndexOf(SEP); int l = nowCdbFile.LastIndexOf(SEP);
GAMEPATH=(l>0)?nowCdbFile.Substring(0,l+1):cdb; GAMEPATH = (l > 0) ? nowCdbFile.Substring(0, l + 1) : cdb;
} }
else else
GAMEPATH=Application.StartupPath; GAMEPATH = Application.StartupPath;
PICPATH=MyPath.Combine(GAMEPATH,"pics"); PICPATH = MyPath.Combine(GAMEPATH, "pics");
PICPATH2=MyPath.Combine(PICPATH,"thumbnail"); PICPATH2 = MyPath.Combine(PICPATH, "thumbnail");
LUAPTH=MyPath.Combine(GAMEPATH,"script"); LUAPTH = MyPath.Combine(GAMEPATH, "script");
} }
//初始化文件路径 //初始化文件路径
void InitPath(string datapath) void InitPath(string datapath)
{ {
this.datapath=datapath; this.datapath = datapath;
confcover= MyPath.Combine(datapath, "cover.jpg"); confcover = MyPath.Combine(datapath, "cover.jpg");
if(File.Exists(confcover)) if (File.Exists(confcover))
m_cover=Image.FromFile(confcover); m_cover = Image.FromFile(confcover);
else else
m_cover=null; m_cover = null;
} }
//保存dic //保存dic
void SaveDic(string file, Dictionary<long, string> dic) void SaveDic(string file, Dictionary<long, string> dic)
{ {
using(FileStream fs=new FileStream(file,FileMode.OpenOrCreate,FileAccess.Write)) using (FileStream fs = new FileStream(file, FileMode.OpenOrCreate, FileAccess.Write))
{ {
StreamWriter sw=new StreamWriter(fs,Encoding.UTF8); StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
foreach(long k in dic.Keys) foreach (long k in dic.Keys)
{ {
sw.WriteLine("0x"+k.ToString("x")+" "+dic[k]); sw.WriteLine("0x" + k.ToString("x") + " " + dic[k]);
} }
sw.Close(); sw.Close();
fs.Close(); fs.Close();
...@@ -243,7 +264,7 @@ void InitControl() ...@@ -243,7 +264,7 @@ void InitControl()
//card categorys //card categorys
InitCheckPanel(pl_category, datacfg.dicCardcategorys); InitCheckPanel(pl_category, datacfg.dicCardcategorys);
//setname //setname
string[] setnames=DataManager.GetValues(datacfg.dicSetnames); string[] setnames = DataManager.GetValues(datacfg.dicSetnames);
cb_setname1.Items.AddRange(setnames); cb_setname1.Items.AddRange(setnames);
cb_setname2.Items.AddRange(setnames); cb_setname2.Items.AddRange(setnames);
cb_setname3.Items.AddRange(setnames); cb_setname3.Items.AddRange(setnames);
...@@ -255,14 +276,14 @@ void InitCheckPanel(FlowLayoutPanel fpanel, Dictionary<long, string> dic) ...@@ -255,14 +276,14 @@ void InitCheckPanel(FlowLayoutPanel fpanel, Dictionary<long, string> dic)
{ {
fpanel.SuspendLayout(); fpanel.SuspendLayout();
fpanel.Controls.Clear(); fpanel.Controls.Clear();
foreach(long key in dic.Keys) foreach (long key in dic.Keys)
{ {
CheckBox _cbox=new CheckBox(); CheckBox _cbox = new CheckBox();
_cbox.Name=fpanel.Name+key.ToString(); _cbox.Name = fpanel.Name + key.ToString();
_cbox.Text=dic[key]; _cbox.Text = dic[key];
_cbox.AutoSize=true; _cbox.AutoSize = true;
_cbox.Margin=fpanel.Margin; _cbox.Margin = fpanel.Margin;
_cbox.Click+= PanelOnCheckClick; _cbox.Click += PanelOnCheckClick;
fpanel.Controls.Add(_cbox); fpanel.Controls.Add(_cbox);
} }
fpanel.ResumeLayout(false); fpanel.ResumeLayout(false);
...@@ -278,28 +299,28 @@ void InitComboBox(ComboBox cb, Dictionary<long, string> tempdic) ...@@ -278,28 +299,28 @@ void InitComboBox(ComboBox cb, Dictionary<long, string> tempdic)
{ {
cb.Items.Clear(); cb.Items.Clear();
cb.Items.AddRange(DataManager.GetValues(tempdic)); cb.Items.AddRange(DataManager.GetValues(tempdic));
cb.SelectedIndex=0; cb.SelectedIndex = 0;
} }
//计算list最大行数 //计算list最大行数
void InitListRows() void InitListRows()
{ {
if ( lv_cardlist.Items.Count==0 ) if (lv_cardlist.Items.Count == 0)
{ {
ListViewItem item=new ListViewItem(); ListViewItem item = new ListViewItem();
item.Text="Test"; item.Text = "Test";
lv_cardlist.Items.Add(item); lv_cardlist.Items.Add(item);
} }
int headH=lv_cardlist.Items[0].GetBounds(ItemBoundsPortion.ItemOnly).Y; int headH = lv_cardlist.Items[0].GetBounds(ItemBoundsPortion.ItemOnly).Y;
int itemH=lv_cardlist.Items[0].GetBounds(ItemBoundsPortion.ItemOnly).Height; int itemH = lv_cardlist.Items[0].GetBounds(ItemBoundsPortion.ItemOnly).Height;
if ( itemH>0 ) if (itemH > 0)
{ {
int n=( lv_cardlist.Height-headH-4 )/itemH; int n = (lv_cardlist.Height - headH - 4) / itemH;
if ( n>0 ) if (n > 0)
MaxRow=n; MaxRow = n;
} }
lv_cardlist.Items.Clear(); lv_cardlist.Items.Clear();
if ( MaxRow<10 ) if (MaxRow < 10)
MaxRow=20; MaxRow = 20;
} }
//设置checkbox //设置checkbox
string SetCheck(FlowLayoutPanel fpl, long number) string SetCheck(FlowLayoutPanel fpl, long number)
...@@ -448,43 +469,43 @@ void AddListView(int p) ...@@ -448,43 +469,43 @@ void AddListView(int p)
#region 设置卡片 #region 设置卡片
void SetCard(Card c) void SetCard(Card c)
{ {
oldCard=c; oldCard = c;
tb_cardname.Text=c.name; tb_cardname.Text = c.name;
tb_cardtext.Text=c.desc; tb_cardtext.Text = c.desc;
strs=new string[c.str.Length]; strs = new string[c.str.Length];
Array.Copy(c.str,strs,c.str.Length); Array.Copy(c.str, strs, c.str.Length);
lb_scripttext.Items.Clear(); lb_scripttext.Items.Clear();
lb_scripttext.Items.AddRange(c.str); lb_scripttext.Items.AddRange(c.str);
tb_edittext.Text=""; tb_edittext.Text = "";
//data //data
SetSelect(datacfg.dicCardRules,cb_cardrule,(long)c.ot); SetSelect(datacfg.dicCardRules, cb_cardrule, (long)c.ot);
SetSelect(datacfg.dicCardAttributes,cb_cardattribute,(long)c.attribute); SetSelect(datacfg.dicCardAttributes, cb_cardattribute, (long)c.attribute);
SetSelect(datacfg.dicCardLevels,cb_cardlevel,(long)(c.level&0xff)); SetSelect(datacfg.dicCardLevels, cb_cardlevel, (long)(c.level & 0xff));
SetSelect(datacfg.dicCardRaces,cb_cardrace,c.race); SetSelect(datacfg.dicCardRaces, cb_cardrace, c.race);
//setcode //setcode
long sc1=c.setcode&0xffff; long sc1 = c.setcode & 0xffff;
long sc2=(c.setcode>>0x10)&0xffff; long sc2 = (c.setcode >> 0x10) & 0xffff;
long sc3=(c.setcode>>0x20)&0xffff; long sc3 = (c.setcode >> 0x20) & 0xffff;
long sc4=(c.setcode>>0x30)&0xffff; long sc4 = (c.setcode >> 0x30) & 0xffff;
tb_setcode1.Text=sc1.ToString("x"); tb_setcode1.Text = sc1.ToString("x");
tb_setcode2.Text=sc2.ToString("x"); tb_setcode2.Text = sc2.ToString("x");
tb_setcode3.Text=sc3.ToString("x"); tb_setcode3.Text = sc3.ToString("x");
tb_setcode4.Text=sc4.ToString("x"); tb_setcode4.Text = sc4.ToString("x");
SetSelect(datacfg.dicSetnames, cb_setname1, sc1); SetSelect(datacfg.dicSetnames, cb_setname1, sc1);
SetSelect(datacfg.dicSetnames, cb_setname2, sc2); SetSelect(datacfg.dicSetnames, cb_setname2, sc2);
SetSelect(datacfg.dicSetnames, cb_setname3, sc3); SetSelect(datacfg.dicSetnames, cb_setname3, sc3);
SetSelect(datacfg.dicSetnames, cb_setname4, sc4); SetSelect(datacfg.dicSetnames, cb_setname4, sc4);
//type,category //type,category
SetCheck(pl_cardtype,c.type); SetCheck(pl_cardtype, c.type);
SetCheck(pl_category,c.category); SetCheck(pl_category, c.category);
//text //text
tb_pleft.Text=((c.level >> 0x18) & 0xff).ToString(); tb_pleft.Text = ((c.level >> 0x18) & 0xff).ToString();
tb_pright.Text=((c.level >> 0x10) & 0xff).ToString(); tb_pright.Text = ((c.level >> 0x10) & 0xff).ToString();
tb_atk.Text=(c.atk<0)?"?":c.atk.ToString(); tb_atk.Text = (c.atk < 0) ? "?" : c.atk.ToString();
tb_def.Text=(c.def<0)?"?":c.def.ToString(); tb_def.Text = (c.def < 0) ? "?" : c.def.ToString();
tb_cardcode.Text=c.id.ToString(); tb_cardcode.Text = c.id.ToString();
tb_cardalias.Text=c.alias.ToString(); tb_cardalias.Text = c.alias.ToString();
setImage(c.id.ToString()); setImage(c.id.ToString());
} }
#endregion #endregion
...@@ -493,47 +514,47 @@ void SetCard(Card c) ...@@ -493,47 +514,47 @@ void SetCard(Card c)
Card GetCard() Card GetCard()
{ {
int temp; int temp;
Card c=new Card(0); Card c = new Card(0);
c.name=tb_cardname.Text; c.name = tb_cardname.Text;
c.desc=tb_cardtext.Text; c.desc = tb_cardtext.Text;
Array.Copy(strs,c.str, c.str.Length); Array.Copy(strs, c.str, c.str.Length);
int.TryParse(GetSelect(datacfg.dicCardRules,cb_cardrule),out c.ot); int.TryParse(GetSelect(datacfg.dicCardRules, cb_cardrule), out c.ot);
int.TryParse(GetSelect(datacfg.dicCardAttributes,cb_cardattribute),out c.attribute); int.TryParse(GetSelect(datacfg.dicCardAttributes, cb_cardattribute), out c.attribute);
long.TryParse(GetSelect(datacfg.dicCardLevels,cb_cardlevel),out c.level); long.TryParse(GetSelect(datacfg.dicCardLevels, cb_cardlevel), out c.level);
long.TryParse(GetSelect(datacfg.dicCardRaces,cb_cardrace),out c.race); long.TryParse(GetSelect(datacfg.dicCardRaces, cb_cardrace), out c.race);
//setcode //setcode
int.TryParse(tb_setcode1.Text, NumberStyles.HexNumber,null,out temp); int.TryParse(tb_setcode1.Text, NumberStyles.HexNumber, null, out temp);
c.setcode =temp; c.setcode = temp;
int.TryParse(tb_setcode2.Text, NumberStyles.HexNumber,null,out temp); int.TryParse(tb_setcode2.Text, NumberStyles.HexNumber, null, out temp);
c.setcode +=((long)temp<<0x10); c.setcode += ((long)temp << 0x10);
int.TryParse(tb_setcode3.Text, NumberStyles.HexNumber,null,out temp); int.TryParse(tb_setcode3.Text, NumberStyles.HexNumber, null, out temp);
c.setcode +=((long)temp<<0x20); c.setcode += ((long)temp << 0x20);
int.TryParse(tb_setcode4.Text, NumberStyles.HexNumber,null,out temp); int.TryParse(tb_setcode4.Text, NumberStyles.HexNumber, null, out temp);
c.setcode +=((long)temp<<0x30); c.setcode += ((long)temp << 0x30);
//c.setcode = getSetcodeByText(); //c.setcode = getSetcodeByText();
c.type=GetCheck(pl_cardtype); c.type = GetCheck(pl_cardtype);
c.category=GetCheck(pl_category); c.category = GetCheck(pl_category);
int.TryParse(tb_pleft.Text,out temp); int.TryParse(tb_pleft.Text, out temp);
c.level+=(temp << 0x18); c.level += (temp << 0x18);
int.TryParse(tb_pright.Text,out temp); int.TryParse(tb_pright.Text, out temp);
c.level+=(temp << 0x10); c.level += (temp << 0x10);
if(tb_atk.Text=="?"||tb_atk.Text=="?") if (tb_atk.Text == "?" || tb_atk.Text == "?")
c.atk=-2; c.atk = -2;
else if(tb_atk.Text==".") else if (tb_atk.Text == ".")
c.atk=-1; c.atk = -1;
else else
int.TryParse( tb_atk.Text,out c.atk); int.TryParse(tb_atk.Text, out c.atk);
if(tb_def.Text=="?"||tb_def.Text=="?") if (tb_def.Text == "?" || tb_def.Text == "?")
c.def=-2; c.def = -2;
else if(tb_def.Text==".") else if (tb_def.Text == ".")
c.def=-1; c.def = -1;
else else
int.TryParse( tb_def.Text,out c.def); int.TryParse(tb_def.Text, out c.def);
long.TryParse( tb_cardcode.Text,out c.id); long.TryParse(tb_cardcode.Text, out c.id);
long.TryParse( tb_cardalias.Text,out c.alias); long.TryParse(tb_cardalias.Text, out c.alias);
return c; return c;
} }
...@@ -543,13 +564,13 @@ Card GetCard() ...@@ -543,13 +564,13 @@ Card GetCard()
//列表选择 //列表选择
void Lv_cardlistSelectedIndexChanged(object sender, EventArgs e) void Lv_cardlistSelectedIndexChanged(object sender, EventArgs e)
{ {
if(lv_cardlist.SelectedItems.Count>0) if (lv_cardlist.SelectedItems.Count > 0)
{ {
int sel=lv_cardlist.SelectedItems[0].Index; int sel = lv_cardlist.SelectedItems[0].Index;
int index=(page-1)*MaxRow+sel; int index = (page - 1) * MaxRow + sel;
if(index<cardlist.Count) if (index < cardlist.Count)
{ {
Card c=cardlist[index]; Card c = cardlist[index];
SetCard(c); SetCard(c);
} }
} }
...@@ -557,17 +578,17 @@ void Lv_cardlistSelectedIndexChanged(object sender, EventArgs e) ...@@ -557,17 +578,17 @@ void Lv_cardlistSelectedIndexChanged(object sender, EventArgs e)
//列表按键 //列表按键
void Lv_cardlistKeyDown(object sender, KeyEventArgs e) void Lv_cardlistKeyDown(object sender, KeyEventArgs e)
{ {
switch(e.KeyCode) switch (e.KeyCode)
{ {
case Keys.Delete:DelCards();break; case Keys.Delete: DelCards(); break;
case Keys.Right:Btn_PageDownClick(null,null);break; case Keys.Right: Btn_PageDownClick(null, null); break;
case Keys.Left:Btn_PageUpClick(null,null);break; case Keys.Left: Btn_PageUpClick(null, null); break;
} }
} }
//上一页 //上一页
void Btn_PageUpClick(object sender, EventArgs e) void Btn_PageUpClick(object sender, EventArgs e)
{ {
if(!Check()) if (!Check())
return; return;
page--; page--;
AddListView(page); AddListView(page);
...@@ -575,7 +596,7 @@ void Btn_PageUpClick(object sender, EventArgs e) ...@@ -575,7 +596,7 @@ void Btn_PageUpClick(object sender, EventArgs e)
//下一页 //下一页
void Btn_PageDownClick(object sender, EventArgs e) void Btn_PageDownClick(object sender, EventArgs e)
{ {
if(!Check()) if (!Check())
return; return;
page++; page++;
AddListView(page); AddListView(page);
...@@ -583,11 +604,11 @@ void Btn_PageDownClick(object sender, EventArgs e) ...@@ -583,11 +604,11 @@ void Btn_PageDownClick(object sender, EventArgs e)
//跳转到指定页数 //跳转到指定页数
void Tb_pageKeyPress(object sender, KeyPressEventArgs e) void Tb_pageKeyPress(object sender, KeyPressEventArgs e)
{ {
if(e.KeyChar==(char)Keys.Enter) if (e.KeyChar == (char)Keys.Enter)
{ {
int p; int p;
int.TryParse(tb_page.Text,out p); int.TryParse(tb_page.Text, out p);
if(p>0) if (p > 0)
AddListView(p); AddListView(p);
} }
} }
...@@ -597,9 +618,9 @@ void Tb_pageKeyPress(object sender, KeyPressEventArgs e) ...@@ -597,9 +618,9 @@ void Tb_pageKeyPress(object sender, KeyPressEventArgs e)
//检查是否打开数据库 //检查是否打开数据库
public bool Check() public bool Check()
{ {
if(datacfg == null) if (datacfg == null)
return false; return false;
if(File.Exists(nowCdbFile)) if (File.Exists(nowCdbFile))
return true; return true;
else else
{ {
...@@ -608,10 +629,10 @@ public bool Check() ...@@ -608,10 +629,10 @@ public bool Check()
} }
} }
//打开数据库 //打开数据库
public bool Open(string cdbFile) public bool Open(string file)
{ {
SetCDB(cdbFile); SetCDB(file);
if(!File.Exists(cdbFile)) if (!File.Exists(file))
{ {
MyMsg.Error(LMSG.FileIsNotExists); MyMsg.Error(LMSG.FileIsNotExists);
return false; return false;
...@@ -620,44 +641,45 @@ public bool Open(string cdbFile) ...@@ -620,44 +641,45 @@ public bool Open(string cdbFile)
tmpCodes.Clear(); tmpCodes.Clear();
cardlist.Clear(); cardlist.Clear();
//检查表是否存在 //检查表是否存在
DataBase.CheckTable(cdbFile); DataBase.CheckTable(file);
srcCard=new Card(); srcCard = new Card();
SetCards(DataBase.Read(cdbFile,true,""),false); SetCards(DataBase.Read(file, true, ""), false);
return true; return true;
} }
//设置卡片组 //设置卡片组
public void SetCards(Card[] cards, bool isfresh) public void SetCards(Card[] cards, bool isfresh)
{ {
if(cards!=null) if (cards != null)
{ {
cardlist.Clear(); cardlist.Clear();
foreach(Card c in cards){ foreach (Card c in cards)
if(srcCard.setcode==0) {
if (srcCard.setcode == 0)
cardlist.Add(c); cardlist.Add(c);
else if(c.IsSetCode(srcCard.setcode&0xffff)) else if (c.IsSetCode(srcCard.setcode & 0xffff))
cardlist.Add(c); cardlist.Add(c);
} }
cardcount=cardlist.Count; cardcount = cardlist.Count;
pageNum=cardcount/MaxRow; pageNum = cardcount / MaxRow;
if(cardcount%MaxRow > 0) if (cardcount % MaxRow > 0)
pageNum++; pageNum++;
else if(cardcount==0) else if (cardcount == 0)
pageNum=1; pageNum = 1;
tb_pagenum.Text=pageNum.ToString(); tb_pagenum.Text = pageNum.ToString();
if(isfresh) if (isfresh)
AddListView(page); AddListView(page);
else else
AddListView(1); AddListView(1);
} }
else else
{ {
cardcount=0; cardcount = 0;
page=1; page = 1;
pageNum=1; pageNum = 1;
tb_page.Text=page.ToString(); tb_page.Text = page.ToString();
tb_pagenum.Text=pageNum.ToString(); tb_pagenum.Text = pageNum.ToString();
cardlist.Clear(); cardlist.Clear();
lv_cardlist.Items.Clear(); lv_cardlist.Items.Clear();
SetCard(new Card(0)); SetCard(new Card(0));
...@@ -666,27 +688,28 @@ public void SetCards(Card[] cards, bool isfresh) ...@@ -666,27 +688,28 @@ public void SetCards(Card[] cards, bool isfresh)
//搜索卡片 //搜索卡片
public void Search(Card c, bool isfresh) public void Search(Card c, bool isfresh)
{ {
if(!Check()) if (!Check())
return; return;
if (tmpCodes.Count>0) if (tmpCodes.Count > 0)
{ {
Card[] mcards = DataBase.Read(nowCdbFile, Card[] mcards = DataBase.Read(nowCdbFile,
true, tmpCodes.ToArray()); true, tmpCodes.ToArray());
SetCards(getCompCards(), true); SetCards(getCompCards(), true);
} }
else{ else
srcCard=c; {
string sql=DataBase.GetSelectSQL(c); srcCard = c;
#if DEBUG string sql = DataBase.GetSelectSQL(c);
#if DEBUG
MyMsg.Show(sql); MyMsg.Show(sql);
#endif #endif
SetCards(DataBase.Read(nowCdbFile, true, sql),isfresh); SetCards(DataBase.Read(nowCdbFile, true, sql), isfresh);
} }
} }
//更新临时卡片 //更新临时卡片
public void Reset() public void Reset()
{ {
oldCard=new Card(0); oldCard = new Card(0);
SetCard(oldCard); SetCard(oldCard);
} }
#endregion #endregion
...@@ -695,26 +718,26 @@ public void Reset() ...@@ -695,26 +718,26 @@ public void Reset()
//添加 //添加
public bool AddCard() public bool AddCard()
{ {
if(!Check()) if (!Check())
return false; return false;
Card c=GetCard(); Card c = GetCard();
if(c.id<=0) if (c.id <= 0)
{ {
MyMsg.Error(LMSG.CodeCanNotIsZero); MyMsg.Error(LMSG.CodeCanNotIsZero);
return false; return false;
} }
foreach(Card ckey in cardlist) foreach (Card ckey in cardlist)
{ {
if(c.id==ckey.id) if (c.id == ckey.id)
{ {
MyMsg.Warning(LMSG.ItIsExists); MyMsg.Warning(LMSG.ItIsExists);
return false; return false;
} }
} }
if(DataBase.Command(nowCdbFile, DataBase.GetInsertSQL(c,true))>=2) if (DataBase.Command(nowCdbFile, DataBase.GetInsertSQL(c, true)) >= 2)
{ {
MyMsg.Show(LMSG.AddSucceed); MyMsg.Show(LMSG.AddSucceed);
undoString=DataBase.GetDeleteSQL(c); undoString = DataBase.GetDeleteSQL(c);
Search(srcCard, true); Search(srcCard, true);
return true; return true;
} }
...@@ -724,40 +747,40 @@ public bool AddCard() ...@@ -724,40 +747,40 @@ public bool AddCard()
//修改 //修改
public bool ModCard() public bool ModCard()
{ {
if(!Check()) if (!Check())
return false; return false;
Card c=GetCard(); Card c = GetCard();
if(c.Equals(oldCard)) if (c.Equals(oldCard))
{ {
MyMsg.Show(LMSG.ItIsNotChanged); MyMsg.Show(LMSG.ItIsNotChanged);
return false; return false;
} }
if(c.id<=0) if (c.id <= 0)
{ {
MyMsg.Error(LMSG.CodeCanNotIsZero); MyMsg.Error(LMSG.CodeCanNotIsZero);
return false; return false;
} }
string sql; string sql;
if(c.id!=oldCard.id) if (c.id != oldCard.id)
{ {
if(MyMsg.Question(LMSG.IfDeleteCard)) if (MyMsg.Question(LMSG.IfDeleteCard))
{ {
if(DataBase.Command(nowCdbFile, DataBase.GetDeleteSQL(oldCard))<2) if (DataBase.Command(nowCdbFile, DataBase.GetDeleteSQL(oldCard)) < 2)
{ {
MyMsg.Error(LMSG.DeleteFail); MyMsg.Error(LMSG.DeleteFail);
return false; return false;
} }
} }
sql=DataBase.GetInsertSQL(c,false); sql = DataBase.GetInsertSQL(c, false);
} }
else else
sql=DataBase.GetUpdateSQL(c); sql = DataBase.GetUpdateSQL(c);
if(DataBase.Command(nowCdbFile, sql)>0) if (DataBase.Command(nowCdbFile, sql) > 0)
{ {
MyMsg.Show(LMSG.ModifySucceed); MyMsg.Show(LMSG.ModifySucceed);
undoString=DataBase.GetDeleteSQL(c); undoString = DataBase.GetDeleteSQL(c);
undoString+=DataBase.GetInsertSQL(oldCard,false); undoString += DataBase.GetInsertSQL(oldCard, false);
Search(srcCard, true); Search(srcCard, true);
SetCard(c); SetCard(c);
} }
...@@ -768,25 +791,25 @@ public bool ModCard() ...@@ -768,25 +791,25 @@ public bool ModCard()
//删除 //删除
public bool DelCards() public bool DelCards()
{ {
if(!Check()) if (!Check())
return false; return false;
int ic=lv_cardlist.SelectedItems.Count; int ic = lv_cardlist.SelectedItems.Count;
if(ic==0) if (ic == 0)
return false; return false;
if(!MyMsg.Question(LMSG.IfDeleteCard)) if (!MyMsg.Question(LMSG.IfDeleteCard))
return false; return false;
List<string> sql=new List<string>(); List<string> sql = new List<string>();
foreach(ListViewItem lvitem in lv_cardlist.SelectedItems) foreach (ListViewItem lvitem in lv_cardlist.SelectedItems)
{ {
int index=lvitem.Index+(page-1)*MaxRow; int index = lvitem.Index + (page - 1) * MaxRow;
if(index<cardlist.Count) if (index < cardlist.Count)
{ {
Card c=cardlist[index]; Card c = cardlist[index];
undoString+=DataBase.GetInsertSQL(c, true); undoString += DataBase.GetInsertSQL(c, true);
sql.Add(DataBase.GetDeleteSQL(c)); sql.Add(DataBase.GetDeleteSQL(c));
} }
} }
if(DataBase.Command(nowCdbFile, sql.ToArray())>=(sql.Count*2)) if (DataBase.Command(nowCdbFile, sql.ToArray()) >= (sql.Count * 2))
{ {
MyMsg.Show(LMSG.DeleteSucceed); MyMsg.Show(LMSG.DeleteSucceed);
Search(srcCard, true); Search(srcCard, true);
...@@ -803,30 +826,30 @@ public bool DelCards() ...@@ -803,30 +826,30 @@ public bool DelCards()
//打开脚本 //打开脚本
public bool OpenScript() public bool OpenScript()
{ {
if(!Check()) if (!Check())
return false; return false;
string lua=MyPath.Combine(LUAPTH,"c"+tb_cardcode.Text+".lua"); string lua = MyPath.Combine(LUAPTH, "c" + tb_cardcode.Text + ".lua");
if(!File.Exists(lua)) if (!File.Exists(lua))
{ {
if(! Directory.Exists(LUAPTH)) if (!Directory.Exists(LUAPTH))
Directory.CreateDirectory(LUAPTH); Directory.CreateDirectory(LUAPTH);
if(MyMsg.Question(LMSG.IfCreateScript)) if (MyMsg.Question(LMSG.IfCreateScript))
{ {
if(!Directory.Exists(LUAPTH)) if (!Directory.Exists(LUAPTH))
Directory.CreateDirectory(LUAPTH); Directory.CreateDirectory(LUAPTH);
using(FileStream fs=new FileStream( using (FileStream fs = new FileStream(
lua, lua,
FileMode.OpenOrCreate, FileMode.OpenOrCreate,
FileAccess.Write)) FileAccess.Write))
{ {
StreamWriter sw=new StreamWriter(fs,new UTF8Encoding(false)); StreamWriter sw = new StreamWriter(fs, new UTF8Encoding(false));
sw.WriteLine("--"+tb_cardname.Text); sw.WriteLine("--" + tb_cardname.Text);
sw.Close(); sw.Close();
fs.Close(); fs.Close();
} }
} }
} }
if(File.Exists(lua)) if (File.Exists(lua))
{ {
System.Diagnostics.Process.Start(lua); System.Diagnostics.Process.Start(lua);
} }
...@@ -835,11 +858,11 @@ public bool OpenScript() ...@@ -835,11 +858,11 @@ public bool OpenScript()
//撤销 //撤销
public void Undo() public void Undo()
{ {
if(string.IsNullOrEmpty(undoString)) if (string.IsNullOrEmpty(undoString))
{ {
return; return;
} }
DataBase.Command(nowCdbFile,undoString); DataBase.Command(nowCdbFile, undoString);
Search(srcCard, true); Search(srcCard, true);
} }
...@@ -883,14 +906,14 @@ void Btn_undoClick(object sender, EventArgs e) ...@@ -883,14 +906,14 @@ void Btn_undoClick(object sender, EventArgs e)
} }
void Btn_imgClick(object sender, EventArgs e) void Btn_imgClick(object sender, EventArgs e)
{ {
string tid=tb_cardcode.Text; string tid = tb_cardcode.Text;
if(tid=="0" || tid.Length==0) if (tid == "0" || tid.Length == 0)
return; return;
using(OpenFileDialog dlg=new OpenFileDialog()) using (OpenFileDialog dlg = new OpenFileDialog())
{ {
dlg.Title=LANG.GetMsg(LMSG.SelectImage)+"-"+tb_cardname.Text; dlg.Title = LANG.GetMsg(LMSG.SelectImage) + "-" + tb_cardname.Text;
dlg.Filter=LANG.GetMsg(LMSG.ImageType); dlg.Filter = LANG.GetMsg(LMSG.ImageType);
if(dlg.ShowDialog()==DialogResult.OK) if (dlg.ShowDialog() == DialogResult.OK)
{ {
//dlg.FileName; //dlg.FileName;
ImportImage(dlg.FileName, tid); ImportImage(dlg.FileName, tid);
...@@ -903,11 +926,11 @@ void Btn_imgClick(object sender, EventArgs e) ...@@ -903,11 +926,11 @@ void Btn_imgClick(object sender, EventArgs e)
//卡片密码搜索 //卡片密码搜索
void Tb_cardcodeKeyPress(object sender, KeyPressEventArgs e) void Tb_cardcodeKeyPress(object sender, KeyPressEventArgs e)
{ {
if(e.KeyChar==(char)Keys.Enter) if (e.KeyChar == (char)Keys.Enter)
{ {
Card c=new Card(0); Card c = new Card(0);
long.TryParse(tb_cardcode.Text, out c.id); long.TryParse(tb_cardcode.Text, out c.id);
if(c.id>0) if (c.id > 0)
{ {
tmpCodes.Clear(); tmpCodes.Clear();
Search(c, false); Search(c, false);
...@@ -917,11 +940,12 @@ void Tb_cardcodeKeyPress(object sender, KeyPressEventArgs e) ...@@ -917,11 +940,12 @@ void Tb_cardcodeKeyPress(object sender, KeyPressEventArgs e)
//卡片名称搜索、编辑 //卡片名称搜索、编辑
void Tb_cardnameKeyDown(object sender, KeyEventArgs e) void Tb_cardnameKeyDown(object sender, KeyEventArgs e)
{ {
if(e.KeyCode==Keys.Enter) if (e.KeyCode == Keys.Enter)
{
Card c = new Card(0);
c.name = tb_cardname.Text;
if (c.name.Length > 0)
{ {
Card c=new Card(0);
c.name=tb_cardname.Text;
if(c.name.Length>0){
tmpCodes.Clear(); tmpCodes.Clear();
Search(c, false); Search(c, false);
} }
...@@ -930,35 +954,39 @@ void Tb_cardnameKeyDown(object sender, KeyEventArgs e) ...@@ -930,35 +954,39 @@ void Tb_cardnameKeyDown(object sender, KeyEventArgs e)
//卡片描述编辑 //卡片描述编辑
void Setscripttext(string str) void Setscripttext(string str)
{ {
int index=-1; int index = -1;
try{ try
index=lb_scripttext.SelectedIndex; {
index = lb_scripttext.SelectedIndex;
} }
catch{ catch
index=-1; {
index = -1;
MyMsg.Error(LMSG.NotSelectScriptText); MyMsg.Error(LMSG.NotSelectScriptText);
} }
if(index>=0) if (index >= 0)
{ {
strs[index]=str; strs[index] = str;
lb_scripttext.Items.Clear(); lb_scripttext.Items.Clear();
lb_scripttext.Items.AddRange(strs); lb_scripttext.Items.AddRange(strs);
lb_scripttext.SelectedIndex=index; lb_scripttext.SelectedIndex = index;
} }
} }
string Getscripttext() string Getscripttext()
{ {
int index=-1; int index = -1;
try{ try
index=lb_scripttext.SelectedIndex; {
index = lb_scripttext.SelectedIndex;
} }
catch{ catch
index=-1; {
index = -1;
MyMsg.Error(LMSG.NotSelectScriptText); MyMsg.Error(LMSG.NotSelectScriptText);
} }
if(index>=0) if (index >= 0)
return strs[index]; return strs[index];
else else
return ""; return "";
...@@ -966,7 +994,7 @@ string Getscripttext() ...@@ -966,7 +994,7 @@ string Getscripttext()
//脚本文本 //脚本文本
void Lb_scripttextSelectedIndexChanged(object sender, EventArgs e) void Lb_scripttextSelectedIndexChanged(object sender, EventArgs e)
{ {
tb_edittext.Text=Getscripttext(); tb_edittext.Text = Getscripttext();
} }
//脚本文本 //脚本文本
...@@ -980,8 +1008,8 @@ void Tb_edittextTextChanged(object sender, EventArgs e) ...@@ -980,8 +1008,8 @@ void Tb_edittextTextChanged(object sender, EventArgs e)
void Menuitem_aboutClick(object sender, EventArgs e) void Menuitem_aboutClick(object sender, EventArgs e)
{ {
MyMsg.Show( MyMsg.Show(
LANG.GetMsg(LMSG.About)+"\t"+Application.ProductName+"\n" LANG.GetMsg(LMSG.About) + "\t" + Application.ProductName + "\n"
+LANG.GetMsg(LMSG.Version)+"\t"+Application.ProductVersion+"\n" + LANG.GetMsg(LMSG.Version) + "\t" + Application.ProductVersion + "\n"
+ LANG.GetMsg(LMSG.Author) + "\t柯永裕\n" + LANG.GetMsg(LMSG.Author) + "\t柯永裕\n"
+ "Email:\t247321453@qq.com"); + "Email:\t247321453@qq.com");
} }
...@@ -992,21 +1020,23 @@ void Menuitem_checkupdateClick(object sender, EventArgs e) ...@@ -992,21 +1020,23 @@ void Menuitem_checkupdateClick(object sender, EventArgs e)
} }
public void CheckUpdate(bool showNew) public void CheckUpdate(bool showNew)
{ {
if(!isRun()) if (!isRun())
{ {
tasker.SetTask(MyTask.CheckUpdate,null,showNew.ToString()); tasker.SetTask(MyTask.CheckUpdate, null, showNew.ToString());
Run(LANG.GetMsg(LMSG.checkUpdate)); Run(LANG.GetMsg(LMSG.checkUpdate));
} }
} }
bool CancelTask() bool CancelTask()
{ {
bool bl=false; bool bl = false;
if(tasker !=null && tasker.IsRuning()){ if (tasker != null && tasker.IsRuning())
bl=MyMsg.Question(LMSG.IfCancelTask); {
if(bl){ bl = MyMsg.Question(LMSG.IfCancelTask);
if(tasker!=null) if (bl)
{
if (tasker != null)
tasker.Cancel(); tasker.Cancel();
if(bgWorker1.IsBusy) if (bgWorker1.IsBusy)
bgWorker1.CancelAsync(); bgWorker1.CancelAsync();
} }
} }
...@@ -1018,18 +1048,18 @@ void Menuitem_cancelTaskClick(object sender, EventArgs e) ...@@ -1018,18 +1048,18 @@ void Menuitem_cancelTaskClick(object sender, EventArgs e)
} }
void Menuitem_githubClick(object sender, EventArgs e) void Menuitem_githubClick(object sender, EventArgs e)
{ {
System.Diagnostics.Process.Start(ConfigurationManager.AppSettings["sourceURL"]); System.Diagnostics.Process.Start(MyConfig.readString(MyConfig.TAG_SOURCE_URL));
} }
#endregion #endregion
#region 文件菜单 #region 文件菜单
void Menuitem_openClick(object sender, EventArgs e) void Menuitem_openClick(object sender, EventArgs e)
{ {
using(OpenFileDialog dlg=new OpenFileDialog()) using (OpenFileDialog dlg = new OpenFileDialog())
{ {
dlg.Title=LANG.GetMsg(LMSG.SelectDataBasePath); dlg.Title = LANG.GetMsg(LMSG.SelectDataBasePath);
dlg.Filter=LANG.GetMsg(LMSG.CdbType); dlg.Filter = LANG.GetMsg(LMSG.CdbType);
if(dlg.ShowDialog()==DialogResult.OK) if (dlg.ShowDialog() == DialogResult.OK)
{ {
Open(dlg.FileName); Open(dlg.FileName);
} }
...@@ -1037,15 +1067,15 @@ void Menuitem_openClick(object sender, EventArgs e) ...@@ -1037,15 +1067,15 @@ void Menuitem_openClick(object sender, EventArgs e)
} }
void Menuitem_newClick(object sender, EventArgs e) void Menuitem_newClick(object sender, EventArgs e)
{ {
using(SaveFileDialog dlg=new SaveFileDialog()) using (SaveFileDialog dlg = new SaveFileDialog())
{ {
dlg.Title=LANG.GetMsg(LMSG.SelectDataBasePath); dlg.Title = LANG.GetMsg(LMSG.SelectDataBasePath);
dlg.Filter=LANG.GetMsg(LMSG.CdbType); dlg.Filter = LANG.GetMsg(LMSG.CdbType);
if(dlg.ShowDialog()==DialogResult.OK) if (dlg.ShowDialog() == DialogResult.OK)
{ {
if(DataBase.Create(dlg.FileName)) if (DataBase.Create(dlg.FileName))
{ {
if(MyMsg.Question(LMSG.IfOpenDataBase)) if (MyMsg.Question(LMSG.IfOpenDataBase))
Open(dlg.FileName); Open(dlg.FileName);
} }
} }
...@@ -1054,13 +1084,13 @@ void Menuitem_newClick(object sender, EventArgs e) ...@@ -1054,13 +1084,13 @@ void Menuitem_newClick(object sender, EventArgs e)
void Menuitem_readydkClick(object sender, EventArgs e) void Menuitem_readydkClick(object sender, EventArgs e)
{ {
if(!Check()) if (!Check())
return; return;
using(OpenFileDialog dlg=new OpenFileDialog()) using (OpenFileDialog dlg = new OpenFileDialog())
{ {
dlg.Title=LANG.GetMsg(LMSG.SelectYdkPath); dlg.Title = LANG.GetMsg(LMSG.SelectYdkPath);
dlg.Filter=LANG.GetMsg(LMSG.ydkType); dlg.Filter = LANG.GetMsg(LMSG.ydkType);
if(dlg.ShowDialog()==DialogResult.OK) if (dlg.ShowDialog() == DialogResult.OK)
{ {
tmpCodes.Clear(); tmpCodes.Clear();
string[] ids = YGOUtil.ReadYDK(dlg.FileName); string[] ids = YGOUtil.ReadYDK(dlg.FileName);
...@@ -1073,12 +1103,12 @@ void Menuitem_readydkClick(object sender, EventArgs e) ...@@ -1073,12 +1103,12 @@ void Menuitem_readydkClick(object sender, EventArgs e)
void Menuitem_readimagesClick(object sender, EventArgs e) void Menuitem_readimagesClick(object sender, EventArgs e)
{ {
if(!Check()) if (!Check())
return; return;
using(FolderBrowserDialog fdlg=new FolderBrowserDialog()) using (FolderBrowserDialog fdlg = new FolderBrowserDialog())
{ {
fdlg.Description= LANG.GetMsg(LMSG.SelectImagePath); fdlg.Description = LANG.GetMsg(LMSG.SelectImagePath);
if(fdlg.ShowDialog()==DialogResult.OK) if (fdlg.ShowDialog() == DialogResult.OK)
{ {
tmpCodes.Clear(); tmpCodes.Clear();
string[] ids = YGOUtil.ReadImage(fdlg.SelectedPath); string[] ids = YGOUtil.ReadImage(fdlg.SelectedPath);
...@@ -1096,19 +1126,22 @@ void Menuitem_quitClick(object sender, EventArgs e) ...@@ -1096,19 +1126,22 @@ void Menuitem_quitClick(object sender, EventArgs e)
#endregion #endregion
#region 线程 #region 线程
bool isRun(){ bool isRun()
if(tasker !=null && tasker.IsRuning()){ {
if (tasker != null && tasker.IsRuning())
{
MyMsg.Warning(LMSG.RunError); MyMsg.Warning(LMSG.RunError);
return true; return true;
} }
return false; return false;
} }
void Run(string name){ void Run(string name)
if(isRun()) {
if (isRun())
return; return;
taskname=name; taskname = name;
title=title+" ("+taskname+")"; title = title + " (" + taskname + ")";
SetTitle(); SetTitle();
bgWorker1.RunWorkerAsync(); bgWorker1.RunWorkerAsync();
} }
...@@ -1119,7 +1152,7 @@ void BgWorker1DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) ...@@ -1119,7 +1152,7 @@ void BgWorker1DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
} }
void BgWorker1ProgressChanged(object sender, System.ComponentModel.ProgressChangedEventArgs e) void BgWorker1ProgressChanged(object sender, System.ComponentModel.ProgressChangedEventArgs e)
{ {
title=string.Format("{0} ({1}-{2})", title = string.Format("{0} ({1}-{2})",
RemoveTag(title), RemoveTag(title),
taskname, taskname,
// e.ProgressPercentage, // e.ProgressPercentage,
...@@ -1130,23 +1163,26 @@ void BgWorker1ProgressChanged(object sender, System.ComponentModel.ProgressChang ...@@ -1130,23 +1163,26 @@ void BgWorker1ProgressChanged(object sender, System.ComponentModel.ProgressChang
void BgWorker1RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e) void BgWorker1RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
{ {
// //
int t=title.LastIndexOf(" ("); int t = title.LastIndexOf(" (");
if(t>0) if (t > 0)
{ {
title=title.Substring(0,t); title = title.Substring(0, t);
SetTitle(); SetTitle();
} }
if ( e.Error != null){ if (e.Error != null)
{
MyMsg.Show(LANG.GetMsg(LMSG.TaskError)+"\n"+e.Error); MyMsg.Show(LANG.GetMsg(LMSG.TaskError) + "\n" + e.Error);
} }
else if(tasker.IsCancel() || e.Cancelled){ else if (tasker.IsCancel() || e.Cancelled)
{
MyMsg.Show(LMSG.CancelTask); MyMsg.Show(LMSG.CancelTask);
} }
else else
{ {
MyTask mt=tasker.getLastTask(); MyTask mt = tasker.getLastTask();
switch(mt){ switch (mt)
{
case MyTask.CheckUpdate: case MyTask.CheckUpdate:
break; break;
case MyTask.ExportData: case MyTask.ExportData:
...@@ -1169,105 +1205,107 @@ void BgWorker1RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerC ...@@ -1169,105 +1205,107 @@ void BgWorker1RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerC
#region setcode #region setcode
void Cb_setname2SelectedIndexChanged(object sender, EventArgs e) void Cb_setname2SelectedIndexChanged(object sender, EventArgs e)
{ {
if(setcodeIsedit[2]) if (setcodeIsedit[2])
return; return;
setcodeIsedit[2]=true; setcodeIsedit[2] = true;
tb_setcode2.Text=GetSelectHex(datacfg.dicSetnames, cb_setname2); tb_setcode2.Text = GetSelectHex(datacfg.dicSetnames, cb_setname2);
setcodeIsedit[2]=false; setcodeIsedit[2] = false;
} }
void Cb_setname1SelectedIndexChanged(object sender, EventArgs e) void Cb_setname1SelectedIndexChanged(object sender, EventArgs e)
{ {
if(setcodeIsedit[1]) if (setcodeIsedit[1])
return; return;
setcodeIsedit[1]=true; setcodeIsedit[1] = true;
tb_setcode1.Text=GetSelectHex(datacfg.dicSetnames, cb_setname1); tb_setcode1.Text = GetSelectHex(datacfg.dicSetnames, cb_setname1);
setcodeIsedit[1]=false; setcodeIsedit[1] = false;
} }
void Cb_setname3SelectedIndexChanged(object sender, EventArgs e) void Cb_setname3SelectedIndexChanged(object sender, EventArgs e)
{ {
if(setcodeIsedit[3]) if (setcodeIsedit[3])
return; return;
setcodeIsedit[3]=true; setcodeIsedit[3] = true;
tb_setcode3.Text=GetSelectHex(datacfg.dicSetnames, cb_setname3); tb_setcode3.Text = GetSelectHex(datacfg.dicSetnames, cb_setname3);
setcodeIsedit[3]=false; setcodeIsedit[3] = false;
} }
void Cb_setname4SelectedIndexChanged(object sender, EventArgs e) void Cb_setname4SelectedIndexChanged(object sender, EventArgs e)
{ {
if(setcodeIsedit[4]) if (setcodeIsedit[4])
return; return;
setcodeIsedit[4]=true; setcodeIsedit[4] = true;
tb_setcode4.Text=GetSelectHex(datacfg.dicSetnames, cb_setname4); tb_setcode4.Text = GetSelectHex(datacfg.dicSetnames, cb_setname4);
setcodeIsedit[4]=false; setcodeIsedit[4] = false;
} }
void Tb_setcode4TextChanged(object sender, EventArgs e) void Tb_setcode4TextChanged(object sender, EventArgs e)
{ {
if(setcodeIsedit[4]) if (setcodeIsedit[4])
return; return;
setcodeIsedit[4]=true; setcodeIsedit[4] = true;
long temp; long temp;
long.TryParse(tb_setcode4.Text,NumberStyles.HexNumber, null ,out temp); long.TryParse(tb_setcode4.Text, NumberStyles.HexNumber, null, out temp);
SetSelect(datacfg.dicSetnames, cb_setname4, temp); SetSelect(datacfg.dicSetnames, cb_setname4, temp);
setcodeIsedit[4]=false; setcodeIsedit[4] = false;
} }
void Tb_setcode3TextChanged(object sender, EventArgs e) void Tb_setcode3TextChanged(object sender, EventArgs e)
{ {
if(setcodeIsedit[3]) if (setcodeIsedit[3])
return; return;
setcodeIsedit[3]=true; setcodeIsedit[3] = true;
long temp; long temp;
long.TryParse(tb_setcode3.Text,NumberStyles.HexNumber, null ,out temp); long.TryParse(tb_setcode3.Text, NumberStyles.HexNumber, null, out temp);
SetSelect(datacfg.dicSetnames, cb_setname3, temp); SetSelect(datacfg.dicSetnames, cb_setname3, temp);
setcodeIsedit[3]=false; setcodeIsedit[3] = false;
} }
void Tb_setcode2TextChanged(object sender, EventArgs e) void Tb_setcode2TextChanged(object sender, EventArgs e)
{ {
if(setcodeIsedit[2]) if (setcodeIsedit[2])
return; return;
setcodeIsedit[2]=true; setcodeIsedit[2] = true;
long temp; long temp;
long.TryParse(tb_setcode2.Text,NumberStyles.HexNumber, null ,out temp); long.TryParse(tb_setcode2.Text, NumberStyles.HexNumber, null, out temp);
SetSelect(datacfg.dicSetnames, cb_setname2, temp); SetSelect(datacfg.dicSetnames, cb_setname2, temp);
setcodeIsedit[2]=false; setcodeIsedit[2] = false;
} }
void Tb_setcode1TextChanged(object sender, EventArgs e) void Tb_setcode1TextChanged(object sender, EventArgs e)
{ {
if(setcodeIsedit[1]) if (setcodeIsedit[1])
return; return;
setcodeIsedit[1]=true; setcodeIsedit[1] = true;
long temp; long temp;
long.TryParse(tb_setcode1.Text,NumberStyles.HexNumber, null ,out temp); long.TryParse(tb_setcode1.Text, NumberStyles.HexNumber, null, out temp);
SetSelect(datacfg.dicSetnames, cb_setname1, temp); SetSelect(datacfg.dicSetnames, cb_setname1, temp);
setcodeIsedit[1]=false; setcodeIsedit[1] = false;
} }
#endregion #endregion
#region 复制卡片 #region 复制卡片
public Card[] getCardList(bool onlyselect){ public Card[] getCardList(bool onlyselect)
if(!Check()) {
if (!Check())
return null; return null;
List<Card> cards=new List<Card>(); List<Card> cards = new List<Card>();
if(onlyselect) if (onlyselect)
{ {
#if DEBUG #if DEBUG
MessageBox.Show("select"); MessageBox.Show("select");
#endif #endif
foreach(ListViewItem lvitem in lv_cardlist.SelectedItems) foreach (ListViewItem lvitem in lv_cardlist.SelectedItems)
{ {
int index=lvitem.Index+(page-1)*MaxRow; int index = lvitem.Index + (page - 1) * MaxRow;
if(index<cardlist.Count) if (index < cardlist.Count)
cards.Add(cardlist[index]); cards.Add(cardlist[index]);
} }
} }
else else
cards.AddRange(cardlist.ToArray()); cards.AddRange(cardlist.ToArray());
if(cards.Count==0){ if (cards.Count == 0)
{
MyMsg.Show(LMSG.NoSelectCard); MyMsg.Show(LMSG.NoSelectCard);
return null; return null;
} }
...@@ -1284,33 +1322,34 @@ void Menuitem_copyselecttoClick(object sender, EventArgs e) ...@@ -1284,33 +1322,34 @@ void Menuitem_copyselecttoClick(object sender, EventArgs e)
} }
public void SaveCards(Card[] cards) public void SaveCards(Card[] cards)
{ {
if(!Check()) if (!Check())
return; return;
bool replace=MyMsg.Question(LMSG.IfReplaceExistingCard); bool replace = MyMsg.Question(LMSG.IfReplaceExistingCard);
DataBase.CopyDB(nowCdbFile, !replace, cards); DataBase.CopyDB(nowCdbFile, !replace, cards);
Search(srcCard, true); Search(srcCard, true);
} }
void CopyTo(bool onlyselect) void CopyTo(bool onlyselect)
{ {
if(!Check()) if (!Check())
return; return;
Card[] cards=getCardList(onlyselect); Card[] cards = getCardList(onlyselect);
if(cards==null) if (cards == null)
return; return;
//select file //select file
bool replace=false; bool replace = false;
string filename=null; string filename = null;
using(OpenFileDialog dlg=new OpenFileDialog()) using (OpenFileDialog dlg = new OpenFileDialog())
{ {
dlg.Title=LANG.GetMsg(LMSG.SelectDataBasePath); dlg.Title = LANG.GetMsg(LMSG.SelectDataBasePath);
dlg.Filter=LANG.GetMsg(LMSG.CdbType); dlg.Filter = LANG.GetMsg(LMSG.CdbType);
if(dlg.ShowDialog()==DialogResult.OK) if (dlg.ShowDialog() == DialogResult.OK)
{ {
filename=dlg.FileName; filename = dlg.FileName;
replace=MyMsg.Question(LMSG.IfReplaceExistingCard); replace = MyMsg.Question(LMSG.IfReplaceExistingCard);
} }
} }
if(!string.IsNullOrEmpty(filename)){ if (!string.IsNullOrEmpty(filename))
{
DataBase.CopyDB(filename, !replace, cards); DataBase.CopyDB(filename, !replace, cards);
MyMsg.Show(LMSG.CopyCardsToDBIsOK); MyMsg.Show(LMSG.CopyCardsToDBIsOK);
} }
...@@ -1321,11 +1360,11 @@ void CopyTo(bool onlyselect) ...@@ -1321,11 +1360,11 @@ void CopyTo(bool onlyselect)
#region MSE存档 #region MSE存档
void Menuitem_cutimagesClick(object sender, EventArgs e) void Menuitem_cutimagesClick(object sender, EventArgs e)
{ {
if(!Check()) if (!Check())
return; return;
if(isRun()) if (isRun())
return; return;
bool isreplace=MyMsg.Question(LMSG.IfReplaceExistingImage); bool isreplace = MyMsg.Question(LMSG.IfReplaceExistingImage);
tasker.SetTask(MyTask.CutImages, cardlist.ToArray(), tasker.SetTask(MyTask.CutImages, cardlist.ToArray(),
PICPATH, isreplace.ToString()); PICPATH, isreplace.ToString());
Run(LANG.GetMsg(LMSG.CutImage)); Run(LANG.GetMsg(LMSG.CutImage));
...@@ -1339,27 +1378,28 @@ void Menuitem_saveasmseClick(object sender, EventArgs e) ...@@ -1339,27 +1378,28 @@ void Menuitem_saveasmseClick(object sender, EventArgs e)
{ {
SaveAsMSE(false); SaveAsMSE(false);
} }
void SaveAsMSE(bool onlyselect){ void SaveAsMSE(bool onlyselect)
if(!Check()) {
if (!Check())
return; return;
if(isRun()) if (isRun())
return; return;
Card[] cards=getCardList(onlyselect); Card[] cards = getCardList(onlyselect);
if(cards==null) if (cards == null)
return; return;
//select save mse-set //select save mse-set
using(SaveFileDialog dlg=new SaveFileDialog()) using (SaveFileDialog dlg = new SaveFileDialog())
{ {
dlg.Title=LANG.GetMsg(LMSG.selectMseset); dlg.Title = LANG.GetMsg(LMSG.selectMseset);
dlg.Filter=LANG.GetMsg(LMSG.MseType); dlg.Filter = LANG.GetMsg(LMSG.MseType);
if(dlg.ShowDialog()==DialogResult.OK) if (dlg.ShowDialog() == DialogResult.OK)
{ {
bool isUpdate=false; bool isUpdate = false;
#if DEBUG #if DEBUG
isUpdate=MyMsg.Question(LMSG.OnlySet); isUpdate=MyMsg.Question(LMSG.OnlySet);
#endif #endif
tasker.SetTask(MyTask.SaveAsMSE,cards, tasker.SetTask(MyTask.SaveAsMSE, cards,
dlg.FileName,isUpdate.ToString()); dlg.FileName, isUpdate.ToString());
Run(LANG.GetMsg(LMSG.SaveMse)); Run(LANG.GetMsg(LMSG.SaveMse));
} }
} }
...@@ -1369,11 +1409,11 @@ void Menuitem_saveasmseClick(object sender, EventArgs e) ...@@ -1369,11 +1409,11 @@ void Menuitem_saveasmseClick(object sender, EventArgs e)
#region 导入卡图 #region 导入卡图
void Pl_imageDragDrop(object sender, DragEventArgs e) void Pl_imageDragDrop(object sender, DragEventArgs e)
{ {
string[] files=e.Data.GetData(DataFormats.FileDrop) as string[]; string[] files = e.Data.GetData(DataFormats.FileDrop) as string[];
#if DEBUG #if DEBUG
MessageBox.Show(files[0]); MessageBox.Show(files[0]);
#endif #endif
if(File.Exists(files[0])) if (File.Exists(files[0]))
ImportImage(files[0], tb_cardcode.Text); ImportImage(files[0], tb_cardcode.Text);
} }
...@@ -1386,11 +1426,11 @@ void Pl_imageDragEnter(object sender, DragEventArgs e) ...@@ -1386,11 +1426,11 @@ void Pl_imageDragEnter(object sender, DragEventArgs e)
} }
void Menuitem_importmseimgClick(object sender, EventArgs e) void Menuitem_importmseimgClick(object sender, EventArgs e)
{ {
string tid=tb_cardcode.Text; string tid = tb_cardcode.Text;
menuitem_importmseimg.Checked=!menuitem_importmseimg.Checked; menuitem_importmseimg.Checked = !menuitem_importmseimg.Checked;
setImage(tid); setImage(tid);
} }
void ImportImage(string file,string tid) void ImportImage(string file, string tid)
{ {
string f; string f;
if (pl_image.BackgroundImage != null if (pl_image.BackgroundImage != null
...@@ -1399,16 +1439,18 @@ void ImportImage(string file,string tid) ...@@ -1399,16 +1439,18 @@ void ImportImage(string file,string tid)
pl_image.BackgroundImage.Dispose(); pl_image.BackgroundImage.Dispose();
pl_image.BackgroundImage = m_cover; pl_image.BackgroundImage = m_cover;
} }
if(menuitem_importmseimg.Checked){ if (menuitem_importmseimg.Checked)
if(!Directory.Exists(tasker.MSEImage)) {
if (!Directory.Exists(tasker.MSEImage))
Directory.CreateDirectory(tasker.MSEImage); Directory.CreateDirectory(tasker.MSEImage);
f=MyPath.Combine(tasker.MSEImage, tid+".jpg"); f = MyPath.Combine(tasker.MSEImage, tid + ".jpg");
File.Copy(file, f, true); File.Copy(file, f, true);
} }
else{ else
f=MyPath.Combine(PICPATH,tid+".jpg"); {
tasker.ToImg(file,f, f = MyPath.Combine(PICPATH, tid + ".jpg");
MyPath.Combine(PICPATH2,tid+".jpg")); tasker.ToImg(file, f,
MyPath.Combine(PICPATH2, tid + ".jpg"));
} }
setImage(tid); setImage(tid);
} }
...@@ -1418,50 +1460,52 @@ void setImage(string id) ...@@ -1418,50 +1460,52 @@ void setImage(string id)
long.TryParse(id, out t); long.TryParse(id, out t);
setImage(t); setImage(t);
} }
void setImage(long id){ void setImage(long id)
if(pl_image.BackgroundImage != null {
&& pl_image.BackgroundImage!=m_cover) if (pl_image.BackgroundImage != null
&& pl_image.BackgroundImage != m_cover)
pl_image.BackgroundImage.Dispose(); pl_image.BackgroundImage.Dispose();
Bitmap temp; Bitmap temp;
string pic=MyPath.Combine(PICPATH, id+".jpg"); string pic = MyPath.Combine(PICPATH, id + ".jpg");
string pic2=MyPath.Combine(tasker.MSEImage, id+".jpg"); string pic2 = MyPath.Combine(tasker.MSEImage, id + ".jpg");
string pic3=MyPath.Combine(tasker.MSEImage, new Card(id).idString+".jpg"); string pic3 = MyPath.Combine(tasker.MSEImage, new Card(id).idString + ".jpg");
if(menuitem_importmseimg.Checked && File.Exists(pic2)) if (menuitem_importmseimg.Checked && File.Exists(pic2))
{ {
temp=new Bitmap(pic2); temp = new Bitmap(pic2);
pl_image.BackgroundImage=temp; pl_image.BackgroundImage = temp;
} }
else if(menuitem_importmseimg.Checked && File.Exists(pic3)) else if (menuitem_importmseimg.Checked && File.Exists(pic3))
{ {
temp=new Bitmap(pic3); temp = new Bitmap(pic3);
pl_image.BackgroundImage=temp; pl_image.BackgroundImage = temp;
} }
else if(File.Exists(pic)){ else if (File.Exists(pic))
temp=new Bitmap(pic); {
pl_image.BackgroundImage=temp; temp = new Bitmap(pic);
pl_image.BackgroundImage = temp;
} }
else else
pl_image.BackgroundImage=m_cover; pl_image.BackgroundImage = m_cover;
} }
void Menuitem_compdbClick(object sender, EventArgs e) void Menuitem_compdbClick(object sender, EventArgs e)
{ {
if(!Check()) if (!Check())
return; return;
DataBase.Compression(nowCdbFile); DataBase.Compression(nowCdbFile);
MyMsg.Show(LMSG.CompDBOK); MyMsg.Show(LMSG.CompDBOK);
} }
void Menuitem_convertimageClick(object sender, EventArgs e) void Menuitem_convertimageClick(object sender, EventArgs e)
{ {
if(!Check()) if (!Check())
return; return;
if(isRun()) if (isRun())
return; return;
using(FolderBrowserDialog fdlg=new FolderBrowserDialog()) using (FolderBrowserDialog fdlg = new FolderBrowserDialog())
{ {
fdlg.Description= LANG.GetMsg(LMSG.SelectImagePath); fdlg.Description = LANG.GetMsg(LMSG.SelectImagePath);
if(fdlg.ShowDialog()==DialogResult.OK) if (fdlg.ShowDialog() == DialogResult.OK)
{ {
bool isreplace=MyMsg.Question(LMSG.IfReplaceExistingImage); bool isreplace = MyMsg.Question(LMSG.IfReplaceExistingImage);
tasker.SetTask(MyTask.ConvertImages, null, tasker.SetTask(MyTask.ConvertImages, null,
fdlg.SelectedPath, GAMEPATH, isreplace.ToString()); fdlg.SelectedPath, GAMEPATH, isreplace.ToString());
Run(LANG.GetMsg(LMSG.ConvertImage)); Run(LANG.GetMsg(LMSG.ConvertImage));
...@@ -1473,14 +1517,14 @@ void Menuitem_convertimageClick(object sender, EventArgs e) ...@@ -1473,14 +1517,14 @@ void Menuitem_convertimageClick(object sender, EventArgs e)
#region 导出数据包 #region 导出数据包
void Menuitem_exportdataClick(object sender, EventArgs e) void Menuitem_exportdataClick(object sender, EventArgs e)
{ {
if(!Check()) if (!Check())
return; return;
if(isRun()) if (isRun())
return; return;
using(SaveFileDialog dlg=new SaveFileDialog()) using (SaveFileDialog dlg = new SaveFileDialog())
{ {
dlg.Filter="Zip|(*.zip|All Files(*.*)|*.*"; dlg.Filter = "Zip|(*.zip|All Files(*.*)|*.*";
if(dlg.ShowDialog()==DialogResult.OK) if (dlg.ShowDialog() == DialogResult.OK)
{ {
tasker.SetTask(MyTask.ExportData, getCardList(false), dlg.FileName); tasker.SetTask(MyTask.ExportData, getCardList(false), dlg.FileName);
Run(LANG.GetMsg(LMSG.ExportData)); Run(LANG.GetMsg(LMSG.ExportData));
...@@ -1497,14 +1541,14 @@ void Menuitem_exportdataClick(object sender, EventArgs e) ...@@ -1497,14 +1541,14 @@ void Menuitem_exportdataClick(object sender, EventArgs e)
/// <param name="cards"></param> /// <param name="cards"></param>
/// <param name="card"></param> /// <param name="card"></param>
/// <returns></returns> /// <returns></returns>
bool CheckCard(Card[] cards,Card card,bool checkinfo) bool CheckCard(Card[] cards, Card card, bool checkinfo)
{ {
foreach(Card c in cards) foreach (Card c in cards)
{ {
if(c.id!=card.id) if (c.id != card.id)
continue; continue;
//data数据不一样 //data数据不一样
if(checkinfo) if (checkinfo)
return card.EqualsData(c); return card.EqualsData(c);
else else
return true; return true;
...@@ -1519,15 +1563,15 @@ Card[] getCompCards() ...@@ -1519,15 +1563,15 @@ Card[] getCompCards()
return null; return null;
return DataBase.Read(nowCdbFile, true, tmpCodes.ToArray()); return DataBase.Read(nowCdbFile, true, tmpCodes.ToArray());
} }
public void CompareCards(string cdbfile,bool checktext) public void CompareCards(string cdbfile, bool checktext)
{ {
if(!Check()) if (!Check())
return; return;
tmpCodes.Clear(); tmpCodes.Clear();
srcCard=new Card(); srcCard = new Card();
Card[] mcards=DataBase.Read(nowCdbFile,true,""); Card[] mcards = DataBase.Read(nowCdbFile, true, "");
Card[] cards=DataBase.Read(cdbfile,true,""); Card[] cards = DataBase.Read(cdbfile, true, "");
foreach(Card card in mcards) foreach (Card card in mcards)
{ {
if (!CheckCard(cards, card, checktext)) if (!CheckCard(cards, card, checktext))
tmpCodes.Add(card.id.ToString()); tmpCodes.Add(card.id.ToString());
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
</Reference> </Reference>
<Reference Include="Microsoft.VisualBasic" /> <Reference Include="Microsoft.VisualBasic" />
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" /> <Reference Include="System.configuration" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Data.SQLite"> <Reference Include="System.Data.SQLite">
<HintPath>DLL\System.Data.SQLite.dll</HintPath> <HintPath>DLL\System.Data.SQLite.dll</HintPath>
...@@ -68,20 +68,21 @@ ...@@ -68,20 +68,21 @@
<DependentUpon>CodeEditForm.cs</DependentUpon> <DependentUpon>CodeEditForm.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Common\CheckUpdate.cs" /> <Compile Include="Common\CheckUpdate.cs" />
<Compile Include="Common\CodeEdit.cs"> <Compile Include="Controls\DoubleContorl.cs">
<SubType>Component</SubType> <SubType>Component</SubType>
</Compile> </Compile>
<Compile Include="Common\DoubleContorl.cs"> <Compile Include="Controls\FastColoredTextBoxEx.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Common\FastColoredTextBoxEx.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
<Compile Include="Common\MyPath.cs" /> <Compile Include="Common\MyPath.cs" />
<Compile Include="Common\MySyntaxHighlighter.cs" /> <Compile Include="Controls\History.cs" />
<Compile Include="Controls\IEditForm.cs" />
<Compile Include="Controls\MySyntaxHighlighter.cs" />
<Compile Include="Common\MyBitmap.cs" /> <Compile Include="Common\MyBitmap.cs" />
<Compile Include="Common\User32.cs" /> <Compile Include="Common\User32.cs" />
<Compile Include="Common\ZipStorer.cs" /> <Compile Include="Common\ZipStorer.cs" />
<Compile Include="Common\Area.cs" />
<Compile Include="Config\Config.cs" />
<Compile Include="Core\Card.cs" /> <Compile Include="Core\Card.cs" />
<Compile Include="Core\CardAttribute.cs" /> <Compile Include="Core\CardAttribute.cs" />
<Compile Include="Core\CardRace.cs" /> <Compile Include="Core\CardRace.cs" />
...@@ -213,13 +214,7 @@ ...@@ -213,13 +214,7 @@
<None Include="chinese\cover.jpg"> <None Include="chinese\cover.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Include="chinese\language-codeeditor.txt"> <None Include="chinese\language.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="chinese\language-dataeditor.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="chinese\language-mainform.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Include="chinese\message.txt"> <None Include="chinese\message.txt">
...@@ -343,5 +338,6 @@ ...@@ -343,5 +338,6 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>
\ No newline at end of file
...@@ -19,244 +19,226 @@ namespace DataEditorX.Language ...@@ -19,244 +19,226 @@ namespace DataEditorX.Language
/// </summary> /// </summary>
public static class LANG public static class LANG
{ {
static Dictionary<string, SortedList<string, string>> wordslist; static SortedList<string, string> mWordslist = new SortedList<string, string>();
static SortedList<LMSG, string> msglist; static SortedList<LMSG, string> msglist = new SortedList<LMSG, string>();
static string SEP="->"; static string SEP_CONTROL = ".";
static string SEP_LINE = " ";
static LANG() #region 获取消息文字
{
wordslist=new Dictionary<string, SortedList<string, string>>();
msglist=new SortedList<LMSG, string>();
}
public static void InitForm(Form fm, string langfile)
{
if(!wordslist.ContainsKey(fm.Name))
{
wordslist.Add(fm.Name, LoadLanguage(langfile));
}
}
/// <summary>
/// 获取消息文字
/// </summary>
/// <param name="lMsg"></param>
/// <returns></returns>
public static string GetMsg(LMSG lMsg) public static string GetMsg(LMSG lMsg)
{ {
if(msglist.IndexOfKey(lMsg)>=0) if (msglist.IndexOfKey(lMsg) >= 0)
return msglist[lMsg]; return msglist[lMsg];
return lMsg.ToString(); else
return lMsg.ToString().Replace("_", " ");
} }
#endregion
#region 设置控件信息 #region 设置控件信息
/// <summary> /// <summary>
/// 设置控件文字 /// 设置控件文字
/// </summary> /// </summary>
/// <param name="fm"></param> /// <param name="fm"></param>
public static bool SetLanguage(Form fm) public static void SetFormLabel(Form fm)
{
if(wordslist.ContainsKey(fm.Name))
{ {
SortedList<string, string> list=wordslist[fm.Name]; if (fm == null)
return;
// fm.SuspendLayout(); // fm.SuspendLayout();
fm.ResumeLayout(true); fm.ResumeLayout(true);
SetText(fm, list); SetControlLabel(fm, "", fm.Name);
fm.ResumeLayout(false); fm.ResumeLayout(false);
//fm.PerformLayout(); //fm.PerformLayout();
}
static bool GetLabel(string key, out string title)
{
string v;
if (mWordslist.TryGetValue(key, out v))
{
title = v;
return true; return true;
} }
title = null;
return false; return false;
} }
static void SetText(Control c, SortedList<string, string> list)
static void SetControlLabel(Control c, string pName, string formName)
{ {
if ( c is ListView ) if (!string.IsNullOrEmpty(pName))
pName += SEP_CONTROL;
pName += c.Name;
string title;
if (c is ListView)
{ {
ListView lv = (ListView)c; ListView lv = (ListView)c;
int i,count=lv.Columns.Count; int i, count = lv.Columns.Count;
for(i=0;i<count;i++) for (i = 0; i < count; i++)
{ {
ColumnHeader cn=lv.Columns[i]; ColumnHeader ch = lv.Columns[i];
string v; if (GetLabel(pName + SEP_CONTROL + i.ToString(), out title))
list.TryGetValue(lv.Name+i.ToString(), out v); ch.Text = title;
if(!string.IsNullOrEmpty(v))
cn.Text = v;
} }
} }
else if ( c is ToolStrip) else if (c is ToolStrip)
{ {
ToolStrip ms = (ToolStrip)c; ToolStrip ms = (ToolStrip)c;
foreach ( ToolStripItem tsi in ms.Items ) foreach (ToolStripItem tsi in ms.Items)
{ {
SetMenuItem(tsi, list); SetMenuItem(formName, tsi);
} }
} }
else else
{ {
string v; if (GetLabel(pName, out title))
list.TryGetValue(c.Name, out v); c.Text = title;
if(!string.IsNullOrEmpty(v))
c.Text = v;
} }
if ( c.Controls.Count > 0 ) if (c.Controls.Count > 0)
{ {
foreach ( Control sc in c.Controls ) foreach (Control sc in c.Controls)
{ {
SetText(sc, list); SetControlLabel(sc, pName, formName);
} }
} }
ContextMenuStrip conms=c.ContextMenuStrip; ContextMenuStrip conms = c.ContextMenuStrip;
if ( conms!=null ) if (conms != null)
{ {
foreach ( ToolStripItem ts in conms.Items ) foreach (ToolStripItem ts in conms.Items)
{ {
SetMenuItem(ts, list); SetMenuItem(formName, ts);
} }
} }
} }
static void SetMenuItem(string pName, ToolStripItem tsi)
static void SetMenuItem(ToolStripItem tsi, SortedList<string, string> list)
{ {
if ( tsi is ToolStripMenuItem ) string tName = pName + SEP_CONTROL + tsi.Name;
string title;
if (tsi is ToolStripMenuItem)
{ {
ToolStripMenuItem tsmi = (ToolStripMenuItem)tsi; ToolStripMenuItem tsmi = (ToolStripMenuItem)tsi;
string v; if (GetLabel(tName, out title))
list.TryGetValue(tsmi.Name, out v); tsmi.Text = title;
if(!string.IsNullOrEmpty(v)) if (tsmi.HasDropDownItems)
tsmi.Text = v;
if(tsmi.HasDropDownItems)
{
foreach ( ToolStripItem subtsi in tsmi.DropDownItems )
{ {
if ( subtsi is ToolStripMenuItem ) foreach (ToolStripItem subtsi in tsmi.DropDownItems)
{ {
ToolStripMenuItem ts2 = (ToolStripMenuItem)subtsi; SetMenuItem(tName, subtsi);
SetMenuItem(ts2, list);
}
} }
} }
} }
else if ( tsi is ToolStripLabel ) else if (tsi is ToolStripLabel)
{ {
ToolStripLabel tlbl=(ToolStripLabel)tsi; ToolStripLabel tlbl = (ToolStripLabel)tsi;
string v; if (GetLabel(tName, out title))
list.TryGetValue(tlbl.Name, out v); tlbl.Text = title;
if(!string.IsNullOrEmpty(v))
tlbl.Text = v;
} }
} }
#endregion #endregion
#region 获取控件信息 #region 获取控件信息
/// <summary> public static void GetFormLabel(Form fm)
/// 获取控件名
/// </summary>
/// <param name="fm"></param>
public static void GetLanguage(Form fm)
{ {
SortedList<string, string> list=new SortedList<string, string>(); if (fm == null)
GetText(fm, list); return;
if(wordslist.ContainsKey(fm.Name)) // fm.SuspendLayout();
wordslist[fm.Name]=list; //fm.ResumeLayout(true);
else GetControlLabel(fm, "", fm.Name);
wordslist.Add(fm.Name, list); //fm.ResumeLayout(false);
//fm.PerformLayout();
} }
static void GetText(Control c, SortedList<string, string> list)
static void AddLabel(string key, string title)
{
if (!mWordslist.ContainsKey(key))
mWordslist.Add(key, title);
}
static void GetControlLabel(Control c, string pName,
string formName)
{ {
if ( c is ListView ) if (!string.IsNullOrEmpty(pName))
pName += SEP_CONTROL;
if (string.IsNullOrEmpty(c.Name))
return;
pName += c.Name;
if (c is ListView)
{ {
ListView lv = (ListView)c; ListView lv = (ListView)c;
int i,count=lv.Columns.Count; int i, count = lv.Columns.Count;
for(i=0;i<count;i++) for (i = 0; i < count; i++)
{ {
ColumnHeader cn=lv.Columns[i]; AddLabel(pName + SEP_CONTROL + i.ToString(),
if ( list.ContainsKey(lv.Name+i.ToString()) ) lv.Columns[i].Text);
list[cn.Name]=cn.Text;
else
list.Add(lv.Name+i.ToString(), cn.Text);
} }
} }
else if ( c is ToolStrip) else if (c is ToolStrip)
{ {
ToolStrip ms = (ToolStrip)c; ToolStrip ms = (ToolStrip)c;
foreach ( ToolStripItem tsi in ms.Items ) foreach (ToolStripItem tsi in ms.Items)
{ {
GetMenuItem(tsi, list); GetMenuItem(formName, tsi);
} }
} }
else else
{ {
if(list.ContainsKey(c.Name)) AddLabel(pName, c.Text);
list[c.Name]=c.Text;
else
list.Add(c.Name, c.Text);
} }
if ( c.Controls.Count > 0 ) if (c.Controls.Count > 0)
{ {
foreach ( Control sc in c.Controls ) foreach (Control sc in c.Controls)
{ {
GetText(sc, list); GetControlLabel(sc, pName, formName);
} }
} }
ContextMenuStrip conms=c.ContextMenuStrip; ContextMenuStrip conms = c.ContextMenuStrip;
if ( conms!=null ) if (conms != null)
{ {
foreach ( ToolStripItem ts in conms.Items ) foreach (ToolStripItem ts in conms.Items)
{ {
GetMenuItem(ts, list); GetMenuItem(formName, ts);
} }
} }
} }
static void GetMenuItem(string pName, ToolStripItem tsi)
static void GetMenuItem(ToolStripItem tsi, SortedList<string, string> list)
{ {
if ( tsi is ToolStripMenuItem ) string tName = pName + SEP_CONTROL + tsi.Name;
if (string.IsNullOrEmpty(tsi.Name))
return;
if (tsi is ToolStripMenuItem)
{ {
ToolStripMenuItem tsmi = (ToolStripMenuItem)tsi; ToolStripMenuItem tsmi = (ToolStripMenuItem)tsi;
if(list.ContainsKey(tsmi.Name)) AddLabel(tName, tsmi.Text);
list[tsi.Name] = tsmi.Text; if (tsmi.HasDropDownItems)
else
list.Add(tsi.Name, tsmi.Text);
if(tsmi.HasDropDownItems)
{ {
foreach ( ToolStripItem subtsi in tsmi.DropDownItems ) foreach (ToolStripItem subtsi in tsmi.DropDownItems)
{ {
if ( subtsi is ToolStripMenuItem ) GetMenuItem(tName, subtsi);
{
ToolStripMenuItem ts2 = (ToolStripMenuItem)subtsi;
GetMenuItem(ts2, list);
}
} }
} }
} }
else if ( tsi is ToolStripLabel ) else if (tsi is ToolStripLabel)
{ {
ToolStripLabel tlbl=(ToolStripLabel)tsi; ToolStripLabel tlbl = (ToolStripLabel)tsi;
if(list.ContainsKey(tlbl.Name)) AddLabel(tName, tlbl.Text);
list[tlbl.Name] = tlbl.Text;
else
list.Add(tlbl.Name, tlbl.Text);
} }
} }
#endregion #endregion
#region 保存语言文件 #region 保存语言文件
public static bool SaveLanguage(Form fm, string f) public static bool SaveLanguage(string conf)
{ {
if(!wordslist.ContainsKey(fm.Name)) using (FileStream fs = new FileStream(conf, FileMode.Create, FileAccess.Write))
return false;
SortedList<string, string> fmlist=wordslist[fm.Name];
using(FileStream fs=new FileStream(f, FileMode.Create, FileAccess.Write))
{ {
StreamWriter sw=new StreamWriter(fs, Encoding.UTF8); StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
foreach(string k in fmlist.Keys) foreach (string k in mWordslist.Keys)
{ {
sw.WriteLine(fm.Name+SEP+k+" "+fmlist[k]); sw.WriteLine(k + SEP_LINE + mWordslist[k]);
} }
sw.Close(); sw.Close();
fs.Close(); fs.Close();
...@@ -266,17 +248,17 @@ public static bool SaveLanguage(Form fm, string f) ...@@ -266,17 +248,17 @@ public static bool SaveLanguage(Form fm, string f)
public static bool SaveMessage(string f) public static bool SaveMessage(string f)
{ {
using(FileStream fs=new FileStream(f, FileMode.Create, FileAccess.Write)) using (FileStream fs = new FileStream(f, FileMode.Create, FileAccess.Write))
{ {
StreamWriter sw=new StreamWriter(fs, Encoding.UTF8); StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
foreach(LMSG k in msglist.Keys) foreach (LMSG k in msglist.Keys)
{ {
sw.WriteLine("0x"+((uint)k).ToString("x")+"\t"+msglist[k].Replace("\n","/n")); sw.WriteLine("0x" + ((uint)k).ToString("x") + "\t" + msglist[k].Replace("\n", "/n"));
} }
foreach ( LMSG k in Enum.GetValues(typeof(LMSG))) foreach (LMSG k in Enum.GetValues(typeof(LMSG)))
{ {
if(!msglist.ContainsKey(k)) if (!msglist.ContainsKey(k))
sw.WriteLine("0x"+((uint)k).ToString("x")+"\t"+k.ToString()); sw.WriteLine("0x" + ((uint)k).ToString("x") + "\t" + k.ToString());
} }
sw.Close(); sw.Close();
fs.Close(); fs.Close();
...@@ -286,66 +268,63 @@ public static bool SaveMessage(string f) ...@@ -286,66 +268,63 @@ public static bool SaveMessage(string f)
#endregion #endregion
#region 加载语言文件 #region 加载语言文件
public static SortedList<string, string> LoadLanguage(string f) public static void LoadFormLabels(string f)
{ {
SortedList<string, string> list=new SortedList<string, string>(); if (!File.Exists(f))
if(File.Exists(f)) return;
mWordslist.Clear();
using (FileStream fs = new FileStream(f, FileMode.Open, FileAccess.Read))
{ {
using(FileStream fs=new FileStream(f, FileMode.Open, FileAccess.Read)) StreamReader sr = new StreamReader(fs, Encoding.UTF8);
string line, sk, v;
while ((line = sr.ReadLine()) != null)
{ {
StreamReader sr=new StreamReader(fs, Encoding.UTF8); if (!line.StartsWith("#")&&line.Length>0)
string line,sk,v;
while((line=sr.ReadLine())!=null)
{ {
if(!line.StartsWith("#")) int si = line.IndexOf(SEP_LINE);
if (si > 0)
{ {
int ss=line.IndexOf(SEP); sk = line.Substring(0, si);
int si=(ss>0)?line.IndexOf(" "):-1; v = line.Substring(si + 1);
if(si>0)
{
sk=line.Substring(ss+SEP.Length,si-ss-SEP.Length);
v=line.Substring(si+1);
if(!list.ContainsKey(sk)) if (!mWordslist.ContainsKey(sk))
list.Add(sk,v); mWordslist.Add(sk, v);
} }
} }
} }
sr.Close(); sr.Close();
fs.Close(); fs.Close();
} }
}
return list;
}
}
public static void LoadMessage(string f) public static void LoadMessage(string f)
{ {
if(File.Exists(f)) if (!File.Exists(f))
{ return;
msglist.Clear(); msglist.Clear();
using(FileStream fs=new FileStream(f, FileMode.Open, FileAccess.Read)) using (FileStream fs = new FileStream(f, FileMode.Open, FileAccess.Read))
{ {
StreamReader sr=new StreamReader(fs, Encoding.UTF8); StreamReader sr = new StreamReader(fs, Encoding.UTF8);
string line,sk,v; string line, sk, v;
uint utemp; uint utemp;
LMSG ltemp; LMSG ltemp;
while((line=sr.ReadLine())!=null) while ((line = sr.ReadLine()) != null)
{ {
if(!line.StartsWith("#")) if (!line.StartsWith("#"))
{ {
int si=line.IndexOf("\t"); int si = line.IndexOf("\t");
if(si>0) if (si > 0)
{ {
sk=line.Substring(0,si); sk = line.Substring(0, si);
v=line.Substring(si+1); v = line.Substring(si + 1);
if(sk.StartsWith("0x")) if (sk.StartsWith("0x"))
uint.TryParse(sk.Replace("0x",""), NumberStyles.HexNumber, null, out utemp); uint.TryParse(sk.Replace("0x", ""), NumberStyles.HexNumber, null, out utemp);
else else
uint.TryParse(sk, out utemp); uint.TryParse(sk, out utemp);
ltemp=(LMSG)utemp; ltemp = (LMSG)utemp;
if(msglist.IndexOfKey(ltemp)<0) if (msglist.IndexOfKey(ltemp) < 0)
msglist.Add(ltemp, v.Replace("/n","\n")); msglist.Add(ltemp, v.Replace("/n", "\n"));
} }
} }
} }
...@@ -353,7 +332,6 @@ public static void LoadMessage(string f) ...@@ -353,7 +332,6 @@ public static void LoadMessage(string f)
fs.Close(); fs.Close();
} }
} }
}
#endregion #endregion
} }
......
...@@ -16,217 +16,115 @@ ...@@ -16,217 +16,115 @@
using FastColoredTextBoxNS; using FastColoredTextBoxNS;
using DataEditorX.Language; using DataEditorX.Language;
using DataEditorX.Core; using DataEditorX.Core;
using DataEditorX.Config;
using System.Text; using System.Text;
using DataEditorX.Controls;
namespace DataEditorX namespace DataEditorX
{ {
/// <summary> /// <summary>
/// Description of MainForm. /// Description of MainForm.
/// </summary> /// </summary>
public partial class MainForm : Form public partial class MainForm : Form, IMainForm
{ {
#region member #region member
string cdbHistoryFile; //历史
List<string> cdbhistory; History history;
List<string> luahistory; //数据目录
string datapath; string datapath;
string conflang,conflang_de,conflang_ce,confmsg,conflang_pe; //语言配置
DataEditForm compare1,compare2; string conflang;
string confmsg;
//打开历史
string historyFile;
//数据库对比
DataEditForm compare1, compare2;
Card[] tCards; Card[] tCards;
// //
DataConfig datacfg = null; DataConfig datacfg = null;
CodeConfig codecfg = null; CodeConfig codecfg = null;
#endregion #endregion
#region init #region 设置界面,消息语言
public MainForm(string datapath, string file) public void SetLanguage(string language)
{
Init(datapath);
if(MainForm.isScript(file))
OpenScript(file);
else
Open(file);
}
public MainForm(string datapath)
{
Init(datapath);
}
void Init(string datapath)
{ {
//判断是否合法
if (string.IsNullOrEmpty(language))
return;
tCards = null; tCards = null;
cdbhistory = new List<string>();
luahistory = new List<string>();
this.datapath = datapath; this.datapath = MyPath.Combine(Application.StartupPath, language);
InitDataEditor();
InitCodeEditor();
cdbHistoryFile =MyPath.Combine(datapath, "history.txt"); //文件路径
conflang = MyPath.Combine(datapath, "language-mainform.txt"); historyFile = MyPath.Combine(datapath, MyConfig.FILE_HISTORY);
conflang_de = MyPath.Combine(datapath, "language-dataeditor.txt"); conflang = MyPath.Combine(datapath, MyConfig.FILE_LANGUAGE);
conflang_ce = MyPath.Combine(datapath, "language-codeeditor.txt"); confmsg = MyPath.Combine(datapath, MyConfig.FILE_MESSAGE);
conflang_pe = MyPath.Combine(datapath, "language-puzzleditor.txt"); //游戏数据
confmsg = MyPath.Combine(datapath, "message.txt"); datacfg = new DataConfig(datapath);
datacfg.Init();
//
YGOUtil.SetConfig(datacfg);
//代码提示
codecfg = new CodeConfig(datapath);
codecfg.Init();
codecfg.SetNames(datacfg.dicSetnames);
codecfg.AddStrings();
InitializeComponent(); InitializeComponent();
LANG.InitForm(this, conflang); history = new History(this);
//加载多语言
LANG.LoadFormLabels(conflang);
LANG.LoadMessage(confmsg); LANG.LoadMessage(confmsg);
LANG.SetLanguage(this); LANG.SetFormLabel(this);
ReadHistory(); //设置所有窗口
MenuHistory(); DockContentCollection contents = dockPanel1.Contents;
bgWorker1.RunWorkerAsync(); foreach (DockContent dc in contents)
}
#endregion
#region const
public const int WM_OPEN=0x0401;
public const int WM_OPEN_SCRIPT=0x0402;
public const string TMPFILE="open.tmp";
public const int MAX_HISTORY=0x10;
public static bool isScript(string file)
{
if(file!=null && file.EndsWith("lua",StringComparison.OrdinalIgnoreCase))
return true;
return false;
}
#endregion
#region History
void ReadHistory()
{
if(!File.Exists(cdbHistoryFile))
return;
string[] lines=File.ReadAllLines(cdbHistoryFile);
AddHistorys(lines);
}
void AddHistorys(string[] lines)
{
luahistory.Clear();
cdbhistory.Clear();
foreach (string line in lines)
{
if (string.IsNullOrEmpty(line) || line.StartsWith("#"))
continue;
if (File.Exists(line))
{
if (MainForm.isScript(line))
{
if (luahistory.Count < MainForm.MAX_HISTORY
&& luahistory.IndexOf(line) < 0)
luahistory.Add(line);
}
else
{
if (cdbhistory.Count < MainForm.MAX_HISTORY
&& cdbhistory.IndexOf(line) < 0)
cdbhistory.Add(line);
}
}
}
}
void AddHistory(string file)
{
List<string> tmplist = new List<string>();
//添加到开始
tmplist.Add(file);
//添加旧记录
tmplist.AddRange(cdbhistory.ToArray());
tmplist.AddRange(luahistory.ToArray());
//
AddHistorys(tmplist.ToArray());
SaveHistory();
MenuHistory();
}
void SaveHistory()
{
string texts="# database history";
foreach(string str in cdbhistory)
{ {
if(File.Exists(str)) if (dc is Form)
texts += Environment.NewLine + str;
}
texts += Environment.NewLine + "# script history";
foreach (string str in luahistory)
{ {
if (File.Exists(str)) LANG.SetFormLabel((Form)dc);
texts += Environment.NewLine + str;
} }
File.Delete(cdbHistoryFile);
File.WriteAllText(cdbHistoryFile, texts);
} }
void MenuHistory()
{ //读取历史记录
menuitem_history.DropDownItems.Clear(); history.ReadHistory(historyFile);
menuitem_shistory.DropDownItems.Clear(); history.MenuHistory();
foreach(string str in cdbhistory)
{
ToolStripMenuItem tsmi=new ToolStripMenuItem(str);
tsmi.Click+=MenuHistoryItem_Click;
menuitem_history.DropDownItems.Add(tsmi);
} }
menuitem_history.DropDownItems.Add(new ToolStripSeparator()); #endregion
ToolStripMenuItem tsmiclear=new ToolStripMenuItem(LANG.GetMsg(LMSG.ClearHistory));
tsmiclear.Click+=MenuHistoryClear_Click;
menuitem_history.DropDownItems.Add(tsmiclear);
foreach (string str in luahistory) #region 打开历史
public void CdbMenuClear()
{ {
ToolStripMenuItem tsmi = new ToolStripMenuItem(str); menuitem_history.DropDownItems.Clear();
tsmi.Click += MenuHistoryItem_Click;
menuitem_shistory.DropDownItems.Add(tsmi);
}
menuitem_shistory.DropDownItems.Add(new ToolStripSeparator());
ToolStripMenuItem tsmiclear2 = new ToolStripMenuItem(LANG.GetMsg(LMSG.ClearHistory));
tsmiclear2.Click += MenuHistoryClear2_Click;
menuitem_shistory.DropDownItems.Add(tsmiclear2);
} }
void MenuHistoryClear2_Click(object sender, EventArgs e) public void LuaMenuClear()
{ {
luahistory.Clear(); menuitem_shistory.DropDownItems.Clear();
MenuHistory();
SaveHistory();
} }
void MenuHistoryClear_Click(object sender, EventArgs e) public void AddCdbMenu(ToolStripItem item)
{ {
cdbhistory.Clear(); menuitem_history.DropDownItems.Add(item);
MenuHistory();
SaveHistory();
} }
void MenuHistoryItem_Click(object sender, EventArgs e) public void AddLuaMenu(ToolStripItem item)
{
ToolStripMenuItem tsmi=sender as ToolStripMenuItem;
if(tsmi!=null){
string file = tsmi.Text;
if (MainForm.isScript(file))
{ {
OpenScript(file); menuitem_shistory.DropDownItems.Add(item);
}
else
Open(file);
}
} }
#endregion #endregion
#region message #region 处理窗口消息
protected override void DefWndProc(ref System.Windows.Forms.Message m) protected override void DefWndProc(ref System.Windows.Forms.Message m)
{ {
string file=null; string file = null;
switch (m.Msg) switch (m.Msg)
{ {
case MainForm.WM_OPEN://处理消息 case MyConfig.WM_OPEN://处理消息
file=Path.Combine(Application.StartupPath, MainForm.TMPFILE); file = MyPath.Combine(Application.StartupPath, MyConfig.FILE_TEMP);
if(File.Exists(file)){ if (File.Exists(file))
{
this.Activate(); this.Activate();
Open(File.ReadAllText(file)); Open(File.ReadAllText(file));
File.Delete(file); //File.Delete(file);
}
break;
case MainForm.WM_OPEN_SCRIPT:
file=Path.Combine(Application.StartupPath, MainForm.TMPFILE);
if(File.Exists(file)){
this.Activate();
OpenScript(File.ReadAllText(file));
File.Delete(file);
} }
break; break;
default: default:
...@@ -236,290 +134,253 @@ protected override void DefWndProc(ref System.Windows.Forms.Message m) ...@@ -236,290 +134,253 @@ protected override void DefWndProc(ref System.Windows.Forms.Message m)
} }
#endregion #endregion
#region open #region 打开文件
public void OpenScript(string file) //打开脚本
void OpenScript(string file)
{ {
if(!string.IsNullOrEmpty(file) && File.Exists(file)){ CodeEditForm cf = new CodeEditForm();
AddHistory(file); LANG.SetFormLabel(cf);
}
if (checkOpen(file)) cf.SetCDBList(history.GetcdbHistory());
return;
if (OpenInNull(file))
return;
CodeEditForm cf=new CodeEditForm();
LANG.InitForm(cf, conflang_ce);
LANG.SetLanguage(cf);
InitCodeEditor();
cf.SetCDBList(cdbhistory.ToArray());
cf.InitTooltip(codecfg.TooltipDic, codecfg.FunList, codecfg.ConList); cf.InitTooltip(codecfg.TooltipDic, codecfg.FunList, codecfg.ConList);
//cf.SetIMEMode(ImeMode.Inherit);
cf.Open(file); cf.Open(file);
cf.Show(dockPanel1, DockState.Document); cf.Show(dockPanel1, DockState.Document);
} }
void InitCodeEditor() //打开数据库
{ void OpenDataBase(string file)
if (codecfg == null)
{
codecfg = new CodeConfig(datapath);
codecfg.Init();
InitDataEditor();
codecfg.SetNames(datacfg.dicSetnames);
codecfg.AddStrings();
}
}
void InitDataEditor()
{
if (datacfg == null)
{
datacfg = new DataConfig(datapath);
datacfg.Init();
YGOUtil.SetConfig(datacfg);
}
}
public void Open(string file)
{ {
if (MainForm.isScript(file))
{
OpenScript(file);
return;
}
if(!string.IsNullOrEmpty(file) && File.Exists(file)){
AddHistory(file);
}
if(checkOpen(file))
return;
if(OpenInNull(file))
return;
DataEditForm def; DataEditForm def;
if(string.IsNullOrEmpty(file)|| !File.Exists(file)) if (string.IsNullOrEmpty(file) || !File.Exists(file))
def=new DataEditForm(datapath); def = new DataEditForm(datapath);
else else
def=new DataEditForm(datapath,file); def = new DataEditForm(datapath, file);
LANG.InitForm(def, conflang_de); LANG.SetFormLabel(def);
LANG.SetLanguage(def);
InitDataEditor();
def.InitGameData(datacfg); def.InitGameData(datacfg);
def.Show(dockPanel1, DockState.Document); def.Show(dockPanel1, DockState.Document);
} }
//打开文件
bool checkOpen(string file) public void Open(string file)
{
DockContentCollection contents = dockPanel1.Contents;
foreach (DockContent dc in contents)
{
if (!MainForm.isScript(file))
{
DataEditForm df = dc as DataEditForm;
if (df != null && !df.IsDisposed)
{ {
if (df.getNowCDB() == file) if (string.IsNullOrEmpty(file) || !File.Exists(file))
{ {
df.Show(); return;
return true;
}
}
} }
//添加历史
history.AddHistory(file);
//检查是否已经打开
if (FindEditForm(file, true))
return;
//检查可用的
if (FindEditForm(file, false))
return;
if (YGOUtil.isScript(file))
OpenScript(file);
else else
{ OpenDataBase(file);
CodeEditForm cf = dc as CodeEditForm;
if (cf != null && !cf.IsDisposed)
{
if (cf.NowFile == file)
{
cf.Show();
return true;
}
} }
} //检查是否打开
} bool FindEditForm(string file, bool isOpen)
return false;
}
bool OpenInNull(string file)
{ {
if(string.IsNullOrEmpty(file) || !File.Exists(file))
return false;
DockContentCollection contents = dockPanel1.Contents; DockContentCollection contents = dockPanel1.Contents;
foreach (DockContent dc in contents) foreach (DockContent dc in contents)
{ {
if (!MainForm.isScript(file)) IEditForm edform = (IEditForm)dc;
{ if (edform == null)
DataEditForm df = dc as DataEditForm; continue;
if (df != null && !df.IsDisposed) if (isOpen)//是否检查打开
{ {
if (string.IsNullOrEmpty(df.getNowCDB())) if (file != null && file.Equals(edform.GetOpenFile()))
{ {
df.Open(file); edform.SetActived();
df.Show();
return true; return true;
} }
} }
} else//检查空白
else
{
CodeEditForm cf = dc as CodeEditForm;
if (cf != null && !cf.IsDisposed)
{ {
if (string.IsNullOrEmpty(cf.NowFile)) if (string.IsNullOrEmpty(edform.GetOpenFile()) && edform.CanOpen(file))
{ {
cf.Open(file); edform.Open(file);
cf.Show(); edform.SetActived();
return true; return true;
} }
}
} }
} }
return false; return false;
} }
void DataEditorToolStripMenuItemClick(object sender, EventArgs e)
{
Open(null);
}
#endregion #endregion
#region form #region 加载,关闭
void MainFormLoad(object sender, System.EventArgs e) void MainFormLoad(object sender, System.EventArgs e)
{ {
// //检查更新
bgWorker1.RunWorkerAsync();
if (dockPanel1.Contents.Count == 0)
OpenDataBase(null);
} }
void MainFormFormClosing(object sender, FormClosingEventArgs e) void MainFormFormClosing(object sender, FormClosingEventArgs e)
{ {
#if DEBUG #if DEBUG
LANG.SaveMessage(confmsg+".bak"); LANG.GetFormLabel(this);
#endif DockContentCollection contents = dockPanel1.Contents;
foreach (DockContent dc in contents)
{
LANG.GetFormLabel(dc);
}
//获取窗体文字
LANG.SaveLanguage(conflang + ".bak");
LANG.SaveMessage(confmsg + ".bak");
#endif
} }
#endregion #endregion
#region windows #region 窗口管理
void CloseToolStripMenuItemClick(object sender, EventArgs e) void CloseToolStripMenuItemClick(object sender, EventArgs e)
{ {
//关闭当前
dockPanel1.ActiveContent.DockHandler.Close(); dockPanel1.ActiveContent.DockHandler.Close();
} }
//打开脚本编辑
void Menuitem_codeeditorClick(object sender, EventArgs e) void Menuitem_codeeditorClick(object sender, EventArgs e)
{ {
OpenScript(null); OpenScript(null);
} }
//新建DataEditorX
void DataEditorToolStripMenuItemClick(object sender, EventArgs e)
{
OpenDataBase(null);
}
//关闭其他或者所有
void CloseMdi(bool isall) void CloseMdi(bool isall)
{ {
DockContentCollection contents = dockPanel1.Contents; DockContentCollection contents = dockPanel1.Contents;
int num = contents.Count-1; int num = contents.Count - 1;
try{ try
while (num >=0) {
while (num >= 0)
{ {
if (contents[num].DockHandler.DockState == DockState.Document) if (contents[num].DockHandler.DockState == DockState.Document)
{ {
if(isall) if (isall)
contents[num].DockHandler.Close(); contents[num].DockHandler.Close();
else if(dockPanel1.ActiveContent != contents[num]) else if (dockPanel1.ActiveContent != contents[num])
contents[num].DockHandler.Close(); contents[num].DockHandler.Close();
} }
num--; num--;
} }
}catch{}
} }
catch { }
}
//关闭其他
void CloseOtherToolStripMenuItemClick(object sender, EventArgs e) void CloseOtherToolStripMenuItemClick(object sender, EventArgs e)
{ {
CloseMdi(false); CloseMdi(false);
} }
//关闭所有
void CloseAllToolStripMenuItemClick(object sender, EventArgs e) void CloseAllToolStripMenuItemClick(object sender, EventArgs e)
{ {
CloseMdi(true); CloseMdi(true);
} }
#endregion #endregion
#region file #region 文件菜单
//得到当前的数据编辑
DataEditForm GetActive() DataEditForm GetActive()
{ {
DataEditForm df = dockPanel1.ActiveContent as DataEditForm; DataEditForm df = dockPanel1.ActiveContent as DataEditForm;
return df; return df;
} }
//打开文件
void Menuitem_openClick(object sender, EventArgs e) void Menuitem_openClick(object sender, EventArgs e)
{ {
using(OpenFileDialog dlg=new OpenFileDialog()) using (OpenFileDialog dlg = new OpenFileDialog())
{ {
dlg.Title=LANG.GetMsg(LMSG.OpenFile); dlg.Title = LANG.GetMsg(LMSG.OpenFile);
if(GetActive() !=null) if (GetActive() != null)//判断当前窗口是不是DataEditor
dlg.Filter=LANG.GetMsg(LMSG.CdbType); dlg.Filter = LANG.GetMsg(LMSG.CdbType);
else else
dlg.Filter=LANG.GetMsg(LMSG.ScriptFilter); dlg.Filter = LANG.GetMsg(LMSG.ScriptFilter);
if(dlg.ShowDialog()==DialogResult.OK) if (dlg.ShowDialog() == DialogResult.OK)
{ {
string file=dlg.FileName; string file = dlg.FileName;
if(MainForm.isScript(file))
OpenScript(file);
else
Open(file); Open(file);
} }
} }
} }
//退出
void QuitToolStripMenuItemClick(object sender, EventArgs e) void QuitToolStripMenuItemClick(object sender, EventArgs e)
{ {
this.Close(); this.Close();
} }
//新建文件
void Menuitem_newClick(object sender, EventArgs e) void Menuitem_newClick(object sender, EventArgs e)
{ {
using(SaveFileDialog dlg=new SaveFileDialog()) using (SaveFileDialog dlg = new SaveFileDialog())
{ {
dlg.Title=LANG.GetMsg(LMSG.NewFile); dlg.Title = LANG.GetMsg(LMSG.NewFile);
if(GetActive() !=null) if (GetActive() != null)//判断当前窗口是不是DataEditor
dlg.Filter=LANG.GetMsg(LMSG.CdbType); dlg.Filter = LANG.GetMsg(LMSG.CdbType);
else else
dlg.Filter=LANG.GetMsg(LMSG.ScriptFilter); dlg.Filter = LANG.GetMsg(LMSG.ScriptFilter);
if(dlg.ShowDialog()==DialogResult.OK) if (dlg.ShowDialog() == DialogResult.OK)
{ {
string file=dlg.FileName; string file = dlg.FileName;
if(MainForm.isScript(file)){
File.Delete(file); File.Delete(file);
OpenScript(file);
} if (YGOUtil.isDataBase(file))
else
{ {
if(DataBase.Create(file)) if (DataBase.Create(file))
{ {
if(MyMsg.Question(LMSG.IfOpenDataBase)) if (MyMsg.Question(LMSG.IfOpenDataBase))
Open(file); Open(file);
} }
} }
else
{
File.Delete(file);
Open(file);
}
} }
} }
} }
//保存文件
void Menuitem_saveClick(object sender, EventArgs e) void Menuitem_saveClick(object sender, EventArgs e)
{ {
CodeEditForm cf= dockPanel1.ActiveContent as CodeEditForm; IEditForm cf = dockPanel1.ActiveContent as IEditForm;
if(cf!=null) if (cf != null)
{ {
if(cf.Save()) if (cf.Save())
MyMsg.Show(LMSG.SaveFileOK); MyMsg.Show(LMSG.SaveFileOK);
} }
} }
#endregion #endregion
#region copy #region 卡片复制粘贴
//复制选中
void Menuitem_copyselecttoClick(object sender, EventArgs e) void Menuitem_copyselecttoClick(object sender, EventArgs e)
{ {
DataEditForm df =GetActive(); DataEditForm df = GetActive();
if(df!=null) if (df != null)
{
tCards = df.getCardList(true);
if (tCards != null)
{ {
tCards=df.getCardList(true);
if(tCards!=null){
SetCopyNumber(tCards.Length); SetCopyNumber(tCards.Length);
MyMsg.Show(LMSG.CopyCards); MyMsg.Show(LMSG.CopyCards);
} }
} }
} }
//复制当前结果
void Menuitem_copyallClick(object sender, EventArgs e) void Menuitem_copyallClick(object sender, EventArgs e)
{ {
DataEditForm df =GetActive(); DataEditForm df = GetActive();
if(df!=null) if (df != null)
{
tCards = df.getCardList(false);
if (tCards != null)
{ {
tCards=df.getCardList(false);
if(tCards!=null){
SetCopyNumber(tCards.Length); SetCopyNumber(tCards.Length);
MyMsg.Show(LMSG.CopyCards); MyMsg.Show(LMSG.CopyCards);
} }
...@@ -527,20 +388,20 @@ void Menuitem_copyallClick(object sender, EventArgs e) ...@@ -527,20 +388,20 @@ void Menuitem_copyallClick(object sender, EventArgs e)
} }
void SetCopyNumber(int c) void SetCopyNumber(int c)
{ {
string tmp=menuitem_pastecards.Text; string tmp = menuitem_pastecards.Text;
int t=tmp.LastIndexOf(" ("); int t = tmp.LastIndexOf(" (");
if(t>0) if (t > 0)
tmp=tmp.Substring(0,t); tmp = tmp.Substring(0, t);
tmp=tmp+" ("+c.ToString()+")"; tmp = tmp + " (" + c.ToString() + ")";
menuitem_pastecards.Text=tmp; menuitem_pastecards.Text = tmp;
} }
//粘贴卡片
void Menuitem_pastecardsClick(object sender, EventArgs e) void Menuitem_pastecardsClick(object sender, EventArgs e)
{ {
if(tCards==null) if (tCards == null)
return; return;
DataEditForm df =GetActive(); DataEditForm df = GetActive();
if(df==null) if (df == null)
return; return;
df.SaveCards(tCards); df.SaveCards(tCards);
MyMsg.Show(LMSG.PasteCards); MyMsg.Show(LMSG.PasteCards);
...@@ -548,46 +409,49 @@ void Menuitem_pastecardsClick(object sender, EventArgs e) ...@@ -548,46 +409,49 @@ void Menuitem_pastecardsClick(object sender, EventArgs e)
#endregion #endregion
#region compare #region 数据对比
void Menuitem_comp1Click(object sender, EventArgs e) void Menuitem_comp1Click(object sender, EventArgs e)
{ {
compare1 = GetActive(); compare1 = GetActive();
if(compare1 != null && !string.IsNullOrEmpty(compare1.getNowCDB())) if (compare1 != null && !string.IsNullOrEmpty(compare1.GetOpenFile()))
{
menuitem_comp2.Enabled = true;
CompareDB();
}
}
void Menuitem_comp2Click(object sender, EventArgs e)
{
compare2 = GetActive();
if (compare2 != null && !string.IsNullOrEmpty(compare2.GetOpenFile()))
{ {
menuitem_comp2.Enabled=true;
CompareDB(); CompareDB();
} }
} }
//对比数据库
void CompareDB() void CompareDB()
{ {
if(compare1 == null || compare2 == null) if (compare1 == null || compare2 == null)
return; return;
string cdb1=compare1.getNowCDB(); string cdb1 = compare1.GetOpenFile();
string cdb2=compare2.getNowCDB(); string cdb2 = compare2.GetOpenFile();
if(string.IsNullOrEmpty(cdb1) if (string.IsNullOrEmpty(cdb1)
|| string.IsNullOrEmpty(cdb2) || string.IsNullOrEmpty(cdb2)
||cdb1==cdb2) || cdb1 == cdb2)
return; return;
bool checktext=MyMsg.Question(LMSG.CheckText); bool checktext = MyMsg.Question(LMSG.CheckText);
compare1.CompareCards(cdb2, checktext); compare1.CompareCards(cdb2, checktext);
compare2.CompareCards(cdb1, checktext); compare2.CompareCards(cdb1, checktext);
MyMsg.Show(LMSG.CompareOK); MyMsg.Show(LMSG.CompareOK);
menuitem_comp2.Enabled=false; menuitem_comp2.Enabled = false;
compare1=null; compare1 = null;
compare2=null; compare2 = null;
}
void Menuitem_comp2Click(object sender, EventArgs e)
{
compare2 = GetActive();
if(compare2 != null && !string.IsNullOrEmpty(compare2.getNowCDB()))
{
CompareDB();
}
} }
#endregion #endregion
#region complate #region 获取函数列表
void Menuitem_findluafuncClick(object sender, EventArgs e) void Menuitem_findluafuncClick(object sender, EventArgs e)
{ {
using (FolderBrowserDialog fd = new FolderBrowserDialog()) using (FolderBrowserDialog fd = new FolderBrowserDialog())
...@@ -603,9 +467,11 @@ void Menuitem_findluafuncClick(object sender, EventArgs e) ...@@ -603,9 +467,11 @@ void Menuitem_findluafuncClick(object sender, EventArgs e)
} }
#endregion #endregion
#region 自动更新
private void bgWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) private void bgWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
{ {
TaskHelper.CheckVersion(false); TaskHelper.CheckVersion(false);
} }
#endregion
} }
} }
...@@ -11,44 +11,38 @@ ...@@ -11,44 +11,38 @@
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Windows.Forms; using System.Windows.Forms;
using DataEditorX.Config;
namespace DataEditorX namespace DataEditorX
{ {
/// Class with program entry point.
/// </summary>
internal sealed class Program internal sealed class Program
{ {
/// <summary>
/// <summary>
/// Program entry point.
/// </summary>
[STAThread] [STAThread]
private static void Main(string[] args) private static void Main(string[] args)
{ {
string arg=""; string file = (args.Length > 0) ? args[0] : "";
if(args.Length>0)
{
arg=args[0];
}
Process instance = RunningInstance(); Process instance = RunningInstance();
//判断是否已经运行
if (instance == null) if (instance == null)
{ {
ShowForm(arg); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
MainForm mainForm = new MainForm();
mainForm.SetLanguage(MyConfig.readString(MyConfig.TAG_LANGUAGE));
mainForm.Open(file);
Application.Run(mainForm);
} }
else else
{ {
int msg=MainForm.WM_OPEN; //发送消息给窗口
if(MainForm.isScript(arg)) string tmpfile = Path.Combine(Application.StartupPath, MyConfig.FILE_TEMP);
msg=MainForm.WM_OPEN_SCRIPT; File.WriteAllText(tmpfile, file);
File.WriteAllText(Path.Combine(Application.StartupPath, MainForm.TMPFILE), arg); User32.SendMessage(instance.MainWindowHandle, MyConfig.WM_OPEN, 0, 0);
User32.SendMessage(instance.MainWindowHandle, msg, 0 ,0);
//Thread.Sleep(1000);
Environment.Exit(1); Environment.Exit(1);
} }
} }
private static Process RunningInstance() static Process RunningInstance()
{ {
Process current = Process.GetCurrentProcess(); Process current = Process.GetCurrentProcess();
Process[] processes = Process.GetProcessesByName(current.ProcessName); Process[] processes = Process.GetProcessesByName(current.ProcessName);
...@@ -70,18 +64,5 @@ private static Process RunningInstance() ...@@ -70,18 +64,5 @@ private static Process RunningInstance()
} }
return null; return null;
} }
static void ShowForm(string file)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
string dir=ConfigurationManager.AppSettings["language"];
if(string.IsNullOrEmpty(dir))
{
Application.Exit();
}
string datapath=Path.Combine(Application.StartupPath, dir);
Application.Run(new MainForm(datapath, file));
}
} }
} }
0x0 卡片种族 0x0 卡片种族
0x1 战士族 0x1 战士族
0x2 魔法使 0x2 魔法
0x4 天使族 0x4 天使族
0x8 恶魔族 0x8 恶魔族
0x10 不死族 0x10 不死族
......
CodeEditForm->CodeEditForm 脚本编辑器
CodeEditForm->menuitem_file 文件(&F)
CodeEditForm->menuitem_open 打开
CodeEditForm->menuitem_save 保存
CodeEditForm->menuitem_saveas 另存为
CodeEditForm->menuitem_quit 退出
CodeEditForm->menuitem_setting 设置(&S)
CodeEditForm->menuitem_showmap 显示缩略图
CodeEditForm->menuitem_showinput 显示文本框
CodeEditForm->menuitem_setcard 设置卡片库
CodeEditForm->menuitem_find 查找
CodeEditForm->menuitem_replace 替换
CodeEditForm->menuitem_help 帮助(&H)
CodeEditForm->menuitem_about 关于
\ No newline at end of file
DataEditForm->btn_add 添加(&A)
DataEditForm->btn_del 删除(&D)
DataEditForm->btn_lua 脚本(&L)
DataEditForm->btn_img 导入卡图(&I)
DataEditForm->btn_undo 撤销(&U)
DataEditForm->btn_mod 修改(&M)
DataEditForm->btn_PageDown 下一页
DataEditForm->btn_PageUp 上一页
DataEditForm->btn_reset 重置(&R)
DataEditForm->btn_serach 搜索(&S)
DataEditForm->DataEditForm DataEditorX
DataEditForm->lb_atkdef ATK/DEF
DataEditForm->lb_cardalias 同名卡
DataEditForm->lb_cardcode 卡片密码
DataEditForm->lb_categorys 效果种类
DataEditForm->lb_pleft_right 灵摆刻度
DataEditForm->lb_scripttext
DataEditForm->lb_tiptexts 提示文字
DataEditForm->lb_types 卡片种类
DataEditForm->lb2 /
DataEditForm->lb4 /
DataEditForm->lb5 /
DataEditForm->lv_cardlist0 密码
DataEditForm->lv_cardlist1 卡片名称
DataEditForm->menu_tools 功能(&T)
DataEditForm->menuitem_exportdata 导出所有卡片数据为zip
DataEditForm->menuitem_cancelTask 取消当前任务
DataEditForm->menuitem_compdb 压缩当前数据库
DataEditForm->menuitem_convertimage 批量导入卡图
DataEditForm->menuitem_importmseimg MSE图片库
DataEditForm->menuitem_openLastDataBase 最后打开的数据库
DataEditForm->menuitem_cutimages 裁剪列表卡片的图片
DataEditForm->menuitem_saveasmse_select 所选卡片导出MSE存档
DataEditForm->menuitem_saveasmse 当前所有卡片导出MSE存档
DataEditForm->menuitem_about 关于(&A)
DataEditForm->menuitem_checkupdate 检查更新
DataEditForm->menuitem_copyselectto 所选卡片复制到...
DataEditForm->menuitem_copyto 当前所有卡片复制到...
DataEditForm->menuitem_file 文件(&F)
DataEditForm->menuitem_github 源码主页
DataEditForm->menuitem_help 帮助(&H)
DataEditForm->menuitem_new 新建(&N)
DataEditForm->menuitem_open 打开(&O)
DataEditForm->menuitem_quit 退出(&Q)
DataEditForm->menuitem_readimages 从图像文件夹读取
DataEditForm->menuitem_readydk 从ydk文件读取
\ No newline at end of file
MainForm->menuitem_file 文件(&F)
MainForm->menuitem_new 新建(&N)
MainForm->menuitem_open 打开(&O)
MainForm->menuitem_save 保存(&S)
MainForm->menuitem_copyselect 复制所选卡片
MainForm->menuitem_copyall 复制当前结果的所有卡片
MainForm->menuitem_findluafunc 从源码获取Lua函数
MainForm->menuitem_pastecards 粘贴卡片
MainForm->menuitem_comp1 对比-卡片数据 1
MainForm->menuitem_comp2 对比-卡片数据 2
MainForm->menuitem_history 数据库历史记录(&H)
MainForm->menuitem_shistory 脚本历史记录
MainForm->menuitem_quit 退出(&Q)
MainForm->menuitem_windows 窗口(&W)
MainForm->menuitem_dataeditor DataEditor
MainForm->menuitem_codeeditor CodeEditor
MainForm->menuitem_closeall 关闭所有
MainForm->menuitem_closeother 关闭其他
MainForm->menuitem_close 关闭当前
\ No newline at end of file
CodeEditForm 脚本编辑
CodeEditForm.CodeEditForm 脚本编辑器
CodeEditForm.documentMap1 预览图
CodeEditForm.fctb
CodeEditForm.menuitem_about 关于
CodeEditForm.menuitem_file 文件(&F)
CodeEditForm.menuitem_file.menuitem_open 打开
CodeEditForm.menuitem_file.menuitem_quit 退出
CodeEditForm.menuitem_file.menuitem_save 保存
CodeEditForm.menuitem_file.menuitem_saveas 另存为
CodeEditForm.menuitem_find 查找
CodeEditForm.menuitem_help 帮助(&H)
CodeEditForm.menuitem_help.menuitem_about 关于(&A)
CodeEditForm.menuitem_open 打开
CodeEditForm.menuitem_quit 退出
CodeEditForm.menuitem_replace 替换
CodeEditForm.menuitem_save 保存
CodeEditForm.menuitem_saveas 另存为
CodeEditForm.menuitem_setcard 设置卡片库
CodeEditForm.menuitem_setting 设置(&S)
CodeEditForm.menuitem_setting.menuitem_find 查找
CodeEditForm.menuitem_setting.menuitem_replace 替换
CodeEditForm.menuitem_setting.menuitem_setcard 设置卡片库
CodeEditForm.menuitem_setting.menuitem_showinput 显示输入框
CodeEditForm.menuitem_setting.menuitem_showmap 显示预览图
CodeEditForm.menuitem_showinput 显示文本框
CodeEditForm.menuitem_showmap 显示缩略图
CodeEditForm.tb_input
DataEditForm 数据编辑
DataEditForm.btn_add 添加(&A)
DataEditForm.btn_del 删除(&D)
DataEditForm.btn_img 导入卡图(&I)
DataEditForm.btn_lua 脚本(&L)
DataEditForm.btn_mod 修改(&M)
DataEditForm.btn_PageDown 下一页
DataEditForm.btn_PageUp 上一页
DataEditForm.btn_reset 重置(&R)
DataEditForm.btn_serach 搜索(&S)
DataEditForm.btn_undo 撤销(&U)
DataEditForm.lb_atkdef ATK/DEF
DataEditForm.lb_cardalias 同名卡
DataEditForm.lb_cardcode 卡片密码
DataEditForm.lb_categorys 效果种类
DataEditForm.lb_pleft_right 灵摆刻度
DataEditForm.lb_scripttext
DataEditForm.lb_tiptexts 提示文字
DataEditForm.lb_types 卡片种类
DataEditForm.lb2 /
DataEditForm.lb4 /
DataEditForm.lb5 /
DataEditForm.lv_cardlist.0 密码
DataEditForm.lv_cardlist.1 卡片名称
DataEditForm.lv_cardlist0 密码
DataEditForm.lv_cardlist1 卡片名称
DataEditForm.menuitem_file 文件(&F)
DataEditForm.menuitem_help 帮助(&H)
DataEditForm.menuitem_new 新建(&N)
DataEditForm.menuitem_open 打开(&O)
DataEditForm.menuitem_openLastDataBase 最后打开的数据库
DataEditForm.menuitem_quit 退出(&Q)
DataEditForm.menu_tools 功能(&T)
DataEditForm.menu_tools.menuitem_cancelTask 取消当前任务
DataEditForm.menu_tools.menuitem_compdb 压缩数据库
DataEditForm.menu_tools.menuitem_convertimage 批量导入卡图
DataEditForm.menu_tools.menuitem_cutimages 裁剪卡图
DataEditForm.menu_tools.menuitem_exportdata 导出所有卡片数据为zip
DataEditForm.menu_tools.menuitem_importmseimg 设置为MSE图片库
DataEditForm.menu_tools.menuitem_readimages 从图片读取卡片(&I)
DataEditForm.menu_tools.menuitem_readydk 从卡组读取卡片(&Y)
DataEditForm.menu_tools.menuitem_saveasmse 保存当前所有卡片到MSE存档
DataEditForm.menu_tools.menuitem_saveasmse_select 保存选中卡片到MSE存档
DataEditForm.menuitem_help.menuitem_about 关于
DataEditForm.menuitem_help.menuitem_checkupdate 检查更新
DataEditForm.menuitem_help.menuitem_github 软件源码
MainForm.menuitem_close 关闭当前
MainForm.menuitem_closeall 关闭所有
MainForm.menuitem_closeother 关闭其他
MainForm.menuitem_codeeditor CodeEditor
MainForm.menuitem_comp1 对比-卡片数据 1
MainForm.menuitem_comp2 对比-卡片数据 2
MainForm.menuitem_copyall 复制当前结果的所有卡片
MainForm.menuitem_copyselect 复制所选卡片
MainForm.menuitem_dataeditor DataEditor
MainForm.menuitem_file 文件(&F)
MainForm.menuitem_file.menuitem_comp1 设为对比的数据库1
MainForm.menuitem_file.menuitem_comp2 设为对比的数据库2
MainForm.menuitem_file.menuitem_copyall 复制所有结果卡片
MainForm.menuitem_file.menuitem_copyselect 复制选中卡片
MainForm.menuitem_file.menuitem_copyselectto 复制选中卡片到...
MainForm.menuitem_file.menuitem_copyto 复制所有结果卡片到...
MainForm.menuitem_file.menuitem_findluafunc 查找函数
MainForm.menuitem_file.menuitem_history 历史(&H)
MainForm.menuitem_file.menuitem_new 新建
MainForm.menuitem_file.menuitem_open 打开
MainForm.menuitem_file.menuitem_openLastDataBase 打开最后数据卡
MainForm.menuitem_file.menuitem_pastecards 粘贴卡片
MainForm.menuitem_file.menuitem_quit 退出
MainForm.menuitem_file.menuitem_save 保存
MainForm.menuitem_file.menuitem_shistory 脚本历史
MainForm.menuitem_windows 窗口(&W)
MainForm.menuitem_windows.menuitem_close 关闭当前
MainForm.menuitem_windows.menuitem_closeall 关闭所有
MainForm.menuitem_windows.menuitem_closeother 关闭其他
MainForm.menuitem_windows.menuitem_codeeditor 代码编辑
MainForm.menuitem_windows.menuitem_dataeditor 数据编辑
[DataEditorX]2.2.8.4[DataEditorX] [DataEditorX]2.2.8.4[DataEditorX]
[URL]https://github.com/247321453/DataEditorX/raw/master/win32/win32.zip[URL] [URL]https://github.com/247321453/DataEditorX/raw/master/win32/win32.zip[URL]
★文件关联 ★文件关联(File association)
.lua notepad++/sublime text/DataEditorX .lua notepad++/sublime text/DataEditorX
.cdb DataEditorX .cdb DataEditorX
★bug反馈 ★bug反馈(Feedback)
Email:247321453@qq.com Email:247321453@qq.com
提交版本前,请检查更新。 提交版本前,请检查更新。
...@@ -14,7 +14,10 @@ Email:247321453@qq.com ...@@ -14,7 +14,10 @@ Email:247321453@qq.com
错误提示文字:(弹出出错框,请按Ctrl+C,然后找地方粘贴) 错误提示文字:(弹出出错框,请按Ctrl+C,然后找地方粘贴)
详细描述:(卡片信息,杀毒软件,本程序目录等等) 详细描述:(卡片信息,杀毒软件,本程序目录等等)
★支持多语言化 Title:(DataEditorX+Version)
Content:Error Message
★支持多语言化(Language setting)
DataEditorX.exe.config DataEditorX.exe.config
<add key="language" value="chinese" />简体 <add key="language" value="chinese" />简体
<add key="language" value="english" />英文 <add key="language" value="english" />英文
......
No preview for this file type
0x0 卡片种族 0x0 卡片种族
0x1 战士族 0x1 战士族
0x2 魔法使 0x2 魔法
0x4 天使族 0x4 天使族
0x8 恶魔族 0x8 恶魔族
0x10 不死族 0x10 不死族
......
...@@ -3,19 +3,19 @@ F:\games\ygopro\cards.cdb ...@@ -3,19 +3,19 @@ F:\games\ygopro\cards.cdb
F:\games\[jp]cards.cdb F:\games\[jp]cards.cdb
F:\games\ygopro\p.zip.cdb F:\games\ygopro\p.zip.cdb
# script history # script history
F:\games\ygopro\script\c131182.lua
F:\games\ygopro\script\c168917.lua
F:\games\ygopro\script\c114932.lua
F:\games\ygopro\script\c269012.lua
F:\games\ygopro\script\c296499.lua
F:\games\ygopro\script\c218704.lua
F:\games\ygopro\script\c126218.lua
F:\games\ygopro\script\c102380.lua F:\games\ygopro\script\c102380.lua
F:\games\ygopro\script\c135598.lua
F:\games\ygopro\script\c176392.lua
F:\games\ygopro\script\c27551.lua F:\games\ygopro\script\c27551.lua
F:\games\ygopro\script\c168917.lua
F:\games\ygopro\script\c131182.lua
F:\games\ygopro\script\c255998.lua F:\games\ygopro\script\c255998.lua
F:\games\ygopro\script\c47198668.lua F:\games\ygopro\script\c47198668.lua
F:\games\ygopro\script\c4239451.lua F:\games\ygopro\script\c4239451.lua
F:\games\ygopro\script\c93368494.lua F:\games\ygopro\script\c93368494.lua
F:\games\ygopro\script\c50485594.lua F:\games\ygopro\script\c50485594.lua
\ No newline at end of file
F:\games\ygopro\script\c17857780.lua
F:\games\ygopro\script\c65518099.lua
F:\games\ygopro\script\c64496451.lua
F:\games\ygopro\script\c78835747.lua
F:\games\ygopro\script\c94415058.lua
F:\games\ygopro\script\c26270847.lua
F:\games\ygopro\script\c65025250.lua
\ No newline at end of file
CodeEditForm->CodeEditForm 脚本编辑器
CodeEditForm->menuitem_file 文件(&F)
CodeEditForm->menuitem_open 打开
CodeEditForm->menuitem_save 保存
CodeEditForm->menuitem_saveas 另存为
CodeEditForm->menuitem_quit 退出
CodeEditForm->menuitem_setting 设置(&S)
CodeEditForm->menuitem_showmap 显示缩略图
CodeEditForm->menuitem_showinput 显示文本框
CodeEditForm->menuitem_setcard 设置卡片库
CodeEditForm->menuitem_find 查找
CodeEditForm->menuitem_replace 替换
CodeEditForm->menuitem_help 帮助(&H)
CodeEditForm->menuitem_about 关于
\ No newline at end of file
DataEditForm->btn_add 添加(&A)
DataEditForm->btn_del 删除(&D)
DataEditForm->btn_lua 脚本(&L)
DataEditForm->btn_img 导入卡图(&I)
DataEditForm->btn_undo 撤销(&U)
DataEditForm->btn_mod 修改(&M)
DataEditForm->btn_PageDown 下一页
DataEditForm->btn_PageUp 上一页
DataEditForm->btn_reset 重置(&R)
DataEditForm->btn_serach 搜索(&S)
DataEditForm->DataEditForm DataEditorX
DataEditForm->lb_atkdef ATK/DEF
DataEditForm->lb_cardalias 同名卡
DataEditForm->lb_cardcode 卡片密码
DataEditForm->lb_categorys 效果种类
DataEditForm->lb_pleft_right 灵摆刻度
DataEditForm->lb_scripttext
DataEditForm->lb_tiptexts 提示文字
DataEditForm->lb_types 卡片种类
DataEditForm->lb2 /
DataEditForm->lb4 /
DataEditForm->lb5 /
DataEditForm->lv_cardlist0 密码
DataEditForm->lv_cardlist1 卡片名称
DataEditForm->menu_tools 功能(&T)
DataEditForm->menuitem_exportdata 导出所有卡片数据为zip
DataEditForm->menuitem_cancelTask 取消当前任务
DataEditForm->menuitem_compdb 压缩当前数据库
DataEditForm->menuitem_convertimage 批量导入卡图
DataEditForm->menuitem_importmseimg MSE图片库
DataEditForm->menuitem_openLastDataBase 最后打开的数据库
DataEditForm->menuitem_cutimages 裁剪列表卡片的图片
DataEditForm->menuitem_saveasmse_select 所选卡片导出MSE存档
DataEditForm->menuitem_saveasmse 当前所有卡片导出MSE存档
DataEditForm->menuitem_about 关于(&A)
DataEditForm->menuitem_checkupdate 检查更新
DataEditForm->menuitem_copyselectto 所选卡片复制到...
DataEditForm->menuitem_copyto 当前所有卡片复制到...
DataEditForm->menuitem_file 文件(&F)
DataEditForm->menuitem_github 源码主页
DataEditForm->menuitem_help 帮助(&H)
DataEditForm->menuitem_new 新建(&N)
DataEditForm->menuitem_open 打开(&O)
DataEditForm->menuitem_quit 退出(&Q)
DataEditForm->menuitem_readimages 从图像文件夹读取
DataEditForm->menuitem_readydk 从ydk文件读取
\ No newline at end of file
MainForm->menuitem_file 文件(&F)
MainForm->menuitem_new 新建(&N)
MainForm->menuitem_open 打开(&O)
MainForm->menuitem_save 保存(&S)
MainForm->menuitem_copyselect 复制所选卡片
MainForm->menuitem_copyall 复制当前结果的所有卡片
MainForm->menuitem_findluafunc 从源码获取Lua函数
MainForm->menuitem_pastecards 粘贴卡片
MainForm->menuitem_comp1 对比-卡片数据 1
MainForm->menuitem_comp2 对比-卡片数据 2
MainForm->menuitem_history 数据库历史记录(&H)
MainForm->menuitem_shistory 脚本历史记录
MainForm->menuitem_quit 退出(&Q)
MainForm->menuitem_windows 窗口(&W)
MainForm->menuitem_dataeditor DataEditor
MainForm->menuitem_codeeditor CodeEditor
MainForm->menuitem_closeall 关闭所有
MainForm->menuitem_closeother 关闭其他
MainForm->menuitem_close 关闭当前
\ No newline at end of file
CodeEditForm 脚本编辑
CodeEditForm.CodeEditForm 脚本编辑器
CodeEditForm.documentMap1 预览图
CodeEditForm.fctb
CodeEditForm.menuitem_about 关于
CodeEditForm.menuitem_file 文件(&F)
CodeEditForm.menuitem_file.menuitem_open 打开
CodeEditForm.menuitem_file.menuitem_quit 退出
CodeEditForm.menuitem_file.menuitem_save 保存
CodeEditForm.menuitem_file.menuitem_saveas 另存为
CodeEditForm.menuitem_find 查找
CodeEditForm.menuitem_help 帮助(&H)
CodeEditForm.menuitem_help.menuitem_about 关于(&A)
CodeEditForm.menuitem_open 打开
CodeEditForm.menuitem_quit 退出
CodeEditForm.menuitem_replace 替换
CodeEditForm.menuitem_save 保存
CodeEditForm.menuitem_saveas 另存为
CodeEditForm.menuitem_setcard 设置卡片库
CodeEditForm.menuitem_setting 设置(&S)
CodeEditForm.menuitem_setting.menuitem_find 查找
CodeEditForm.menuitem_setting.menuitem_replace 替换
CodeEditForm.menuitem_setting.menuitem_setcard 设置卡片库
CodeEditForm.menuitem_setting.menuitem_showinput 显示输入框
CodeEditForm.menuitem_setting.menuitem_showmap 显示预览图
CodeEditForm.menuitem_showinput 显示文本框
CodeEditForm.menuitem_showmap 显示缩略图
CodeEditForm.tb_input
DataEditForm 数据编辑
DataEditForm.btn_add 添加(&A)
DataEditForm.btn_del 删除(&D)
DataEditForm.btn_img 导入卡图(&I)
DataEditForm.btn_lua 脚本(&L)
DataEditForm.btn_mod 修改(&M)
DataEditForm.btn_PageDown 下一页
DataEditForm.btn_PageUp 上一页
DataEditForm.btn_reset 重置(&R)
DataEditForm.btn_serach 搜索(&S)
DataEditForm.btn_undo 撤销(&U)
DataEditForm.lb_atkdef ATK/DEF
DataEditForm.lb_cardalias 同名卡
DataEditForm.lb_cardcode 卡片密码
DataEditForm.lb_categorys 效果种类
DataEditForm.lb_pleft_right 灵摆刻度
DataEditForm.lb_scripttext
DataEditForm.lb_tiptexts 提示文字
DataEditForm.lb_types 卡片种类
DataEditForm.lb2 /
DataEditForm.lb4 /
DataEditForm.lb5 /
DataEditForm.lv_cardlist.0 密码
DataEditForm.lv_cardlist.1 卡片名称
DataEditForm.lv_cardlist0 密码
DataEditForm.lv_cardlist1 卡片名称
DataEditForm.menuitem_file 文件(&F)
DataEditForm.menuitem_help 帮助(&H)
DataEditForm.menuitem_new 新建(&N)
DataEditForm.menuitem_open 打开(&O)
DataEditForm.menuitem_openLastDataBase 最后打开的数据库
DataEditForm.menuitem_quit 退出(&Q)
DataEditForm.menu_tools 功能(&T)
DataEditForm.menu_tools.menuitem_cancelTask 取消当前任务
DataEditForm.menu_tools.menuitem_compdb 压缩数据库
DataEditForm.menu_tools.menuitem_convertimage 批量导入卡图
DataEditForm.menu_tools.menuitem_cutimages 裁剪卡图
DataEditForm.menu_tools.menuitem_exportdata 导出所有卡片数据为zip
DataEditForm.menu_tools.menuitem_importmseimg 设置为MSE图片库
DataEditForm.menu_tools.menuitem_readimages 从图片读取卡片(&I)
DataEditForm.menu_tools.menuitem_readydk 从卡组读取卡片(&Y)
DataEditForm.menu_tools.menuitem_saveasmse 保存当前所有卡片到MSE存档
DataEditForm.menu_tools.menuitem_saveasmse_select 保存选中卡片到MSE存档
DataEditForm.menuitem_help.menuitem_about 关于
DataEditForm.menuitem_help.menuitem_checkupdate 检查更新
DataEditForm.menuitem_help.menuitem_github 软件源码
MainForm.menuitem_close 关闭当前
MainForm.menuitem_closeall 关闭所有
MainForm.menuitem_closeother 关闭其他
MainForm.menuitem_codeeditor CodeEditor
MainForm.menuitem_comp1 对比-卡片数据 1
MainForm.menuitem_comp2 对比-卡片数据 2
MainForm.menuitem_copyall 复制当前结果的所有卡片
MainForm.menuitem_copyselect 复制所选卡片
MainForm.menuitem_dataeditor DataEditor
MainForm.menuitem_file 文件(&F)
MainForm.menuitem_file.menuitem_comp1 设为对比的数据库1
MainForm.menuitem_file.menuitem_comp2 设为对比的数据库2
MainForm.menuitem_file.menuitem_copyall 复制所有结果卡片
MainForm.menuitem_file.menuitem_copyselect 复制选中卡片
MainForm.menuitem_file.menuitem_copyselectto 复制选中卡片到...
MainForm.menuitem_file.menuitem_copyto 复制所有结果卡片到...
MainForm.menuitem_file.menuitem_findluafunc 查找函数
MainForm.menuitem_file.menuitem_history 历史(&H)
MainForm.menuitem_file.menuitem_new 新建
MainForm.menuitem_file.menuitem_open 打开
MainForm.menuitem_file.menuitem_openLastDataBase 打开最后数据卡
MainForm.menuitem_file.menuitem_pastecards 粘贴卡片
MainForm.menuitem_file.menuitem_quit 退出
MainForm.menuitem_file.menuitem_save 保存
MainForm.menuitem_file.menuitem_shistory 脚本历史
MainForm.menuitem_windows 窗口(&W)
MainForm.menuitem_windows.menuitem_close 关闭当前
MainForm.menuitem_windows.menuitem_closeall 关闭所有
MainForm.menuitem_windows.menuitem_closeother 关闭其他
MainForm.menuitem_windows.menuitem_codeeditor 代码编辑
MainForm.menuitem_windows.menuitem_dataeditor 数据编辑
[DataEditorX]2.2.8.4[DataEditorX] [DataEditorX]2.2.8.4[DataEditorX]
[URL]https://github.com/247321453/DataEditorX/raw/master/win32/win32.zip[URL] [URL]https://github.com/247321453/DataEditorX/raw/master/win32/win32.zip[URL]
★文件关联 ★文件关联(File association)
.lua notepad++/sublime text/DataEditorX .lua notepad++/sublime text/DataEditorX
.cdb DataEditorX .cdb DataEditorX
★bug反馈 ★bug反馈(Feedback)
Email:247321453@qq.com Email:247321453@qq.com
提交版本前,请检查更新。 提交版本前,请检查更新。
...@@ -14,7 +14,10 @@ Email:247321453@qq.com ...@@ -14,7 +14,10 @@ Email:247321453@qq.com
错误提示文字:(弹出出错框,请按Ctrl+C,然后找地方粘贴) 错误提示文字:(弹出出错框,请按Ctrl+C,然后找地方粘贴)
详细描述:(卡片信息,杀毒软件,本程序目录等等) 详细描述:(卡片信息,杀毒软件,本程序目录等等)
★支持多语言化 Title:(DataEditorX+Version)
Content:Error Message
★支持多语言化(Language setting)
DataEditorX.exe.config DataEditorX.exe.config
<add key="language" value="chinese" />简体 <add key="language" value="chinese" />简体
<add key="language" value="english" />英文 <add key="language" value="english" />英文
......
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