Commit 44764797 authored by JoyJ's avatar JoyJ

code format

parent b448b34a
......@@ -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)
......@@ -258,7 +258,7 @@ public void InitTooltip(CodeConfig codeconfig)
this.popupMenu.Items.SetAutocompleteItems(this.items);
}
#endregion
#region 悬停的函数说明
//查找函数说明
string FindTooltip(string word)
......
......@@ -64,30 +64,30 @@ 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)
{
//从左到右比较数字
for (int i = 0; i < oldvers.Length; i++)
{
int.TryParse(vers[i], out int j);
int.TryParse(oldvers[i], out int k);
if (j > k)//新的版本号大于旧的
{
hasNew = true;
break;
}
else if (j < k)
{
hasNew = false;
break;
}
}
}
//从左到右比较数字
for (int i = 0; i < oldvers.Length; i++)
{
int.TryParse(vers[i], out int j);
int.TryParse(oldvers[i], out int k);
if (j > k)//新的版本号大于旧的
{
hasNew = true;
break;
}
else if (j < k)
{
hasNew = false;
break;
}
}
}
return hasNew;
}
#endregion
......@@ -107,12 +107,12 @@ public static string GetHtmlContentByUrl(string url)
(HttpWebRequest)WebRequest.Create(url);
httpWebRequest.Timeout = 15000;
using (HttpWebResponse httpWebResponse =
(HttpWebResponse)httpWebRequest.GetResponse())
(HttpWebResponse)httpWebRequest.GetResponse())
{
using (Stream stream = httpWebResponse.GetResponseStream())
{
using (StreamReader streamReader =
new StreamReader(stream, Encoding.UTF8))
new StreamReader(stream, Encoding.UTF8))
{
htmlContent = streamReader.ReadToEnd();
streamReader.Close();
......@@ -142,11 +142,11 @@ public static bool DownLoad(string filename)
try
{
if (File.Exists(filename))
{
File.Delete(filename);
}
{
File.Delete(filename);
}
HttpWebRequest Myrq = (HttpWebRequest)WebRequest.Create(URL);
HttpWebRequest Myrq = (HttpWebRequest)WebRequest.Create(URL);
HttpWebResponse myrp = (HttpWebResponse)Myrq.GetResponse();
long totalBytes = myrp.ContentLength;
......
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))//创建文件夹
string path=Path.GetDirectoryName(filename);
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,17 +5,16 @@
* 时间: 10:26
*
*/
using System;
using System.Text;
using System.Windows.Forms;
namespace System.IO
{
/// <summary>
/// 路径处理
/// </summary>
public class MyPath
{
/// <summary>
/// 路径处理
/// </summary>
public class MyPath
{
/// <summary>
/// 从相对路径获取真实路径
/// </summary>
......@@ -30,68 +29,69 @@ public static string GetRealPath(string dir)
}
return dir;
}
/// <summary>
/// 合并路径
/// </summary>
/// <param name="paths"></param>
/// <returns></returns>
/// <summary>
/// 合并路径
/// </summary>
/// <param name="paths"></param>
/// <returns></returns>
public static string Combine(params string[] paths)
{
if (paths.Length == 0)
{
throw new ArgumentException("please input path");
}
else
{
StringBuilder builder = new StringBuilder();
string spliter = Path.DirectorySeparatorChar.ToString();
string firstPath = paths[0];
if (firstPath.StartsWith("HTTP", StringComparison.OrdinalIgnoreCase))
{
spliter = "/";
}
if (!firstPath.EndsWith(spliter))
{
firstPath += spliter;
}
builder.Append(firstPath);
for (int i = 1; i < paths.Length; i++)
{
string nextPath = paths[i];
if (nextPath.StartsWith("/") || nextPath.StartsWith("\\"))
{
nextPath = nextPath.Substring(1);
}
if (i != paths.Length - 1)//not the last one
{
if (nextPath.EndsWith("/") || nextPath.EndsWith("\\"))
{
nextPath = nextPath.Substring(0, nextPath.Length - 1) + spliter;
}
else
{
nextPath += spliter;
}
}
builder.Append(nextPath);
}
return builder.ToString();
}
}
{
if (paths.Length == 0)
{
throw new ArgumentException("please input path");
}
else
{
StringBuilder builder = new StringBuilder();
string spliter = Path.DirectorySeparatorChar.ToString();
string firstPath = paths[0];
if (firstPath.StartsWith("HTTP", StringComparison.OrdinalIgnoreCase))
{
spliter = "/";
}
if (!firstPath.EndsWith(spliter))
{
firstPath += spliter;
}
builder.Append(firstPath);
for (int i = 1; i < paths.Length; i++)
{
string nextPath = paths[i];
if (nextPath.StartsWith("/") || nextPath.StartsWith("\\"))
{
nextPath = nextPath.Substring(1);
}
if (i != paths.Length - 1)//not the last one
{
if (nextPath.EndsWith("/") || nextPath.EndsWith("\\"))
{
nextPath = nextPath.Substring(0, nextPath.Length - 1) + spliter;
}
else
{
nextPath += spliter;
}
}
builder.Append(nextPath);
}
return builder.ToString();
}
}
/// <summary>
/// 检查目录是否合法
/// </summary>
/// <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
{
class MyComparer<K> : IComparer<K>
{
public int Compare(K x, K y)
{
return 1; //永远不等,允许重复
}
}
public class MySortList<K,V> : SortedList<K,V>
{
class MyComparer<K> : IComparer<K>
{
public int Compare(K x, K y)
{
return 1; //永远不等,允许重复
}
}
public MySortList():base(new MyComparer<K>())
{
}
public new void Add(K key, V value)
{
//falg用于跳出函数
int flag = 0;
//检查是否具备这个key,并且检查value是否重复
foreach (KeyValuePair<K,V> item in this)
{
if (item.Key.ToString() == key.ToString() && item.Value.ToString() == value.ToString())
{
flag=1;
}
}
if (flag == 1)
public class MySortList<K, V> : SortedList<K, V>
{
public MySortList() : base(new MyComparer<K>())
{
}
public new void Add(K key, V value)
{
//falg用于跳出函数
int flag = 0;
//检查是否具备这个key,并且检查value是否重复
foreach (KeyValuePair<K, V> item in this)
{
if (item.Key.ToString() == key.ToString() && item.Value.ToString() == value.ToString())
{
flag = 1;
}
}
if (flag == 1)
{
return; //跳出函数
}
//否则就加入
base.Add(key, value);
}
}
}
}
}
......@@ -6,47 +6,47 @@
*
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
*/
using System;
using System.Text;
using System.IO;
using System.Text;
namespace DataEditorX.Common
{
/// <summary>
/// Description of MyUtils.
/// </summary>
public class MyUtils
{
/// <summary>
/// 计算文件的MD5校验
/// </summary>
/// <param name="fileName"></param>
/// <returns></returns>
public static string GetMD5HashFromFile(string fileName)
{
try
{
FileStream file = new FileStream(fileName, FileMode.Open);
System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
byte[] retVal = md5.ComputeHash(file);
file.Close();
/// <summary>
/// Description of MyUtils.
/// </summary>
public class MyUtils
{
/// <summary>
/// 计算文件的MD5校验
/// </summary>
/// <param name="fileName"></param>
/// <returns></returns>
public static string GetMD5HashFromFile(string fileName)
{
try
{
FileStream file = new FileStream(fileName, FileMode.Open);
System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
byte[] retVal = md5.ComputeHash(file);
file.Close();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < retVal.Length; i++)
{
sb.Append(retVal[i].ToString("x2"));
}
return sb.ToString();
}
catch
{
}
return "";
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < retVal.Length; i++)
{
sb.Append(retVal[i].ToString("x2"));
}
return sb.ToString();
}
catch
{
}
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
{
public class StrUtil
{
public static string AutoEnter(string str, int lineNum, char re)
{
if (str == null || str.Length == 0)
public class StrUtil
{
public static string AutoEnter(string str, int lineNum, char re)
{
if (str == null || str.Length == 0)
{
return "";
}
str = " "+str.Replace("\r\n", "\n");
char[] ch = str.ToCharArray();
str = " " + str.Replace("\r\n", "\n");
char[] ch = str.ToCharArray();
_ = ch.Length;
StringBuilder sb = new StringBuilder();
int i = 0;
foreach (char c in ch)
{
int ic = c;
if (ic > 128)
int i = 0;
foreach (char c in ch)
{
int ic = c;
if (ic > 128)
{
i += 2;
}
......@@ -33,25 +31,27 @@ public static string AutoEnter(string str, int lineNum, char re)
}
if (c == '\n' || c == '\r')
{
sb.Append(re);
i = 0;
}
else if(c == re)
{
sb.Append(c);
i = 0;
}
else if (i >= lineNum)
{
sb.Append(c);
sb.Append(re);
i = 0;
}else{
sb.Append(c);
}
}
return sb.ToString();
}
}
{
sb.Append(re);
i = 0;
}
else if (c == re)
{
sb.Append(c);
i = 0;
}
else if (i >= lineNum)
{
sb.Append(c);
sb.Append(re);
i = 0;
}
else
{
sb.Append(c);
}
}
return sb.ToString();
}
}
}
/*
* 由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,
Store = 0,
/// <summary>Deflate compression method</summary>
Deflate = 8 }
Deflate = 8
}
#region ZipFileEntry
/// <summary>
......@@ -28,7 +30,7 @@ public enum Compression : ushort {
public struct ZipFileEntry
{
/// <summary>Compression method</summary>
public Compression Method;
public Compression Method;
/// <summary>Full path and filename as stored in Zip</summary>
public string FilenameInZip;
/// <summary>Original file size</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;
......@@ -185,7 +187,7 @@ public static ZipStorer Open(Stream _stream, FileAccess _access)
throw new InvalidDataException();
}
/// <summary>
/// <summary>
/// Add full contents of a file into the Zip storage
/// </summary>
/// <param name="_method">Compression method</param>
......@@ -194,7 +196,7 @@ public static ZipStorer Open(Stream _stream, FileAccess _access)
/// <param name="_comment">Comment for stored file</param>
public void AddFile(string _pathname, string _filenameInZip, string _comment)
{
Compression _method=Compression.Deflate;
Compression _method=Compression.Deflate;
if (this.access == FileAccess.Read)
{
throw new InvalidOperationException("Writing is not alowed");
......@@ -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)
......@@ -401,7 +403,7 @@ public bool ExtractFile(ZipFileEntry _zfe, string _filename)
File.SetCreationTime(_filename, _zfe.ModifyTime);
File.SetLastWriteTime(_filename, _zfe.ModifyTime);
return result;
}
/// <summary>
......@@ -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);
......@@ -671,7 +673,7 @@ private void Store(ref ZipFileEntry _zfe, Stream _source)
}
_zfe.Crc32 = 0 ^ 0xffffffff;
do
{
bytesRead = _source.Read(buffer, 0, buffer.Length);
......@@ -721,8 +723,8 @@ private void Store(ref ZipFileEntry _zfe, Stream _source)
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.Second / 2) | (_dt.Minute << 5) | (_dt.Hour << 11) |
(_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>();
......@@ -54,7 +54,7 @@ public void InitMember(string conf)
this.dicCardRaces = DataManager.Read(text, MyConfig.TAG_RACE);
this.dicCardLevels = DataManager.Read(text, MyConfig.TAG_LEVEL);
}
}
/// <summary>
/// 规则
/// </summary>
......
......@@ -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>
/// 从文件读取内容,按行读取
......@@ -122,7 +122,7 @@ public static string SubString(string content, string tag)
}
#endregion
#region 查找
public static List<long> GetKeys(Dictionary<long, string> dic)
{
......@@ -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
......@@ -16,13 +13,14 @@ namespace DataEditorX.Config
/// 裁剪图片是、配置
/// </summary>
public class ImageSet
{
public ImageSet(){
{
public ImageSet()
{
this.Init();
}
}
//初始化
void Init()
{
void Init()
{
this.normalArea = MyConfig.ReadArea(MyConfig.TAG_IMAGE_OTHER);
this.xyzArea = MyConfig.ReadArea(MyConfig.TAG_IMAGE_XYZ);
......@@ -37,7 +35,7 @@ void Init()
this.H = ints[3];
this.quilty = MyConfig.ReadInteger(MyConfig.TAG_IMAGE_QUILTY, 95);
}
}
/// <summary>
/// jpeg质量
/// </summary>
......@@ -70,5 +68,5 @@ void Init()
/// p怪的中间图
/// </summary>
public Area pendulumArea;
}
}
}
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
{
......@@ -88,10 +87,10 @@ public class MyConfig : XMLReader
/// 用本程序打开文件
/// </summary>
public const string TAG_OPEN_IN_THIS = "open_file_in_this";
/// <summary>
/// 自动检查更新
/// </summary>
public const string TAG_AUTO_CHECK_UPDATE = "auto_check_update";
/// <summary>
/// 自动检查更新
/// </summary>
public const string TAG_AUTO_CHECK_UPDATE = "auto_check_update";
/// <summary>
/// add require automatically
/// </summary>
......@@ -259,20 +258,22 @@ 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)){
return true;
}
if("false".Equals(val, StringComparison.OrdinalIgnoreCase)){
return false;
}
string val= ReadString(key);
if ("true".Equals(val, StringComparison.OrdinalIgnoreCase))
{
return true;
}
if ("false".Equals(val, StringComparison.OrdinalIgnoreCase))
{
return false;
}
return def;
}
#endregion
#endregion
/// <summary>
/// 语言配置文件名
/// </summary>
......@@ -280,27 +281,27 @@ public static bool ReadBoolean(string key,bool def=false)
/// <returns></returns>
public static string GetLanguageFile(string path)
{
if (ReadBoolean(TAG_CHECK_SYSLANG) && Directory.Exists(path))
{
Save(TAG_CHECK_SYSLANG, "false");
string[] words = CultureInfo.InstalledUICulture.EnglishName.Split(' ');
string syslang = words[0];
string[] files = Directory.GetFiles(path);
foreach (string file in files)
{
string name = MyPath.GetFullFileName(TAG_LANGUAGE, file);
if (string.IsNullOrEmpty(name))
if (ReadBoolean(TAG_CHECK_SYSLANG) && Directory.Exists(path))
{
Save(TAG_CHECK_SYSLANG, "false");
string[] words = CultureInfo.InstalledUICulture.EnglishName.Split(' ');
string syslang = words[0];
string[] files = Directory.GetFiles(path);
foreach (string file in files)
{
string name = MyPath.GetFullFileName(TAG_LANGUAGE, file);
if (string.IsNullOrEmpty(name))
{
continue;
}
if (syslang.Equals(name, StringComparison.OrdinalIgnoreCase))
{
Save(TAG_LANGUAGE, syslang);
break;
}
}
}
{
Save(TAG_LANGUAGE, syslang);
break;
}
}
}
return MyPath.Combine(path, MyPath.GetFileName(TAG_LANGUAGE, GetAppConfig(TAG_LANGUAGE)));
}
/// <summary>
......@@ -310,7 +311,7 @@ public static string GetLanguageFile(string path)
/// <returns></returns>
public static string GetCardInfoFile(string path)
{
return MyPath.Combine(path, MyPath.GetFileName(TAG_CARDINFO, GetAppConfig(TAG_LANGUAGE)));
return MyPath.Combine(path, MyPath.GetFileName(TAG_CARDINFO, GetAppConfig(TAG_LANGUAGE)));
}
/// <summary>
/// 发送消息打开文件
......
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.IO;
namespace DataEditorX.Config
{
......@@ -20,7 +17,7 @@ public void SetPath(string gamepath)
this.luapath = MyPath.Combine(gamepath, "script");
this.ydkpath = MyPath.Combine(gamepath, "deck");
this.replaypath = MyPath.Combine(gamepath, "replay");
}
}
/// <summary>游戏目录</summary>
public string gamepath;
/// <summary>大图目录</summary>
......@@ -36,67 +33,67 @@ public void SetPath(string gamepath)
/// <summary>录像目录</summary>
public string replaypath;
public string GetImage(long id)
public string GetImage(long id)
{
return this.GetImage(id.ToString());
}
//public string GetImageThum(long id)
//{
// return GetImageThum(id.ToString());
//}
public string GetImageField(long id)
{
return this.GetImageField(id.ToString());//场地图
}
public string GetScript(long id)
{
return this.GetImage(id.ToString());
}
//public string GetImageThum(long id)
//{
// return GetImageThum(id.ToString());
//}
public string GetImageField(long id)
return this.GetScript(id.ToString());
}
public string GetYdk(string name)
{
return this.GetImageField(id.ToString());//场地图
return MyPath.Combine(this.ydkpath, name + ".ydk");
}
public string GetScript(long id)
//字符串id
public string GetImage(string id)
{
return this.GetScript(id.ToString());
}
public string GetYdk(string name)
{
return MyPath.Combine(this.ydkpath, name + ".ydk");
}
//字符串id
public string GetImage(string id)
{
return MyPath.Combine(this.picpath, id + ".jpg");
}
//public string GetImageThum(string id)
//{
// return MyPath.Combine(picpath2, id + ".jpg");
//}
public string GetImageField(string id)
return MyPath.Combine(this.picpath, id + ".jpg");
}
//public string GetImageThum(string id)
//{
// return MyPath.Combine(picpath2, id + ".jpg");
//}
public string GetImageField(string id)
{
return MyPath.Combine(this.fieldpath, id+ ".png");//场地图
return MyPath.Combine(this.fieldpath, id + ".png");//场地图
}
public string GetScript(string id)
{
return MyPath.Combine(this.luapath, "c" + id + ".lua");
}
public string GetModuleScript(string modulescript)
{
return MyPath.Combine(this.luapath, modulescript + ".lua");
}
public string GetScript(string id)
{
return MyPath.Combine(this.luapath, "c" + id + ".lua");
}
public string GetModuleScript(string modulescript)
{
return MyPath.Combine(this.luapath, modulescript + ".lua");
}
public string[] GetCardfiles(long id)
{
string[] files = new string[]{
public string[] GetCardfiles(long id)
{
string[] files = new string[]{
this.GetImage(id),//大图
//GetImageThum(id),//小图
this.GetImageField(id),//场地图
this.GetScript(id)
};
return files;
}
public string[] GetCardfiles(string id)
{
string[] files = new string[]{
};
return files;
}
public string[] GetCardfiles(string id)
{
string[] files = new string[]{
this.GetImage(id),//大图
//GetImageThum(id),//小图
this.GetImageField(id),//场地图
this.GetScript(id)
};
return files;
}
}
};
return files;
}
}
}
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,20 +7,17 @@
*/
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Text;
namespace FastColoredTextBoxNS
{
public class FastColoredTextBoxEx : FastColoredTextBox
public class FastColoredTextBoxEx : FastColoredTextBox
{
public Label lbTooltip;
Point lastMouseCoord;
public FastColoredTextBoxEx() : base()
{
public FastColoredTextBoxEx() : base()
{
this.SyntaxHighlighter = new MySyntaxHighlighter();
this.TextChanged += this.FctbTextChanged;
this.ToolTipDelay = 1;
......@@ -30,15 +27,15 @@ public FastColoredTextBoxEx() : base()
}
public new event EventHandler<ToolTipNeededEventArgs> ToolTipNeeded;
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
this.lastMouseCoord = e.Location;
}
//函数悬停提示
protected override void OnToolTip()
{
if (this.ToolTip == null)
}
//函数悬停提示
protected override void OnToolTip()
{
if (this.ToolTip == null)
{
return;
}
......@@ -51,36 +48,36 @@ protected override void OnToolTip()
//get place under mouse
Place place = this.PointToPlace(this.lastMouseCoord);
//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)
//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)
{
return;
}
//get word under mouse
var r = new Range(this, place, place);
string hoveredWord = r.GetFragment("[a-zA-Z0-9_]").Text;
//event handler
var ea = new ToolTipNeededEventArgs(place, hoveredWord);
ToolTipNeeded(this, ea);
string hoveredWord = r.GetFragment("[a-zA-Z0-9_]").Text;
//event handler
var ea = new ToolTipNeededEventArgs(place, hoveredWord);
ToolTipNeeded(this, ea);
if (ea.ToolTipText != null)
{
if (ea.ToolTipText != null)
{
this.ShowTooltipWithLabel(ea.ToolTipTitle, ea.ToolTipText);
}
}
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);
}
......@@ -143,7 +143,7 @@ public void MenuHistory()
tsmiclear2.Click += this.MenuHistoryClear2_Click;
this.mainForm.AddLuaMenu(tsmiclear2);
}
void MenuHistoryClear2_Click(object sender, EventArgs e)
{
this.luahistory.Clear();
......
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
{
......@@ -20,14 +14,14 @@ namespace FastColoredTextBoxNS
/// </summary>
public class MySyntaxHighlighter : SyntaxHighlighter
{
readonly TextStyle mNumberStyle = new TextStyle(Brushes.Orange, null, FontStyle.Regular);
readonly TextStyle mStrStyle = new TextStyle(Brushes.Gold, null, FontStyle.Regular);
readonly TextStyle conStyle = new TextStyle(Brushes.YellowGreen, null, FontStyle.Regular);
readonly TextStyle mKeywordStyle = new TextStyle(Brushes.DeepSkyBlue, null, FontStyle.Regular);
readonly TextStyle mGrayStyle = new TextStyle(Brushes.Gray, null, FontStyle.Regular);
readonly TextStyle mFunStyle = new TextStyle(Brushes.LightGray, null, FontStyle.Bold);
readonly TextStyle mNumberStyle = new TextStyle(Brushes.Orange, null, FontStyle.Regular);
readonly TextStyle mStrStyle = new TextStyle(Brushes.Gold, null, FontStyle.Regular);
readonly TextStyle conStyle = new TextStyle(Brushes.YellowGreen, null, FontStyle.Regular);
readonly TextStyle mKeywordStyle = new TextStyle(Brushes.DeepSkyBlue, null, FontStyle.Regular);
readonly TextStyle mGrayStyle = new TextStyle(Brushes.Gray, null, FontStyle.Regular);
readonly TextStyle mFunStyle = new TextStyle(Brushes.LightGray, null, FontStyle.Bold);
/// <summary>
/// Highlights Lua code
/// </summary>
......@@ -47,28 +41,28 @@ 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)
{
InitLuaRegex();
}
//string highlighting
range.SetStyle(this.mStrStyle, LuaStringRegex);
if (this.LuaStringRegex == null)
{
this.InitLuaRegex();
}
//string highlighting
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|,|;]");
//range.SetStyle(mFunStyle, @"[:|\.|\s](?<range>[a-zA-Z0-9_]*?)[\(|\)|\s]");
//clear folding markers
range.ClearFoldingMarkers();
//set folding markers
......
This diff is collapsed.
This diff is collapsed.
......@@ -3,96 +3,96 @@
namespace DataEditorX.Core
{
public delegate void StatusBool(bool val);
public interface ICommand : ICloneable
{
bool Excute(params object[] args);
}
public interface IBackableCommand : ICommand
{
void Undo();
}
public interface ICommandManager
{
void ExcuteCommand(ICommand command, params object[] args);
void Undo();
void ReverseUndo();//反撤销
event StatusBool UndoStateChanged;
}
public class CommandManager : ICommandManager
{
private readonly Stack<ICommand> undoStack = new Stack<ICommand>();
private readonly Stack<ICommand> reverseStack = new Stack<ICommand>();
public event StatusBool UndoStateChanged;
public CommandManager()
{
UndoStateChanged += new StatusBool(this.CommandManager_UndoStateChanged);
UndoStateChanged += new StatusBool(this.CommandManager_ReverseUndoStateChanged);
}
private void CommandManager_UndoStateChanged(bool val)
{
}
private void CommandManager_ReverseUndoStateChanged(bool val)
{
}
#region ICommandManager 成员
public void ExcuteCommand(ICommand command, params object[] args)
{
if(!command.Excute(args))
public delegate void StatusBool(bool val);
public interface ICommand : ICloneable
{
bool Excute(params object[] args);
}
public interface IBackableCommand : ICommand
{
void Undo();
}
public interface ICommandManager
{
void ExcuteCommand(ICommand command, params object[] args);
void Undo();
void ReverseUndo();//反撤销
event StatusBool UndoStateChanged;
}
public class CommandManager : ICommandManager
{
private readonly Stack<ICommand> undoStack = new Stack<ICommand>();
private readonly Stack<ICommand> reverseStack = new Stack<ICommand>();
public event StatusBool UndoStateChanged;
public CommandManager()
{
UndoStateChanged += new StatusBool(this.CommandManager_UndoStateChanged);
UndoStateChanged += new StatusBool(this.CommandManager_ReverseUndoStateChanged);
}
private void CommandManager_UndoStateChanged(bool val)
{
}
private void CommandManager_ReverseUndoStateChanged(bool val)
{
}
#region ICommandManager 成员
public void ExcuteCommand(ICommand command, params object[] args)
{
if (!command.Excute(args))
{
return;
}
this.reverseStack.Clear();
if (command is IBackableCommand)
{
if (command is IBackableCommand)
{
this.undoStack.Push((ICommand)command.Clone());
}
else
{
}
else
{
this.undoStack.Clear();
}
}
UndoStateChanged(this.undoStack.Count > 0);
}
UndoStateChanged(this.undoStack.Count > 0);
}
public void Undo()
{
IBackableCommand command = (IBackableCommand)this.undoStack.Pop();
if (command == null)
{
return;
}
public void Undo()
{
IBackableCommand command = (IBackableCommand)this.undoStack.Pop();
if (command == null)
{
return;
}
command.Undo();
command.Undo();
this.reverseStack.Push((ICommand)command.Clone());
UndoStateChanged(this.undoStack.Count > 0);
//UndoStateChanged(reverseStack.Count > 0);
}
UndoStateChanged(this.undoStack.Count > 0);
//UndoStateChanged(reverseStack.Count > 0);
}
public void ReverseUndo()
{
IBackableCommand command = (IBackableCommand)this.reverseStack.Pop();
if (command == null)
{
return;
}
public void ReverseUndo()
{
IBackableCommand command = (IBackableCommand)this.reverseStack.Pop();
if (command == null)
{
return;
}
command.Excute();
command.Excute();
this.undoStack.Push((ICommand)command.Clone());
UndoStateChanged(this.undoStack.Count > 0);
}
#endregion
}
UndoStateChanged(this.undoStack.Count > 0);
}
#endregion
}
}
This diff is collapsed.
......@@ -5,7 +5,6 @@
* 时间: 9:47
*
*/
using System;
namespace DataEditorX.Core.Info
{
......
......@@ -6,13 +6,12 @@
*
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
*/
using System;
namespace DataEditorX.Core.Info
{
public static class CardLink
{
/*
public static class CardLink
{
/*
0x1 ↙
0x2 ↓
0x4 ↘
......@@ -21,17 +20,18 @@ public static class CardLink
0x40 ↖
0x80 ↑
0x100 ↗*/
public const int DownLeft=0x1;
public const int Down = 0x2;
public const int DownRight = 0x4;
public const int Left = 0x8;
public const int Right = 0x20;
public const int UpLeft = 0x40;
public const int Up = 0x80;
public const int UpRight = 0x100;
public static bool IsLink(int marks, int mark){
return (marks & mark) == mark;
}
}
public const int DownLeft=0x1;
public const int Down = 0x2;
public const int DownRight = 0x4;
public const int Left = 0x8;
public const int Right = 0x20;
public const int UpLeft = 0x40;
public const int Up = 0x80;
public const int UpRight = 0x100;
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,
......
This diff is collapsed.
This diff is collapsed.
......@@ -6,95 +6,98 @@
*
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
*/
using System;
namespace DataEditorX.Core
{
/// <summary>
/// Description of CardPack.
/// </summary>
public class CardPack
{
public CardPack(long id)
{
this.CardId=id;
}
public long CardId{
get;
private set;
}
public string pack_id;
public string pack_name;
public string rarity;
public string date;
public string GetMseRarity(){
if(this.rarity==null)
/// <summary>
/// Description of CardPack.
/// </summary>
public class CardPack
{
public CardPack(long id)
{
this.CardId = id;
}
public long CardId
{
get;
private set;
}
public string pack_id;
public string pack_name;
public string rarity;
public string date;
public string GetMseRarity()
{
if (this.rarity == null)
{
return "common";
}
string rarity=this.rarity.Trim().ToLower();
if(rarity.Equals("common") || rarity.Equals("short print"))
{
return "common";
}
if(rarity.Equals("rare") ||rarity.Equals("normal rare"))
{
return "rare";
}else if(rarity.Contains("parallel") || rarity.Contains("Kaiba") || rarity.Contains("duel terminal"))
{
return "parallel rare";
}
else if(rarity.Contains("super") ||rarity.Contains("holofoil"))
{
return "super rare";
}
else if(rarity.Contains("ultra"))
{
return "ultra rare";
}
else if(rarity.Contains("secret"))
{
return "secret rare";
}
else if(rarity.Contains("gold"))
{
return "gold rare";
}
else if(rarity.Contains("ultimate"))
{
return "ultimate rare";
}
else if(rarity.Contains("prismatic"))
{
return "prismatic rare";
}
else if(rarity.Contains("star"))
{
return "star rare";
}
else if(rarity.Contains("mosaic"))
{
return "mosaic rare";
}
else if(rarity.Contains("platinum"))
{
return "platinum rare";
}
else if(rarity.Contains("ghost") || rarity.Contains("holographic"))
{
return "ghost rare";
}
else if(rarity.Contains("millenium"))
{
return "millenium rare";
}
if(this.rarity.Contains("/")){
return this.rarity.Split('/')[0];
}
return this.rarity;
}
}
if (rarity.Equals("common") || rarity.Equals("short print"))
{
return "common";
}
if (rarity.Equals("rare") || rarity.Equals("normal rare"))
{
return "rare";
}
else if (rarity.Contains("parallel") || rarity.Contains("Kaiba") || rarity.Contains("duel terminal"))
{
return "parallel rare";
}
else if (rarity.Contains("super") || rarity.Contains("holofoil"))
{
return "super rare";
}
else if (rarity.Contains("ultra"))
{
return "ultra rare";
}
else if (rarity.Contains("secret"))
{
return "secret rare";
}
else if (rarity.Contains("gold"))
{
return "gold rare";
}
else if (rarity.Contains("ultimate"))
{
return "ultimate rare";
}
else if (rarity.Contains("prismatic"))
{
return "prismatic rare";
}
else if (rarity.Contains("star"))
{
return "star rare";
}
else if (rarity.Contains("mosaic"))
{
return "mosaic rare";
}
else if (rarity.Contains("platinum"))
{
return "platinum rare";
}
else if (rarity.Contains("ghost") || rarity.Contains("holographic"))
{
return "ghost rare";
}
else if (rarity.Contains("millenium"))
{
return "millenium rare";
}
if (this.rarity.Contains("/"))
{
return this.rarity.Split('/')[0];
}
return this.rarity;
}
}
}
This diff is collapsed.
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 int game;
public int version;
public MySortList<string, CardInfo> cards;
}
public class CardInfo{
public string title;
public string artwork;
public int[] artwork_crop;
/// <summary>
/// ?
/// </summary>
public int background;
/// <summary>
/// ?
/// </summary>
public int rarity;
public int attribute;
public int level;
public int icon;
public string description;
public string pendulum_description;
public int[] pendulum_scales ;
public string[] subtypes;
public string atk;
public string def;
public string edition;
public string @set;
public string card_number;
public string limitation;
/// <summary>
/// 0,1,1
/// </summary>
public int sticker;
public string copyright;
public override string ToString()
{
return string.Format("[CardInfo Title={0}, Artwork={1}, Artwork_crop={2}, Background={3}, Rarity={4}, Attribute={5}, Level={6}, Icon={7}, Description={8}, Pendulum_description={9}, Pendulum_scales={10}, Subtypes={11}, Atk={12}, Def={13}, Edition={14}, Set={15}, Card_number={16}, Limitation={17}, Sticker={18}, Copyright={19}]", this.title, this.artwork, this.artwork_crop, this.background, this.rarity, this.attribute, this.level, this.icon, this.description, this.pendulum_description, this.pendulum_scales, this.subtypes, this.atk, this.def, this.edition, this.set, this.card_number, this.limitation, this.sticker, this.copyright);
}
}
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){
int index=0;
foreach(string key in cardset.cards.Keys){
Console.WriteLine(key);
CardInfo card = cardset.cards.Values[index];
Console.WriteLine(card);
index++;
}
}
Console.ReadKey();
}
}
public class CardSet
{
public int game;
public int version;
public MySortList<string, CardInfo> cards;
}
public class CardInfo
{
public string title;
public string artwork;
public int[] artwork_crop;
/// <summary>
/// ?
/// </summary>
public int background;
/// <summary>
/// ?
/// </summary>
public int rarity;
public int attribute;
public int level;
public int icon;
public string description;
public string pendulum_description;
public int[] pendulum_scales ;
public string[] subtypes;
public string atk;
public string def;
public string edition;
public string @set;
public string card_number;
public string limitation;
/// <summary>
/// 0,1,1
/// </summary>
public int sticker;
public string copyright;
public override string ToString()
{
return string.Format("[CardInfo Title={0}, Artwork={1}, Artwork_crop={2}, Background={3}, Rarity={4}, Attribute={5}, Level={6}, Icon={7}, Description={8}, Pendulum_description={9}, Pendulum_scales={10}, Subtypes={11}, Atk={12}, Def={13}, Edition={14}, Set={15}, Card_number={16}, Limitation={17}, Sticker={18}, Copyright={19}]", this.title, this.artwork, this.artwork_crop, this.background, this.rarity, this.attribute, this.level, this.icon, this.description, this.pendulum_description, this.pendulum_scales, this.subtypes, this.atk, this.def, this.edition, this.set, this.card_number, this.limitation, this.sticker, this.copyright);
}
}
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)
{
int index=0;
foreach (string key in cardset.cards.Keys)
{
Console.WriteLine(key);
CardInfo card = cardset.cards.Values[index];
Console.WriteLine(card);
index++;
}
}
Console.ReadKey();
}
}
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#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