Commit 44764797 authored by JoyJ's avatar JoyJ

code format

parent b448b34a
Pipeline #87 passed with stage
in 49 seconds
......@@ -5,19 +5,19 @@
* 时间: 19:16
*
*/
using DataEditorX.Config;
using DataEditorX.Controls;
using DataEditorX.Core;
using DataEditorX.Language;
using FastColoredTextBoxNS;
using System;
using System.IO;
using System.Drawing;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Drawing;
using System.IO;
using System.Text;
using WeifenLuo.WinFormsUI.Docking;
using FastColoredTextBoxNS;
using DataEditorX.Language;
using System.Text.RegularExpressions;
using DataEditorX.Core;
using DataEditorX.Config;
using DataEditorX.Controls;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;
namespace DataEditorX
{
......@@ -91,8 +91,8 @@ void InitForm()
this.popupMenu.ForeColor = this.fctb.ForeColor;
this.popupMenu.Closed += new ToolStripDropDownClosedEventHandler(this.popupMenu_Closed);
this.popupMenu.SelectedColor = Color.LightGray;
popupMenu.VisibleChanged += this.PopupMenu_VisibleChanged;
popupMenu.Items.FocussedItemIndexChanged += this.Items_FocussedItemIndexChanged;
this.popupMenu.VisibleChanged += this.PopupMenu_VisibleChanged;
this.popupMenu.Items.FocussedItemIndexChanged += this.Items_FocussedItemIndexChanged;
this.title = this.Text;
}
......@@ -105,38 +105,38 @@ private void ToolTip_Popup(object sender, PopupEventArgs e)
private void PopupMenu_VisibleChanged(object sender, EventArgs e)
{
this.AdjustPopupMenuSize();
if (!popupMenu.Visible || popupMenu.Items.FocussedItem == null)
if (!this.popupMenu.Visible || this.popupMenu.Items.FocussedItem == null)
{
return;
}
this.fctb.ShowTooltipWithLabel(popupMenu.Items.FocussedItem.ToolTipTitle,
popupMenu.Items.FocussedItem.ToolTipText);
this.fctb.ShowTooltipWithLabel(this.popupMenu.Items.FocussedItem.ToolTipTitle,
this.popupMenu.Items.FocussedItem.ToolTipText);
}
private void AdjustPopupMenuSize()
{
if (!popupMenu.Visible || popupMenu.Items.FocussedItem == null)
if (!this.popupMenu.Visible || this.popupMenu.Items.FocussedItem == null)
{
popupMenu.Size = new Size(300, 0);
popupMenu.MinimumSize = new Size(300, 0);
this.popupMenu.Size = new Size(300, 0);
this.popupMenu.MinimumSize = new Size(300, 0);
}
Size s = TextRenderer.MeasureText(popupMenu.Items.FocussedItem.ToolTipTitle,
popupMenu.Items.Font, new Size(0, 0), TextFormatFlags.NoPadding);
s = new Size(s.Width + 50, popupMenu.Size.Height);
if (popupMenu.Size.Width < s.Width)
Size s = TextRenderer.MeasureText(this.popupMenu.Items.FocussedItem.ToolTipTitle,
this.popupMenu.Items.Font, new Size(0, 0), TextFormatFlags.NoPadding);
s = new Size(s.Width + 50, this.popupMenu.Size.Height);
if (this.popupMenu.Size.Width < s.Width)
{
popupMenu.Size = s;
popupMenu.MinimumSize = s;
this.popupMenu.Size = s;
this.popupMenu.MinimumSize = s;
}
}
private void Items_FocussedItemIndexChanged(object sender, EventArgs e)
{
if (popupMenu.Items.FocussedItem == null)
if (this.popupMenu.Items.FocussedItem == null)
{
return;
}
this.AdjustPopupMenuSize();
this.fctb.ShowTooltipWithLabel(popupMenu.Items.FocussedItem.ToolTipTitle,
popupMenu.Items.FocussedItem.ToolTipText);
this.fctb.ShowTooltipWithLabel(this.popupMenu.Items.FocussedItem.ToolTipTitle,
this.popupMenu.Items.FocussedItem.ToolTipText);
}
void popupMenu_Closed(object sender, ToolStripDropDownClosedEventArgs e)
......
......@@ -64,9 +64,9 @@ public static string GetNewVersion(string VERURL)
public static bool CheckVersion(string ver, string oldver)
{
bool hasNew = false;
#if DEBUG
System.Windows.Forms.MessageBox.Show(oldver+"=>"+ver);
#endif
#if DEBUG
System.Windows.Forms.MessageBox.Show(oldver + "=>" + ver);
#endif
string[] vers = ver.Split('.');
string[] oldvers = oldver.Split('.');
if (vers.Length == oldvers.Length)
......
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
namespace DataEditorX.Common
{
......@@ -109,7 +108,7 @@ public static int GetIntegerValue(string line, int defalut)
i = int.Parse(GetValue(line));
return i;
}
catch{}
catch { }
return defalut;
}
/// <summary>
......
......@@ -2,10 +2,10 @@
* date :2014-02-07
* desc :图像处理,裁剪,缩放,保存
*/
using System.IO;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
namespace DataEditorX.Common
{
......@@ -35,7 +35,7 @@ public static Bitmap ReadImage(string file)
/// <returns>处理好的图像</returns>
public static Bitmap Zoom(Bitmap sourceBitmap, int newWidth, int newHeight)
{
if ( sourceBitmap != null )
if (sourceBitmap != null)
{
Bitmap b = new Bitmap(newWidth, newHeight);
Graphics graphics = Graphics.FromImage(b);
......@@ -79,17 +79,17 @@ public static Bitmap Cut(Bitmap sourceBitmap, Area area)
/// <returns>处理好的图像</returns>
public static Bitmap Cut(Bitmap sourceBitmap, int StartX, int StartY, int cutWidth, int cutHeight)
{
if ( sourceBitmap != null )
if (sourceBitmap != null)
{
int w = sourceBitmap.Width;
int h = sourceBitmap.Height;
//裁剪的区域宽度调整
if ( ( StartX + cutWidth ) > w )
if ((StartX + cutWidth) > w)
{
cutWidth = w - StartX;
}
//裁剪的区域高度调整
if ( ( StartY + cutHeight ) > h )
if ((StartY + cutHeight) > h)
{
cutHeight = h - StartY;
}
......@@ -121,12 +121,12 @@ public static Bitmap Cut(Bitmap sourceBitmap, int StartX, int StartY, int cutWid
/// <param name="filename">保存路径</param>
/// <param name="quality">质量</param>
/// <returns>是否保存成功</returns>
public static bool SaveAsJPEG(Bitmap bitmap, string filename, int quality=90)
public static bool SaveAsJPEG(Bitmap bitmap, string filename, int quality = 90)
{
if ( bitmap != null )
if (bitmap != null)
{
string path=Path.GetDirectoryName(filename);
if(!Directory.Exists(path))//创建文件夹
if (!Directory.Exists(path))//创建文件夹
{
Directory.CreateDirectory(path);
}
......@@ -138,9 +138,9 @@ public static bool SaveAsJPEG(Bitmap bitmap, string filename, int quality=90)
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();
ImageCodecInfo ici = null;
foreach ( ImageCodecInfo codec in codecs )
foreach (ImageCodecInfo codec in codecs)
{
if ( codec.MimeType.IndexOf("jpeg") > -1 )
if (codec.MimeType.IndexOf("jpeg") > -1)
{
ici = codec;
break;
......@@ -152,7 +152,7 @@ public static bool SaveAsJPEG(Bitmap bitmap, string filename, int quality=90)
}
EncoderParameters encoderParams = new EncoderParameters();
encoderParams.Param[0] = new EncoderParameter(Encoder.Quality, (long)quality);
encoderParams.Param[0] = new EncoderParameter(Encoder.Quality, quality);
if (ici != null)
{
bitmap.Save(filename, ici, encoderParams);
......
......@@ -5,7 +5,6 @@
* 时间: 10:26
*
*/
using System;
using System.Text;
using System.Windows.Forms;
......@@ -84,14 +83,15 @@ public static string Combine(params string[] paths)
/// <param name="dir">目录</param>
/// <param name="defalut">不合法时,采取的目录</param>
/// <returns></returns>
public static string CheckDir(string dir,string defalut)
public static string CheckDir(string dir, string defalut)
{
DirectoryInfo fo;
try
{
fo = new DirectoryInfo(GetRealPath(dir));
}
catch{
catch
{
//路径不合法
fo = new DirectoryInfo(defalut);
}
......@@ -110,7 +110,7 @@ public static string CheckDir(string dir,string defalut)
/// <param name="tag">前面</param>
/// <param name="lang"></param>
/// <returns></returns>
public static string GetFileName(string tag,string lang)
public static string GetFileName(string tag, string lang)
{
return tag + "_" + lang + ".txt";
}
......

using System;
using System.Collections.Generic;
using System.Collections.Generic;
namespace DataEditorX
{
......@@ -12,10 +10,10 @@ public int Compare(K x, K y)
}
}
public class MySortList<K,V> : SortedList<K,V>
public class MySortList<K, V> : SortedList<K, V>
{
public MySortList():base(new MyComparer<K>())
public MySortList() : base(new MyComparer<K>())
{
}
......@@ -24,11 +22,11 @@ public new void Add(K key, V value)
//falg用于跳出函数
int flag = 0;
//检查是否具备这个key,并且检查value是否重复
foreach (KeyValuePair<K,V> item in this)
foreach (KeyValuePair<K, V> item in this)
{
if (item.Key.ToString() == key.ToString() && item.Value.ToString() == value.ToString())
{
flag=1;
flag = 1;
}
}
if (flag == 1)
......
......@@ -6,9 +6,8 @@
*
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
*/
using System;
using System.Text;
using System.IO;
using System.Text;
namespace DataEditorX.Common
{
......@@ -45,8 +44,9 @@ public static string GetMD5HashFromFile(string fileName)
return "";
}
public static bool Md5isEmpty(string md5){
return md5==null||md5.Length<16;
public static bool Md5isEmpty(string md5)
{
return md5 == null || md5.Length < 16;
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using System.Text;
namespace DataEditorX.Common
{
......@@ -13,7 +11,7 @@ public static string AutoEnter(string str, int lineNum, char re)
return "";
}
str = " "+str.Replace("\r\n", "\n");
str = " " + str.Replace("\r\n", "\n");
char[] ch = str.ToCharArray();
_ = ch.Length;
......@@ -37,7 +35,7 @@ public static string AutoEnter(string str, int lineNum, char re)
sb.Append(re);
i = 0;
}
else if(c == re)
else if (c == re)
{
sb.Append(c);
i = 0;
......@@ -47,7 +45,9 @@ public static string AutoEnter(string str, int lineNum, char re)
sb.Append(c);
sb.Append(re);
i = 0;
}else{
}
else
{
sb.Append(c);
}
}
......
/*
* 由SharpDevelop创建。
* 用户: Acer
* 日期: 2014-10-25
* 时间: 21:30
*
*/
using System;
/*
* 由SharpDevelop创建。
* 用户: Acer
* 日期: 2014-10-25
* 时间: 21:30
*
*/
using System.Runtime.InteropServices;
namespace System
......
using System;
using System.Windows.Forms;
using System.Xml;
using System.IO;
using DataEditorX.Common;
using System.Windows.Forms;
using System.Diagnostics;
using System.Reflection;
namespace DataEditorX.Common
{
......
......@@ -15,11 +15,13 @@ public class ZipStorer : IDisposable
/// <summary>
/// Compression method enumeration
/// </summary>
public enum Compression : ushort {
public enum Compression : ushort
{
/// <summary>Uncompressed storage</summary>
Store = 0,
/// <summary>Deflate compression method</summary>
Deflate = 8 }
Deflate = 8
}
#region ZipFileEntry
/// <summary>
......@@ -151,7 +153,7 @@ public static ZipStorer Create(Stream _stream, string _comment)
/// <returns>A valid ZipStorer object</returns>
public static ZipStorer Open(string _filename, FileAccess _access)
{
Stream stream = (Stream)new FileStream(_filename, FileMode.Open, _access == FileAccess.Read ? FileAccess.Read : FileAccess.ReadWrite);
Stream stream = new FileStream(_filename, FileMode.Open, _access == FileAccess.Read ? FileAccess.Read : FileAccess.ReadWrite);
ZipStorer zip = Open(stream, _access);
zip.fileName = _filename;
......@@ -237,7 +239,7 @@ public void AddStream(Compression _method, string _filenameInZip, Stream _source
throw new InvalidOperationException("Writing is not alowed");
}
if (this.files.Count==0)
if (this.files.Count == 0)
{
}
else
......@@ -325,7 +327,7 @@ public List<ZipFileEntry> ReadCentralDir()
List<ZipFileEntry> result = new List<ZipFileEntry>();
for (int pointer = 0; pointer < this.centralDirImage.Length; )
for (int pointer = 0; pointer < this.centralDirImage.Length;)
{
uint signature = BitConverter.ToUInt32(this.centralDirImage, pointer);
if (signature != 0x02014b50)
......@@ -561,7 +563,7 @@ private void WriteLocalHeader(ref ZipFileEntry _zfe)
Encoding encoder = _zfe.EncodeUTF8 ? Encoding.UTF8 : _defaultEncoding;
byte[] encodedFilename = encoder.GetBytes(_zfe.FilenameInZip);
this.zipFileStream.Write(new byte[] { 80, 75, 3, 4, 20, 0}, 0, 6); // No extra header
this.zipFileStream.Write(new byte[] { 80, 75, 3, 4, 20, 0 }, 0, 6); // No extra header
this.zipFileStream.Write(BitConverter.GetBytes((ushort)(_zfe.EncodeUTF8 ? 0x0800 : 0)), 0, 2); // filename and comment encoding
this.zipFileStream.Write(BitConverter.GetBytes((ushort)_zfe.Method), 0, 2); // zipping method
this.zipFileStream.Write(BitConverter.GetBytes(this.DateTimeToDosTime(_zfe.ModifyTime)), 0, 4); // zipping date and time
......@@ -643,8 +645,8 @@ private void WriteEndRecord(uint _size, uint _offset)
byte[] encodedComment = encoder.GetBytes(this.comment);
this.zipFileStream.Write(new byte[] { 80, 75, 5, 6, 0, 0, 0, 0 }, 0, 8);
this.zipFileStream.Write(BitConverter.GetBytes((ushort)this.files.Count+ this.existingFiles), 0, 2);
this.zipFileStream.Write(BitConverter.GetBytes((ushort)this.files.Count+ this.existingFiles), 0, 2);
this.zipFileStream.Write(BitConverter.GetBytes((ushort)this.files.Count + this.existingFiles), 0, 2);
this.zipFileStream.Write(BitConverter.GetBytes((ushort)this.files.Count + this.existingFiles), 0, 2);
this.zipFileStream.Write(BitConverter.GetBytes(_size), 0, 4);
this.zipFileStream.Write(BitConverter.GetBytes(_offset), 0, 4);
this.zipFileStream.Write(BitConverter.GetBytes((ushort)encodedComment.Length), 0, 2);
......@@ -722,7 +724,7 @@ private uint DateTimeToDosTime(DateTime _dt)
{
return (uint)(
(_dt.Second / 2) | (_dt.Minute << 5) | (_dt.Hour << 11) |
(_dt.Day<<16) | (_dt.Month << 21) | ((_dt.Year - 1980) << 25));
(_dt.Day << 16) | (_dt.Month << 21) | ((_dt.Year - 1980) << 25));
}
private DateTime DosTimeToDateTime(uint _dt)
{
......
using System;
using FastColoredTextBoxNS;
using System;
using System.Collections.Generic;
using System.IO;
using FastColoredTextBoxNS;
namespace DataEditorX.Config
{
/// <summary>
......@@ -209,7 +208,7 @@ void AddToolIipDic(string key, string val)
nval += Environment.NewLine;
}
nval += Environment.NewLine +val;
nval += Environment.NewLine + val;
this.tooltipDic[skey] = nval;
}
else
......
......@@ -18,7 +18,7 @@ public class DataConfig
{
public DataConfig()
{
this.InitMember(MyPath.Combine(Application.StartupPath, MyConfig.TAG_CARDINFO+".txt"));
this.InitMember(MyPath.Combine(Application.StartupPath, MyConfig.TAG_CARDINFO + ".txt"));
}
public DataConfig(string conf)
{
......@@ -31,7 +31,7 @@ public DataConfig(string conf)
public void InitMember(string conf)
{
//conf = MyPath.Combine(datapath, MyConfig.FILE_INFO);
if(!File.Exists(conf))
if (!File.Exists(conf))
{
this.dicCardRules = new Dictionary<long, string>();
this.dicSetnames = new Dictionary<long, string>();
......
......@@ -6,11 +6,11 @@
*
*/
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Globalization;
using System.Collections.Generic;
namespace DataEditorX.Config
{
......@@ -42,7 +42,7 @@ public static string SubString(string content, string tag)
Match mac = reg.Match(reReturn(content));
if (mac.Success)//把相应的内容提取出来
{
return mac.Groups[1].Value.Replace("\n",Environment.NewLine);
return mac.Groups[1].Value.Replace("\n", Environment.NewLine);
}
return "";
}
......@@ -57,7 +57,7 @@ public static string SubString(string content, string tag)
/// <returns></returns>
public static Dictionary<long, string> Read(string content, string tag)
{
return Read(SubString(content,tag));
return Read(SubString(content, tag));
}
/// <summary>
/// 从文件读取内容,按行读取
......@@ -150,7 +150,7 @@ public static string[] GetValues(Dictionary<long, string> dic)
/// <returns></returns>
public static string GetValue(Dictionary<long, string> dic, long key)
{
if(dic.ContainsKey(key))
if (dic.ContainsKey(key))
{
return dic[key].Trim();
}
......
......@@ -5,9 +5,6 @@
* 时间: 9:02
*
*/
using System;
using System.Configuration;
using DataEditorX.Config;
using DataEditorX.Common;
namespace DataEditorX.Config
......@@ -17,7 +14,8 @@ namespace DataEditorX.Config
/// </summary>
public class ImageSet
{
public ImageSet(){
public ImageSet()
{
this.Init();
}
//初始化
......
using System;
using System.Xml;
using System.IO;
using System.Globalization;
using DataEditorX.Common;
using System.Windows.Forms;
using DataEditorX.Common;
using System;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
namespace DataEditorX.Config
{
......@@ -259,13 +258,15 @@ public static Area ReadArea(string key)
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static bool ReadBoolean(string key,bool def=false)
public static bool ReadBoolean(string key, bool def = false)
{
string val= ReadString(key);
if("true".Equals(val, StringComparison.OrdinalIgnoreCase)){
if ("true".Equals(val, StringComparison.OrdinalIgnoreCase))
{
return true;
}
if("false".Equals(val, StringComparison.OrdinalIgnoreCase)){
if ("false".Equals(val, StringComparison.OrdinalIgnoreCase))
{
return false;
}
return def;
......
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.IO;
namespace DataEditorX.Config
{
......@@ -67,7 +64,7 @@ public string GetImage(string id)
//}
public string GetImageField(string id)
{
return MyPath.Combine(this.fieldpath, id+ ".png");//场地图
return MyPath.Combine(this.fieldpath, id + ".png");//场地图
}
public string GetScript(string id)
{
......
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms;
namespace DataEditorX
{
......
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms;
namespace DataEditorX
{
......
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms;
namespace DataEditorX
{
......
......@@ -7,10 +7,7 @@
*/
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Text;
namespace FastColoredTextBoxNS
{
......@@ -53,8 +50,8 @@ protected override void OnToolTip()
//check distance
Point p = this.PlaceToPoint(place);
if (Math.Abs(p.X - this.lastMouseCoord.X) > this.CharWidth *2 ||
Math.Abs(p.Y - this.lastMouseCoord.Y) > this.CharHeight *2)
if (Math.Abs(p.X - this.lastMouseCoord.X) > this.CharWidth * 2 ||
Math.Abs(p.Y - this.lastMouseCoord.Y) > this.CharHeight * 2)
{
return;
}
......@@ -73,14 +70,14 @@ protected override void OnToolTip()
public void ShowTooltipWithLabel(string title, string text, int height)
{
lbTooltip.Visible = true;
lbTooltip.Text = $"{title}\r\n\r\n{text}";
lbTooltip.Location = new Point(this.Size.Width - 500, height);
this.lbTooltip.Visible = true;
this.lbTooltip.Text = $"{title}\r\n\r\n{text}";
this.lbTooltip.Location = new Point(this.Size.Width - 500, height);
}
public void ShowTooltipWithLabel(string title, string text)
{
this.ShowTooltipWithLabel(title,text, this.lastMouseCoord.Y + this.CharHeight);
this.ShowTooltipWithLabel(title, text, this.lastMouseCoord.Y + this.CharHeight);
}
//高亮当前词
......@@ -127,7 +124,7 @@ private void InitializeComponent()
//
this.lbTooltip.AutoSize = true;
this.lbTooltip.BackColor = SystemColors.Desktop;
this.lbTooltip.Font = new Font("微软雅黑", 15.75F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
this.lbTooltip.Font = new Font("微软雅黑", 15.75F, FontStyle.Regular, GraphicsUnit.Point, 0);
this.lbTooltip.ForeColor = SystemColors.Control;
this.lbTooltip.Location = new Point(221, 117);
this.lbTooltip.MaximumSize = new Size(480, 0);
......@@ -157,7 +154,7 @@ private void FastColoredTextBoxEx_Load(object sender, EventArgs e)
private void lbTooltip_MouseMove(object sender, MouseEventArgs e)
{
lbTooltip.Visible = false;
this.lbTooltip.Visible = false;
}
}
}
using System;
using DataEditorX.Config;
using DataEditorX.Core;
using DataEditorX.Language;
using System;
using System.Collections.Generic;
using System.IO;
using DataEditorX.Core;
using DataEditorX.Config;
using System.Windows.Forms;
using DataEditorX.Language;
namespace DataEditorX.Controls
{
......@@ -108,7 +108,7 @@ void SaveHistory()
texts += Environment.NewLine + str;
}
}
if(File.Exists(this.historyFile))
if (File.Exists(this.historyFile))
{
File.Delete(this.historyFile);
}
......
using System;
using System.Collections.Generic;
using System.Text;
namespace DataEditorX.Controls
namespace DataEditorX.Controls
{
public interface IEditForm
{
......
......@@ -5,13 +5,7 @@
* 时间: 23:14
*
*/
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Text.RegularExpressions;
using System.Xml;
namespace FastColoredTextBoxNS
{
......@@ -47,23 +41,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 (LuaStringRegex == null)
if (this.LuaStringRegex == null)
{
InitLuaRegex();
this.InitLuaRegex();
}
//string highlighting
range.SetStyle(this.mStrStyle, LuaStringRegex);
range.SetStyle(this.mStrStyle, this.LuaStringRegex);
//comment highlighting
range.SetStyle(this.mGrayStyle, LuaCommentRegex1);
range.SetStyle(this.mGrayStyle, LuaCommentRegex2);
range.SetStyle(this.mGrayStyle, LuaCommentRegex3);
range.SetStyle(this.mGrayStyle, this.LuaCommentRegex1);
range.SetStyle(this.mGrayStyle, this.LuaCommentRegex2);
range.SetStyle(this.mGrayStyle, this.LuaCommentRegex3);
//number highlighting
range.SetStyle(this.mNumberStyle, LuaNumberRegex);
range.SetStyle(this.mNumberStyle, this.LuaNumberRegex);
//keyword highlighting
range.SetStyle(this.mKeywordStyle, LuaKeywordRegex);
range.SetStyle(this.mKeywordStyle, this.LuaKeywordRegex);
//functions highlighting
range.SetStyle(this.mFunStyle, LuaFunctionsRegex);
range.SetStyle(this.mFunStyle, this.LuaFunctionsRegex);
range.SetStyle(this.mNumberStyle, @"\bc\d+\b");
range.SetStyle(this.conStyle, @"[\s|\(|+|,]{0,1}(?<range>[A-Z_]+?)[\)|+|\s|,|;]");
......
......@@ -3,10 +3,10 @@
* desc :卡片类
* ModiftyDate :2014-02-12
*/
using DataEditorX.Core.Info;
using System;
using System.Globalization;
using System.Text.RegularExpressions;
using DataEditorX.Core.Info;
namespace DataEditorX.Core
{
......@@ -75,7 +75,8 @@ public Card(long cardCode)
/// <summary>脚本文件文字</summary>
public string[] Str
{
get {
get
{
if (this.str == null)
{
this.str = new string[STR_MAX];
......@@ -91,7 +92,7 @@ public string[] Str
public long[] GetSetCode()
{
long[] setcodes = new long[SETCODE_MAX];
for (int i = 0,k = 0; i < SETCODE_MAX; k += 0x10, i++)
for (int i = 0, k = 0; i < SETCODE_MAX; k += 0x10, i++)
{
setcodes[i] = (this.setcode >> k) & 0xffff;
}
......@@ -222,7 +223,7 @@ public bool EqualsData(Card other)
public bool Equals(Card other)
{
bool equalBool=this.EqualsData(other);
if(!equalBool)
if (!equalBool)
{
return false;
}
......@@ -266,8 +267,9 @@ public override int GetHashCode()
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public bool IsType(CardType type){
if((this.type & (long)type) == (long)type)
public bool IsType(CardType type)
{
if ((this.type & (long)type) == (long)type)
{
return true;
}
......@@ -318,22 +320,26 @@ public string IdString
public override string ToString()
{
string str;
if (this.IsType(CardType.TYPE_MONSTER)){
if (this.IsType(CardType.TYPE_MONSTER))
{
str = this.name + "[" + this.IdString + "]\n["
+ YGOUtil.GetTypeString(this.type) + "] "
+ YGOUtil.GetRace(this.race) + "/" + YGOUtil.GetAttributeString(this.attribute)
+ "\n" + this.levelString() + " " + this.atk + "/" + this.def + "\n" + this.redesc();
}else
}
else
{
str = this.name +"[" + this.IdString +"]\n["+YGOUtil.GetTypeString(this.type)+"]\n"+ this.redesc();
str = this.name + "[" + this.IdString + "]\n[" + YGOUtil.GetTypeString(this.type) + "]\n" + this.redesc();
}
return str;
}
public string ToShortString(){
return this.name+" ["+ this.IdString +"]";
public string ToShortString()
{
return this.name + " [" + this.IdString + "]";
}
public string ToLongString(){
public string ToLongString()
{
return this.ToString();
}
......
using System;
using DataEditorX.Config;
using DataEditorX.Language;
using System.Collections.Generic;
using System.Text;
using System.IO;
using DataEditorX.Config;
using DataEditorX.Language;
using DataEditorX.Core.Info;
using System.Text;
namespace DataEditorX.Core
{
......@@ -27,7 +25,7 @@ public CardEdit(IDataForm dataform)
#region 添加
//添加
public class AddCommand: IBackableCommand
public class AddCommand : IBackableCommand
{
private string undoSQL;
readonly IDataForm dataform;
......@@ -84,7 +82,7 @@ public object Clone()
#region 修改
//修改
public class ModCommand: IBackableCommand
public class ModCommand : IBackableCommand
{
private string undoSQL;
private bool modifiled = false;
......@@ -283,11 +281,16 @@ public bool OpenScript(bool openinthis, string addrequire)
Card c = this.dataform.GetCard();
long id = c.id;
string lua;
if (c.id > 0) {
if (c.id > 0)
{
lua = this.dataform.GetPath().GetScript(id);
} else if (addrequire.Length > 0) {
}
else if (addrequire.Length > 0)
{
lua = this.dataform.GetPath().GetModuleScript(addrequire);
} else {
}
else
{
return false;
}
if (!File.Exists(lua))
......@@ -296,7 +299,7 @@ public bool OpenScript(bool openinthis, string addrequire)
if (MyMsg.Question(LMSG.IfCreateScript))//是否创建脚本
{
using (FileStream fs = new FileStream(lua,
FileMode.OpenOrCreate,FileAccess.Write))
FileMode.OpenOrCreate, FileAccess.Write))
{
StreamWriter sw = new StreamWriter(fs, new UTF8Encoding(false));
if (string.IsNullOrEmpty(addrequire))
......
......@@ -46,7 +46,7 @@ private void CommandManager_ReverseUndoStateChanged(bool val)
#region ICommandManager 成员
public void ExcuteCommand(ICommand command, params object[] args)
{
if(!command.Excute(args))
if (!command.Excute(args))
{
return;
}
......
......@@ -6,8 +6,8 @@
*
*/
using System;
using System.Data.SQLite;
using System.Collections.Generic;
using System.Data.SQLite;
using System.IO;
using System.Text;
......@@ -28,7 +28,7 @@ static DataBase()
"SELECT datas.*,texts.* FROM datas,texts WHERE datas.id=texts.id ";
StringBuilder st = new StringBuilder();
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(i.ToString());
......@@ -39,8 +39,8 @@ static DataBase()
st.Append("id integer primary key,ot integer,alias integer,");
st.Append("setcode integer,type integer,atk integer,def integer,");
st.Append("level integer,race integer,attribute integer,category integer) ");
_defaultTableSQL=st.ToString();
st.Remove(0,st.Length);
_defaultTableSQL = st.ToString();
st.Remove(0, st.Length);
}
#endregion
......@@ -51,7 +51,7 @@ static DataBase()
/// <param name="Db">新数据库路径</param>
public static bool Create(string Db)
{
if ( File.Exists(Db) )
if (File.Exists(Db))
{
File.Delete(Db);
}
......@@ -69,7 +69,8 @@ public static bool Create(string Db)
}
public static bool CheckTable(string db)
{
try{
try
{
Command(db, _defaultTableSQL);
}
catch
......@@ -90,18 +91,18 @@ public static bool CheckTable(string db)
public static int Command(string DB, params string[] SQLs)
{
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();
using ( SQLiteTransaction trans = con.BeginTransaction() )
using (SQLiteTransaction trans = con.BeginTransaction())
{
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;
result += cmd.ExecuteNonQuery();
......@@ -126,7 +127,7 @@ public static int Command(string DB, params string[] SQLs)
#endregion
#region 根据SQL读取
static Card ReadCard(SQLiteDataReader reader,bool reNewLine)
static Card ReadCard(SQLiteDataReader reader, bool reNewLine)
{
Card c = new Card(0)
{
......@@ -147,13 +148,13 @@ static Card ReadCard(SQLiteDataReader reader,bool reNewLine)
};
if (reNewLine)
{
c.desc=Retext(c.desc);
c.desc = Retext(c.desc);
}
for ( int i = 0; i < 0x10; i++ )
for (int i = 0; i < 0x10; i++)
{
string temp = reader.GetString(reader.GetOrdinal("str" + (i + 1).ToString()));
c.Str[i]= temp ?? "";
c.Str[i] = temp ?? "";
}
return c;
}
......@@ -182,7 +183,7 @@ public static Card[] Read(string DB, bool reNewLine, params long[] ids)
/// <param name="DB">数据库</param>
/// <param name="reNewLine">调整换行符</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<long> idlist=new List<long>();
......@@ -242,7 +243,7 @@ public static Card[] Read(string DB,bool reNewLine, params string[] SQLs)
sqliteconn.Close();
}
}
if (list.Count==0)
if (list.Count == 0)
{
return null;
}
......@@ -262,16 +263,16 @@ public static Card[] Read(string DB,bool reNewLine, params string[] SQLs)
public static int CopyDB(string DB, bool ignore, params Card[] cards)
{
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();
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 = GetInsertSQL(c, ignore);
result += cmd.ExecuteNonQuery();
......@@ -319,12 +320,12 @@ public static void Compression(string db)
{
if (File.Exists(db))
{
using ( SQLiteConnection con = new SQLiteConnection(@"Data Source=" + db) )
using (SQLiteConnection con = new SQLiteConnection(@"Data Source=" + db))
{
con.Open();
using(SQLiteCommand cmd = new SQLiteCommand(con) )
using (SQLiteCommand cmd = new SQLiteCommand(con))
{
cmd.CommandText="vacuum";
cmd.CommandText = "vacuum";
cmd.ExecuteNonQuery();
}
con.Close();
......@@ -338,7 +339,8 @@ public static void Compression(string db)
#region 查询
static string toInt(long l)
{
unchecked{
unchecked
{
return ((int)l).ToString();
}
}
......@@ -351,36 +353,37 @@ public static string GetSelectSQL(Card c)
return sb.ToString();
}
if (!string.IsNullOrEmpty(c.name)){
if(c.name.IndexOf("%%")>=0)
if (!string.IsNullOrEmpty(c.name))
{
if (c.name.IndexOf("%%") >= 0)
{
c.name=c.name.Replace("%%","%");
c.name = c.name.Replace("%%", "%");
}
else
{
c.name="%"+c.name.Replace("%","/%").Replace("_","/_")+"%";
c.name = "%" + c.name.Replace("%", "/%").Replace("_", "/_") + "%";
}
sb.Append(" and texts.name like '"+c.name.Replace("'", "''")+"' ");
sb.Append(" and texts.name like '" + c.name.Replace("'", "''") + "' ");
}
if(!string.IsNullOrEmpty(c.desc))
if (!string.IsNullOrEmpty(c.desc))
{
sb.Append(" and texts.desc like '%"+c.desc.Replace("'", "''") + "%' ");
sb.Append(" and texts.desc like '%" + c.desc.Replace("'", "''") + "%' ");
}
if (c.ot>0)
if (c.ot > 0)
{
sb.Append(" and datas.ot = "+c.ot.ToString());
sb.Append(" and datas.ot = " + c.ot.ToString());
}
if (c.attribute>0)
if (c.attribute > 0)
{
sb.Append(" and datas.attribute = "+c.attribute.ToString());
sb.Append(" and datas.attribute = " + c.attribute.ToString());
}
if ((c.level & 0xff) > 0)
{
sb.Append(" and (datas.level & 255) = "+toInt(c.level & 0xff));
sb.Append(" and (datas.level & 255) = " + toInt(c.level & 0xff));
}
if ((c.level & 0xff000000) > 0)
......@@ -393,28 +396,28 @@ public static string GetSelectSQL(Card c)
sb.Append(" and (datas.level & 16711680) = " + toInt(c.level & 0xff0000));
}
if (c.race>0)
if (c.race > 0)
{
sb.Append(" and datas.race = "+toInt(c.race));
sb.Append(" and datas.race = " + toInt(c.race));
}
if (c.type>0)
if (c.type > 0)
{
sb.Append(" and datas.type & "+toInt(c.type)+" = "+toInt(c.type));
sb.Append(" and datas.type & " + toInt(c.type) + " = " + toInt(c.type));
}
if (c.category>0)
if (c.category > 0)
{
sb.Append(" and datas.category & "+toInt(c.category)+" = "+toInt(c.category));
sb.Append(" and datas.category & " + toInt(c.category) + " = " + toInt(c.category));
}
if (c.atk==-1)
if (c.atk == -1)
{
sb.Append(" and datas.type & 1 = 1 and datas.atk = 0");
}
else if(c.atk<0 || c.atk>0)
else if (c.atk < 0 || c.atk > 0)
{
sb.Append(" and datas.atk = "+c.atk.ToString());
sb.Append(" and datas.atk = " + c.atk.ToString());
}
if (c.IsType(Info.CardType.TYPE_LINK))
......@@ -433,17 +436,17 @@ public static string GetSelectSQL(Card c)
}
}
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();
......@@ -458,10 +461,10 @@ public static string GetSelectSQL(Card c)
/// <param name="c">卡片数据</param>
/// <param name="ignore"></param>
/// <returns>SQL语句</returns>
public static string GetInsertSQL(Card c, bool ignore,bool hex= false)
public static string GetInsertSQL(Card c, bool ignore, bool hex = false)
{
StringBuilder st = new StringBuilder();
if(ignore)
if (ignore)
{
st.Append("INSERT or ignore into datas values(");
}
......@@ -473,27 +476,33 @@ public static string GetInsertSQL(Card c, bool ignore,bool hex= false)
st.Append(c.id.ToString()); st.Append(",");
st.Append(c.ot.ToString()); st.Append(",");
st.Append(c.alias.ToString()); st.Append(",");
if(hex){
st.Append("0x"+c.setcode.ToString("x")); st.Append(",");
st.Append("0x"+c.type.ToString("x")); st.Append(",");
}else{
if (hex)
{
st.Append("0x" + c.setcode.ToString("x")); st.Append(",");
st.Append("0x" + c.type.ToString("x")); st.Append(",");
}
else
{
st.Append(c.setcode.ToString()); st.Append(",");
st.Append(c.type.ToString()); st.Append(",");
}
st.Append(c.atk.ToString()); ; st.Append(",");
st.Append(c.def.ToString()); st.Append(",");
if(hex){
st.Append("0x"+c.level.ToString("x")); st.Append(",");
st.Append("0x"+c.race.ToString("x")); st.Append(",");
st.Append("0x"+c.attribute.ToString("x")); st.Append(",");
st.Append("0x"+c.category.ToString("x")); st.Append(")");
}else{
if (hex)
{
st.Append("0x" + c.level.ToString("x")); st.Append(",");
st.Append("0x" + c.race.ToString("x")); st.Append(",");
st.Append("0x" + c.attribute.ToString("x")); st.Append(",");
st.Append("0x" + c.category.ToString("x")); st.Append(")");
}
else
{
st.Append(c.level.ToString()); st.Append(",");
st.Append(c.race.ToString()); st.Append(",");
st.Append(c.attribute.ToString()); st.Append(",");
st.Append(c.category.ToString()); st.Append(")");
}
if(ignore)
if (ignore)
{
st.Append(";\nINSERT or ignore into texts values(");
}
......@@ -505,7 +514,7 @@ public static string GetInsertSQL(Card c, bool ignore,bool hex= false)
st.Append(c.id.ToString()); st.Append(",'");
st.Append(c.name.Replace("'", "''")); st.Append("','");
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("'", "''"));
}
......@@ -537,11 +546,11 @@ public static string GetUpdateSQL(Card c)
st.Append(" where id="); st.Append(c.id.ToString());
st.Append("; update texts set name='"); st.Append(c.name.Replace("'", "''"));
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("'", "''"));
if ( i < 15 )
if (i < 15)
{
st.Append("',");
}
......@@ -568,7 +577,8 @@ public static string GetDeleteSQL(Card c)
#endregion
public static void ExportSql(string file,params Card[] cards){
public static void ExportSql(string file, params Card[] cards)
{
using (FileStream fs = new FileStream(file, FileMode.Create, FileAccess.Write))
{
StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
......@@ -580,19 +590,20 @@ public static string GetDeleteSQL(Card c)
}
}
public static CardPack FindPack(string db, long id){
public static CardPack FindPack(string db, long id)
{
CardPack cardpack=null;
if ( File.Exists(db) && id>=0)
if (File.Exists(db) && id >= 0)
{
using ( SQLiteConnection sqliteconn = new SQLiteConnection(@"Data Source=" + db) )
using (SQLiteConnection sqliteconn = new SQLiteConnection(@"Data Source=" + db))
{
sqliteconn.Open();
using ( SQLiteCommand sqlitecommand = new SQLiteCommand(sqliteconn) )
using (SQLiteCommand sqlitecommand = new SQLiteCommand(sqliteconn))
{
sqlitecommand.CommandText = "select id,pack_id,pack,rarity,date from pack where id="+id+" order by date desc";
using ( SQLiteDataReader reader = sqlitecommand.ExecuteReader() )
sqlitecommand.CommandText = "select id,pack_id,pack,rarity,date from pack where id=" + id + " order by date desc";
using (SQLiteDataReader reader = sqlitecommand.ExecuteReader())
{
if(reader.Read())
if (reader.Read())
{
cardpack = new CardPack(id)
{
......
......@@ -5,7 +5,6 @@
* 时间: 9:47
*
*/
using System;
namespace DataEditorX.Core.Info
{
......
......@@ -6,7 +6,6 @@
*
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
*/
using System;
namespace DataEditorX.Core.Info
{
......@@ -30,7 +29,8 @@ public static class CardLink
public const int Up = 0x80;
public const int UpRight = 0x100;
public static bool IsLink(int marks, int mark){
public static bool IsLink(int marks, int mark)
{
return (marks & mark) == mark;
}
}
......
......@@ -5,7 +5,6 @@
* 时间: 9:44
*
*/
using System;
namespace DataEditorX.Core.Info
{
......

namespace DataEditorX.Core.Info
{
public enum CardRule :int
public enum CardRule : int
{
/// <summary>无</summary>
NONE = 0,
......
......@@ -5,7 +5,6 @@
* 时间: 9:08
*
*/
using System;
using System.Collections.Generic;
namespace DataEditorX.Core.Info
......@@ -16,61 +15,62 @@ namespace DataEditorX.Core.Info
public enum CardType : long
{
///<summary>怪兽卡</summary>
TYPE_MONSTER =0x1 ,
TYPE_MONSTER =0x1,
///<summary>魔法卡</summary>
TYPE_SPELL =0x2 ,
TYPE_SPELL =0x2,
///<summary>陷阱卡</summary>
TYPE_TRAP =0x4 ,
TYPE_TRAP =0x4,
///<summary>通常</summary>
TYPE_NORMAL =0x10 ,
TYPE_NORMAL =0x10,
///<summary>效果</summary>
TYPE_EFFECT =0x20 ,
TYPE_EFFECT =0x20,
///<summary>融合</summary>
TYPE_FUSION =0x40 ,
TYPE_FUSION =0x40,
///<summary>仪式</summary>
TYPE_RITUAL =0x80 ,
TYPE_RITUAL =0x80,
///<summary>陷阱怪兽</summary>
TYPE_TRAPMONSTER =0x100 ,
TYPE_TRAPMONSTER =0x100,
///<summary>灵魂</summary>
TYPE_SPIRIT =0x200 ,
TYPE_SPIRIT =0x200,
///<summary>同盟</summary>
TYPE_UNION =0x400 ,
TYPE_UNION =0x400,
///<summary>二重</summary>
TYPE_DUAL =0x800 ,
TYPE_DUAL =0x800,
///<summary>调整</summary>
TYPE_TUNER =0x1000 ,
TYPE_TUNER =0x1000,
///<summary>同调</summary>
TYPE_SYNCHRO =0x2000 ,
TYPE_SYNCHRO =0x2000,
///<summary>衍生物</summary>
TYPE_TOKEN =0x4000 ,
TYPE_TOKEN =0x4000,
///<summary>速攻</summary>
TYPE_QUICKPLAY =0x10000 ,
TYPE_QUICKPLAY =0x10000,
///<summary>永续</summary>
TYPE_CONTINUOUS =0x20000 ,
TYPE_CONTINUOUS =0x20000,
///<summary>装备</summary>
TYPE_EQUIP =0x40000 ,
TYPE_EQUIP =0x40000,
///<summary>场地</summary>
TYPE_FIELD =0x80000 ,
TYPE_FIELD =0x80000,
///<summary>反击</summary>
TYPE_COUNTER =0x100000 ,
TYPE_COUNTER =0x100000,
///<summary>反转</summary>
TYPE_FLIP =0x200000 ,
TYPE_FLIP =0x200000,
///<summary>卡通</summary>
TYPE_TOON =0x400000 ,
TYPE_TOON =0x400000,
///<summary>超量</summary>
TYPE_XYZ =0x800000 ,
TYPE_XYZ =0x800000,
///<summary>灵摆</summary>
TYPE_PENDULUM =0x1000000 ,
TYPE_PENDULUM =0x1000000,
///<summary>特殊召唤</summary>
TYPE_SPSUMMON =0x2000000 ,
TYPE_SPSUMMON =0x2000000,
///<summary>连接</summary>
TYPE_LINK =0x4000000 ,
TYPE_LINK =0x4000000,
}
public static class CardTypes{
public static class CardTypes
{
public static readonly CardType[] TYPE1 = {
CardType.TYPE_TOKEN,
CardType.TYPE_LINK,
......@@ -157,16 +157,20 @@ public static class CardTypes{
CardType.TYPE_EFFECT,
CardType.TYPE_NORMAL,
};
public static CardType[] GetMonsterTypes(long type,bool no10=false){
public static CardType[] GetMonsterTypes(long type, bool no10 = false)
{
var list = new List<CardType>(5);
var typeList=new List<CardType[]>(5);
if(no10){
if (no10)
{
typeList.Add(TYPE1_10);
typeList.Add(TYPE2_10);
typeList.Add(TYPE3_10);
typeList.Add(TYPE4_10);
typeList.Add(TYPE4_10);
}else{
}
else
{
typeList.Add(TYPE1);
typeList.Add(TYPE2);
typeList.Add(TYPE3);
......@@ -175,11 +179,15 @@ public static class CardTypes{
}
int count = typeList.Count;
for(int i=0;i<count;i++){
for (int i = 0; i < count; i++)
{
CardType[] types = typeList[i];
foreach(var t in types){
if((type & (long)t)==(long)t){
if(!list.Contains(t)){
foreach (var t in types)
{
if ((type & (long)t) == (long)t)
{
if (!list.Contains(t))
{
list.Add(t);
break;
}
......
......@@ -6,9 +6,9 @@
*
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace DataEditorX
......@@ -25,7 +25,7 @@ static void ResetLog()
}
static void Log(string str)
{
File.AppendAllText(_logtxt, str+Environment.NewLine);
File.AppendAllText(_logtxt, str + Environment.NewLine);
}
#endregion
......@@ -38,16 +38,16 @@ static void Log(string str)
public static void Read(string funtxt)
{
_funclist.Clear();
_oldfun=funtxt;
if(File.Exists(funtxt))
_oldfun = funtxt;
if (File.Exists(funtxt))
{
string[] lines=File.ReadAllLines(funtxt);
bool isFind=false;
string name="";
string desc="";
foreach(string line in lines)
foreach (string line in lines)
{
if(string.IsNullOrEmpty(line)
if (string.IsNullOrEmpty(line)
|| line.StartsWith("==")
|| line.StartsWith("#"))
{
......@@ -61,14 +61,16 @@ public static void Read(string funtxt)
int w=line.IndexOf("(");
int t=line.IndexOf(" ");
//获取当前名字
if(t<w && t>0){
name=line.Substring(t+1,w-t-1);
isFind=true;
desc=line.Replace("●","");
if (t < w && t > 0)
{
name = line.Substring(t + 1, w - t - 1);
isFind = true;
desc = line.Replace("●", "");
}
}
else if(isFind){
desc+=Environment.NewLine+line;
else if (isFind)
{
desc += Environment.NewLine + line;
}
}
AddOldFun(name, desc);
......@@ -102,18 +104,21 @@ public static bool Find(string path)
string name="interpreter.cpp";
string file=Path.Combine(path,name);
string file2=Path.Combine(Path.Combine(path, "ocgcore"), name);
_logtxt=Path.Combine(path, "find_functions.log");
_logtxt = Path.Combine(path, "find_functions.log");
ResetLog();
_funclisttxt =Path.Combine(path, "_functions.txt");
_funclisttxt = Path.Combine(path, "_functions.txt");
File.Delete(_funclisttxt);
if(!File.Exists(file)){//判断用户选择的目录
Log("error: no find file "+file);
if(File.Exists(file2)){
file=file2;
path=Path.Combine(path, "ocgcore");
}
else{
Log("error: no find file "+file2);
if (!File.Exists(file))
{//判断用户选择的目录
Log("error: no find file " + file);
if (File.Exists(file2))
{
file = file2;
path = Path.Combine(path, "ocgcore");
}
else
{
Log("error: no find file " + file2);
return false;
}
}
......@@ -121,15 +126,16 @@ public static bool Find(string path)
Regex libRex=new Regex(@"\sluaL_Reg\s([a-z]*?)lib\[\]([\s\S]*?)^\}"
,RegexOptions.Multiline);
MatchCollection libsMatch=libRex.Matches(texts);
Log("log:count "+libsMatch.Count.ToString());
foreach ( Match m in libsMatch )//获取lib函数库
Log("log:count " + libsMatch.Count.ToString());
foreach (Match m in libsMatch)//获取lib函数库
{
if (m.Groups.Count > 2)
{
if(m.Groups.Count>2){
string word=m.Groups[1].Value;
Log("log:find "+word);
Log("log:find " + word);
//分别去获取函数库的函数
GetFunctions(word, m.Groups[2].Value,
Path.Combine(path,"lib"+word+".cpp"));
Path.Combine(path, "lib" + word + ".cpp"));
}
}
Save();
......@@ -161,24 +167,24 @@ static void Save()
#region find function name
static string ToTitle(string str)
{
return str.Substring(0, 1).ToUpper()+str.Substring(1);
return str.Substring(0, 1).ToUpper() + str.Substring(1);
}
//获取函数库的lua函数名,和对应的c++函数
static Dictionary<string,string> GetFunctionNames(string texts,string name)
static Dictionary<string, string> GetFunctionNames(string texts, string name)
{
Dictionary<string,string> dic=new Dictionary<string, string>();
Regex funcRex=new Regex("\"(\\S*?)\",\\s*?(\\S*?::\\S*?)\\s");
MatchCollection funcsMatch=funcRex.Matches(texts);
Log("log: functions count "+name+":"+funcsMatch.Count.ToString());
foreach ( Match m in funcsMatch )
Log("log: functions count " + name + ":" + funcsMatch.Count.ToString());
foreach (Match m in funcsMatch)
{
if(m.Groups.Count>2)
if (m.Groups.Count > 2)
{
string k=ToTitle(name)+"."+m.Groups[1].Value;
string v=m.Groups[2].Value;
if(!dic.ContainsKey(k))
if (!dic.ContainsKey(k))
{
dic.Add(k,v);
dic.Add(k, v);
}
}
}
......@@ -188,20 +194,20 @@ static string ToTitle(string str)
#region find code
//查找c++代码
static string FindCode(string texts,string name)
static string FindCode(string texts, string name)
{
Regex reg=new Regex(@"int32\s+?"+name
+@"[\s\S]+?\{([\s\S]*?^)\}",
RegexOptions.Multiline);
Match mc=reg.Match(texts);
if(mc.Success)
if (mc.Success)
{
if(mc.Groups.Count>1)
if (mc.Groups.Count > 1)
{
return mc.Groups[0].Value
.Replace("\r\n","\n")
.Replace("\r","\n")
.Replace("\n",Environment.NewLine);
.Replace("\r\n", "\n")
.Replace("\r", "\n")
.Replace("\n", Environment.NewLine);
}
}
return "";
......@@ -213,48 +219,49 @@ static string FindCode(string texts,string name)
static string FindReturn(string texts)
{
string restr="";
if(texts.IndexOf("lua_pushboolean")>=0)
if (texts.IndexOf("lua_pushboolean") >= 0)
{
return "bool ";
}
else
{
if(texts.IndexOf("interpreter::card2value")>=0)
if (texts.IndexOf("interpreter::card2value") >= 0)
{
restr += "Card ";
}
if (texts.IndexOf("interpreter::group2value")>=0)
if (texts.IndexOf("interpreter::group2value") >= 0)
{
restr += "Group ";
}
if (texts.IndexOf("interpreter::effect2value")>=0)
if (texts.IndexOf("interpreter::effect2value") >= 0)
{
restr += "Effect ";
}
else if(texts.IndexOf("interpreter::function2value")>=0)
else if (texts.IndexOf("interpreter::function2value") >= 0)
{
restr += "function ";
}
if (texts.IndexOf("lua_pushinteger")>=0)
if (texts.IndexOf("lua_pushinteger") >= 0)
{
restr += "int ";
}
if (texts.IndexOf("lua_pushstring")>=0)
if (texts.IndexOf("lua_pushstring") >= 0)
{
restr += "string ";
}
}
if(string.IsNullOrEmpty(restr))
if (string.IsNullOrEmpty(restr))
{
restr ="void ";
restr = "void ";
}
if (restr.IndexOf(" ") !=restr.Length-1){
restr = restr.Replace(" ","|").Substring(0,restr.Length-1)+" ";
if (restr.IndexOf(" ") != restr.Length - 1)
{
restr = restr.Replace(" ", "|").Substring(0, restr.Length - 1) + " ";
}
return restr;
}
......@@ -264,17 +271,17 @@ static string FindReturn(string texts)
//查找参数
static string getUserType(string str)
{
if(str.IndexOf("card")>=0)
if (str.IndexOf("card") >= 0)
{
return "Card";
}
if (str.IndexOf("effect")>=0)
if (str.IndexOf("effect") >= 0)
{
return "Effect";
}
if (str.IndexOf("group")>=0)
if (str.IndexOf("group") >= 0)
{
return "Group";
}
......@@ -282,24 +289,24 @@ static string getUserType(string str)
return "Any";
}
static void AddArgs(string texts,string regx,string arg,SortedList<int,string> dic)
static void AddArgs(string texts, string regx, string arg, SortedList<int, string> dic)
{
//function
Regex reg=new Regex(regx);
MatchCollection mcs=reg.Matches(texts);
foreach(Match m in mcs)
foreach (Match m in mcs)
{
if(m.Groups.Count>1)
if (m.Groups.Count > 1)
{
string v=arg;
int k=int.Parse(m.Groups[1].Value);
if(dic.ContainsKey(k))
if (dic.ContainsKey(k))
{
dic[k] = dic[k]+"|"+v;
dic[k] = dic[k] + "|" + v;
}
else
{
dic.Add(k,v);
dic.Add(k, v);
}
}
}
......@@ -310,42 +317,42 @@ static string FindArgs(string texts)
//card effect ggroup
Regex reg=new Regex(@"\((\S+?)\)\s+?lua_touserdata\(L,\s+(\d+)\)");
MatchCollection mcs=reg.Matches(texts);
foreach(Match m in mcs)
foreach (Match m in mcs)
{
if(m.Groups.Count>2)
if (m.Groups.Count > 2)
{
string v=m.Groups[1].Value.ToLower();
v = getUserType(v);
int k=int.Parse(m.Groups[2].Value);
if(dic.ContainsKey(k))
if (dic.ContainsKey(k))
{
dic[k] = dic[k]+"|"+v;
dic[k] = dic[k] + "|" + v;
}
else
{
dic.Add(k,v);
dic.Add(k, v);
}
}
}
//function
AddArgs(texts
,@"interpreter::get_function_handle\(L,\s+(\d+)\)"
,"function",dic);
, @"interpreter::get_function_handle\(L,\s+(\d+)\)"
, "function", dic);
//int
AddArgs(texts,@"lua_tointeger\(L,\s+(\d+)\)","integer",dic);
AddArgs(texts, @"lua_tointeger\(L,\s+(\d+)\)", "integer", dic);
//string
AddArgs(texts,@"lua_tostring\(L,\s+(\d+)\)","string",dic);
AddArgs(texts, @"lua_tostring\(L,\s+(\d+)\)", "string", dic);
//bool
AddArgs(texts,@"lua_toboolean\(L,\s+(\d+)\)","boolean",dic);
AddArgs(texts, @"lua_toboolean\(L,\s+(\d+)\)", "boolean", dic);
string args="(";
foreach(int i in dic.Keys)
foreach (int i in dic.Keys)
{
args +=dic[i]+", ";
args += dic[i] + ", ";
}
if(args.Length>1)
if (args.Length > 1)
{
args = args.Substring(0,args.Length-2);
args = args.Substring(0, args.Length - 2);
}
args += ")";
......@@ -357,7 +364,7 @@ static string FindArgs(string texts)
//查找旧函数的描述
static string FindOldDesc(string name)
{
if(_funclist.ContainsKey(name))
if (_funclist.ContainsKey(name))
{
return _funclist[name];
}
......@@ -368,29 +375,31 @@ static string FindOldDesc(string name)
#region Save Functions
//保存函数
public static void GetFunctions(string name,string texts,string file)
public static void GetFunctions(string name, string texts, string file)
{
if (!File.Exists(file))
{
if(!File.Exists(file)){
Log("error:no find file "+file);
Log("error:no find file " + file);
return;
}
string cpps=File.ReadAllText(file);
//lua name /cpp name
Dictionary<string,string> fun=GetFunctionNames(texts,name);
if(fun==null || fun.Count==0){
Log("warning: no find functions of "+name);
if (fun == null || fun.Count == 0)
{
Log("warning: no find functions of " + name);
return;
}
Log("log: find functions "+name+":"+fun.Count.ToString());
Log("log: find functions " + name + ":" + fun.Count.ToString());
using(FileStream fs=new FileStream(file+".txt",
using (FileStream fs = new FileStream(file + ".txt",
FileMode.Create,
FileAccess.Write))
{
StreamWriter sw=new StreamWriter(fs, Encoding.UTF8);
sw.WriteLine("========== "+name+" ==========");
sw.WriteLine("========== " + name + " ==========");
File.AppendAllText(_funclisttxt, "========== " + name + " ==========" + Environment.NewLine);
foreach(string k in fun.Keys)
foreach (string k in fun.Keys)
{
string v=fun[k];
string code=FindCode(cpps, v);
......@@ -401,7 +410,7 @@ public static void GetFunctions(string name,string texts,string file)
+code;
sw.WriteLine(txt);
File.AppendAllText(_funclisttxt,txt + Environment.NewLine);
File.AppendAllText(_funclisttxt, txt + Environment.NewLine);
}
sw.Close();
}
......
......@@ -6,7 +6,6 @@
*
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
*/
using System;
namespace DataEditorX.Core
{
......@@ -17,10 +16,11 @@ public class CardPack
{
public CardPack(long id)
{
this.CardId=id;
this.CardId = id;
}
public long CardId{
public long CardId
{
get;
private set;
}
......@@ -29,69 +29,72 @@ public CardPack(long id)
public string rarity;
public string date;
public string GetMseRarity(){
if(this.rarity==null)
public string GetMseRarity()
{
if (this.rarity == null)
{
return "common";
}
string rarity=this.rarity.Trim().ToLower();
if(rarity.Equals("common") || rarity.Equals("short print"))
if (rarity.Equals("common") || rarity.Equals("short print"))
{
return "common";
}
if(rarity.Equals("rare") ||rarity.Equals("normal rare"))
if (rarity.Equals("rare") || rarity.Equals("normal rare"))
{
return "rare";
}else if(rarity.Contains("parallel") || rarity.Contains("Kaiba") || rarity.Contains("duel terminal"))
}
else if (rarity.Contains("parallel") || rarity.Contains("Kaiba") || rarity.Contains("duel terminal"))
{
return "parallel rare";
}
else if(rarity.Contains("super") ||rarity.Contains("holofoil"))
else if (rarity.Contains("super") || rarity.Contains("holofoil"))
{
return "super rare";
}
else if(rarity.Contains("ultra"))
else if (rarity.Contains("ultra"))
{
return "ultra rare";
}
else if(rarity.Contains("secret"))
else if (rarity.Contains("secret"))
{
return "secret rare";
}
else if(rarity.Contains("gold"))
else if (rarity.Contains("gold"))
{
return "gold rare";
}
else if(rarity.Contains("ultimate"))
else if (rarity.Contains("ultimate"))
{
return "ultimate rare";
}
else if(rarity.Contains("prismatic"))
else if (rarity.Contains("prismatic"))
{
return "prismatic rare";
}
else if(rarity.Contains("star"))
else if (rarity.Contains("star"))
{
return "star rare";
}
else if(rarity.Contains("mosaic"))
else if (rarity.Contains("mosaic"))
{
return "mosaic rare";
}
else if(rarity.Contains("platinum"))
else if (rarity.Contains("platinum"))
{
return "platinum rare";
}
else if(rarity.Contains("ghost") || rarity.Contains("holographic"))
else if (rarity.Contains("ghost") || rarity.Contains("holographic"))
{
return "ghost rare";
}
else if(rarity.Contains("millenium"))
else if (rarity.Contains("millenium"))
{
return "millenium rare";
}
if(this.rarity.Contains("/")){
if (this.rarity.Contains("/"))
{
return this.rarity.Split('/')[0];
}
return this.rarity;
......
......@@ -5,15 +5,11 @@
* 时间: 15:47
*
*/
using System;
using System.Configuration;
using DataEditorX.Common;
using DataEditorX.Config;
using System.Collections.Generic;
using System.IO;
using System.Text;
using DataEditorX.Language;
using System.Globalization;
using DataEditorX.Common;
using DataEditorX.Config;
namespace DataEditorX.Core.Mse
{
......@@ -125,26 +121,34 @@ public void SetConfig(string config, string path)
{
this.maxcount = ConfHelper.GetIntegerValue(line, 0);
}
else if (line.StartsWith(TAG_WIDTH)){
this.width =ConfHelper.GetIntegerValue(line,0);
else if (line.StartsWith(TAG_WIDTH))
{
this.width = ConfHelper.GetIntegerValue(line, 0);
}
else if (line.StartsWith(TAG_HEIGHT)){
this.height =ConfHelper.GetIntegerValue(line,0);
else if (line.StartsWith(TAG_HEIGHT))
{
this.height = ConfHelper.GetIntegerValue(line, 0);
}
else if (line.StartsWith(TAG_PEND_WIDTH)){
this.pwidth =ConfHelper.GetIntegerValue(line,0);
else if (line.StartsWith(TAG_PEND_WIDTH))
{
this.pwidth = ConfHelper.GetIntegerValue(line, 0);
}
else if (line.StartsWith(TAG_PEND_HEIGHT)){
this.pheight =ConfHelper.GetIntegerValue(line,0);
else if (line.StartsWith(TAG_PEND_HEIGHT))
{
this.pheight = ConfHelper.GetIntegerValue(line, 0);
}
else if(line.StartsWith(TAG_NO_TEN)){
else if (line.StartsWith(TAG_NO_TEN))
{
this.no10 = ConfHelper.GetBooleanValue(line);
}else if(line.StartsWith(TAG_NO_START_CARDS)){
}
else if (line.StartsWith(TAG_NO_START_CARDS))
{
string val = ConfHelper.GetValue(line);
string[] cs = val.Split(',');
this.noStartCards =new long[cs.Length];
this.noStartCards = new long[cs.Length];
int i=0;
foreach(string str in cs){
foreach (string str in cs)
{
long.TryParse(str, out long l);
this.noStartCards[i++] = l;
}
......@@ -174,7 +178,9 @@ public void SetConfig(string config, string path)
else if (line.StartsWith(TAG_TYPE))
{//类型
ConfHelper.DicAdd(this.typeDic, line);
}else if(line.StartsWith(TAG_REIMAGE)){
}
else if (line.StartsWith(TAG_REIMAGE))
{
this.reimage = ConfHelper.GetBooleanValue(line);
}
}
......@@ -189,7 +195,7 @@ public void Init(string path)
if (!File.Exists(tmp))
{
tmp = MyPath.Combine(path, MyPath.GetFileName(TAG, FILE_CONFIG_NAME));
if(!File.Exists(tmp))
if (!File.Exists(tmp))
{
return;//如果默认的也不存在
}
......
using System;
using System.Collections.Generic;
using System.Text;
namespace DataEditorX.Core.Mse
namespace DataEditorX.Core.Mse
{
public class MseAttribute
{
......
......@@ -5,20 +5,18 @@
* 时间: 12:48
*
*/
using DataEditorX.Common;
using DataEditorX.Core.Info;
using DataEditorX.Language;
using Microsoft.VisualBasic;
using System;
using System.IO;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using Microsoft.VisualBasic;
using System.Drawing;
using DataEditorX.Core.Info;
using DataEditorX.Config;
using DataEditorX.Language;
using DataEditorX.Common;
using System.Windows.Forms;
using System.Threading;
using System.Windows.Forms;
namespace DataEditorX.Core.Mse
{
......@@ -310,18 +308,22 @@ public string[] GetTypes(Card c)
int MAX_TYPE= 5;
var types = new string[MAX_TYPE+1];
types[0] = MseCardType.CARD_NORMAL;
for(int i=1;i<types.Length;i++){
types[i]="";
for (int i = 1; i < types.Length; i++)
{
types[i] = "";
}
if (c.IsType(CardType.TYPE_MONSTER))
{
CardType[] cardTypes = CardTypes.GetMonsterTypes(c.type, this.cfg.no10);
int count = cardTypes.Length;
for(int i=0; i<count && i<MAX_TYPE; i++){
types[i+1] = this.GetType(cardTypes[i]);
for (int i = 0; i < count && i < MAX_TYPE; i++)
{
types[i + 1] = this.GetType(cardTypes[i]);
}
if(cardTypes.Length>0){
if(c.IsType(CardType.TYPE_LINK)){
if (cardTypes.Length > 0)
{
if (c.IsType(CardType.TYPE_LINK))
{
types[0] = MseCardType.CARD_LINK;
}
else if (c.IsType(CardType.TYPE_TOKEN))
......@@ -350,9 +352,11 @@ public string[] GetTypes(Card c)
{
types[0] = MseCardType.CARD_EFFECT;
}
else{
else
{
types[0] = MseCardType.CARD_NORMAL;
if(cardTypes.Length==1){
if (cardTypes.Length == 1)
{
//xxx/通常
}
}
......@@ -371,9 +375,9 @@ public string[] GetTypes(Card c)
#region 写存档
//写存档
public Dictionary<Card, string> WriteSet(string file, Card[] cards,string cardpack_db,bool rarity=true)
public Dictionary<Card, string> WriteSet(string file, Card[] cards, string cardpack_db, bool rarity = true)
{
// MessageBox.Show(""+cfg.replaces.Keys[0]+"/"+cfg.replaces[cfg.replaces.Keys[0]]);
// MessageBox.Show(""+cfg.replaces.Keys[0]+"/"+cfg.replaces[cfg.replaces.Keys[0]]);
Dictionary<Card, string> list = new Dictionary<Card, string>();
string pic = this.cfg.imagepath;
using (FileStream fs = new FileStream(file,
......@@ -392,11 +396,11 @@ public string[] GetTypes(Card c)
CardPack cardpack=DataBase.FindPack(cardpack_db, c.id);
if (c.IsType(CardType.TYPE_SPELL) || c.IsType(CardType.TYPE_TRAP))
{
sw.WriteLine(this.getSpellTrap(c, jpg, c.IsType(CardType.TYPE_SPELL), cardpack,rarity));
sw.WriteLine(this.getSpellTrap(c, jpg, c.IsType(CardType.TYPE_SPELL), cardpack, rarity));
}
else
{
sw.WriteLine(this.getMonster(c, jpg, cardpack,rarity));
sw.WriteLine(this.getMonster(c, jpg, cardpack, rarity));
}
}
sw.WriteLine(this.cfg.end);
......@@ -405,19 +409,22 @@ public string[] GetTypes(Card c)
return list;
}
int getLinkNumber(long link){
int getLinkNumber(long link)
{
string str = Convert.ToString(link, 2);
char[] cs = str.ToCharArray();
int i = 0;
foreach(char c in cs){
if(c == '1'){
foreach (char c in cs)
{
if (c == '1')
{
i++;
}
}
return i;
}
//怪兽,pendulum怪兽
string getMonster(Card c, string img,CardPack cardpack=null,bool rarity=true)
string getMonster(Card c, string img, CardPack cardpack = null, bool rarity = true)
{
StringBuilder sb = new StringBuilder();
string[] types = this.GetTypes(c);
......@@ -427,15 +434,19 @@ string getMonster(Card c, string img,CardPack cardpack=null,bool rarity=true)
sb.AppendLine(this.GetLine(TAG_NAME, this.ReItalic(c.name)));
sb.AppendLine(this.GetLine(TAG_ATTRIBUTE, GetAttribute(c.attribute)));
bool noStar = false;
if(this.cfg.noStartCards != null){
foreach(long id in this.cfg.noStartCards){
if(c.alias == id || c.id == id){
if (this.cfg.noStartCards != null)
{
foreach (long id in this.cfg.noStartCards)
{
if (c.alias == id || c.id == id)
{
noStar = true;
break;
}
}
}
if(!noStar){
if (!noStar)
{
sb.AppendLine(this.GetLine(TAG_LEVEL, GetStar(c.level)));
}
sb.AppendLine(this.GetLine(TAG_IMAGE, img));
......@@ -444,41 +455,54 @@ string getMonster(Card c, string img,CardPack cardpack=null,bool rarity=true)
sb.AppendLine(this.GetLine(TAG_TYPE3, this.CN2TW(types[2])));
sb.AppendLine(this.GetLine(TAG_TYPE4, this.CN2TW(types[3])));
sb.AppendLine(this.GetLine(TAG_TYPE5, this.CN2TW(types[4])));
if(cardpack!=null){
if (cardpack != null)
{
sb.AppendLine(this.GetLine(TAG_NUMBER, cardpack.pack_id));
if(rarity){
if (rarity)
{
sb.AppendLine(this.GetLine(TAG_RARITY, cardpack.GetMseRarity()));
}
}
if(c.IsType(CardType.TYPE_LINK)){
if(CardLink.IsLink(c.def, CardLink.DownLeft)){
if (c.IsType(CardType.TYPE_LINK))
{
if (CardLink.IsLink(c.def, CardLink.DownLeft))
{
sb.AppendLine(this.GetLine(TAG_Link_Marker_DL, "yes"));
}
if(CardLink.IsLink(c.def, CardLink.Down)){
if (CardLink.IsLink(c.def, CardLink.Down))
{
sb.AppendLine(this.GetLine(TAG_Link_Marker_Down, "yes"));
}
if(CardLink.IsLink(c.def, CardLink.DownRight)){
if (CardLink.IsLink(c.def, CardLink.DownRight))
{
sb.AppendLine(this.GetLine(TAG_Link_Marker_DR, "yes"));
}
if(CardLink.IsLink(c.def, CardLink.UpLeft)){
if (CardLink.IsLink(c.def, CardLink.UpLeft))
{
sb.AppendLine(this.GetLine(TAG_Link_Marker_UL, "yes"));
}
if(CardLink.IsLink(c.def, CardLink.Up)){
if (CardLink.IsLink(c.def, CardLink.Up))
{
sb.AppendLine(this.GetLine(TAG_Link_Marker_Up, "yes"));
}
if(CardLink.IsLink(c.def, CardLink.UpRight)){
if (CardLink.IsLink(c.def, CardLink.UpRight))
{
sb.AppendLine(this.GetLine(TAG_Link_Marker_UR, "yes"));
}
if(CardLink.IsLink(c.def, CardLink.Left)){
if (CardLink.IsLink(c.def, CardLink.Left))
{
sb.AppendLine(this.GetLine(TAG_Link_Marker_Left, "yes"));
}
if(CardLink.IsLink(c.def, CardLink.Right)){
if (CardLink.IsLink(c.def, CardLink.Right))
{
sb.AppendLine(this.GetLine(TAG_Link_Marker_Right, "yes"));
}
sb.AppendLine(this.GetLine(TAG_Link_Number, ""+ this.getLinkNumber(c.def)));
sb.AppendLine(this.GetLine(TAG_Link_Number, "" + this.getLinkNumber(c.def)));
sb.AppendLine(" " + TAG_TEXT + ":");
sb.AppendLine(" " + this.ReText(this.ReItalic(c.desc)));
}else{
}
else
{
if (c.IsType(CardType.TYPE_PENDULUM))//P怪兽
{
string text = GetDesc(c.desc, this.cfg.regx_monster);
......@@ -495,7 +519,8 @@ string getMonster(Card c, string img,CardPack cardpack=null,bool rarity=true)
sb.AppendLine(this.GetLine(TAG_PSCALE2, ((c.level >> 0x10) & 0xff).ToString()));
sb.AppendLine(" " + TAG_PEND_TEXT + ":");
sb.AppendLine(" " + this.ReText(this.ReItalic(GetDesc(c.desc, this.cfg.regx_pendulum))));
}else//一般怪兽
}
else//一般怪兽
{
sb.AppendLine(" " + TAG_TEXT + ":");
sb.AppendLine(" " + this.ReText(this.ReItalic(c.desc)));
......@@ -508,7 +533,7 @@ string getMonster(Card c, string img,CardPack cardpack=null,bool rarity=true)
return sb.ToString();
}
//魔法陷阱
string getSpellTrap(Card c, string img, bool isSpell,CardPack cardpack=null,bool rarity=true)
string getSpellTrap(Card c, string img, bool isSpell, CardPack cardpack = null, bool rarity = true)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine(TAG_CARD + ":");
......@@ -517,9 +542,11 @@ string getSpellTrap(Card c, string img, bool isSpell,CardPack cardpack=null,bool
sb.AppendLine(this.GetLine(TAG_ATTRIBUTE, isSpell ? "spell" : "trap"));
sb.AppendLine(this.GetLine(TAG_LEVEL, this.GetSpellTrapSymbol(c, isSpell)));
sb.AppendLine(this.GetLine(TAG_IMAGE, img));
if(cardpack!=null){
if (cardpack != null)
{
sb.AppendLine(this.GetLine(TAG_NUMBER, cardpack.pack_id));
if(rarity){
if (rarity)
{
sb.AppendLine(this.GetLine(TAG_RARITY, cardpack.GetMseRarity()));
}
}
......@@ -709,7 +736,7 @@ long GetCardType(string cardtype, string level, params string[] types)
//怪兽
type |= this.GetMonsterType(cardtype);
//types是识别怪兽效果类型
foreach(string typ in types)
foreach (string typ in types)
{
type |= this.GetTypeInt(typ);
}
......@@ -780,14 +807,14 @@ public Card ReadCard(string content, out string img)
if (c.IsType(CardType.TYPE_PENDULUM))
{//根据预设的模版,替换内容
tmp = this.cfg.temp_text.Replace(TAG_REP_TEXT,
GetMultiValue(content,TAG_TEXT));
GetMultiValue(content, TAG_TEXT));
tmp = tmp.Replace(TAG_REP_PTEXT,
GetMultiValue(content, TAG_PEND_TEXT));
c.desc = tmp;
}
else
{
c.desc = GetMultiValue(content,TAG_TEXT);
c.desc = GetMultiValue(content, TAG_TEXT);
}
//摇摆刻度
int.TryParse(GetValue(content, TAG_PSCALE1), out int itmp);
......@@ -862,41 +889,50 @@ public Card[] ReadCards(string set, bool repalceOld)
/// <param name="img"></param>
/// <param name="card"></param>
/// <returns></returns>
public string GetImageCache(string img,Card card){
if(!this.cfg.reimage){
public string GetImageCache(string img, Card card)
{
if (!this.cfg.reimage)
{
//不需要调整
return img;
}
bool isPendulum = card.IsType(CardType.TYPE_PENDULUM);
if(isPendulum){
if(this.cfg.pwidth<=0 && this.cfg.pheight<=0)
if (isPendulum)
{
if (this.cfg.pwidth <= 0 && this.cfg.pheight <= 0)
{
return img;
}
}
else{
if(this.cfg.width<=0 && this.cfg.height<=0)
else
{
if (this.cfg.width <= 0 && this.cfg.height <= 0)
{
return img;
}
}
string md5=MyUtils.GetMD5HashFromFile(img);
if(MyUtils.Md5isEmpty(md5)|| this.cfg.imagecache==null){
if (MyUtils.Md5isEmpty(md5) || this.cfg.imagecache == null)
{
//md5为空
return img;
}
string file = MyPath.Combine(this.cfg.imagecache, md5);
if(!File.Exists(file)){
if (!File.Exists(file))
{
//生成缓存
Bitmap bmp=MyBitmap.ReadImage(img);
//缩放
if(isPendulum){
bmp=MyBitmap.Zoom(bmp, this.cfg.pwidth, this.cfg.pheight);
}else{
bmp=MyBitmap.Zoom(bmp, this.cfg.width, this.cfg.height);
if (isPendulum)
{
bmp = MyBitmap.Zoom(bmp, this.cfg.pwidth, this.cfg.pheight);
}
else
{
bmp = MyBitmap.Zoom(bmp, this.cfg.width, this.cfg.height);
}
//保存文件
MyBitmap.SaveAsJPEG(bmp, file,100);
MyBitmap.SaveAsJPEG(bmp, file, 100);
}
return file;
}
......@@ -905,51 +941,65 @@ public Card[] ReadCards(string set, bool repalceOld)
#region export
static System.Diagnostics.Process _mseProcess;
static EventHandler _exitHandler;
private static void exportSetThread(object obj){
private static void exportSetThread(object obj)
{
string[] args=(string[])obj;
if(args==null||args.Length<3){
if (args == null || args.Length < 3)
{
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)){
if (string.IsNullOrEmpty(mse_path) || string.IsNullOrEmpty(setfile))
{
MessageBox.Show(LanguageHelper.GetMsg(LMSG.exportMseImagesErr));
return;
}else{
}
else
{
string cmd=" --export "+setfile.Replace("\\\\","\\").Replace("\\","/")+" {card.gamecode}.png";
_mseProcess = new System.Diagnostics.Process();
_mseProcess.StartInfo.FileName = mse_path;
_mseProcess.StartInfo.Arguments = cmd;
_mseProcess.StartInfo.WorkingDirectory=path;
_mseProcess.EnableRaisingEvents=true;
_mseProcess.StartInfo.WorkingDirectory = path;
_mseProcess.EnableRaisingEvents = true;
MyPath.CreateDir(path);
try{
try
{
_mseProcess.Start();
//等待结束,需要把当前方法放到线程里面
_mseProcess.WaitForExit();
_mseProcess.Exited += new EventHandler(_exitHandler);
_mseProcess.Close();
_mseProcess=null;
_mseProcess = null;
MessageBox.Show(LanguageHelper.GetMsg(LMSG.exportMseImages));
}catch{
}
catch
{
}
}
}
public static bool MseIsRunning(){
public static bool MseIsRunning()
{
return _mseProcess != null;
}
public static void MseStop(){
try{
public static void MseStop()
{
try
{
_mseProcess.Kill();
_mseProcess.Close();
}catch{}
}
public static void ExportSet(string mse_path,string setfile,string path,EventHandler handler){
if(string.IsNullOrEmpty(mse_path)||setfile==null||setfile.Length==0){
catch { }
}
public static void ExportSet(string mse_path, string setfile, string path, EventHandler handler)
{
if (string.IsNullOrEmpty(mse_path) || setfile == null || setfile.Length == 0)
{
return;
}
ParameterizedThreadStart ParStart = new ParameterizedThreadStart(exportSetThread);
......@@ -957,7 +1007,7 @@ public Card[] ReadCards(string set, bool repalceOld)
{
IsBackground = true
};
myThread.Start(new string[]{mse_path,setfile,path});
myThread.Start(new string[] { mse_path, setfile, path });
_exitHandler = handler;
}
#endregion
......

using Newtonsoft.Json;
using System;
using System.IO;
using Newtonsoft.Json;
namespace DataEditorX
{
public class CardSet{
public class CardSet
{
public int game;
public int version;
public MySortList<string, CardInfo> cards;
}
public class CardInfo{
public class CardInfo
{
public string title;
public string artwork;
public int[] artwork_crop;
......@@ -47,13 +49,17 @@ public override string ToString()
}
}
public class CardJson{
public static void Test(){
public class CardJson
{
public static void Test()
{
string json = File.ReadAllText(@"F:\TCGEditor_v1.2\t.tcgb");
CardSet cardset = JsonConvert.DeserializeObject<CardSet>(json);
if(cardset.cards!=null){
if (cardset.cards != null)
{
int index=0;
foreach(string key in cardset.cards.Keys){
foreach (string key in cardset.cards.Keys)
{
Console.WriteLine(key);
CardInfo card = cardset.cards.Values[index];
Console.WriteLine(card);
......
......@@ -5,22 +5,17 @@
* 时间: 19:43
*
*/
using System;
using DataEditorX.Common;
using DataEditorX.Config;
using DataEditorX.Core.Info;
using DataEditorX.Core.Mse;
using DataEditorX.Language;
using System.Collections.Generic;
using System.Configuration;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.IO.Compression;
using System.Windows.Forms;
using System.ComponentModel;
using DataEditorX.Language;
using DataEditorX.Common;
using DataEditorX.Config;
using DataEditorX.Core.Mse;
using DataEditorX.Core.Info;
using System.Xml;
namespace DataEditorX.Core
{
......@@ -103,7 +98,8 @@ public MyTask GetLastTask()
return this.lastTask;
}
public void TestPendulumText(string desc){
public void TestPendulumText(string desc)
{
this.mseHelper.TestPendulum(desc);
}
#endregion
......@@ -281,23 +277,23 @@ public string MSEImagePath
public string Datapath { get; }
public void SaveMSEs(string file, Card[] cards,bool isUpdate)
public void SaveMSEs(string file, Card[] cards, bool isUpdate)
{
if(cards == null)
if (cards == null)
{
return;
}
string pack_db=MyPath.GetRealPath(MyConfig.ReadString("pack_db"));
bool rarity=MyConfig.ReadBoolean("mse_auto_rarity", false);
#if DEBUG
MessageBox.Show("db = "+pack_db+",auto rarity="+rarity);
#endif
#if DEBUG
MessageBox.Show("db = " + pack_db + ",auto rarity=" + rarity);
#endif
int c = cards.Length;
//不分开,或者卡片数小于单个存档的最大值
if (this.mseHelper.MaxNum == 0 || c < this.mseHelper.MaxNum)
{
this.SaveMSE(1, file, cards,pack_db, rarity, isUpdate);
this.SaveMSE(1, file, cards, pack_db, rarity, isUpdate);
}
else
{
......@@ -322,11 +318,11 @@ public void SaveMSEs(string file, Card[] cards,bool isUpdate)
int t = file.LastIndexOf(".mse-set");
string fname = (t > 0) ? file.Substring(0, t) : file;
fname += string.Format("_{0}.mse-set", i + 1);
this.SaveMSE(i + 1, fname, clist.ToArray(),pack_db, rarity, isUpdate);
this.SaveMSE(i + 1, fname, clist.ToArray(), pack_db, rarity, isUpdate);
}
}
}
public void SaveMSE(int num, string file, Card[] cards,string pack_db,bool rarity, bool isUpdate)
public void SaveMSE(int num, string file, Card[] cards, string pack_db, bool rarity, bool isUpdate)
{
string setFile = file + ".txt";
Dictionary<Card, string> images = this.mseHelper.WriteSet(setFile, cards,pack_db,rarity);
......@@ -352,7 +348,7 @@ public void SaveMSE(int num, string file, Card[] cards,string pack_db,bool rarit
i++;
this.worker.ReportProgress(i / count, string.Format("{0}/{1}-{2}", i, count, num));
//TODO 先裁剪图片
zips.AddFile(this.mseHelper.GetImageCache(img,c), Path.GetFileName(img), "");
zips.AddFile(this.mseHelper.GetImageCache(img, c), Path.GetFileName(img), "");
}
}
File.Delete(setFile);
......@@ -360,7 +356,7 @@ public void SaveMSE(int num, string file, Card[] cards,string pack_db,bool rarit
public Card[] ReadMSE(string mseset, bool repalceOld)
{
//解压所有文件
using (ZipStorer zips = ZipStorer.Open(mseset,FileAccess.Read))
using (ZipStorer zips = ZipStorer.Open(mseset, FileAccess.Read))
{
zips.EncodeUTF8 = true;
List<ZipStorer.ZipFileEntry> files = zips.ReadCentralDir();
......@@ -439,7 +435,7 @@ public void ExportData(string path, string zipname, string _cdbfile, string modu
{
if (!string.Equals(file, extra_script) && File.Exists(file))
{
zips.AddFile(file, file.Replace(path,""), "");
zips.AddFile(file, file.Replace(path, ""), "");
}
}
}
......@@ -531,7 +527,7 @@ public void Run()
this.isRun = false;
this.lastTask = this.nowTask;
this.nowTask = MyTask.NONE;
if(this.lastTask != MyTask.ReadMSE)
if (this.lastTask != MyTask.ReadMSE)
{
this.cardlist = null;
}
......
using System;
using System.Text;
using System.IO;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using Microsoft.VisualBasic.FileIO;
using System.Configuration;
using DataEditorX.Config;
using DataEditorX.Config;
using DataEditorX.Core.Info;
using Microsoft.VisualBasic.FileIO;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace DataEditorX.Core
{
......@@ -271,7 +268,8 @@ public static void CardRename(long newid, long oldid, YgoPath ygopath)
{
if (File.Exists(oldfiles[i]))
{
try {
try
{
File.Move(oldfiles[i], newfiles[i]);
}
catch { }
......@@ -290,7 +288,8 @@ public static void CardCopy(long newid, long oldid, YgoPath ygopath)
{
if (File.Exists(oldfiles[i]))
{
try {
try
{
File.Copy(oldfiles[i], newfiles[i], false);
}
catch { }
......
......@@ -5,18 +5,17 @@
* 时间: 20:22
*
*/
using DataEditorX.Common;
using DataEditorX.Config;
using DataEditorX.Core;
using DataEditorX.Core.Mse;
using DataEditorX.Language;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Windows.Forms;
using DataEditorX.Common;
using DataEditorX.Config;
using DataEditorX.Core;
using DataEditorX.Core.Mse;
using DataEditorX.Language;
using WeifenLuo.WinFormsUI.Docking;
namespace DataEditorX
......@@ -343,17 +342,20 @@ void InitCheckPanel(FlowLayoutPanel fpanel, Dictionary<long, string> dic)
foreach (long key in dic.Keys)
{
string value = dic[key];
if(value != null && value.StartsWith("NULL"))
if (value != null && value.StartsWith("NULL"))
{
Label lab=new Label();
string[] sizes = value.Split(',');
if(sizes.Length>=3){
lab.Size=new Size(int.Parse(sizes[1]),int.Parse(sizes[2]));
if (sizes.Length >= 3)
{
lab.Size = new Size(int.Parse(sizes[1]), int.Parse(sizes[2]));
}
lab.AutoSize = false;
lab.Margin = fpanel.Margin;
fpanel.Controls.Add(lab);
}else{
}
else
{
CheckBox _cbox = new CheckBox
{
//_cbox.Name = fpanel.Name + key.ToString("x");
......@@ -404,12 +406,14 @@ void InitListRows()
if (itemH > 0)
{
int n = (this.lv_cardlist.Height - headH) / itemH;
if (n > 0){
if (n > 0)
{
this.maxRow = n;
}
//MessageBox.Show("height="+lv_cardlist.Height+",item="+itemH+",head="+headH+",max="+MaxRow);
}
if(addTest){
if (addTest)
{
this.lv_cardlist.Items.Clear();
}
if (this.maxRow < 10)
......@@ -587,13 +591,13 @@ public Card GetOldCard()
return this.oldCard;
}
private void setLinkMarks(long mark,bool setCheck=false)
private void setLinkMarks(long mark, bool setCheck = false)
{
if(setCheck)
if (setCheck)
{
this.SetCheck(this.pl_markers, mark);
}
this.tb_link.Text= Convert.ToString(mark, 2).PadLeft(9,'0');
this.tb_link.Text = Convert.ToString(mark, 2).PadLeft(9, '0');
}
public void SetCard(Card c)
......@@ -621,11 +625,13 @@ public void SetCard(Card c)
this.tb_setcode4.Text = setcodes[3].ToString("x");
//type,category
this.SetCheck(this.pl_cardtype, c.type);
if (c.IsType(Core.Info.CardType.TYPE_LINK)){
if (c.IsType(Core.Info.CardType.TYPE_LINK))
{
this.setLinkMarks(c.def, true);
}
else{
this.tb_link.Text="";
else
{
this.tb_link.Text = "";
this.SetCheck(this.pl_markers, 0);
}
this.SetCheck(this.pl_category, c.category);
......@@ -1318,7 +1324,7 @@ public Card[] GetCardList(bool onlyselect)
index = lvitem.Index + (this.page - 1) * this.maxRow;
}
if (index>=0 && index < this.cardlist.Count)
if (index >= 0 && index < this.cardlist.Count)
{
cards.Add(this.cardlist[index]);
}
......@@ -1444,8 +1450,8 @@ void SaveAsMSE(bool onlyselect)
if (dlg.ShowDialog() == DialogResult.OK)
{
bool isUpdate = false;
#if DEBUG
isUpdate=MyMsg.Question(LMSG.OnlySet);
#if DEBUG
isUpdate = MyMsg.Question(LMSG.OnlySet);
#endif
this.tasker.SetTask(MyTask.SaveAsMSE, cards,
dlg.FileName, isUpdate.ToString());
......@@ -1543,7 +1549,7 @@ public void SetImage(long id)
if (this.menuitem_importmseimg.Checked)//显示MSE图片
{
string msepic = MseMaker.GetCardImagePath(this.tasker.MSEImagePath, this.oldCard);
if(File.Exists(msepic))
if (File.Exists(msepic))
{
this.pl_image.BackgroundImage = MyBitmap.ReadImage(msepic);
}
......@@ -1685,7 +1691,7 @@ public void CompareCards(string cdbfile, bool checktext)
//把文件添加到菜单
void AddMenuItemFormMSE()
{
if(!Directory.Exists(this.datapath))
if (!Directory.Exists(this.datapath))
{
return;
}
......@@ -1755,7 +1761,7 @@ private void menuitem_findluafunc_Click(object sender, EventArgs e)
//系列名输入时
void setCode_InputText(int index, ComboBox cb, TextBox tb)
{
if(index>=0 && index < this.setcodeIsedit.Length)
if (index >= 0 && index < this.setcodeIsedit.Length)
{
if (this.setcodeIsedit[index])//如果正在编辑
{
......@@ -1959,16 +1965,22 @@ void Menuitem_exportMSEimageClick(object sender, EventArgs e)
}
string msepath=MyPath.GetRealPath(MyConfig.ReadString(MyConfig.TAG_MSE_PATH));
if(!File.Exists(msepath)){
if (!File.Exists(msepath))
{
MyMsg.Error(LMSG.exportMseImagesErr);
this.menuitem_exportMSEimage.Checked=false;
this.menuitem_exportMSEimage.Checked = false;
return;
}else{
if(MseMaker.MseIsRunning()){
}
else
{
if (MseMaker.MseIsRunning())
{
MseMaker.MseStop();
this.menuitem_exportMSEimage.Checked=false;
this.menuitem_exportMSEimage.Checked = false;
return;
}else{
}
else
{
}
}
......@@ -1981,26 +1993,32 @@ void Menuitem_exportMSEimageClick(object sender, EventArgs e)
{
string mseset=dlg.FileName;
string exportpath=MyPath.GetRealPath(MyConfig.ReadString(MyConfig.TAG_MSE_EXPORT));
MseMaker.ExportSet(msepath, mseset, exportpath, delegate{
this.menuitem_exportMSEimage.Checked=false;
MseMaker.ExportSet(msepath, mseset, exportpath, delegate
{
this.menuitem_exportMSEimage.Checked = false;
});
this.menuitem_exportMSEimage.Checked=true;
}else{
this.menuitem_exportMSEimage.Checked=false;
this.menuitem_exportMSEimage.Checked = true;
}
else
{
this.menuitem_exportMSEimage.Checked = false;
}
}
}
void Menuitem_testPendulumTextClick(object sender, EventArgs e)
{
Card c = this.GetCard();
if(c != null){
if (c != null)
{
this.tasker.TestPendulumText(c.desc);
}
}
void Menuitem_export_select_sqlClick(object sender, EventArgs e)
{
using(SaveFileDialog dlg = new SaveFileDialog()){
if(dlg.ShowDialog() == DialogResult.OK){
using (SaveFileDialog dlg = new SaveFileDialog())
{
if (dlg.ShowDialog() == DialogResult.OK)
{
DataBase.ExportSql(dlg.FileName, this.GetCardList(true));
MyMsg.Show("OK");
}
......@@ -2008,8 +2026,10 @@ void Menuitem_export_select_sqlClick(object sender, EventArgs e)
}
void Menuitem_export_all_sqlClick(object sender, EventArgs e)
{
using(SaveFileDialog dlg = new SaveFileDialog()){
if(dlg.ShowDialog() == DialogResult.OK){
using (SaveFileDialog dlg = new SaveFileDialog())
{
if (dlg.ShowDialog() == DialogResult.OK)
{
DataBase.ExportSql(dlg.FileName, this.GetCardList(false));
MyMsg.Show("OK");
}
......@@ -2041,7 +2061,8 @@ void Menuitem_autoreturnClick(object sender, EventArgs e)
int len = MyConfig.ReadInteger(MyConfig.TAG_AUTO_LEN, 30);
for (int i = 0; i < count; i++)
{
if(cards[i].desc!=null){
if (cards[i].desc != null)
{
cards[i].desc = StrUtil.AutoEnter(cards[i].desc, len, ' ');
}
}
......@@ -2092,10 +2113,13 @@ void Menuitem_replaceClick(object sender, EventArgs e)
private void text2LinkMarks(string text)
{
try{
try
{
long mark=Convert.ToInt64(text, 2);
this.setLinkMarks(mark, true);
}catch{
}
catch
{
//
}
}
......@@ -2138,10 +2162,13 @@ private void menuitem_language_Click(object sender, EventArgs e)
void Tb_linkKeyPress(object sender, KeyPressEventArgs e)
{
if(e.KeyChar != '0' && e.KeyChar != '1' && e.KeyChar != 1 && e.KeyChar!=22 && e.KeyChar!=3 && e.KeyChar != 8){
// MessageBox.Show("key="+(int)e.KeyChar);
if (e.KeyChar != '0' && e.KeyChar != '1' && e.KeyChar != 1 && e.KeyChar != 22 && e.KeyChar != 3 && e.KeyChar != 8)
{
// MessageBox.Show("key="+(int)e.KeyChar);
e.Handled = true;
}else{
}
else
{
this.text2LinkMarks(this.tb_link.Text);
}
}
......
......@@ -5,13 +5,12 @@
* 时间: 10:21
*
*/
using System;
namespace DataEditorX.Language
{
public enum LMSG : uint
{
titleInfo = 0 ,
titleInfo = 0,
titleError = 0x1,
titleWarning = 0x2,
titleQuestion = 0x3,
......
......@@ -6,10 +6,10 @@
*
*/
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
using System.Globalization;
using System.Collections.Generic;
using System.Windows.Forms;
namespace DataEditorX.Language
......
......@@ -5,12 +5,7 @@
* 时间: 7:40
*
*/
using System;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Configuration;
using System.Collections.Generic;
namespace DataEditorX.Language
{
......@@ -19,34 +14,34 @@ namespace DataEditorX.Language
/// </summary>
public static class MyMsg
{
static readonly string info, warning, error, question;
static readonly string _info, _warning, _error, _question;
static MyMsg()
{
info = LanguageHelper.GetMsg(LMSG.titleInfo);
warning = LanguageHelper.GetMsg(LMSG.titleWarning);
error = LanguageHelper.GetMsg(LMSG.titleError);
question = LanguageHelper.GetMsg(LMSG.titleQuestion);
_info = LanguageHelper.GetMsg(LMSG.titleInfo);
_warning = LanguageHelper.GetMsg(LMSG.titleWarning);
_error = LanguageHelper.GetMsg(LMSG.titleError);
_question = LanguageHelper.GetMsg(LMSG.titleQuestion);
}
public static void Show(string strMsg)
{
MessageBox.Show(strMsg, info,
MessageBox.Show(strMsg, _info,
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
public static void Warning(string strWarn)
{
MessageBox.Show(strWarn, warning,
MessageBox.Show(strWarn, _warning,
MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
public static void Error(string strError)
{
MessageBox.Show(strError, error,
MessageBox.Show(strError, _error,
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
public static bool Question(string strQues)
{
if(MessageBox.Show(strQues, question,
if (MessageBox.Show(strQues, _question,
MessageBoxButtons.OKCancel,
MessageBoxIcon.Question)==DialogResult.OK)
MessageBoxIcon.Question) == DialogResult.OK)
{
return true;
}
......@@ -57,24 +52,24 @@ public static bool Question(string strQues)
}
public static void Show(LMSG msg)
{
MessageBox.Show(LanguageHelper.GetMsg(msg), info,
MessageBox.Show(LanguageHelper.GetMsg(msg), _info,
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
public static void Warning(LMSG msg)
{
MessageBox.Show(LanguageHelper.GetMsg(msg), warning,
MessageBox.Show(LanguageHelper.GetMsg(msg), _warning,
MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
public static void Error(LMSG msg)
{
MessageBox.Show(LanguageHelper.GetMsg(msg), error,
MessageBox.Show(LanguageHelper.GetMsg(msg), _error,
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
public static bool Question(LMSG msg)
{
if(MessageBox.Show(LanguageHelper.GetMsg(msg), question,
if (MessageBox.Show(LanguageHelper.GetMsg(msg), _question,
MessageBoxButtons.OKCancel,
MessageBoxIcon.Question)==DialogResult.OK)
MessageBoxIcon.Question) == DialogResult.OK)
{
return true;
}
......
......@@ -5,18 +5,16 @@
* 时间: 9:19
*
*/
using DataEditorX.Config;
using DataEditorX.Controls;
using DataEditorX.Core;
using DataEditorX.Language;
using System;
using System.IO;
using System.Drawing;
using System.Threading;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;
using DataEditorX.Language;
using DataEditorX.Core;
using DataEditorX.Config;
using DataEditorX.Controls;
using System.Threading;
namespace DataEditorX
{
public partial class MainForm : Form, IMainForm
......@@ -114,7 +112,7 @@ void InitForm()
{
if (dc is Form)
{
LanguageHelper.SetFormLabel((Form)dc);
LanguageHelper.SetFormLabel(dc);
}
}
//添加历史菜单
......@@ -385,7 +383,7 @@ void Menuitem_newClick(object sender, EventArgs e)
if (dlg.ShowDialog() == DialogResult.OK)
{
string file = dlg.FileName;
if(File.Exists(file))
if (File.Exists(file))
{
File.Delete(file);
}
......
......@@ -5,14 +5,11 @@
* 时间: 12:00
*
*/
using DataEditorX.Config;
using DataEditorX.Language;
using System;
using System.Configuration;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
using DataEditorX.Config;
using DataEditorX.Language;
namespace DataEditorX
......
#region Using directives
using System;
using System.Reflection;
using System.Runtime.InteropServices;
......
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