Commit ca0729aa authored by JoyJ's avatar JoyJ

code format

parent c45b91fe
......@@ -79,14 +79,14 @@ void InitForm()
}
Font ft = new Font(this.fctb.Font.Name, this.fctb.Font.Size / 1.2f, FontStyle.Regular);
this.popupMenu = new FastColoredTextBoxNS.AutocompleteMenu(this.fctb)
this.popupMenu = new AutocompleteMenu(this.fctb)
{
MinFragmentLength = 2
};
this.popupMenu.ToolTip.Popup += this.ToolTip_Popup;
this.popupMenu.Items.Font = ft;
this.popupMenu.AutoSize = true;
this.popupMenu.MinimumSize = new System.Drawing.Size(300, 0);
this.popupMenu.MinimumSize = new Size(300, 0);
this.popupMenu.BackColor = this.fctb.BackColor;
this.popupMenu.ForeColor = this.fctb.ForeColor;
this.popupMenu.Closed += new ToolStripDropDownClosedEventHandler(this.popupMenu_Closed);
......@@ -567,7 +567,7 @@ void FctbMouseClick(object sender, MouseEventArgs e)
return;
}
if (e.Button == MouseButtons.Left && Control.ModifierKeys == Keys.Control)
if (e.Button == MouseButtons.Left && ModifierKeys == Keys.Control)
{
List<int> linenums = this.fctb.FindLines(@"function\s+?\S+?\." + text + @"\(", RegexOptions.Singleline);
if (linenums.Count > 0)
......
......@@ -146,21 +146,21 @@ public static bool DownLoad(string filename)
File.Delete(filename);
}
HttpWebRequest Myrq = (HttpWebRequest)System.Net.HttpWebRequest.Create(URL);
HttpWebRequest Myrq = (HttpWebRequest)WebRequest.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);
Stream so = new FileStream(filename + ".tmp", FileMode.Create);
long totalDownloadedByte = 0;
byte[] by = new byte[1024 * 512];
int osize = st.Read(by, 0, (int)by.Length);
int osize = st.Read(by, 0, 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);
osize = st.Read(by, 0, by.Length);
}
so.Close();
st.Close();
......
......@@ -26,7 +26,7 @@ public static string GetRealPath(string dir)
string path = Application.StartupPath;
if (dir.StartsWith("."))
{
dir = MyPath.Combine(path, dir.Substring(2));
dir = Combine(path, dir.Substring(2));
}
return dir;
}
......@@ -89,7 +89,7 @@ public static string CheckDir(string dir,string defalut)
DirectoryInfo fo;
try
{
fo = new DirectoryInfo(MyPath.GetRealPath(dir));
fo = new DirectoryInfo(GetRealPath(dir));
}
catch{
//路径不合法
......
......@@ -43,6 +43,6 @@ public class User32
/// </summary>
/// <returns></returns>
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern System.IntPtr GetForegroundWindow();
public static extern IntPtr GetForegroundWindow();
}
}
\ No newline at end of file
......@@ -19,7 +19,7 @@ public class XMLReader
public static void Save(string appKey, string appValue)
{
XmlDocument xDoc = new XmlDocument();
xDoc.Load(System.Windows.Forms.Application.ExecutablePath + ".config");
xDoc.Load(Application.ExecutablePath + ".config");
XmlNode xNode = xDoc.SelectSingleNode("//appSettings");
......@@ -35,7 +35,7 @@ public static void Save(string appKey, string appValue)
xNewElem.SetAttribute("value", appValue);
xNode.AppendChild(xNewElem);
}
xDoc.Save(System.Windows.Forms.Application.ExecutablePath + ".config");
xDoc.Save(Application.ExecutablePath + ".config");
}
/// <summary>
/// 获取值
......@@ -45,7 +45,7 @@ public static void Save(string appKey, string appValue)
public static string GetAppConfig(string appKey)
{
XmlDocument xDoc = new XmlDocument();
xDoc.Load(System.Windows.Forms.Application.ExecutablePath + ".config");
xDoc.Load(Application.ExecutablePath + ".config");
XmlNode xNode = xDoc.SelectSingleNode("//appSettings");
......
......@@ -183,7 +183,7 @@ public static ZipStorer Open(Stream _stream, FileAccess _access)
return zip;
}
throw new System.IO.InvalidDataException();
throw new InvalidDataException();
}
/// <summary>
/// Add full contents of a file into the Zip storage
......@@ -380,7 +380,7 @@ public List<ZipFileEntry> ReadCentralDir()
public bool ExtractFile(ZipFileEntry _zfe, string _filename)
{
// Make sure the parent directory exist
string path = System.IO.Path.GetDirectoryName(_filename);
string path = Path.GetDirectoryName(_filename);
if (!Directory.Exists(path))
{
......@@ -485,7 +485,7 @@ public static bool RemoveEntries(ref ZipStorer _zip, List<ZipFileEntry> _zfes)
try
{
ZipStorer tempZip = ZipStorer.Create(tempZipName, string.Empty);
ZipStorer tempZip = Create(tempZipName, string.Empty);
foreach (ZipFileEntry zfe in fullList)
{
......@@ -503,7 +503,7 @@ public static bool RemoveEntries(ref ZipStorer _zip, List<ZipFileEntry> _zfes)
File.Delete(_zip.fileName);
File.Move(tempZipName, _zip.fileName);
_zip = ZipStorer.Open(_zip.fileName, _zip.access);
_zip = Open(_zip.fileName, _zip.access);
}
catch
{
......@@ -682,7 +682,7 @@ private void Store(ref ZipFileEntry _zfe, Stream _source)
for (uint i = 0; i < bytesRead; i++)
{
_zfe.Crc32 = ZipStorer._crcTable[(_zfe.Crc32 ^ buffer[i]) & 0xFF] ^ (_zfe.Crc32 >> 8);
_zfe.Crc32 = _crcTable[(_zfe.Crc32 ^ buffer[i]) & 0xFF] ^ (_zfe.Crc32 >> 8);
}
}
} while (bytesRead == buffer.Length);
......
......@@ -288,7 +288,7 @@ public static string GetLanguageFile(string path)
string[] files = Directory.GetFiles(path);
foreach (string file in files)
{
string name = MyPath.GetFullFileName(MyConfig.TAG_LANGUAGE, file);
string name = MyPath.GetFullFileName(TAG_LANGUAGE, file);
if (string.IsNullOrEmpty(name))
{
continue;
......@@ -296,12 +296,12 @@ public static string GetLanguageFile(string path)
if (syslang.Equals(name, StringComparison.OrdinalIgnoreCase))
{
Save(MyConfig.TAG_LANGUAGE, syslang);
Save(TAG_LANGUAGE, syslang);
break;
}
}
}
return MyPath.Combine(path, MyPath.GetFileName(MyConfig.TAG_LANGUAGE, GetAppConfig(TAG_LANGUAGE)));
return MyPath.Combine(path, MyPath.GetFileName(TAG_LANGUAGE, GetAppConfig(TAG_LANGUAGE)));
}
/// <summary>
/// 卡片信息配置文件名
......@@ -310,7 +310,7 @@ public static string GetLanguageFile(string path)
/// <returns></returns>
public static string GetCardInfoFile(string path)
{
return MyPath.Combine(path, MyPath.GetFileName(MyConfig.TAG_CARDINFO, GetAppConfig(TAG_LANGUAGE)));
return MyPath.Combine(path, MyPath.GetFileName(TAG_CARDINFO, GetAppConfig(TAG_LANGUAGE)));
}
/// <summary>
/// 发送消息打开文件
......@@ -327,20 +327,20 @@ public static bool OpenOnExistForm(string file)
else
{
//把需要打开的文件写入临时文件
string tmpfile = Path.Combine(Application.StartupPath, MyConfig.FILE_TEMP);
string tmpfile = Path.Combine(Application.StartupPath, FILE_TEMP);
File.WriteAllText(tmpfile, file);
//发送消息
User32.SendMessage(instance.MainWindowHandle, MyConfig.WM_OPEN, 0, 0);
User32.SendMessage(instance.MainWindowHandle, WM_OPEN, 0, 0);
return true;
}
}
public static void OpenFileInThis(string file)
{
//把需要打开的文件写入临时文件
string tmpfile = Path.Combine(Application.StartupPath, MyConfig.FILE_TEMP);
string tmpfile = Path.Combine(Application.StartupPath, FILE_TEMP);
File.WriteAllText(tmpfile, file);
//发送消息
User32.SendMessage(Process.GetCurrentProcess().MainWindowHandle, MyConfig.WM_OPEN, 0, 0);
User32.SendMessage(Process.GetCurrentProcess().MainWindowHandle, WM_OPEN, 0, 0);
}
public static Process RunningInstance(string filename)
{
......
......@@ -119,31 +119,31 @@ void FctbTextChanged(object sender, TextChangedEventArgs e)
private void InitializeComponent()
{
this.lbTooltip = new System.Windows.Forms.Label();
this.lbTooltip = new Label();
((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
this.SuspendLayout();
//
// lbTooltip
//
this.lbTooltip.AutoSize = true;
this.lbTooltip.BackColor = System.Drawing.SystemColors.Desktop;
this.lbTooltip.Font = new System.Drawing.Font("微软雅黑", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbTooltip.ForeColor = System.Drawing.SystemColors.Control;
this.lbTooltip.Location = new System.Drawing.Point(221, 117);
this.lbTooltip.MaximumSize = new System.Drawing.Size(480, 0);
this.lbTooltip.BackColor = SystemColors.Desktop;
this.lbTooltip.Font = new Font("微软雅黑", 15.75F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
this.lbTooltip.ForeColor = SystemColors.Control;
this.lbTooltip.Location = new Point(221, 117);
this.lbTooltip.MaximumSize = new Size(480, 0);
this.lbTooltip.Name = "lbTooltip";
this.lbTooltip.Size = new System.Drawing.Size(0, 28);
this.lbTooltip.Size = new Size(0, 28);
this.lbTooltip.TabIndex = 1;
this.lbTooltip.MouseMove += new System.Windows.Forms.MouseEventHandler(this.lbTooltip_MouseMove);
this.lbTooltip.MouseMove += new MouseEventHandler(this.lbTooltip_MouseMove);
//
// FastColoredTextBoxEx
//
this.AutoScrollMinSize = new System.Drawing.Size(27, 14);
this.BackColor = System.Drawing.SystemColors.Control;
this.AutoScrollMinSize = new Size(27, 14);
this.BackColor = SystemColors.Control;
this.Controls.Add(this.lbTooltip);
this.Name = "FastColoredTextBoxEx";
this.Size = new System.Drawing.Size(584, 327);
this.Load += new System.EventHandler(this.FastColoredTextBoxEx_Load);
this.Size = new Size(584, 327);
this.Load += new EventHandler(this.FastColoredTextBoxEx_Load);
((System.ComponentModel.ISupportInitialize)(this)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
......
......@@ -47,23 +47,23 @@ public override void LuaSyntaxHighlight(Range range)
//clear style of changed range
range.ClearStyle(this.mStrStyle, this.mGrayStyle, this.conStyle, this.mNumberStyle, this.mKeywordStyle, this.mFunStyle);
//
if (base.LuaStringRegex == null)
if (LuaStringRegex == null)
{
base.InitLuaRegex();
InitLuaRegex();
}
//string highlighting
range.SetStyle(this.mStrStyle, base.LuaStringRegex);
range.SetStyle(this.mStrStyle, LuaStringRegex);
//comment highlighting
range.SetStyle(this.mGrayStyle, base.LuaCommentRegex1);
range.SetStyle(this.mGrayStyle, base.LuaCommentRegex2);
range.SetStyle(this.mGrayStyle, base.LuaCommentRegex3);
range.SetStyle(this.mGrayStyle, LuaCommentRegex1);
range.SetStyle(this.mGrayStyle, LuaCommentRegex2);
range.SetStyle(this.mGrayStyle, LuaCommentRegex3);
//number highlighting
range.SetStyle(this.mNumberStyle, base.LuaNumberRegex);
range.SetStyle(this.mNumberStyle, LuaNumberRegex);
//keyword highlighting
range.SetStyle(this.mKeywordStyle, base.LuaKeywordRegex);
range.SetStyle(this.mKeywordStyle, LuaKeywordRegex);
//functions highlighting
range.SetStyle(this.mFunStyle, base.LuaFunctionsRegex);
range.SetStyle(this.mFunStyle, LuaFunctionsRegex);
range.SetStyle(this.mNumberStyle, @"\bc\d+\b");
range.SetStyle(this.conStyle, @"[\s|\(|+|,]{0,1}(?<range>[A-Z_]+?)[\)|+|\s|,|;]");
......
......@@ -273,7 +273,7 @@ public static int CopyDB(string DB, bool ignore, params Card[] cards)
{
foreach ( Card c in cards )
{
cmd.CommandText = DataBase.GetInsertSQL(c, ignore);
cmd.CommandText = GetInsertSQL(c, ignore);
result += cmd.ExecuteNonQuery();
}
}
......@@ -301,7 +301,7 @@ public static int DeleteDB(string DB, params Card[] cards)
{
foreach (Card c in cards)
{
cmd.CommandText = DataBase.GetDeleteSQL(c);
cmd.CommandText = GetDeleteSQL(c);
result += cmd.ExecuteNonQuery();
}
}
......
......@@ -75,7 +75,7 @@ public void SetConfig(string config, string path)
this.regx_monster = "(\\s\\S*?)";
this.regx_pendulum = "(\\s\\S*?)";
//设置文件名
this.configName = MyPath.GetFullFileName(MSEConfig.TAG, config);
this.configName = MyPath.GetFullFileName(TAG, config);
this.replaces = new SortedList<string, string>();
......@@ -184,11 +184,11 @@ public void Init(string path)
this.Iscn2tw = false;
//读取配置
string tmp = MyPath.Combine(path, MyPath.GetFileName(MSEConfig.TAG, MyConfig.ReadString(MyConfig.TAG_MSE)));
string tmp = MyPath.Combine(path, MyPath.GetFileName(TAG, MyConfig.ReadString(MyConfig.TAG_MSE)));
if (!File.Exists(tmp))
{
tmp = MyPath.Combine(path, MyPath.GetFileName(MSEConfig.TAG, FILE_CONFIG_NAME));
tmp = MyPath.Combine(path, MyPath.GetFileName(TAG, FILE_CONFIG_NAME));
if(!File.Exists(tmp))
{
return;//如果默认的也不存在
......
......@@ -908,14 +908,14 @@ public Card[] ReadCards(string set, bool repalceOld)
private static void exportSetThread(object obj){
string[] args=(string[])obj;
if(args==null||args.Length<3){
System.Windows.Forms.MessageBox.Show(Language.LanguageHelper.GetMsg(LMSG.exportMseImagesErr));
MessageBox.Show(LanguageHelper.GetMsg(LMSG.exportMseImagesErr));
return;
}
string mse_path=args[0];
string setfile=args[1];
string path=args[2];
if(string.IsNullOrEmpty(mse_path)||string.IsNullOrEmpty(setfile)){
System.Windows.Forms.MessageBox.Show(Language.LanguageHelper.GetMsg(LMSG.exportMseImagesErr));
MessageBox.Show(LanguageHelper.GetMsg(LMSG.exportMseImagesErr));
return;
}else{
string cmd=" --export "+setfile.Replace("\\\\","\\").Replace("\\","/")+" {card.gamecode}.png";
......@@ -932,7 +932,7 @@ public Card[] ReadCards(string set, bool repalceOld)
_mseProcess.Exited += new EventHandler(_exitHandler);
_mseProcess.Close();
_mseProcess=null;
System.Windows.Forms.MessageBox.Show(Language.LanguageHelper.GetMsg(LMSG.exportMseImages));
MessageBox.Show(LanguageHelper.GetMsg(LMSG.exportMseImages));
}catch{
}
......
......@@ -181,7 +181,7 @@ public static void CheckVersion(bool showNew)
}
public void OnCheckUpdate(bool showNew)
{
TaskHelper.CheckVersion(showNew);
CheckVersion(showNew);
}
#endregion
......
......@@ -1813,7 +1813,7 @@ void SetMseConfig_Click(object sender, EventArgs e)
//刷新菜单
this.AddMenuItemFormMSE();
//保存配置
MyConfig.Save(MyConfig.TAG_MSE, tsmi.Text);
XMLReader.Save(MyConfig.TAG_MSE, tsmi.Text);
}
}
#endregion
......@@ -1964,26 +1964,26 @@ private void menuitem_compdb_Click(object sender, EventArgs e)
private void menuitem_deletecardsfile_Click(object sender, EventArgs e)
{
this.menuitem_operacardsfile.Checked = !this.menuitem_operacardsfile.Checked;
MyConfig.Save(MyConfig.TAG_DELETE_WITH, this.menuitem_operacardsfile.Checked.ToString().ToLower());
XMLReader.Save(MyConfig.TAG_DELETE_WITH, this.menuitem_operacardsfile.Checked.ToString().ToLower());
}
//用CodeEditor打开lua
private void menuitem_openfileinthis_Click(object sender, EventArgs e)
{
this.menuitem_openfileinthis.Checked = !this.menuitem_openfileinthis.Checked;
MyConfig.Save(MyConfig.TAG_OPEN_IN_THIS, this.menuitem_openfileinthis.Checked.ToString().ToLower());
XMLReader.Save(MyConfig.TAG_OPEN_IN_THIS, this.menuitem_openfileinthis.Checked.ToString().ToLower());
}
//自动检查更新
private void menuitem_autocheckupdate_Click(object sender, EventArgs e)
{
this.menuitem_autocheckupdate.Checked = !this.menuitem_autocheckupdate.Checked;
MyConfig.Save(MyConfig.TAG_AUTO_CHECK_UPDATE, this.menuitem_autocheckupdate.Checked.ToString().ToLower());
XMLReader.Save(MyConfig.TAG_AUTO_CHECK_UPDATE, this.menuitem_autocheckupdate.Checked.ToString().ToLower());
}
//add require automatically
private void menuitem_addrequire_Click(object sender, EventArgs e)
{
this.Addrequire = Microsoft.VisualBasic.Interaction.InputBox("Module script?\n\nPress \"Cancel\" to remove module script.", "", this.Addrequire);
this.menuitem_addrequire.Checked = (this.Addrequire.Length > 0);
MyConfig.Save(MyConfig.TAG_ADD_REQUIRE, this.Addrequire);
XMLReader.Save(MyConfig.TAG_ADD_REQUIRE, this.Addrequire);
}
#endregion
......@@ -2028,7 +2028,7 @@ void SetLanguage_Click(object sender, EventArgs e)
if (sender is ToolStripMenuItem tsmi)
{
MyConfig.Save(MyConfig.TAG_LANGUAGE, tsmi.Text);
XMLReader.Save(MyConfig.TAG_LANGUAGE, tsmi.Text);
this.GetLanguageItem();
MyMsg.Show(LMSG.PlzRestart);
}
......
......@@ -156,7 +156,7 @@ public void AddLuaMenu(ToolStripItem item)
#endregion
#region 处理窗口消息
protected override void DefWndProc(ref System.Windows.Forms.Message m)
protected override void DefWndProc(ref Message m)
{
switch (m.Msg)
{
......
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