Commit 96d6ddde authored by keyongyu's avatar keyongyu

1.5.3.0

parent 1c6b771b
...@@ -13,437 +13,456 @@ ...@@ -13,437 +13,456 @@
namespace DataEditorX.Core namespace DataEditorX.Core
{ {
/// <summary> /// <summary>
/// Description of SQLite. /// Description of SQLite.
/// </summary> /// </summary>
public static class DataBase public static class DataBase
{ {
#region 默认 #region 默认
static string defaultSQL; static string defaultSQL;
static string defaultTableSQL; static string defaultTableSQL;
static DataBase() static DataBase()
{ {
defaultSQL = defaultSQL =
"SELECT datas.*,texts.* FROM datas,texts WHERE datas.id=texts.id "; "SELECT datas.*,texts.* FROM datas,texts WHERE datas.id=texts.id ";
StringBuilder st = new StringBuilder(); StringBuilder st = new StringBuilder();
st.Append(@"CREATE TABLE texts(id integer primary key,name text,desc text"); st.Append(@"CREATE TABLE texts(id integer primary key,name text,desc text");
for ( int i = 1; i <= 16; i++ ) for ( int i = 1; i <= 16; i++ )
{ {
st.Append(",str"); st.Append(",str");
st.Append(i.ToString()); st.Append(i.ToString());
st.Append(" text"); st.Append(" text");
} }
st.Append(");"); st.Append(");");
st.Append(@"CREATE TABLE datas("); st.Append(@"CREATE TABLE datas(");
st.Append("id integer primary key,ot integer,alias integer,"); st.Append("id integer primary key,ot integer,alias integer,");
st.Append("setcode integer,type integer,atk integer,def integer,"); st.Append("setcode integer,type integer,atk integer,def integer,");
st.Append("level integer,race integer,attribute integer,category integer) "); st.Append("level integer,race integer,attribute integer,category integer) ");
defaultTableSQL=st.ToString(); defaultTableSQL=st.ToString();
st.Remove(0,st.Length); st.Remove(0,st.Length);
st=null; st=null;
} }
#endregion #endregion
#region 创建数据库 #region 创建数据库
/// <summary> /// <summary>
/// 创建数据库 /// 创建数据库
/// </summary> /// </summary>
/// <param name="Db">新数据库路径</param> /// <param name="Db">新数据库路径</param>
public static bool Create(string Db) public static bool Create(string Db)
{ {
if ( File.Exists(Db) ) if ( File.Exists(Db) )
File.Delete(Db); File.Delete(Db);
try{ try{
SQLiteConnection.CreateFile(Db); SQLiteConnection.CreateFile(Db);
Command(Db, defaultTableSQL); Command(Db, defaultTableSQL);
} }
catch catch
{ {
return false; return false;
} }
return true; return true;
} }
public static bool CheckTable(string db) public static bool CheckTable(string db)
{ {
try{ try{
Command(db, defaultTableSQL); Command(db, defaultTableSQL);
} }
catch catch
{ {
return false; return false;
} }
return true; return true;
} }
#endregion #endregion
#region 执行sql语句 #region 执行sql语句
/// <summary> /// <summary>
/// 执行sql语句 /// 执行sql语句
/// </summary> /// </summary>
/// <param name="DB">数据库</param> /// <param name="DB">数据库</param>
/// <param name="SQLs">sql语句</param> /// <param name="SQLs">sql语句</param>
/// <returns>返回影响行数</returns> /// <returns>返回影响行数</returns>
public static int Command(string DB, params string[] SQLs) public static int Command(string DB, params string[] SQLs)
{ {
int result = 0; int result = 0;
if ( File.Exists(DB) && SQLs != null ) if ( File.Exists(DB) && SQLs != null )
{ {
using ( SQLiteConnection con = new SQLiteConnection(@"Data Source=" + DB) ) using ( SQLiteConnection con = new SQLiteConnection(@"Data Source=" + DB) )
{ {
con.Open(); con.Open();
using ( SQLiteTransaction trans = con.BeginTransaction() ) using ( SQLiteTransaction trans = con.BeginTransaction() )
{ {
try try
{ {
using ( SQLiteCommand cmd = new SQLiteCommand(con) ) using ( SQLiteCommand cmd = new SQLiteCommand(con) )
{ {
foreach ( string SQLstr in SQLs ) foreach ( string SQLstr in SQLs )
{ {
cmd.CommandText = SQLstr; cmd.CommandText = SQLstr;
result += cmd.ExecuteNonQuery(); result += cmd.ExecuteNonQuery();
} }
} }
} }
catch catch
{ {
trans.Rollback(); trans.Rollback();
result = -1; result = -1;
} }
finally finally
{ {
trans.Commit(); trans.Commit();
} }
} }
con.Close(); con.Close();
} }
} }
return result; return result;
} }
#endregion #endregion
#region 数据读取 #region 数据读取
#region 根据SQL读取 #region 根据SQL读取
static Card ReadCard(SQLiteDataReader reader,bool reNewLine) static Card ReadCard(SQLiteDataReader reader,bool reNewLine)
{ {
Card c = new Card(0); Card c = new Card(0);
c.id = reader.GetInt64(0); c.id = reader.GetInt64(0);
c.ot = reader.GetInt32(1); c.ot = reader.GetInt32(1);
c.alias = reader.GetInt64(2); c.alias = reader.GetInt64(2);
c.setcode = reader.GetInt64(3); c.setcode = reader.GetInt64(3);
c.type = reader.GetInt64(4); c.type = reader.GetInt64(4);
c.atk = reader.GetInt32(5); c.atk = reader.GetInt32(5);
c.def = reader.GetInt32(6); c.def = reader.GetInt32(6);
c.level = reader.GetInt64(7); c.level = reader.GetInt64(7);
c.race = reader.GetInt64(8); c.race = reader.GetInt64(8);
c.attribute = reader.GetInt32(9); c.attribute = reader.GetInt32(9);
c.category = reader.GetInt64(10); c.category = reader.GetInt64(10);
c.name = reader.GetString(12); c.name = reader.GetString(12);
c.desc = reader.GetString(13); c.desc = reader.GetString(13);
if(reNewLine) if(reNewLine)
c.desc=Retext(c.desc); c.desc=Retext(c.desc);
string temp = null; string temp = null;
for ( int i = 0; i < 0x10; i++ ) for ( int i = 0; i < 0x10; i++ )
{ {
temp = reader.GetString(14 + i); temp = reader.GetString(14 + i);
c.str[i]= ( temp == null ) ? "":temp; c.str[i]= ( temp == null ) ? "":temp;
} }
return c; return c;
} }
static string Retext(string text) static string Retext(string text)
{ {
StringBuilder sr = new StringBuilder(text); StringBuilder sr = new StringBuilder(text);
sr.Replace("\r\n", "\n"); sr.Replace("\r\n", "\n");
sr.Replace("\n", Environment.NewLine);//换为当前系统的换行符 sr.Replace("\n", Environment.NewLine);//换为当前系统的换行符
text = sr.ToString(); text = sr.ToString();
sr.Remove(0, sr.Length); sr.Remove(0, sr.Length);
return text; return text;
} }
/// <summary> /// <summary>
/// 根据密码集合,读取数据 /// 根据密码集合,读取数据
/// </summary> /// </summary>
/// <param name="DB">数据库</param> /// <param name="DB">数据库</param>
/// <param name="reNewLine">调整换行符</param> /// <param name="reNewLine">调整换行符</param>
/// <param name="SQLs">SQL/密码语句集合集合</param> /// <param name="SQLs">SQL/密码语句集合集合</param>
public static Card[] Read(string DB,bool reNewLine, params string[] SQLs) public static Card[] Read(string DB,bool reNewLine, params string[] SQLs)
{ {
List<Card> list=new List<Card>(); List<Card> list=new List<Card>();
string SQLstr = ""; string SQLstr = "";
if ( File.Exists(DB) && SQLs != null ) if ( File.Exists(DB) && SQLs != null )
{ {
using ( SQLiteConnection sqliteconn = new SQLiteConnection(@"Data Source=" + DB) ) using ( SQLiteConnection sqliteconn = new SQLiteConnection(@"Data Source=" + DB) )
{ {
sqliteconn.Open(); sqliteconn.Open();
using ( SQLiteTransaction trans = sqliteconn.BeginTransaction() ) using ( SQLiteTransaction trans = sqliteconn.BeginTransaction() )
{ {
using ( SQLiteCommand sqlitecommand = new SQLiteCommand(sqliteconn) ) using ( SQLiteCommand sqlitecommand = new SQLiteCommand(sqliteconn) )
{ {
foreach ( string str in SQLs ) foreach ( string str in SQLs )
{ {
if ( string.IsNullOrEmpty(str) ) if ( string.IsNullOrEmpty(str) )
SQLstr = defaultSQL; SQLstr = defaultSQL;
else if ( str.Length < 20 ) else if ( str.Length < 20 )
SQLstr = defaultSQL + " and datas.id=" + str; SQLstr = defaultSQL + " and datas.id=" + str;
else else
SQLstr = str; SQLstr = str;
sqlitecommand.CommandText = SQLstr; sqlitecommand.CommandText = SQLstr;
using ( SQLiteDataReader reader = sqlitecommand.ExecuteReader() ) using ( SQLiteDataReader reader = sqlitecommand.ExecuteReader() )
{ {
while ( reader.Read() ) while ( reader.Read() )
{ {
list.Add(ReadCard(reader,reNewLine)); list.Add(ReadCard(reader,reNewLine));
} }
reader.Close(); reader.Close();
} }
} }
} }
trans.Commit(); trans.Commit();
} }
sqliteconn.Close(); sqliteconn.Close();
} }
} }
if(list.Count==0) if(list.Count==0)
return null; return null;
return list.ToArray(); return list.ToArray();
} }
#endregion #endregion
#region 根据文件读取数据库 #region 根据文件读取数据库
public static Card[] ReadYdk(string dbfile, string ydkfile) public static Card[] ReadYdk(string dbfile, string ydkfile)
{ {
if ( File.Exists(dbfile) ) if ( File.Exists(dbfile) )
{ {
string[] ids = ReadYDK(ydkfile); string[] ids = ReadYDK(ydkfile);
if(ids!=null) if(ids!=null)
return DataBase.Read(dbfile, true, ids); return DataBase.Read(dbfile, true, ids);
} }
return null; return null;
} }
/// <summary> /// <summary>
/// 读取ydk文件为密码数组 /// 读取ydk文件为密码数组
/// </summary> /// </summary>
/// <param name="file">ydk文件</param> /// <param name="file">ydk文件</param>
/// <returns>密码数组</returns> /// <returns>密码数组</returns>
static string[] ReadYDK(string ydkfile) static string[] ReadYDK(string ydkfile)
{ {
string str; string str;
List<string> IDs = new List<string>(); List<string> IDs = new List<string>();
if ( File.Exists(ydkfile) ) if ( File.Exists(ydkfile) )
{ {
using ( FileStream f = new FileStream(ydkfile, FileMode.Open, FileAccess.Read) ) using ( FileStream f = new FileStream(ydkfile, FileMode.Open, FileAccess.Read) )
{ {
StreamReader sr = new StreamReader(f, Encoding.Default); StreamReader sr = new StreamReader(f, Encoding.Default);
str = sr.ReadLine(); str = sr.ReadLine();
while ( str != null ) while ( str != null )
{ {
if ( !str.StartsWith("!") && !str.StartsWith("#") &&str.Length>0) if ( !str.StartsWith("!") && !str.StartsWith("#") &&str.Length>0)
{ {
if ( IDs.IndexOf(str) < 0 ) if ( IDs.IndexOf(str) < 0 )
IDs.Add(str); IDs.Add(str);
} }
str = sr.ReadLine(); str = sr.ReadLine();
} }
sr.Close(); sr.Close();
f.Close(); f.Close();
} }
} }
if(IDs.Count==0) if(IDs.Count==0)
return null; return null;
return IDs.ToArray(); return IDs.ToArray();
} }
#endregion #endregion
#region 根据图像读取数据库 #region 根据图像读取数据库
public static Card[] ReadImage(string dbfile, string path) public static Card[] ReadImage(string dbfile, string path)
{ {
if ( File.Exists(dbfile) ) if ( File.Exists(dbfile) )
{ {
string[] files = Directory.GetFiles(path, "*.jpg"); string[] files = Directory.GetFiles(path, "*.jpg");
int n = files.Length; int n = files.Length;
for ( int i = 0; i < n; i++ ) for ( int i = 0; i < n; i++ )
{ {
files[i] = Path.GetFileNameWithoutExtension(files[i]); files[i] = Path.GetFileNameWithoutExtension(files[i]);
} }
return DataBase.Read(dbfile, true,files); return DataBase.Read(dbfile, true,files);
} }
return null; return null;
} }
#endregion #endregion
#endregion #endregion
#region 复制数据库 #region 复制数据库
/// <summary> /// <summary>
/// 复制数据库 /// 复制数据库
/// </summary> /// </summary>
/// <param name="DB">复制到的数据库</param> /// <param name="DB">复制到的数据库</param>
/// <param name="cards">卡片集合</param> /// <param name="cards">卡片集合</param>
/// <param name="ignore">是否忽略存在</param> /// <param name="ignore">是否忽略存在</param>
/// <returns>更新数x2</returns> /// <returns>更新数x2</returns>
public static int CopyDB(string DB, bool ignore,params Card[] cards) public static int CopyDB(string DB, bool ignore,params Card[] cards)
{ {
int result = 0; int result = 0;
if ( File.Exists(DB) &&cards!=null) if ( File.Exists(DB) &&cards!=null)
{ {
using ( SQLiteConnection con = new SQLiteConnection(@"Data Source=" + DB) ) using ( SQLiteConnection con = new SQLiteConnection(@"Data Source=" + DB) )
{ {
con.Open(); con.Open();
using ( SQLiteTransaction trans = con.BeginTransaction() ) using ( SQLiteTransaction trans = con.BeginTransaction() )
{ {
using ( SQLiteCommand cmd = new SQLiteCommand(con) ) using ( SQLiteCommand cmd = new SQLiteCommand(con) )
{ {
foreach ( Card c in cards ) foreach ( Card c in cards )
{ {
cmd.CommandText = DataBase.GetInsertSQL(c, ignore); cmd.CommandText = DataBase.GetInsertSQL(c, ignore);
result += cmd.ExecuteNonQuery(); result += cmd.ExecuteNonQuery();
} }
} }
trans.Commit(); trans.Commit();
} }
con.Close(); con.Close();
} }
} }
return result; return result;
} }
#endregion #endregion
#region SQL语句 public static void Compression(string db)
#region 查询 {
static string toInt(long l) if (File.Exists(db))
{ {
unchecked{ using ( SQLiteConnection con = new SQLiteConnection(@"Data Source=" + db) )
return ((int)l).ToString(); {
} con.Open();
} using(SQLiteCommand cmd = new SQLiteCommand(con) )
public static string GetSelectSQL(Card c) {
{ cmd.CommandText="vacuum";
StringBuilder sb=new StringBuilder(); cmd.ExecuteNonQuery();
sb.Append("SELECT datas.*,texts.* FROM datas,texts WHERE datas.id=texts.id "); }
if(!string.IsNullOrEmpty(c.name)) con.Close();
sb.Append(" and texts.name like '%"+c.name+"%' "); }
if(!string.IsNullOrEmpty(c.desc)) }
sb.Append(" and texts.desc like '%"+c.desc+"%' ");
if(c.ot>0) }
sb.Append(" and datas.ot & "+c.ot.ToString()+" = "+c.ot.ToString());
if(c.attribute>0)
sb.Append(" and datas.attribute & "+c.attribute.ToString()+" = "+c.attribute.ToString()); #region SQL语句
if(c.level>0) #region 查询
sb.Append(" and datas.level & "+toInt(c.level)+" = "+toInt(c.level)); static string toInt(long l)
if(c.race>0) {
sb.Append(" and datas.race & "+toInt(c.race)+" = "+toInt(c.race)); unchecked{
if(c.type>0) return ((int)l).ToString();
sb.Append(" and datas.type & "+toInt(c.type)+" = "+toInt(c.type)); }
if(c.category>0) }
sb.Append(" and datas.category & "+toInt(c.category)+" = "+toInt(c.category)); public static string GetSelectSQL(Card c)
{
StringBuilder sb=new StringBuilder();
sb.Append("SELECT datas.*,texts.* FROM datas,texts WHERE datas.id=texts.id ");
if(!string.IsNullOrEmpty(c.name))
sb.Append(" and texts.name like '%"+c.name+"%' ");
if(!string.IsNullOrEmpty(c.desc))
sb.Append(" and texts.desc like '%"+c.desc+"%' ");
if(c.ot>0)
sb.Append(" and datas.ot & "+c.ot.ToString()+" = "+c.ot.ToString());
if(c.attribute>0)
sb.Append(" and datas.attribute & "+c.attribute.ToString()+" = "+c.attribute.ToString());
if(c.level>0)
sb.Append(" and datas.level & "+toInt(c.level)+" = "+toInt(c.level));
if(c.race>0)
sb.Append(" and datas.race & "+toInt(c.race)+" = "+toInt(c.race));
if(c.type>0)
sb.Append(" and datas.type & "+toInt(c.type)+" = "+toInt(c.type));
if(c.category>0)
sb.Append(" and datas.category & "+toInt(c.category)+" = "+toInt(c.category));
if(c.id>0 && c.alias>0) if(c.id>0 && c.alias>0)
sb.Append(" and datas.id BETWEEN "+c.alias.ToString()+" and "+c.id.ToString()); sb.Append(" and datas.id BETWEEN "+c.alias.ToString()+" and "+c.id.ToString());
else if(c.id>0) else if(c.id>0)
{ {
sb.Append(" and ( datas.id="+c.id.ToString()+" or datas.alias="+c.id.ToString()+") "); sb.Append(" and ( datas.id="+c.id.ToString()+" or datas.alias="+c.id.ToString()+") ");
} }
else if(c.alias>0) else if(c.alias>0)
sb.Append(" and datas.alias= "+c.alias.ToString()); sb.Append(" and datas.alias= "+c.alias.ToString());
return sb.ToString(); return sb.ToString();
} }
#endregion #endregion
#region 插入 #region 插入
/// <summary> /// <summary>
/// 转换为插入语句 /// 转换为插入语句
/// </summary> /// </summary>
/// <param name="c">卡片数据</param> /// <param name="c">卡片数据</param>
/// <returns>SQL语句</returns> /// <returns>SQL语句</returns>
public static string GetInsertSQL(Card c, bool ignore) public static string GetInsertSQL(Card c, bool ignore)
{ {
StringBuilder st = new StringBuilder(); StringBuilder st = new StringBuilder();
if(ignore) if(ignore)
st.Append("INSERT or ignore into datas values("); st.Append("INSERT or ignore into datas values(");
else else
st.Append("INSERT or replace into datas values("); st.Append("INSERT or replace into datas values(");
st.Append(c.id.ToString()); st.Append(","); st.Append(c.id.ToString()); st.Append(",");
st.Append(c.ot.ToString()); st.Append(","); st.Append(c.ot.ToString()); st.Append(",");
st.Append(c.alias.ToString()); st.Append(","); st.Append(c.alias.ToString()); st.Append(",");
st.Append(c.setcode.ToString()); st.Append(","); st.Append(c.setcode.ToString()); st.Append(",");
st.Append(c.type.ToString()); st.Append(","); st.Append(c.type.ToString()); st.Append(",");
st.Append(c.atk.ToString()); ; st.Append(","); st.Append(c.atk.ToString()); ; st.Append(",");
st.Append(c.def.ToString()); st.Append(","); st.Append(c.def.ToString()); st.Append(",");
st.Append(c.level.ToString()); st.Append(","); st.Append(c.level.ToString()); st.Append(",");
st.Append(c.race.ToString()); st.Append(","); st.Append(c.race.ToString()); st.Append(",");
st.Append(c.attribute.ToString()); st.Append(","); st.Append(c.attribute.ToString()); st.Append(",");
st.Append(c.category.ToString()); st.Append(")"); st.Append(c.category.ToString()); st.Append(")");
if(ignore) if(ignore)
st.Append(";INSERT or ignore into texts values("); st.Append(";INSERT or ignore into texts values(");
else else
st.Append(";INSERT or replace into texts values("); st.Append(";INSERT or replace into texts values(");
st.Append(c.id.ToString()); st.Append(",'"); st.Append(c.id.ToString()); st.Append(",'");
st.Append(c.name.Replace("'", "''")); st.Append("','"); st.Append(c.name.Replace("'", "''")); st.Append("','");
st.Append(c.desc.Replace("'", "''")); st.Append(c.desc.Replace("'", "''"));
for ( int i = 0; i < 0x10; i++ ) for ( int i = 0; i < 0x10; i++ )
{ {
st.Append("','"); st.Append(c.str[i].Replace("'", "''")); st.Append("','"); st.Append(c.str[i].Replace("'", "''"));
} }
st.Append("');"); st.Append("');");
string sql = st.ToString(); string sql = st.ToString();
st = null; st = null;
return sql; return sql;
} }
#endregion #endregion
#region 更新 #region 更新
/// <summary> /// <summary>
/// 转换为更新语句 /// 转换为更新语句
/// </summary> /// </summary>
/// <param name="c">卡片数据</param> /// <param name="c">卡片数据</param>
/// <returns>SQL语句</returns> /// <returns>SQL语句</returns>
public static string GetUpdateSQL(Card c) public static string GetUpdateSQL(Card c)
{ {
StringBuilder st = new StringBuilder(); StringBuilder st = new StringBuilder();
st.Append("update datas set ot="); st.Append(c.ot.ToString()); st.Append("update datas set ot="); st.Append(c.ot.ToString());
st.Append(",alias="); st.Append(c.alias.ToString()); st.Append(",alias="); st.Append(c.alias.ToString());
st.Append(",setcode="); st.Append(c.setcode.ToString()); st.Append(",setcode="); st.Append(c.setcode.ToString());
st.Append(",type="); st.Append(c.type.ToString()); st.Append(",type="); st.Append(c.type.ToString());
st.Append(",atk="); st.Append(c.atk.ToString()); st.Append(",atk="); st.Append(c.atk.ToString());
st.Append(",def="); st.Append(c.def.ToString()); st.Append(",def="); st.Append(c.def.ToString());
st.Append(",level="); st.Append(c.level.ToString()); st.Append(",level="); st.Append(c.level.ToString());
st.Append(",race="); st.Append(c.race.ToString()); st.Append(",race="); st.Append(c.race.ToString());
st.Append(",attribute="); st.Append(c.attribute.ToString()); st.Append(",attribute="); st.Append(c.attribute.ToString());
st.Append(",category="); st.Append(c.category.ToString()); st.Append(",category="); st.Append(c.category.ToString());
st.Append(" where id="); st.Append(c.id.ToString()); st.Append(" where id="); st.Append(c.id.ToString());
st.Append("; update texts set name='"); st.Append(c.name.Replace("'", "''")); st.Append("; update texts set name='"); st.Append(c.name.Replace("'", "''"));
st.Append("',desc='"); st.Append(c.desc.Replace("'", "''")); st.Append("', "); st.Append("',desc='"); st.Append(c.desc.Replace("'", "''")); st.Append("', ");
for ( int i = 0; i < 0x10; i++ ) for ( int i = 0; i < 0x10; i++ )
{ {
st.Append("str"); st.Append(( i + 1 ).ToString()); st.Append("='"); st.Append("str"); st.Append(( i + 1 ).ToString()); st.Append("='");
st.Append(c.str[i].Replace("'", "''")); st.Append(c.str[i].Replace("'", "''"));
if ( i < 15 ) if ( i < 15 )
{ {
st.Append("',"); st.Append("',");
} }
} }
st.Append("' where id="); st.Append(c.id.ToString()); st.Append("' where id="); st.Append(c.id.ToString());
st.Append(";"); st.Append(";");
string sql = st.ToString(); string sql = st.ToString();
st = null; st = null;
return sql; return sql;
} }
#endregion #endregion
#region 删除 #region 删除
/// <summary> /// <summary>
/// 转换删除语句 /// 转换删除语句
/// </summary> /// </summary>
/// <param name="c">卡片密码</param> /// <param name="c">卡片密码</param>
/// <returns>SQL语句</returns> /// <returns>SQL语句</returns>
public static string GetDeleteSQL(Card c) public static string GetDeleteSQL(Card c)
{ {
string id = c.id.ToString(); string id = c.id.ToString();
return "Delete from datas where id=" + id + ";Delete from texts where id=" + id + ";"; return "Delete from datas where id=" + id + ";Delete from texts where id=" + id + ";";
} }
#endregion #endregion
#endregion #endregion
} }
} }
...@@ -46,6 +46,7 @@ private void InitializeComponent() ...@@ -46,6 +46,7 @@ private void InitializeComponent()
this.menuitem_saveasmse = new System.Windows.Forms.ToolStripMenuItem(); this.menuitem_saveasmse = new System.Windows.Forms.ToolStripMenuItem();
this.tsep4 = new System.Windows.Forms.ToolStripSeparator(); this.tsep4 = new System.Windows.Forms.ToolStripSeparator();
this.menuitem_cutimages = new System.Windows.Forms.ToolStripMenuItem(); this.menuitem_cutimages = new System.Windows.Forms.ToolStripMenuItem();
this.menuitem_convertimage = new System.Windows.Forms.ToolStripMenuItem();
this.tsep1 = new System.Windows.Forms.ToolStripSeparator(); this.tsep1 = new System.Windows.Forms.ToolStripSeparator();
this.menuitem_readydk = new System.Windows.Forms.ToolStripMenuItem(); this.menuitem_readydk = new System.Windows.Forms.ToolStripMenuItem();
this.menuitem_readimages = new System.Windows.Forms.ToolStripMenuItem(); this.menuitem_readimages = new System.Windows.Forms.ToolStripMenuItem();
...@@ -107,7 +108,8 @@ private void InitializeComponent() ...@@ -107,7 +108,8 @@ private void InitializeComponent()
this.lb_setcode = new System.Windows.Forms.Label(); this.lb_setcode = new System.Windows.Forms.Label();
this.btn_img = new System.Windows.Forms.Button(); this.btn_img = new System.Windows.Forms.Button();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.menuitem_convertimage = new System.Windows.Forms.ToolStripMenuItem(); this.tsep5 = new System.Windows.Forms.ToolStripSeparator();
this.menuitem_compdb = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
...@@ -127,6 +129,8 @@ private void InitializeComponent() ...@@ -127,6 +129,8 @@ private void InitializeComponent()
this.menuitem_file.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.menuitem_file.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.menuitem_open, this.menuitem_open,
this.menuitem_new, this.menuitem_new,
this.menuitem_compdb,
this.tsep5,
this.menuitem_copyselectto, this.menuitem_copyselectto,
this.menuitem_saveasmse_select, this.menuitem_saveasmse_select,
this.menuitem_copyto, this.menuitem_copyto,
...@@ -203,6 +207,13 @@ private void InitializeComponent() ...@@ -203,6 +207,13 @@ private void InitializeComponent()
this.menuitem_cutimages.Text = "Cut Images"; this.menuitem_cutimages.Text = "Cut Images";
this.menuitem_cutimages.Click += new System.EventHandler(this.Menuitem_cutimagesClick); this.menuitem_cutimages.Click += new System.EventHandler(this.Menuitem_cutimagesClick);
// //
// menuitem_convertimage
//
this.menuitem_convertimage.Name = "menuitem_convertimage";
this.menuitem_convertimage.Size = new System.Drawing.Size(232, 22);
this.menuitem_convertimage.Text = "Inport Images";
this.menuitem_convertimage.Click += new System.EventHandler(this.Menuitem_convertimageClick);
//
// tsep1 // tsep1
// //
this.tsep1.Name = "tsep1"; this.tsep1.Name = "tsep1";
...@@ -775,12 +786,17 @@ private void InitializeComponent() ...@@ -775,12 +786,17 @@ private void InitializeComponent()
this.btn_img.UseVisualStyleBackColor = true; this.btn_img.UseVisualStyleBackColor = true;
this.btn_img.Click += new System.EventHandler(this.Btn_imgClick); this.btn_img.Click += new System.EventHandler(this.Btn_imgClick);
// //
// menuitem_convertimage // tsep5
// //
this.menuitem_convertimage.Name = "menuitem_convertimage"; this.tsep5.Name = "tsep5";
this.menuitem_convertimage.Size = new System.Drawing.Size(232, 22); this.tsep5.Size = new System.Drawing.Size(229, 6);
this.menuitem_convertimage.Text = "Convert Images"; //
this.menuitem_convertimage.Click += new System.EventHandler(this.Menuitem_convertimageClick); // menuitem_compdb
//
this.menuitem_compdb.Name = "menuitem_compdb";
this.menuitem_compdb.Size = new System.Drawing.Size(232, 22);
this.menuitem_compdb.Text = "Compression DataBase";
this.menuitem_compdb.Click += new System.EventHandler(this.Menuitem_compdbClick);
// //
// DataEditForm // DataEditForm
// //
...@@ -847,6 +863,8 @@ private void InitializeComponent() ...@@ -847,6 +863,8 @@ private void InitializeComponent()
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
} }
private System.Windows.Forms.ToolStripSeparator tsep5;
private System.Windows.Forms.ToolStripMenuItem menuitem_compdb;
private System.Windows.Forms.ToolStripMenuItem menuitem_convertimage; private System.Windows.Forms.ToolStripMenuItem menuitem_convertimage;
private System.Windows.Forms.ToolTip toolTip1; private System.Windows.Forms.ToolTip toolTip1;
private System.Windows.Forms.ToolStripSeparator tsep2; private System.Windows.Forms.ToolStripSeparator tsep2;
......
...@@ -983,7 +983,29 @@ void Menuitem_newClick(object sender, EventArgs e) ...@@ -983,7 +983,29 @@ void Menuitem_newClick(object sender, EventArgs e)
} }
} }
} }
void Menuitem_compdbClick(object sender, EventArgs e)
{
if(!Check())
return;
DataBase.Compression(nowCdbFile);
MyMsg.Show(LMSG.CompDBOK);
}
void Menuitem_convertimageClick(object sender, EventArgs e)
{
if(isRun())
return;
using(FolderBrowserDialog fdlg=new FolderBrowserDialog())
{
fdlg.Description= LANG.GetMsg(LMSG.SelectImagePath);
if(fdlg.ShowDialog()==DialogResult.OK)
{
bool isreplace=MyMsg.Question(LMSG.IfReplaceExistingImage);
TaskHelper.SetTask(MyTask.ConvertImages, null,
fdlg.SelectedPath, GAMEPATH, isreplace.ToString());
Run(LANG.GetMsg(LMSG.ConvertImage));
}
}
}
void Menuitem_readydkClick(object sender, EventArgs e) void Menuitem_readydkClick(object sender, EventArgs e)
{ {
if(!Check()) if(!Check())
...@@ -1281,23 +1303,5 @@ void Menuitem_saveasmseClick(object sender, EventArgs e) ...@@ -1281,23 +1303,5 @@ void Menuitem_saveasmseClick(object sender, EventArgs e)
} }
#endregion #endregion
#region Convert images
void Menuitem_convertimageClick(object sender, EventArgs e)
{
if(isRun())
return;
using(FolderBrowserDialog fdlg=new FolderBrowserDialog())
{
fdlg.Description= LANG.GetMsg(LMSG.SelectImagePath);
if(fdlg.ShowDialog()==DialogResult.OK)
{
bool isreplace=MyMsg.Question(LMSG.IfReplaceExistingImage);
TaskHelper.SetTask(MyTask.ConvertImages, null,
fdlg.SelectedPath, GAMEPATH, isreplace.ToString());
Run(LANG.GetMsg(LMSG.ConvertImage));
}
}
}
#endregion
} }
} }
...@@ -66,6 +66,7 @@ public enum LMSG : uint ...@@ -66,6 +66,7 @@ public enum LMSG : uint
IfReplaceExistingImage, IfReplaceExistingImage,
ConvertImage, ConvertImage,
ConvertImageOK, ConvertImageOK,
CompDBOK,
COUNT, COUNT,
} }
} }
...@@ -28,4 +28,4 @@ ...@@ -28,4 +28,4 @@
// //
// You can specify all the values or you can use the default the Revision and // You can specify all the values or you can use the default the Revision and
// Build Numbers by using the '*' as shown below: // Build Numbers by using the '*' as shown below:
[assembly: AssemblyVersion("1.5.2.1")] [assembly: AssemblyVersion("1.5.3.0")]
...@@ -23,6 +23,7 @@ DataEditForm->lb4 / ...@@ -23,6 +23,7 @@ DataEditForm->lb4 /
DataEditForm->lb5 / DataEditForm->lb5 /
DataEditForm->lv_cardlist0 卡片密码 DataEditForm->lv_cardlist0 卡片密码
DataEditForm->lv_cardlist1 卡片名称 DataEditForm->lv_cardlist1 卡片名称
DataEditForm->menuitem_compdb 压缩当前数据库
DataEditForm->menuitem_convertimage 批量导入卡图 DataEditForm->menuitem_convertimage 批量导入卡图
DataEditForm->menuitem_openLastDataBase 最后打开的数据库 DataEditForm->menuitem_openLastDataBase 最后打开的数据库
DataEditForm->menuitem_cutimages 裁剪列表卡片的图片 DataEditForm->menuitem_cutimages 裁剪列表卡片的图片
......
...@@ -49,4 +49,5 @@ ...@@ -49,4 +49,5 @@
0x30 没有选中一张卡片 0x30 没有选中一张卡片
0x31 是否替换存在的图片? 0x31 是否替换存在的图片?
0x32 正在转换图片 0x32 正在转换图片
0x33 转换图片完成 0x33 转换图片完成
\ No newline at end of file 0x34 压缩数据库完成
\ No newline at end of file
...@@ -23,6 +23,8 @@ DataEditForm->lb4 / ...@@ -23,6 +23,8 @@ DataEditForm->lb4 /
DataEditForm->lb5 / DataEditForm->lb5 /
DataEditForm->lv_cardlist0 Card Code DataEditForm->lv_cardlist0 Card Code
DataEditForm->lv_cardlist1 Card Name DataEditForm->lv_cardlist1 Card Name
DataEditForm->menuitem_compdb Compression DataBase
DataEditForm->menuitem_convertimage Inport Images
DataEditForm->menuitem_openLastDataBase Open Last DataBase DataEditForm->menuitem_openLastDataBase Open Last DataBase
DataEditForm->menuitem_cutimages Cut Images For Game DataEditForm->menuitem_cutimages Cut Images For Game
DataEditForm->menuitem_saveasmse_select Select Cards Save As... DataEditForm->menuitem_saveasmse_select Select Cards Save As...
......
...@@ -49,4 +49,5 @@ ...@@ -49,4 +49,5 @@
0x30 No Select Cards 0x30 No Select Cards
0x31 If Replace Iamge When it's exisit? 0x31 If Replace Iamge When it's exisit?
0x32 Converting Images 0x32 Converting Images
0x33 Convert Images OK 0x33 Convert Images OK
\ No newline at end of file 0x34 Compression DataBase OK
\ No newline at end of file
[DataEditorX]1.5.2.1[DataEditorX] [DataEditorX]1.5.3.0[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]
★使用前,请关联lua的打开方式,例如记事本,notepad++,等。 ★使用前,请关联lua的打开方式,例如记事本,notepad++,等。
...@@ -47,6 +47,8 @@ DataEditorX.exe.config ...@@ -47,6 +47,8 @@ DataEditorX.exe.config
描述不详细的bug,我修复不了。(都不知道是bug是什么) 描述不详细的bug,我修复不了。(都不知道是bug是什么)
★更新历史 ★更新历史
1.5.3.0
增加压缩数据库
1.5.2.1 1.5.2.1
导入卡图的路径改为cdb的目录的pics 导入卡图的路径改为cdb的目录的pics
1.5.2.0 1.5.2.0
......
No preview for this file type
...@@ -23,6 +23,7 @@ DataEditForm->lb4 / ...@@ -23,6 +23,7 @@ DataEditForm->lb4 /
DataEditForm->lb5 / DataEditForm->lb5 /
DataEditForm->lv_cardlist0 卡片密码 DataEditForm->lv_cardlist0 卡片密码
DataEditForm->lv_cardlist1 卡片名称 DataEditForm->lv_cardlist1 卡片名称
DataEditForm->menuitem_compdb 压缩当前数据库
DataEditForm->menuitem_convertimage 批量导入卡图 DataEditForm->menuitem_convertimage 批量导入卡图
DataEditForm->menuitem_openLastDataBase 最后打开的数据库 DataEditForm->menuitem_openLastDataBase 最后打开的数据库
DataEditForm->menuitem_cutimages 裁剪列表卡片的图片 DataEditForm->menuitem_cutimages 裁剪列表卡片的图片
......
...@@ -49,4 +49,5 @@ ...@@ -49,4 +49,5 @@
0x30 没有选中一张卡片 0x30 没有选中一张卡片
0x31 是否替换存在的图片? 0x31 是否替换存在的图片?
0x32 正在转换图片 0x32 正在转换图片
0x33 转换图片完成 0x33 转换图片完成
\ No newline at end of file 0x34 压缩数据库完成
\ No newline at end of file
...@@ -23,6 +23,8 @@ DataEditForm->lb4 / ...@@ -23,6 +23,8 @@ DataEditForm->lb4 /
DataEditForm->lb5 / DataEditForm->lb5 /
DataEditForm->lv_cardlist0 Card Code DataEditForm->lv_cardlist0 Card Code
DataEditForm->lv_cardlist1 Card Name DataEditForm->lv_cardlist1 Card Name
DataEditForm->menuitem_compdb Compression DataBase
DataEditForm->menuitem_convertimage Inport Images
DataEditForm->menuitem_openLastDataBase Open Last DataBase DataEditForm->menuitem_openLastDataBase Open Last DataBase
DataEditForm->menuitem_cutimages Cut Images For Game DataEditForm->menuitem_cutimages Cut Images For Game
DataEditForm->menuitem_saveasmse_select Select Cards Save As... DataEditForm->menuitem_saveasmse_select Select Cards Save As...
......
...@@ -49,4 +49,5 @@ ...@@ -49,4 +49,5 @@
0x30 No Select Cards 0x30 No Select Cards
0x31 If Replace Iamge When it's exisit? 0x31 If Replace Iamge When it's exisit?
0x32 Converting Images 0x32 Converting Images
0x33 Convert Images OK 0x33 Convert Images OK
\ No newline at end of file 0x34 Compression DataBase OK
\ No newline at end of file
[DataEditorX]1.5.2.1[DataEditorX] [DataEditorX]1.5.3.0[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]
★使用前,请关联lua的打开方式,例如记事本,notepad++,等。 ★使用前,请关联lua的打开方式,例如记事本,notepad++,等。
...@@ -47,6 +47,8 @@ DataEditorX.exe.config ...@@ -47,6 +47,8 @@ DataEditorX.exe.config
描述不详细的bug,我修复不了。(都不知道是bug是什么) 描述不详细的bug,我修复不了。(都不知道是bug是什么)
★更新历史 ★更新历史
1.5.3.0
增加压缩数据库
1.5.2.1 1.5.2.1
导入卡图的路径改为cdb的目录的pics 导入卡图的路径改为cdb的目录的pics
1.5.2.0 1.5.2.0
......
No preview for this file type
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