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;
}
......
This diff is collapsed.
......@@ -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;
}
......
This diff is collapsed.
......@@ -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
{
......
This diff is collapsed.

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