Commit 55379b19 authored by keyongyu's avatar keyongyu

2.4.0.0

parent 82b6743c
......@@ -11,164 +11,169 @@
namespace DataEditorX.Common
{
/// <summary>
/// 检查更新
/// </summary>
public static class CheckUpdate
{
static CheckUpdate()
{
//连接数
ServicePointManager.DefaultConnectionLimit = 255;
}
/// <summary>
/// 下载URL
/// </summary>
public static string URL = "";
/// <summary>
/// 从HEAD获取版本号
/// </summary>
const string HEAD = "[DataEditorX]";
const string HEAD2 = "[URL]";
public const string DEFALUT = "0.0.0.0";
const int VER_LENGTH = 4;
/// <summary>
/// 检查更新
/// </summary>
public static class CheckUpdate
{
static CheckUpdate()
{
//连接数
ServicePointManager.DefaultConnectionLimit = 255;
}
/// <summary>
/// 下载URL
/// </summary>
public static string URL = "";
/// <summary>
/// 从HEAD获取版本号
/// </summary>
const string HEAD = "[DataEditorX]";
const string HEAD2 = "[URL]";
public const string DEFALUT = "0.0.0.0";
#region 检查版本
/// <summary>
/// 获取新版本
/// </summary>
/// <param name="VERURL">链接</param>
/// <returns>版本号</returns>
public static string GetNewVersion(string VERURL)
{
string urlver = DEFALUT;
string html = GetHtmlContentByUrl(VERURL);
if (!string.IsNullOrEmpty(html))
{
int t, w;
t = html.IndexOf(HEAD);
w = (t > 0) ? html.IndexOf(HEAD, t + HEAD.Length) : 0;
if (w > 0)
{
//获取版本
urlver = html.Substring(t + HEAD.Length, w - t - HEAD.Length);
}
t = html.IndexOf(HEAD2);
w = (t > 0) ? html.IndexOf(HEAD2, t + HEAD2.Length) : 0;
if (w > 0)
{
//获取下载地址
URL = html.Substring(t + HEAD2.Length, w - t - HEAD2.Length);
}
}
return urlver;
}
/// <summary>
/// 检查版本号,格式0.0.0.0
/// </summary>
/// <param name="ver">0.0.0.0</param>
/// <param name="oldver">0.0.0.0</param>
/// <returns>是否有新版本</returns>
public static bool CheckVersion(string ver, string oldver)
{
bool hasNew = false;
string[] vers = ver.Split('.');
string[] oldvers = oldver.Split('.');
if (vers.Length == oldvers.Length && vers.Length == VER_LENGTH)
{
int j, k;//从左到右比较数字
for (int i = 0; i < VER_LENGTH; i++)
{
int.TryParse(vers[i], out j);
int.TryParse(oldvers[i], out k);
if (j > k)//新的版本号大于旧的
{
hasNew = true;
break;
}
}
}
return hasNew;
}
#endregion
#region 检查版本
/// <summary>
/// 获取新版本
/// </summary>
/// <param name="VERURL">链接</param>
/// <returns>版本号</returns>
public static string GetNewVersion(string VERURL)
{
string urlver = DEFALUT;
string html = GetHtmlContentByUrl(VERURL);
if (!string.IsNullOrEmpty(html))
{
int t, w;
t = html.IndexOf(HEAD);
w = (t > 0) ? html.IndexOf(HEAD, t + HEAD.Length) : 0;
if (w > 0)
{
//获取版本
urlver = html.Substring(t + HEAD.Length, w - t - HEAD.Length);
}
t = html.IndexOf(HEAD2);
w = (t > 0) ? html.IndexOf(HEAD2, t + HEAD2.Length) : 0;
if (w > 0)
{
//获取下载地址
URL = html.Substring(t + HEAD2.Length, w - t - HEAD2.Length);
}
}
return urlver;
}
/// <summary>
/// 检查版本号,格式0.0.0.0
/// </summary>
/// <param name="ver">0.0.0.0</param>
/// <param name="oldver">0.0.0.0</param>
/// <returns>是否有新版本</returns>
public static bool CheckVersion(string ver, string oldver)
{
bool hasNew = false;
#if DEBUG
System.Windows.Forms.MessageBox.Show(oldver+"=>"+ver);
#endif
string[] vers = ver.Split('.');
string[] oldvers = oldver.Split('.');
if (vers.Length == oldvers.Length)
{
int j, k;//从左到右比较数字
for (int i = 0; i < oldvers.Length; i++)
{
int.TryParse(vers[i], out j);
int.TryParse(oldvers[i], out k);
if (j > k)//新的版本号大于旧的
{
hasNew = true;
break;
}else if(j < k){
hasNew = false;
break;
}
}
}
return hasNew;
}
#endregion
#region 获取网址内容
/// <summary>
/// 获取网址内容
/// </summary>
/// <param name="url">网址</param>
/// <returns>内容</returns>
public static string GetHtmlContentByUrl(string url)
{
string htmlContent = string.Empty;
try
{
HttpWebRequest httpWebRequest =
(HttpWebRequest)WebRequest.Create(url);
httpWebRequest.Timeout = 15000;
using (HttpWebResponse httpWebResponse =
(HttpWebResponse)httpWebRequest.GetResponse())
{
using (Stream stream = httpWebResponse.GetResponseStream())
{
using (StreamReader streamReader =
new StreamReader(stream, Encoding.UTF8))
{
htmlContent = streamReader.ReadToEnd();
streamReader.Close();
}
stream.Close();
}
httpWebResponse.Close();
}
return htmlContent;
}
catch
{
#region 获取网址内容
/// <summary>
/// 获取网址内容
/// </summary>
/// <param name="url">网址</param>
/// <returns>内容</returns>
public static string GetHtmlContentByUrl(string url)
{
string htmlContent = string.Empty;
try
{
HttpWebRequest httpWebRequest =
(HttpWebRequest)WebRequest.Create(url);
httpWebRequest.Timeout = 15000;
using (HttpWebResponse httpWebResponse =
(HttpWebResponse)httpWebRequest.GetResponse())
{
using (Stream stream = httpWebResponse.GetResponseStream())
{
using (StreamReader streamReader =
new StreamReader(stream, Encoding.UTF8))
{
htmlContent = streamReader.ReadToEnd();
streamReader.Close();
}
stream.Close();
}
httpWebResponse.Close();
}
return htmlContent;
}
catch
{
}
return "";
}
#endregion
}
return "";
}
#endregion
#region 下载文件
/// <summary>
/// 下载文件
/// </summary>
/// <param name="filename">保存文件路径</param>
/// <returns>是否下载成功</returns>
public static bool DownLoad(string filename)
{
try
{
if (File.Exists(filename))
File.Delete(filename);
HttpWebRequest Myrq = (HttpWebRequest)System.Net.HttpWebRequest.Create(URL);
HttpWebResponse myrp = (HttpWebResponse)Myrq.GetResponse();
long totalBytes = myrp.ContentLength;
#region 下载文件
/// <summary>
/// 下载文件
/// </summary>
/// <param name="filename">保存文件路径</param>
/// <returns>是否下载成功</returns>
public static bool DownLoad(string filename)
{
try
{
if (File.Exists(filename))
File.Delete(filename);
HttpWebRequest Myrq = (HttpWebRequest)System.Net.HttpWebRequest.Create(URL);
HttpWebResponse myrp = (HttpWebResponse)Myrq.GetResponse();
long totalBytes = myrp.ContentLength;
Stream st = myrp.GetResponseStream();
Stream so = new System.IO.FileStream(filename + ".tmp", FileMode.Create);
long totalDownloadedByte = 0;
byte[] by = new byte[2048];
int osize = st.Read(by, 0, (int)by.Length);
while (osize > 0)
{
totalDownloadedByte = osize + totalDownloadedByte;
System.Windows.Forms.Application.DoEvents();
so.Write(by, 0, osize);
osize = st.Read(by, 0, (int)by.Length);
}
so.Close();
st.Close();
File.Move(filename + ".tmp", filename);
}
catch (System.Exception)
{
return false;
}
return true;
}
#endregion
}
Stream st = myrp.GetResponseStream();
Stream so = new System.IO.FileStream(filename + ".tmp", FileMode.Create);
long totalDownloadedByte = 0;
byte[] by = new byte[2048];
int osize = st.Read(by, 0, (int)by.Length);
while (osize > 0)
{
totalDownloadedByte = osize + totalDownloadedByte;
System.Windows.Forms.Application.DoEvents();
so.Write(by, 0, osize);
osize = st.Read(by, 0, (int)by.Length);
}
so.Close();
st.Close();
File.Move(filename + ".tmp", filename);
}
catch (System.Exception)
{
return false;
}
return true;
}
#endregion
}
}
......@@ -18,6 +18,7 @@ public class MyConfig : XMLReader
public const string TAG_SAVE_LAGN = "-savelanguage";
public const string TAG_SAVE_LAGN2 = "-sl";
public const string TAG_MSE_PATH="mse_path";
public const string TAG_MSE_EXPORT="mse_exprotpath";
/// <summary>
/// 窗口消息 打开文件
/// </summary>
......@@ -297,7 +298,8 @@ public static string GetCardInfoFile(string path)
/// <param name="file"></param>
public static bool OpenOnExistForm(string file)
{
Process instance = RunningInstance();
Process instance = RunningInstance(Assembly.GetExecutingAssembly().Location.
Replace('/', Path.DirectorySeparatorChar));
if (instance == null)
{
return false;
......@@ -320,7 +322,7 @@ public static void OpenFileInThis(string file)
//发送消息
User32.SendMessage(Process.GetCurrentProcess().MainWindowHandle, MyConfig.WM_OPEN, 0, 0);
}
static Process RunningInstance()
public static Process RunningInstance(string filename)
{
Process current = Process.GetCurrentProcess();
Process[] processes = Process.GetProcessesByName(current.ProcessName);
......@@ -331,9 +333,7 @@ static Process RunningInstance()
if (process.Id != current.Id)
{
//保证要打开的进程同已经存在的进程来自同一文件路径
if (Assembly.GetExecutingAssembly().Location.
Replace('/', Path.DirectorySeparatorChar)
== current.MainModule.FileName)
if (filename == current.MainModule.FileName)
{
//返回已经存在的进程
return process;
......
......@@ -768,6 +768,8 @@ public Card[] ReadCards(string set, bool repalceOld)
#endregion
#region export
static System.Diagnostics.Process mseProcess;
static EventHandler exitHandler;
private static void exportSetThread(object obj){
string[] args=(string[])obj;
if(args==null||args.Length<3){
......@@ -782,23 +784,36 @@ public Card[] ReadCards(string set, bool repalceOld)
return;
}else{
string cmd=" --export "+setfile.Replace("\\\\","\\").Replace("\\","/")+" {card.gamecode}.png";
System.Diagnostics.Process ie = new System.Diagnostics.Process();
ie.StartInfo.FileName = mse_path;
ie.StartInfo.Arguments = cmd;
ie.StartInfo.WorkingDirectory=path;
mseProcess = new System.Diagnostics.Process();
mseProcess.StartInfo.FileName = mse_path;
mseProcess.StartInfo.Arguments = cmd;
mseProcess.StartInfo.WorkingDirectory=path;
mseProcess.EnableRaisingEvents=true;
MyPath.CreateDir(path);
try{
ie.Start();
mseProcess.Start();
//等待结束,需要把当前方法放到线程里面
ie.WaitForExit();
ie.Close();
mseProcess.WaitForExit();
mseProcess.Exited += new EventHandler(exitHandler);
mseProcess.Close();
mseProcess=null;
System.Windows.Forms.MessageBox.Show(Language.LanguageHelper.GetMsg(LMSG.exportMseImages));
}catch{
}
}
}
public static void exportSet(string mse_path,string setfile,string path){
public static bool MseIsRunning(){
return mseProcess != null;
}
public static void MseStop(){
try{
mseProcess.Kill();
mseProcess.Close();
}catch{}
}
public static void exportSet(string mse_path,string setfile,string path,EventHandler handler){
if(mse_path==null||mse_path.Length==0||setfile==null||setfile.Length==0){
return;
}
......@@ -806,6 +821,7 @@ public Card[] ReadCards(string set, bool repalceOld)
Thread myThread = new Thread(ParStart);
myThread.IsBackground=true;
myThread.Start(new string[]{mse_path,setfile,path});
exitHandler = handler;
}
#endregion
......
......@@ -13,13 +13,12 @@
using System.Windows.Forms;
using DataEditorX.Common;
using DataEditorX.Config;
using DataEditorX.Core;
using DataEditorX.Core.Mse;
using DataEditorX.Language;
using WeifenLuo.WinFormsUI.Docking;
using DataEditorX.Config;
using DataEditorX.Core.Mse;
namespace DataEditorX
{
public partial class DataEditForm : DockContent, IDataForm
......@@ -1632,6 +1631,20 @@ void Menuitem_exportMSEimageClick(object sender, EventArgs e)
{
if (isRun())
return;
string msepath=MyPath.GetRealPath(MyConfig.readString(MyConfig.TAG_MSE_PATH));
if(!File.Exists(msepath)){
MyMsg.Error(LMSG.exportMseImagesErr);
menuitem_exportMSEimage.Checked=false;
return;
}else{
if(MseMaker.MseIsRunning()){
MseMaker.MseStop();
menuitem_exportMSEimage.Checked=false;
return;
}else{
}
}
//select open mse-set
using (OpenFileDialog dlg = new OpenFileDialog())
{
......@@ -1640,8 +1653,13 @@ void Menuitem_exportMSEimageClick(object sender, EventArgs e)
if (dlg.ShowDialog() == DialogResult.OK)
{
string mseset=dlg.FileName;
string msepath=MyConfig.readString(MyConfig.TAG_MSE_PATH);
MseMaker.exportSet(msepath, mseset, MyPath.Combine(Application.StartupPath, "cache"));
string exportpath=MyPath.GetRealPath(MyConfig.readString(MyConfig.TAG_MSE_EXPORT));
MseMaker.exportSet(msepath, mseset, exportpath, delegate{
menuitem_exportMSEimage.Checked=false;
});
menuitem_exportMSEimage.Checked=true;
}else{
menuitem_exportMSEimage.Checked=false;
}
}
}
......
......@@ -28,4 +28,4 @@
//
// You can specify all the values or you can use the default the Revision and
// Build Numbers by using the '*' as shown below:
[assembly: AssemblyVersion("2.3.5.3")]
[assembly: AssemblyVersion("2.4.0.0")]
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<!-- Example connection to a SQL Server Database on localhost. -->
<!-- <add name="ExampleConnectionString"
<connectionStrings>
<!-- Example connection to a SQL Server Database on localhost. -->
<!-- <add name="ExampleConnectionString"
connectionString="Data Source=.;Initial Catalog=DBName;Integrated Security=True"
providerName="System.Data.SqlClient" /> -->
</connectionStrings>
<appSettings>
<!-- access these values via the property:
</connectionStrings>
<appSettings>
<!-- access these values via the property:
System.Configuration.ConfigurationManager.AppSettings[key]
-->
<!-- MSE language data/mse_xxx.txt -->
<add key="mse" value="Chinese-Simplified" />
<!-- Language data/cardinfo_xxxx.txt data/language_xxx.txt -->
<add key="language" value="english" />
<!-- Check system language when running program first time -->
<add key="check_system_language" value="true" />
<!-- async load data -->
<add key="async" value="false" />
<!-- DataEditorX source code -->
<add key="sourceURL" value="https://github.com/247321453/DataEditorX" />
<!-- DataEditorX update url-->
<add key="updateURL" value="https://github.com/247321453/DataEditorX/tree/master/win32/readme.txt" />
<!-- delete,modify with card's files image script -->
<add key="opera_with_cards_file" value="true" />
<!-- open file in this.such as lua -->
<add key="open_file_in_this" value="true" />
<!-- check update when opening application automatically -->
<add key="auto_check_update" value="true" />
<!-- Cut Images Setting -->
<add key="image_quilty" value="100" />
<add key="image" value="44,64,177,254" />
<add key="image_other" value="25,54,128,128" />
<add key="image_xyz" value="24,51,128,128" />
<add key="image_pendulum" value="14,46,149,120" />
<!-- CodeEdiotr Setting
<!-- MSE language data/mse_xxx.txt -->
<add key="mse" value="Chinese-Simplified" />
<!-- Language data/cardinfo_xxxx.txt data/language_xxx.txt -->
<add key="language" value="english" />
<!-- Check system language when running program first time -->
<add key="check_system_language" value="true" />
<!-- async load data -->
<add key="async" value="false" />
<!-- DataEditorX source code -->
<add key="sourceURL" value="https://github.com/247321453/DataEditorX" />
<!-- DataEditorX update url-->
<add key="updateURL" value="https://github.com/247321453/DataEditorX/tree/master/win32/readme.txt" />
<!-- delete,modify with card's files image script -->
<add key="opera_with_cards_file" value="true" />
<!-- open file in this.such as lua -->
<add key="open_file_in_this" value="true" />
<!-- check update when opening application automatically -->
<add key="auto_check_update" value="true" />
<!-- Cut Images Setting -->
<add key="image_quilty" value="100" />
<add key="image" value="44,64,177,254" />
<add key="image_other" value="25,54,128,128" />
<add key="image_xyz" value="24,51,128,128" />
<add key="image_pendulum" value="14,46,149,120" />
<!-- CodeEdiotr Setting
IME = true 使用輸入法,正常顯示文字,反應變慢
IME = false English
-->
<add key="IME" value="false" />
<add key="wordwrap" value="true" />
<add key="tabisspace" value="false" />
<add key="fontname" value="Consolas" />
<add key="fontsize" value="14.5" />
<!-- MSE path-->
<add key="mse_path" value="E:\\git\\MagicSetEditor2\\mse.exe"/>
</appSettings>
<add key="IME" value="false" />
<add key="wordwrap" value="true" />
<add key="tabisspace" value="false" />
<add key="fontname" value="Consolas" />
<add key="fontsize" value="14.5" />
<!-- MSE path-->
<add key="mse_path" value="./MagicSetEditor2/mse.exe"/>
<add key="mse_exprotpath" value="./exprot"/>
</appSettings>
</configuration>
\ No newline at end of file
★更新历史
2.4.0.0
1.mse的相对路径,默认为当前MagicSetEditor2,其他地方请设置config的mse_path,
导出的文件夹为export,其他地方请设置config的mse_exprotpath,
2.从MSE存档导出图片,把MSE存档导出全部图片(如果需要停止,请到任务管理器结束mse.exe)
3.生成MSE存档,不调整图片,测试没问题。
如果需要开启,请修改data文件夹的MSE的配置文件
reimage = true
以及下面的值
2.3.5.3
MSE存档图片调整,灵摆文本测试
2.3.5.2
......
......@@ -55,7 +55,7 @@ DataEditForm.mainMenu.menuitem_saveasmse_select 把选中导为MSE存档
DataEditForm.mainMenu.menuitem_saveasmse 把结果导为MSE存档
DataEditForm.mainMenu.menuitem_cutimages 批量裁剪卡图
DataEditForm.mainMenu.menuitem_convertimage 批量导入卡图
DataEditForm.mainMenu.menuitem_exportMSEimage 从MSE存档导出图片
DataEditForm.mainMenu.menuitem_exportMSEimage 从MSE存档导出图片(再次点击停止)
DataEditForm.mainMenu.menuitem_cancelTask 取消任务
DataEditForm.mainMenu.menuitem_testpendulumtext 测试灵摆效果文本
DataEditForm.mainMenu.menuitem_help 帮助(&H)
......
......@@ -56,7 +56,7 @@ DataEditForm.mainMenu.menuitem_cutimages Cut Images
DataEditForm.mainMenu.menuitem_convertimage Convert Images
DataEditForm.mainMenu.menuitem_importmseimg Set MSE'Image
DataEditForm.mainMenu.menuitem_cancelTask Cancel Task
DataEditForm.mainMenu.menuitem_exportMSEimage export mse-set to images
DataEditForm.mainMenu.menuitem_exportMSEimage export mse-set to images(Click stop)
DataEditForm.mainMenu.menuitem_help Help(&H)
DataEditForm.mainMenu.menuitem_about About
DataEditForm.mainMenu.menuitem_language Laguage
......
[DataEditorX]2.3.5.3[DataEditorX]
[DataEditorX]2.4.0.0[DataEditorX]
[URL]https://github.com/247321453/DataEditorX/raw/master/win32/win32.zip[URL]
★运行环境(Environment)
......
No preview for this file type
......@@ -44,6 +44,7 @@
<add key="fontname" value="Consolas" />
<add key="fontsize" value="14.5" />
<!-- MSE path-->
<add key="mse_path" value="E:\\git\\MagicSetEditor2\\mse.exe" />
<add key="mse_path" value="./MagicSetEditor2/mse.exe" />
<add key="mse_exprotpath" value="./exprot" />
</appSettings>
</configuration>
\ No newline at end of file
★更新历史
2.4.0.0
1.mse的相对路径,默认为当前MagicSetEditor2,其他地方请设置config的mse_path,
导出的文件夹为export,其他地方请设置config的mse_exprotpath,
2.从MSE存档导出图片,把MSE存档导出全部图片(如果需要停止,请到任务管理器结束mse.exe)
3.生成MSE存档,不调整图片,测试没问题。
如果需要开启,请修改data文件夹的MSE的配置文件
reimage = true
以及下面的值
2.3.5.3
MSE存档图片调整,灵摆文本测试
2.3.5.2
......
......@@ -55,7 +55,7 @@ DataEditForm.mainMenu.menuitem_saveasmse_select 把选中导为MSE存档
DataEditForm.mainMenu.menuitem_saveasmse 把结果导为MSE存档
DataEditForm.mainMenu.menuitem_cutimages 批量裁剪卡图
DataEditForm.mainMenu.menuitem_convertimage 批量导入卡图
DataEditForm.mainMenu.menuitem_exportMSEimage 从MSE存档导出图片
DataEditForm.mainMenu.menuitem_exportMSEimage 从MSE存档导出图片(再次点击停止)
DataEditForm.mainMenu.menuitem_cancelTask 取消任务
DataEditForm.mainMenu.menuitem_testpendulumtext 测试灵摆效果文本
DataEditForm.mainMenu.menuitem_help 帮助(&H)
......
......@@ -56,7 +56,7 @@ DataEditForm.mainMenu.menuitem_cutimages Cut Images
DataEditForm.mainMenu.menuitem_convertimage Convert Images
DataEditForm.mainMenu.menuitem_importmseimg Set MSE'Image
DataEditForm.mainMenu.menuitem_cancelTask Cancel Task
DataEditForm.mainMenu.menuitem_exportMSEimage export mse-set to images
DataEditForm.mainMenu.menuitem_exportMSEimage export mse-set to images(Click stop)
DataEditForm.mainMenu.menuitem_help Help(&H)
DataEditForm.mainMenu.menuitem_about About
DataEditForm.mainMenu.menuitem_language Laguage
......
[DataEditorX]2.3.5.3[DataEditorX]
[DataEditorX]2.3.5.4[DataEditorX]
[URL]https://github.com/247321453/DataEditorX/raw/master/win32/win32.zip[URL]
★运行环境(Environment)
......
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