初始备份。
This commit is contained in:
commit
59677e1a85
152 files changed
+54611
No files matched your search
@@ -0,0 +1,497 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace 开发辅助工具.Manager
|
||||
{
|
||||
/// <summary>
|
||||
/// 汉字转拼音静态类,包括功能全拼和缩写,方法全部是静态的
|
||||
/// </summary>
|
||||
public static class Chinese2Spell
|
||||
{
|
||||
#region 属性数据定义
|
||||
/// <summary>
|
||||
/// 汉字的机内码数组
|
||||
/// </summary>
|
||||
private static int[] pyValue = new int[]
|
||||
{
|
||||
-20319,-20317,-20304,-20295,-20292,-20283,-20265,-20257,-20242,-20230,-20051,-20036,
|
||||
-20032,-20026,-20002,-19990,-19986,-19982,-19976,-19805,-19784,-19775,-19774,-19763,
|
||||
-19756,-19751,-19746,-19741,-19739,-19728,-19725,-19715,-19540,-19531,-19525,-19515,
|
||||
-19500,-19484,-19479,-19467,-19289,-19288,-19281,-19275,-19270,-19263,-19261,-19249,
|
||||
-19243,-19242,-19238,-19235,-19227,-19224,-19218,-19212,-19038,-19023,-19018,-19006,
|
||||
-19003,-18996,-18977,-18961,-18952,-18783,-18774,-18773,-18763,-18756,-18741,-18735,
|
||||
-18731,-18722,-18710,-18697,-18696,-18526,-18518,-18501,-18490,-18478,-18463,-18448,
|
||||
-18447,-18446,-18239,-18237,-18231,-18220,-18211,-18201,-18184,-18183, -18181,-18012,
|
||||
-17997,-17988,-17970,-17964,-17961,-17950,-17947,-17931,-17928,-17922,-17759,-17752,
|
||||
-17733,-17730,-17721,-17703,-17701,-17697,-17692,-17683,-17676,-17496,-17487,-17482,
|
||||
-17468,-17454,-17433,-17427,-17417,-17202,-17185,-16983,-16970,-16942,-16915,-16733,
|
||||
-16708,-16706,-16689,-16664,-16657,-16647,-16474,-16470,-16465,-16459,-16452,-16448,
|
||||
-16433,-16429,-16427,-16423,-16419,-16412,-16407,-16403,-16401,-16393,-16220,-16216,
|
||||
-16212,-16205,-16202,-16187,-16180,-16171,-16169,-16158,-16155,-15959,-15958,-15944,
|
||||
-15933,-15920,-15915,-15903,-15889,-15878,-15707,-15701,-15681,-15667,-15661,-15659,
|
||||
-15652,-15640,-15631,-15625,-15454,-15448,-15436,-15435,-15419,-15416,-15408,-15394,
|
||||
-15385,-15377,-15375,-15369,-15363,-15362,-15183,-15180,-15165,-15158,-15153,-15150,
|
||||
-15149,-15144,-15143,-15141,-15140,-15139,-15128,-15121,-15119,-15117,-15110,-15109,
|
||||
-14941,-14937,-14933,-14930,-14929,-14928,-14926,-14922,-14921,-14914,-14908,-14902,
|
||||
-14894,-14889,-14882,-14873,-14871,-14857,-14678,-14674,-14670,-14668,-14663,-14654,
|
||||
-14645,-14630,-14594,-14429,-14407,-14399,-14384,-14379,-14368,-14355,-14353,-14345,
|
||||
-14170,-14159,-14151,-14149,-14145,-14140,-14137,-14135,-14125,-14123,-14122,-14112,
|
||||
-14109,-14099,-14097,-14094,-14092,-14090,-14087,-14083,-13917,-13914,-13910,-13907,
|
||||
-13906,-13905,-13896,-13894,-13878,-13870,-13859,-13847,-13831,-13658,-13611,-13601,
|
||||
-13406,-13404,-13400,-13398,-13395,-13391,-13387,-13383,-13367,-13359,-13356,-13343,
|
||||
-13340,-13329,-13326,-13318,-13147,-13138,-13120,-13107,-13096,-13095,-13091,-13076,
|
||||
-13068,-13063,-13060,-12888,-12875,-12871,-12860,-12858,-12852,-12849,-12838,-12831,
|
||||
-12829,-12812,-12802,-12607,-12597,-12594,-12585,-12556,-12359,-12346,-12320,-12300,
|
||||
-12120,-12099,-12089,-12074,-12067,-12058,-12039,-11867,-11861,-11847,-11831,-11798,
|
||||
-11781,-11604,-11589,-11536,-11358,-11340,-11339,-11324,-11303,-11097,-11077,-11067,
|
||||
-11055,-11052,-11045,-11041,-11038,-11024,-11020,-11019,-11018,-11014,-10838,-10832,
|
||||
-10815,-10800,-10790,-10780,-10764,-10587,-10544,-10533,-10519,-10331,-10329,-10328,
|
||||
-10322,-10315,-10309,-10307,-10296,-10281,-10274,-10270,-10262,-10260,-10256,-10254
|
||||
};
|
||||
/// <summary>
|
||||
/// 机内码对应的拼音数组
|
||||
/// </summary>
|
||||
private static string[] pyName = new string[]
|
||||
{
|
||||
"A","Ai","An","Ang","Ao","Ba","Bai","Ban","Bang","Bao","Bei","Ben",
|
||||
"Beng","Bi","Bian","Biao","Bie","Bin","Bing","Bo","Bu","Ba","Cai","Can",
|
||||
"Cang","Cao","Ce","Ceng","Cha","Chai","Chan","Chang","Chao","Che","Chen","Cheng",
|
||||
"Chi","Chong","Chou","Chu","Chuai","Chuan","Chuang","Chui","Chun","Chuo","Ci","Cong",
|
||||
"Cou","Cu","Cuan","Cui","Cun","Cuo","Da","Dai","Dan","Dang","Dao","De",
|
||||
"Deng","Di","Dian","Diao","Die","Ding","Diu","Dong","Dou","Du","Duan","Dui",
|
||||
"Dun","Duo","E","En","Er","Fa","Fan","Fang","Fei","Fen","Feng","Fo",
|
||||
"Fou","Fu","Ga","Gai","Gan","Gang","Gao","Ge","Gei","Gen","Geng","Gong",
|
||||
"Gou","Gu","Gua","Guai","Guan","Guang","Gui","Gun","Guo","Ha","Hai","Han",
|
||||
"Hang","Hao","He","Hei","Hen","Heng","Hong","Hou","Hu","Hua","Huai","Huan",
|
||||
"Huang","Hui","Hun","Huo","Ji","Jia","Jian","Jiang","Jiao","Jie","Jin","Jing",
|
||||
"Jiong","Jiu","Ju","Juan","Jue","Jun","Ka","Kai","Kan","Kang","Kao","Ke",
|
||||
"Ken","Keng","Kong","Kou","Ku","Kua","Kuai","Kuan","Kuang","Kui","Kun","Kuo",
|
||||
"La","Lai","Lan","Lang","Lao","Le","Lei","Leng","Li","Lia","Lian","Liang",
|
||||
"Liao","Lie","Lin","Ling","Liu","Long","Lou","Lu","Lv","Luan","Lue","Lun",
|
||||
"Luo","Ma","Mai","Man","Mang","Mao","Me","Mei","Men","Meng","Mi","Mian",
|
||||
"Miao","Mie","Min","Ming","Miu","Mo","Mou","Mu","Na","Nai","Nan","Nang",
|
||||
"Nao","Ne","Nei","Nen","Neng","Ni","Nian","Niang","Niao","Nie","Nin","Ning",
|
||||
"Niu","Nong","Nu","Nv","Nuan","Nue","Nuo","O","Ou","Pa","Pai","Pan",
|
||||
"Pang","Pao","Pei","Pen","Peng","Pi","Pian","Piao","Pie","Pin","Ping","Po",
|
||||
"Pu","Qi","Qia","Qian","Qiang","Qiao","Qie","Qin","Qing","Qiong","Qiu","Qu",
|
||||
"Quan","Que","Qun","Ran","Rang","Rao","Re","Ren","Reng","Ri","Rong","Rou",
|
||||
"Ru","Ruan","Rui","Run","Ruo","Sa","Sai","San","Sang","Sao","Se","Sen",
|
||||
"Seng","Sha","Shai","Shan","Shang","Shao","She","Shen","Sheng","Shi","Shou","Shu",
|
||||
"Shua","Shuai","Shuan","Shuang","Shui","Shun","Shuo","Si","Song","Sou","Su","Suan",
|
||||
"Sui","Sun","Suo","Ta","Tai","Tan","Tang","Tao","Te","Teng","Ti","Tian",
|
||||
"Tiao","Tie","Ting","Tong","Tou","Tu","Tuan","Tui","Tun","Tuo","Wa","Wai",
|
||||
"Wan","Wang","Wei","Wen","Weng","Wo","Wu","Xi","Xia","Xian","Xiang","Xiao",
|
||||
"Xie","Xin","Xing","Xiong","Xiu","Xu","Xuan","Xue","Xun","Ya","Yan","Yang",
|
||||
"Yao","Ye","Yi","Yin","Ying","Yo","Yong","You","Yu","Yuan","Yue","Yun",
|
||||
"Za", "Zai","Zan","Zang","Zao","Ze","Zei","Zen","Zeng","Zha","Zhai","Zhan",
|
||||
"Zhang","Zhao","Zhe","Zhen","Zheng","Zhi","Zhong","Zhou","Zhu","Zhua","Zhuai","Zhuan",
|
||||
"Zhuang","Zhui","Zhun","Zhuo","Zi","Zong","Zou","Zu","Zuan","Zui","Zun","Zuo"
|
||||
};
|
||||
#endregion
|
||||
#region 把汉字转换成拼音(全拼)无间隔符号
|
||||
/// <summary>
|
||||
/// 把汉字转换成拼音(全拼)
|
||||
/// </summary>
|
||||
/// <param name="hzString">汉字字符串</param>
|
||||
/// <returns>转换后的拼音(全拼)字符串</returns>
|
||||
public static string Convert(string hzString)
|
||||
{
|
||||
// 匹配中文字符
|
||||
Regex regex = new Regex("^[\\u4e00-\\u9fa5]$");
|
||||
byte[] array = new byte[2];
|
||||
string pyString = "";
|
||||
int chrAsc = 0;
|
||||
int i1 = 0;
|
||||
int i2 = 0;
|
||||
char[] noWChar = hzString.ToCharArray();
|
||||
for (int j = 0; j < noWChar.Length; j++)
|
||||
{
|
||||
// 中文字符
|
||||
if (regex.IsMatch(noWChar[j].ToString()))
|
||||
{
|
||||
array = System.Text.Encoding.Default.GetBytes(noWChar[j].ToString());
|
||||
i1 = (short)(array[0]);
|
||||
i2 = (short)(array[1]);
|
||||
chrAsc = i1 * 256 + i2 - 65536;
|
||||
if (chrAsc > 0 && chrAsc < 160)
|
||||
{
|
||||
pyString += noWChar[j];
|
||||
}
|
||||
else
|
||||
{
|
||||
// 修正部分文字
|
||||
if (chrAsc == -9254) // 修正“圳”字
|
||||
pyString += "Zhen";
|
||||
else
|
||||
{
|
||||
for (int i = (pyValue.Length - 1); i >= 0; i--)
|
||||
{
|
||||
if (pyValue[i] <= chrAsc)
|
||||
{
|
||||
pyString += pyName[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 非中文字符
|
||||
else
|
||||
{
|
||||
pyString += noWChar[j].ToString();
|
||||
}
|
||||
}
|
||||
return pyString;
|
||||
}
|
||||
#endregion
|
||||
#region 把汉字转换成拼音(全拼) 用空格间隔
|
||||
/// <summary>
|
||||
/// 把汉字转换成拼音(全拼)
|
||||
/// </summary>
|
||||
/// <param name="hzString">汉字字符串</param>
|
||||
/// <returns>转换后的拼音(全拼)字符串</returns>
|
||||
public static string ConvertWithBlank(string hzString)
|
||||
{
|
||||
// 匹配中文字符
|
||||
Regex regex = new Regex("^[u4e00-u9fa5]$");
|
||||
byte[] array = new byte[2];
|
||||
string pyString = "";
|
||||
int chrAsc = 0;
|
||||
int i1 = 0;
|
||||
int i2 = 0;
|
||||
char[] noWChar = hzString.ToCharArray();
|
||||
for (int j = 0; j < noWChar.Length; j++)
|
||||
{
|
||||
// 中文字符
|
||||
if (regex.IsMatch(noWChar[j].ToString()))
|
||||
{
|
||||
array = System.Text.Encoding.Default.GetBytes(noWChar[j].ToString());
|
||||
i1 = (short)(array[0]);
|
||||
i2 = (short)(array[1]);
|
||||
chrAsc = i1 * 256 + i2 - 65536;
|
||||
if (chrAsc > 0 && chrAsc < 160)
|
||||
{
|
||||
pyString = pyString + " " + noWChar[j];
|
||||
}
|
||||
else
|
||||
{
|
||||
// 修正部分文字
|
||||
if (chrAsc == -9254) // 修正“圳”字
|
||||
pyString = pyString + " " + "Zhen";
|
||||
else
|
||||
{
|
||||
for (int i = (pyValue.Length - 1); i >= 0; i--)
|
||||
{
|
||||
if (pyValue[i] <= chrAsc)
|
||||
{
|
||||
pyString = pyString + " " + pyName[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 非中文字符
|
||||
else
|
||||
{
|
||||
pyString = pyString + " " + noWChar[j].ToString();
|
||||
}
|
||||
}
|
||||
return pyString.Trim();
|
||||
}
|
||||
#endregion
|
||||
#region 把汉字转换成拼音(全拼)无间隔符号
|
||||
/// <summary>
|
||||
/// 把汉字转换成拼音(全拼)
|
||||
/// </summary>
|
||||
/// <param name="hzString">汉字字符串</param>
|
||||
/// <returns>转换后的拼音(全拼)字符串</returns>
|
||||
public static string ConvertFirstPY(string hzString)
|
||||
{
|
||||
// 匹配中文字符
|
||||
Regex regex = new Regex("^[\\u4e00-\\u9fa5]$");
|
||||
byte[] array = new byte[2];
|
||||
string pyString = "";
|
||||
int chrAsc = 0;
|
||||
int i1 = 0;
|
||||
int i2 = 0;
|
||||
char[] noWChar = hzString.ToCharArray();
|
||||
for (int j = 0; j < noWChar.Length; j++)
|
||||
{
|
||||
// 中文字符
|
||||
if (regex.IsMatch(noWChar[j].ToString()))
|
||||
{
|
||||
array = System.Text.Encoding.Default.GetBytes(noWChar[j].ToString());
|
||||
i1 = (short)(array[0]);
|
||||
i2 = (short)(array[1]);
|
||||
chrAsc = i1 * 256 + i2 - 65536;
|
||||
if (chrAsc > 0 && chrAsc < 160)
|
||||
{
|
||||
pyString += noWChar[j];
|
||||
}
|
||||
else
|
||||
{
|
||||
// 修正部分文字
|
||||
if (chrAsc == -9254) // 修正“圳”字
|
||||
pyString += "z";
|
||||
else
|
||||
{
|
||||
for (int i = (pyValue.Length - 1); i >= 0; i--)
|
||||
{
|
||||
if (pyValue[i] <= chrAsc)
|
||||
{
|
||||
pyString += pyName[i].Substring(0,1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 非中文字符
|
||||
else
|
||||
{
|
||||
pyString += noWChar[j].ToString();
|
||||
}
|
||||
}
|
||||
return pyString;
|
||||
}
|
||||
#endregion
|
||||
#region 把汉字转换成拼音(全拼) 用特定的字符间隔
|
||||
/// <summary>
|
||||
/// 把汉字转换成拼音(全拼)
|
||||
/// </summary>
|
||||
/// <param name="hzString">汉字字符串</param>
|
||||
/// <returns>转换后的拼音(全拼)字符串</returns>
|
||||
public static string ConvertWithSplitChar(string hzString, string splitChar)
|
||||
{
|
||||
// 匹配中文字符
|
||||
Regex regex = new Regex("^[\\u4e00-\\u9fa5]$");
|
||||
byte[] array = new byte[2];
|
||||
string pyString = "";
|
||||
int chrAsc = 0;
|
||||
int i1 = 0;
|
||||
int i2 = 0;
|
||||
char[] noWChar = hzString.ToCharArray();
|
||||
for (int j = 0; j < noWChar.Length; j++)
|
||||
{
|
||||
// 中文字符
|
||||
if (regex.IsMatch(noWChar[j].ToString()))
|
||||
{
|
||||
array = System.Text.Encoding.Default.GetBytes(noWChar[j].ToString());
|
||||
i1 = (short)(array[0]);
|
||||
i2 = (short)(array[1]);
|
||||
chrAsc = i1 * 256 + i2 - 65536;
|
||||
if (chrAsc > 0 && chrAsc < 160)
|
||||
{
|
||||
pyString = pyString + splitChar + noWChar[j];
|
||||
}
|
||||
else
|
||||
{
|
||||
// 修正部分文字
|
||||
if (chrAsc == -9254) // 修正“圳”字
|
||||
pyString = pyString + splitChar + "Zhen";
|
||||
else
|
||||
{
|
||||
for (int i = (pyValue.Length - 1); i >= 0; i--)
|
||||
{
|
||||
if (pyValue[i] <= chrAsc)
|
||||
{
|
||||
pyString = pyString + splitChar + pyName[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 非中文字符
|
||||
else
|
||||
{
|
||||
pyString = pyString + splitChar + noWChar[j].ToString();
|
||||
}
|
||||
}
|
||||
char[] trimAChar = splitChar.ToCharArray();
|
||||
return pyString.TrimStart(trimAChar);
|
||||
}
|
||||
#endregion
|
||||
#region 汉字转拼音缩写 (字符串) (小写)
|
||||
/// <summary>
|
||||
/// 汉字转拼音缩写
|
||||
/// </summary>
|
||||
/// <param name="str">要转换的汉字字符串</param>
|
||||
/// <returns>拼音缩写</returns>
|
||||
public static string GetSpellStringLower(string str)
|
||||
{
|
||||
string tempStr = "";
|
||||
foreach (char c in str)
|
||||
{
|
||||
if ((int)c >= 33 && (int)c <= 126)
|
||||
{
|
||||
//字母和符号原样保留
|
||||
tempStr += c.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
//累加拼音声母
|
||||
tempStr += GetSpellCharLower(c.ToString());
|
||||
}
|
||||
}
|
||||
return tempStr;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 汉字转拼音缩写 (字符串) (小写) (空格间隔)
|
||||
/// <summary>
|
||||
/// 汉字转拼音缩写 (字符串) (小写) (空格间隔)
|
||||
/// </summary>
|
||||
/// <param name="str">要转换的汉字字符串</param>
|
||||
/// <returns>拼音缩写</returns>
|
||||
public static string GetSpellStringLowerSplitWithBlank(string str)
|
||||
{
|
||||
string tempStr = "";
|
||||
foreach (char c in str)
|
||||
{
|
||||
if ((int)c >= 33 && (int)c <= 126)
|
||||
{
|
||||
//字母和符号原样保留
|
||||
tempStr = tempStr + " " + c.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
//累加拼音声母
|
||||
tempStr = tempStr + " " + GetSpellCharLower(c.ToString());
|
||||
}
|
||||
}
|
||||
return tempStr.Trim();
|
||||
}
|
||||
#endregion
|
||||
#region 汉字转拼音缩写 (字符串)(大写)
|
||||
/// <summary>
|
||||
/// 汉字转拼音缩写 (大写)
|
||||
/// </summary>
|
||||
/// <param name="str">要转换的汉字字符串</param>
|
||||
/// <returns>拼音缩写</returns>
|
||||
public static string GetSpellStringSupper(string str)
|
||||
{
|
||||
string tempStr = "";
|
||||
foreach (char c in str)
|
||||
{
|
||||
if ((int)c >= 33 && (int)c <= 126)
|
||||
{
|
||||
//字母和符号原样保留
|
||||
tempStr += c.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
//累加拼音声母
|
||||
tempStr += GetSpellCharSupper(c.ToString());
|
||||
}
|
||||
}
|
||||
return tempStr;
|
||||
}
|
||||
#endregion
|
||||
#region 汉字转拼音缩写 (字符串)(大写)(空格间隔)
|
||||
/// <summary>
|
||||
/// 汉字转拼音缩写 (字符串)(大写)(空格间隔)
|
||||
/// </summary>
|
||||
/// <param name="str">要转换的汉字字符串</param>
|
||||
/// <returns>拼音缩写</returns>
|
||||
public static string GetSpellStringSupperSplitWithBlank(string str)
|
||||
{
|
||||
string tempStr = "";
|
||||
foreach (char c in str)
|
||||
{
|
||||
if ((int)c >= 33 && (int)c <= 126)
|
||||
{
|
||||
//字母和符号原样保留
|
||||
tempStr = tempStr + " " + c.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
//累加拼音声母
|
||||
tempStr = tempStr + " " + GetSpellCharSupper(c.ToString());
|
||||
}
|
||||
}
|
||||
return tempStr.Trim();
|
||||
}
|
||||
#endregion
|
||||
#region 取单个字符的拼音声母(字符)(大写)
|
||||
/// <summary>
|
||||
/// 取单个字符的拼音声母
|
||||
/// </summary>
|
||||
/// <param name="c">要转换的单个汉字</param>
|
||||
/// <returns>拼音声母</returns>
|
||||
public static string GetSpellCharSupper(string c)
|
||||
{
|
||||
byte[] array = new byte[2];
|
||||
array = System.Text.Encoding.Default.GetBytes(c);
|
||||
int i = (short)(array[0] - '0') * 256 + ((short)(array[1] - '0'));
|
||||
if (i < 0xB0A1) return c;
|
||||
if (i < 0xB0C5) return "A";
|
||||
if (i < 0xB2C1) return "B";
|
||||
if (i < 0xB4EE) return "C";
|
||||
if (i < 0xB6EA) return "D";
|
||||
if (i < 0xB7A2) return "E";
|
||||
if (i < 0xB8C1) return "F";
|
||||
if (i < 0xB9FE) return "G";
|
||||
if (i < 0xBBF7) return "H";
|
||||
if (i < 0xBFA6) return "J";
|
||||
if (i < 0xC0AC) return "K";
|
||||
if (i < 0xC2E8) return "L";
|
||||
if (i < 0xC4C3) return "M";
|
||||
if (i < 0xC5B6) return "N";
|
||||
if (i < 0xC5BE) return "O";
|
||||
if (i < 0xC6DA) return "P";
|
||||
if (i < 0xC8BB) return "Q";
|
||||
if (i < 0xC8F6) return "R";
|
||||
if (i < 0xCBFA) return "S";
|
||||
if (i < 0xCDDA) return "T";
|
||||
if (i < 0xCEF4) return "W";
|
||||
if (i < 0xD1B9) return "X";
|
||||
if (i < 0xD4D1) return "Y";
|
||||
if (i < 0xD7FA) return "Z";
|
||||
return c;
|
||||
}
|
||||
#endregion
|
||||
#region 取单个字符的拼音声母(字符)(小写)
|
||||
/// <summary>
|
||||
/// 取单个字符的拼音声母
|
||||
/// </summary>
|
||||
/// <param name="c">要转换的单个汉字</param>
|
||||
/// <returns>拼音声母</returns>
|
||||
public static string GetSpellCharLower(string c)
|
||||
{
|
||||
byte[] array = new byte[2];
|
||||
array = System.Text.Encoding.Default.GetBytes(c);
|
||||
if (array.Length <= 1) { return ""; }
|
||||
int i = (short)(array[0] - '0') * 256 + ((short)(array[1] - '0'));
|
||||
if (i < 0xB0A1) return c;
|
||||
if (i < 0xB0C5) return "a";
|
||||
if (i < 0xB2C1) return "b";
|
||||
if (i < 0xB4EE) return "c";
|
||||
if (i < 0xB6EA) return "d";
|
||||
if (i < 0xB7A2) return "e";
|
||||
if (i < 0xB8C1) return "f";
|
||||
if (i < 0xB9FE) return "g";
|
||||
if (i < 0xBBF7) return "h";
|
||||
if (i < 0xBFA6) return "j";
|
||||
if (i < 0xC0AC) return "k";
|
||||
if (i < 0xC2E8) return "l";
|
||||
if (i < 0xC4C3) return "m";
|
||||
if (i < 0xC5B6) return "n";
|
||||
if (i < 0xC5BE) return "o";
|
||||
if (i < 0xC6DA) return "p";
|
||||
if (i < 0xC8BB) return "q";
|
||||
if (i < 0xC8F6) return "r";
|
||||
if (i < 0xCBFA) return "s";
|
||||
if (i < 0xCDDA) return "t";
|
||||
if (i < 0xCEF4) return "w";
|
||||
if (i < 0xD1B9) return "x";
|
||||
if (i < 0xD4D1) return "y";
|
||||
if (i < 0xD7FA) return "z";
|
||||
return c;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+245
@@ -0,0 +1,245 @@
|
||||
namespace 开发辅助工具.Manager
|
||||
{
|
||||
partial class FrmAddTools
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.TxtName = new ryControls.TextBoxEx2();
|
||||
this.TxtToolAddr = new ryControls.TextBoxEx2();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.TxtToolDes = new ryControls.TextBoxEx2();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.TxtKeys = new ryControls.TextBoxEx2();
|
||||
this.btnCancel = new ryControls.ButtonEx();
|
||||
this.btnOK = new ryControls.ButtonEx();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.numericUpDownEx1 = new ryControls.NumericUpDownEx();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownEx1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(14, 9);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(53, 12);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "工具名称";
|
||||
//
|
||||
// TxtName
|
||||
//
|
||||
this.TxtName.BackColor = System.Drawing.Color.White;
|
||||
this.TxtName.EmptyText = "";
|
||||
this.TxtName.Location = new System.Drawing.Point(14, 27);
|
||||
this.TxtName.MaxLength = 999999999;
|
||||
this.TxtName.Multiline = false;
|
||||
this.TxtName.Name = "TxtName";
|
||||
this.TxtName.OnlyNumeric = false;
|
||||
this.TxtName.PasswordChar = '\0';
|
||||
this.TxtName.ReadOnly = false;
|
||||
this.TxtName.SelectedText = "";
|
||||
this.TxtName.SelectionLength = 0;
|
||||
this.TxtName.SelectionStart = 0;
|
||||
this.TxtName.Size = new System.Drawing.Size(344, 24);
|
||||
this.TxtName.TabIndex = 1;
|
||||
this.TxtName.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
|
||||
this.TxtName.ToolTip = "";
|
||||
//
|
||||
// TxtToolAddr
|
||||
//
|
||||
this.TxtToolAddr.BackColor = System.Drawing.Color.White;
|
||||
this.TxtToolAddr.EmptyText = "";
|
||||
this.TxtToolAddr.Location = new System.Drawing.Point(16, 74);
|
||||
this.TxtToolAddr.MaxLength = 999999999;
|
||||
this.TxtToolAddr.Multiline = false;
|
||||
this.TxtToolAddr.Name = "TxtToolAddr";
|
||||
this.TxtToolAddr.OnlyNumeric = false;
|
||||
this.TxtToolAddr.PasswordChar = '\0';
|
||||
this.TxtToolAddr.ReadOnly = false;
|
||||
this.TxtToolAddr.SelectedText = "";
|
||||
this.TxtToolAddr.SelectionLength = 0;
|
||||
this.TxtToolAddr.SelectionStart = 0;
|
||||
this.TxtToolAddr.Size = new System.Drawing.Size(430, 24);
|
||||
this.TxtToolAddr.TabIndex = 3;
|
||||
this.TxtToolAddr.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
|
||||
this.TxtToolAddr.ToolTip = "";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(16, 56);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(53, 12);
|
||||
this.label2.TabIndex = 2;
|
||||
this.label2.Text = "工具地址";
|
||||
//
|
||||
// TxtToolDes
|
||||
//
|
||||
this.TxtToolDes.BackColor = System.Drawing.Color.White;
|
||||
this.TxtToolDes.EmptyText = "";
|
||||
this.TxtToolDes.Location = new System.Drawing.Point(16, 118);
|
||||
this.TxtToolDes.MaxLength = 999999999;
|
||||
this.TxtToolDes.Multiline = false;
|
||||
this.TxtToolDes.Name = "TxtToolDes";
|
||||
this.TxtToolDes.OnlyNumeric = false;
|
||||
this.TxtToolDes.PasswordChar = '\0';
|
||||
this.TxtToolDes.ReadOnly = false;
|
||||
this.TxtToolDes.SelectedText = "";
|
||||
this.TxtToolDes.SelectionLength = 0;
|
||||
this.TxtToolDes.SelectionStart = 0;
|
||||
this.TxtToolDes.Size = new System.Drawing.Size(430, 24);
|
||||
this.TxtToolDes.TabIndex = 5;
|
||||
this.TxtToolDes.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
|
||||
this.TxtToolDes.ToolTip = "";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(16, 100);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(53, 12);
|
||||
this.label3.TabIndex = 4;
|
||||
this.label3.Text = "工具备注";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(16, 145);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(41, 12);
|
||||
this.label4.TabIndex = 6;
|
||||
this.label4.Text = "关键词";
|
||||
//
|
||||
// TxtKeys
|
||||
//
|
||||
this.TxtKeys.BackColor = System.Drawing.Color.White;
|
||||
this.TxtKeys.EmptyText = "";
|
||||
this.TxtKeys.Location = new System.Drawing.Point(16, 160);
|
||||
this.TxtKeys.MaxLength = 999999999;
|
||||
this.TxtKeys.Multiline = false;
|
||||
this.TxtKeys.Name = "TxtKeys";
|
||||
this.TxtKeys.OnlyNumeric = false;
|
||||
this.TxtKeys.PasswordChar = '\0';
|
||||
this.TxtKeys.ReadOnly = false;
|
||||
this.TxtKeys.SelectedText = "";
|
||||
this.TxtKeys.SelectionLength = 0;
|
||||
this.TxtKeys.SelectionStart = 0;
|
||||
this.TxtKeys.Size = new System.Drawing.Size(430, 24);
|
||||
this.TxtKeys.TabIndex = 7;
|
||||
this.TxtKeys.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
|
||||
this.TxtKeys.ToolTip = "";
|
||||
//
|
||||
// btnCancel
|
||||
//
|
||||
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnCancel.ForeColor = System.Drawing.Color.White;
|
||||
this.btnCancel.Location = new System.Drawing.Point(383, 323);
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.Size = new System.Drawing.Size(65, 27);
|
||||
this.btnCancel.TabIndex = 9;
|
||||
this.btnCancel.Text = "取消";
|
||||
this.btnCancel.UseVisualStyleBackColor = true;
|
||||
this.btnCancel.Click += new System.EventHandler(this.BtnCancel_Click);
|
||||
//
|
||||
// btnOK
|
||||
//
|
||||
this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnOK.ForeColor = System.Drawing.Color.White;
|
||||
this.btnOK.Location = new System.Drawing.Point(312, 323);
|
||||
this.btnOK.Name = "btnOK";
|
||||
this.btnOK.Size = new System.Drawing.Size(65, 27);
|
||||
this.btnOK.TabIndex = 8;
|
||||
this.btnOK.Text = "确定";
|
||||
this.btnOK.UseVisualStyleBackColor = true;
|
||||
this.btnOK.Click += new System.EventHandler(this.BtnOK_Click);
|
||||
//
|
||||
// label5
|
||||
//
|
||||
this.label5.AutoSize = true;
|
||||
this.label5.Location = new System.Drawing.Point(362, 9);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(29, 12);
|
||||
this.label5.TabIndex = 10;
|
||||
this.label5.Text = "排序";
|
||||
//
|
||||
// numericUpDownEx1
|
||||
//
|
||||
this.numericUpDownEx1.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.numericUpDownEx1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.numericUpDownEx1.Location = new System.Drawing.Point(364, 28);
|
||||
this.numericUpDownEx1.Maximum = new decimal(new int[] {
|
||||
100000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownEx1.Name = "numericUpDownEx1";
|
||||
this.numericUpDownEx1.Size = new System.Drawing.Size(81, 22);
|
||||
this.numericUpDownEx1.TabIndex = 11;
|
||||
//
|
||||
// FrmAddTools
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(456, 362);
|
||||
this.Controls.Add(this.numericUpDownEx1);
|
||||
this.Controls.Add(this.label5);
|
||||
this.Controls.Add(this.btnCancel);
|
||||
this.Controls.Add(this.btnOK);
|
||||
this.Controls.Add(this.TxtKeys);
|
||||
this.Controls.Add(this.label4);
|
||||
this.Controls.Add(this.TxtToolDes);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.TxtToolAddr);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.TxtName);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Name = "FrmAddTools";
|
||||
this.Text = "添加工具";
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownEx1)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label label1;
|
||||
private ryControls.TextBoxEx2 TxtName;
|
||||
private ryControls.TextBoxEx2 TxtToolAddr;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private ryControls.TextBoxEx2 TxtToolDes;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private ryControls.TextBoxEx2 TxtKeys;
|
||||
private ryControls.ButtonEx btnCancel;
|
||||
private ryControls.ButtonEx btnOK;
|
||||
private System.Windows.Forms.Label label5;
|
||||
private ryControls.NumericUpDownEx numericUpDownEx1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
using ryCommon;
|
||||
using ryCommonDb;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace 开发辅助工具.Manager
|
||||
{
|
||||
public partial class FrmAddTools : Form
|
||||
{
|
||||
public FrmAddTools()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public ModalForm mr = null;
|
||||
public string tableName = "Tools";
|
||||
public int isAdd = 1;
|
||||
public string selectId = "-1";
|
||||
|
||||
private void BtnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
ModalForm.SetDialogResult(this, mr, DialogResult.Cancel);
|
||||
}
|
||||
|
||||
#region 需要修改
|
||||
public void GetInfo(string id)
|
||||
{
|
||||
selectId = id;
|
||||
DataProvider mydb = new DataProvider();
|
||||
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||||
if (db.ConnDb(Itrycn_Db.Sys_SQLConn) == 1)
|
||||
{
|
||||
DataSet ds = db.ReadData(tableName, id);
|
||||
if (mydb.HaveData(ds))
|
||||
{
|
||||
DataRow reader = ds.Tables[0].Rows[0];
|
||||
#region 读取信息
|
||||
TxtName.Text = reader["Name"].ToString();
|
||||
TxtKeys.Text = reader["Keys"].ToString();
|
||||
TxtToolAddr.Text = reader["Addr"].ToString();
|
||||
TxtToolDes.Text = reader["Des"].ToString();
|
||||
numericUpDownEx1.Value = reader["Sort"].ToDecimal();
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
db.Free();
|
||||
}
|
||||
|
||||
private void BtnOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (TxtName.Text == "")
|
||||
{
|
||||
MessageBox.Show("名称不能为空。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
return;
|
||||
}
|
||||
RyQuickSQL mySQL = new RyQuickSQL(tableName);
|
||||
mySQL.AddField("Name", TxtName.Text);
|
||||
mySQL.AddField("Keys", TxtKeys.Text);
|
||||
mySQL.AddField("Addr", TxtToolAddr.Text);
|
||||
mySQL.AddField("Des", TxtToolDes.Text);
|
||||
mySQL.AddField("Sort", numericUpDownEx1.Value.ToInt());
|
||||
mySQL.AddField("PY", Chinese2Spell.Convert(TxtName.Text + "\n" + TxtKeys.Text)+"\n"+ Chinese2Spell.ConvertFirstPY(TxtName.Text + "\n" + TxtKeys.Text));
|
||||
DataProvider mydb = new DataProvider();
|
||||
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||||
if (db.ConnDb(Itrycn_Db.Sys_SQLConn) == 1)
|
||||
{
|
||||
if (isAdd >= 1)
|
||||
{
|
||||
db.ExecuteNonQuery(mySQL.GetInsertSQL(), db.GetParameter(mySQL));
|
||||
}
|
||||
else
|
||||
{
|
||||
db.ExecuteNonQuery(mySQL.GetUpdateSQL() + " where id=" + selectId, db.GetParameter(mySQL));
|
||||
}
|
||||
}
|
||||
ModalForm.SetDialogResult(this, mr, DialogResult.OK);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
+344
@@ -0,0 +1,344 @@
|
||||
namespace 开发辅助工具.Manager
|
||||
{
|
||||
partial class FrmSetting
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.tabControl1 = new System.Windows.Forms.TabControl();
|
||||
this.tabPage1 = new System.Windows.Forms.TabPage();
|
||||
this.BtnWinRARPath = new ryControls.ButtonEx();
|
||||
this.TxtWinRARPath = new ryControls.TextBoxEx2();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.BtnReactorPath = new ryControls.ButtonEx();
|
||||
this.TxtReactorPath = new ryControls.TextBoxEx2();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.TxtReferenceDll = new ryControls.TextBoxEx2();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.BtnChapeBasePath = new ryControls.ButtonEx();
|
||||
this.TxtCshapeBasePath = new ryControls.TextBoxEx2();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.BtnOK = new ryControls.ButtonEx();
|
||||
this.BtnCancel = new ryControls.ButtonEx();
|
||||
this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
|
||||
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.tabPage2 = new System.Windows.Forms.TabPage();
|
||||
this.ChkAss_Ryp = new System.Windows.Forms.CheckBox();
|
||||
this.ChkAss_Folder = new System.Windows.Forms.CheckBox();
|
||||
this.tabControl1.SuspendLayout();
|
||||
this.tabPage1.SuspendLayout();
|
||||
this.tabPage2.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// tabControl1
|
||||
//
|
||||
this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.tabControl1.Controls.Add(this.tabPage1);
|
||||
this.tabControl1.Controls.Add(this.tabPage2);
|
||||
this.tabControl1.Location = new System.Drawing.Point(3, 2);
|
||||
this.tabControl1.Name = "tabControl1";
|
||||
this.tabControl1.SelectedIndex = 0;
|
||||
this.tabControl1.Size = new System.Drawing.Size(606, 399);
|
||||
this.tabControl1.TabIndex = 0;
|
||||
//
|
||||
// tabPage1
|
||||
//
|
||||
this.tabPage1.Controls.Add(this.BtnWinRARPath);
|
||||
this.tabPage1.Controls.Add(this.TxtWinRARPath);
|
||||
this.tabPage1.Controls.Add(this.label4);
|
||||
this.tabPage1.Controls.Add(this.BtnReactorPath);
|
||||
this.tabPage1.Controls.Add(this.TxtReactorPath);
|
||||
this.tabPage1.Controls.Add(this.label3);
|
||||
this.tabPage1.Controls.Add(this.TxtReferenceDll);
|
||||
this.tabPage1.Controls.Add(this.label2);
|
||||
this.tabPage1.Controls.Add(this.BtnChapeBasePath);
|
||||
this.tabPage1.Controls.Add(this.TxtCshapeBasePath);
|
||||
this.tabPage1.Controls.Add(this.label1);
|
||||
this.tabPage1.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage1.Name = "tabPage1";
|
||||
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage1.Size = new System.Drawing.Size(598, 373);
|
||||
this.tabPage1.TabIndex = 0;
|
||||
this.tabPage1.Text = "路径";
|
||||
this.tabPage1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// BtnWinRARPath
|
||||
//
|
||||
this.BtnWinRARPath.BaseColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(76)))), ((int)(((byte)(95)))));
|
||||
this.BtnWinRARPath.Location = new System.Drawing.Point(515, 321);
|
||||
this.BtnWinRARPath.Name = "BtnWinRARPath";
|
||||
this.BtnWinRARPath.Size = new System.Drawing.Size(69, 27);
|
||||
this.BtnWinRARPath.TabIndex = 10;
|
||||
this.BtnWinRARPath.Text = "浏览";
|
||||
this.BtnWinRARPath.UseVisualStyleBackColor = true;
|
||||
this.BtnWinRARPath.Click += new System.EventHandler(this.BtnWinRARPath_Click);
|
||||
//
|
||||
// TxtWinRARPath
|
||||
//
|
||||
this.TxtWinRARPath.BackColor = System.Drawing.Color.White;
|
||||
this.TxtWinRARPath.EmptyText = "";
|
||||
this.TxtWinRARPath.Location = new System.Drawing.Point(14, 321);
|
||||
this.TxtWinRARPath.MaxLength = 999999999;
|
||||
this.TxtWinRARPath.Multiline = false;
|
||||
this.TxtWinRARPath.Name = "TxtWinRARPath";
|
||||
this.TxtWinRARPath.OnlyNumeric = false;
|
||||
this.TxtWinRARPath.PasswordChar = '\0';
|
||||
this.TxtWinRARPath.ReadOnly = false;
|
||||
this.TxtWinRARPath.SelectedText = "";
|
||||
this.TxtWinRARPath.SelectionLength = 0;
|
||||
this.TxtWinRARPath.SelectionStart = 0;
|
||||
this.TxtWinRARPath.Size = new System.Drawing.Size(495, 27);
|
||||
this.TxtWinRARPath.TabIndex = 9;
|
||||
this.TxtWinRARPath.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
|
||||
this.TxtWinRARPath.ToolTip = "";
|
||||
this.toolTip1.SetToolTip(this.TxtWinRARPath, ".NET Reactor 主程序exe的具体路径");
|
||||
this.TxtWinRARPath.WordWrap = true;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(12, 306);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(101, 12);
|
||||
this.label4.TabIndex = 8;
|
||||
this.label4.Text = "WinRAR主程序路径";
|
||||
//
|
||||
// BtnReactorPath
|
||||
//
|
||||
this.BtnReactorPath.BaseColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(76)))), ((int)(((byte)(95)))));
|
||||
this.BtnReactorPath.Location = new System.Drawing.Point(515, 272);
|
||||
this.BtnReactorPath.Name = "BtnReactorPath";
|
||||
this.BtnReactorPath.Size = new System.Drawing.Size(69, 27);
|
||||
this.BtnReactorPath.TabIndex = 7;
|
||||
this.BtnReactorPath.Text = "浏览";
|
||||
this.BtnReactorPath.UseVisualStyleBackColor = true;
|
||||
this.BtnReactorPath.Click += new System.EventHandler(this.BtnReactorPath_Click);
|
||||
//
|
||||
// TxtReactorPath
|
||||
//
|
||||
this.TxtReactorPath.BackColor = System.Drawing.Color.White;
|
||||
this.TxtReactorPath.EmptyText = "";
|
||||
this.TxtReactorPath.Location = new System.Drawing.Point(14, 272);
|
||||
this.TxtReactorPath.MaxLength = 999999999;
|
||||
this.TxtReactorPath.Multiline = false;
|
||||
this.TxtReactorPath.Name = "TxtReactorPath";
|
||||
this.TxtReactorPath.OnlyNumeric = false;
|
||||
this.TxtReactorPath.PasswordChar = '\0';
|
||||
this.TxtReactorPath.ReadOnly = false;
|
||||
this.TxtReactorPath.SelectedText = "";
|
||||
this.TxtReactorPath.SelectionLength = 0;
|
||||
this.TxtReactorPath.SelectionStart = 0;
|
||||
this.TxtReactorPath.Size = new System.Drawing.Size(495, 27);
|
||||
this.TxtReactorPath.TabIndex = 6;
|
||||
this.TxtReactorPath.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
|
||||
this.TxtReactorPath.ToolTip = "";
|
||||
this.toolTip1.SetToolTip(this.TxtReactorPath, ".NET Reactor 主程序exe的具体路径");
|
||||
this.TxtReactorPath.WordWrap = true;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(12, 257);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(143, 12);
|
||||
this.label3.TabIndex = 5;
|
||||
this.label3.Text = ".NET Reactor 主程序路径";
|
||||
//
|
||||
// TxtReferenceDll
|
||||
//
|
||||
this.TxtReferenceDll.BackColor = System.Drawing.Color.White;
|
||||
this.TxtReferenceDll.EmptyText = "";
|
||||
this.TxtReferenceDll.Location = new System.Drawing.Point(14, 69);
|
||||
this.TxtReferenceDll.MaxLength = 999999999;
|
||||
this.TxtReferenceDll.Multiline = true;
|
||||
this.TxtReferenceDll.Name = "TxtReferenceDll";
|
||||
this.TxtReferenceDll.OnlyNumeric = false;
|
||||
this.TxtReferenceDll.PasswordChar = '\0';
|
||||
this.TxtReferenceDll.ReadOnly = false;
|
||||
this.TxtReferenceDll.SelectedText = "";
|
||||
this.TxtReferenceDll.SelectionLength = 0;
|
||||
this.TxtReferenceDll.SelectionStart = 0;
|
||||
this.TxtReferenceDll.Size = new System.Drawing.Size(570, 181);
|
||||
this.TxtReferenceDll.TabIndex = 4;
|
||||
this.TxtReferenceDll.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
|
||||
this.TxtReferenceDll.ToolTip = "";
|
||||
this.toolTip1.SetToolTip(this.TxtReferenceDll, "每行一个路径,软件将自动从上往下搜索");
|
||||
this.TxtReferenceDll.WordWrap = true;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(12, 54);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(89, 12);
|
||||
this.label2.TabIndex = 3;
|
||||
this.label2.Text = "C# 引用dll路径";
|
||||
//
|
||||
// BtnChapeBasePath
|
||||
//
|
||||
this.BtnChapeBasePath.BaseColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(76)))), ((int)(((byte)(95)))));
|
||||
this.BtnChapeBasePath.Location = new System.Drawing.Point(515, 22);
|
||||
this.BtnChapeBasePath.Name = "BtnChapeBasePath";
|
||||
this.BtnChapeBasePath.Size = new System.Drawing.Size(69, 27);
|
||||
this.BtnChapeBasePath.TabIndex = 2;
|
||||
this.BtnChapeBasePath.Text = "浏览";
|
||||
this.BtnChapeBasePath.UseVisualStyleBackColor = true;
|
||||
this.BtnChapeBasePath.Click += new System.EventHandler(this.BtnChapeBasePath_Click);
|
||||
//
|
||||
// TxtCshapeBasePath
|
||||
//
|
||||
this.TxtCshapeBasePath.BackColor = System.Drawing.Color.White;
|
||||
this.TxtCshapeBasePath.EmptyText = "";
|
||||
this.TxtCshapeBasePath.Location = new System.Drawing.Point(14, 22);
|
||||
this.TxtCshapeBasePath.MaxLength = 999999999;
|
||||
this.TxtCshapeBasePath.Multiline = false;
|
||||
this.TxtCshapeBasePath.Name = "TxtCshapeBasePath";
|
||||
this.TxtCshapeBasePath.OnlyNumeric = false;
|
||||
this.TxtCshapeBasePath.PasswordChar = '\0';
|
||||
this.TxtCshapeBasePath.ReadOnly = false;
|
||||
this.TxtCshapeBasePath.SelectedText = "";
|
||||
this.TxtCshapeBasePath.SelectionLength = 0;
|
||||
this.TxtCshapeBasePath.SelectionStart = 0;
|
||||
this.TxtCshapeBasePath.Size = new System.Drawing.Size(495, 27);
|
||||
this.TxtCshapeBasePath.TabIndex = 1;
|
||||
this.TxtCshapeBasePath.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
|
||||
this.TxtCshapeBasePath.ToolTip = "";
|
||||
this.toolTip1.SetToolTip(this.TxtCshapeBasePath, "以该项目为基准,自动生成符合毕方项目标准的项目。");
|
||||
this.TxtCshapeBasePath.WordWrap = true;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(12, 7);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(95, 12);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "C# 基准项目路径";
|
||||
//
|
||||
// BtnOK
|
||||
//
|
||||
this.BtnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.BtnOK.BaseColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(76)))), ((int)(((byte)(95)))));
|
||||
this.BtnOK.Location = new System.Drawing.Point(449, 403);
|
||||
this.BtnOK.Name = "BtnOK";
|
||||
this.BtnOK.Size = new System.Drawing.Size(75, 30);
|
||||
this.BtnOK.TabIndex = 1;
|
||||
this.BtnOK.Text = "确定";
|
||||
this.BtnOK.UseVisualStyleBackColor = true;
|
||||
this.BtnOK.Click += new System.EventHandler(this.BtnOK_Click);
|
||||
//
|
||||
// BtnCancel
|
||||
//
|
||||
this.BtnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.BtnCancel.BaseColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(76)))), ((int)(((byte)(95)))));
|
||||
this.BtnCancel.Location = new System.Drawing.Point(530, 403);
|
||||
this.BtnCancel.Name = "BtnCancel";
|
||||
this.BtnCancel.Size = new System.Drawing.Size(75, 30);
|
||||
this.BtnCancel.TabIndex = 2;
|
||||
this.BtnCancel.Text = "取消";
|
||||
this.BtnCancel.UseVisualStyleBackColor = true;
|
||||
this.BtnCancel.Click += new System.EventHandler(this.BtnCancel_Click);
|
||||
//
|
||||
// tabPage2
|
||||
//
|
||||
this.tabPage2.Controls.Add(this.ChkAss_Folder);
|
||||
this.tabPage2.Controls.Add(this.ChkAss_Ryp);
|
||||
this.tabPage2.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage2.Name = "tabPage2";
|
||||
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage2.Size = new System.Drawing.Size(598, 373);
|
||||
this.tabPage2.TabIndex = 1;
|
||||
this.tabPage2.Text = "基本";
|
||||
this.tabPage2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// ChkAss_Ryp
|
||||
//
|
||||
this.ChkAss_Ryp.AutoSize = true;
|
||||
this.ChkAss_Ryp.Location = new System.Drawing.Point(29, 18);
|
||||
this.ChkAss_Ryp.Name = "ChkAss_Ryp";
|
||||
this.ChkAss_Ryp.Size = new System.Drawing.Size(114, 16);
|
||||
this.ChkAss_Ryp.TabIndex = 0;
|
||||
this.ChkAss_Ryp.Text = "关联ryp文件格式";
|
||||
this.ChkAss_Ryp.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// ChkAss_Folder
|
||||
//
|
||||
this.ChkAss_Folder.AutoSize = true;
|
||||
this.ChkAss_Folder.Location = new System.Drawing.Point(29, 40);
|
||||
this.ChkAss_Folder.Name = "ChkAss_Folder";
|
||||
this.ChkAss_Folder.Size = new System.Drawing.Size(132, 16);
|
||||
this.ChkAss_Folder.TabIndex = 1;
|
||||
this.ChkAss_Folder.Text = "关联文件夹右键菜单";
|
||||
this.ChkAss_Folder.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FrmSetting
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(612, 440);
|
||||
this.Controls.Add(this.BtnCancel);
|
||||
this.Controls.Add(this.BtnOK);
|
||||
this.Controls.Add(this.tabControl1);
|
||||
this.Name = "FrmSetting";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "设置";
|
||||
this.Load += new System.EventHandler(this.FrmSetting_Load);
|
||||
this.tabControl1.ResumeLayout(false);
|
||||
this.tabPage1.ResumeLayout(false);
|
||||
this.tabPage1.PerformLayout();
|
||||
this.tabPage2.ResumeLayout(false);
|
||||
this.tabPage2.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TabControl tabControl1;
|
||||
private System.Windows.Forms.TabPage tabPage1;
|
||||
private ryControls.ButtonEx BtnChapeBasePath;
|
||||
private ryControls.TextBoxEx2 TxtCshapeBasePath;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private ryControls.ButtonEx BtnOK;
|
||||
private ryControls.ButtonEx BtnCancel;
|
||||
private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1;
|
||||
private System.Windows.Forms.ToolTip toolTip1;
|
||||
private ryControls.TextBoxEx2 TxtReferenceDll;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private ryControls.ButtonEx BtnReactorPath;
|
||||
private ryControls.TextBoxEx2 TxtReactorPath;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private ryControls.ButtonEx BtnWinRARPath;
|
||||
private ryControls.TextBoxEx2 TxtWinRARPath;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.TabPage tabPage2;
|
||||
private System.Windows.Forms.CheckBox ChkAss_Folder;
|
||||
private System.Windows.Forms.CheckBox ChkAss_Ryp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
using Microsoft.Win32;
|
||||
using ryCommonDb;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace 开发辅助工具.Manager
|
||||
{
|
||||
public partial class FrmSetting : Form
|
||||
{
|
||||
public FrmSetting()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void BtnChapeBasePath_Click(object sender, EventArgs e)
|
||||
{
|
||||
folderBrowserDialog1.SelectedPath = TxtCshapeBasePath.Text;
|
||||
if (folderBrowserDialog1.ShowDialog()==DialogResult.OK)
|
||||
{
|
||||
TxtCshapeBasePath.Text = folderBrowserDialog1.SelectedPath;
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
}
|
||||
|
||||
private void BtnOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
if(ChkAss_Ryp.Checked)
|
||||
{
|
||||
SetFileAssociation(".ryp", "ryUSQ", "用睿元开发助手打开", Application.ExecutablePath);
|
||||
}
|
||||
else { DelFileAssociation(".ryp", "ryUSQ"); }
|
||||
if(ChkAss_Folder.Checked)
|
||||
{
|
||||
SetFileAssociation("folder", "ryUSQ", "用睿元开发助手打开", Application.ExecutablePath);
|
||||
}
|
||||
else { DelFileAssociation("folder", "ryUSQ"); }
|
||||
ryCommon.Storage mStor = new ryCommon.Storage();
|
||||
mStor.SelectNodeBySet();
|
||||
mStor.SetAttrValue("CshapeBasePath", TxtCshapeBasePath.Text);
|
||||
mStor.SetAttrValue("ReferenceDll", TxtReferenceDll.Text);
|
||||
mStor.SetAttrValue("ReactorPath", TxtReactorPath.Text);
|
||||
mStor.SetAttrValue("WinRARPath", TxtWinRARPath.Text);
|
||||
DataProvider mydb = new DataProvider();
|
||||
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||||
if (db.ConnDb(Itrycn_Db.User_SQLConn) == 1)
|
||||
{
|
||||
RyQuickSQL mySQL = new RyQuickSQL("Settings");
|
||||
mySQL.AddField("name","Setting");
|
||||
mySQL.AddField("value", mStor.XMLText);
|
||||
if(db.ExecuteNonQuery(mySQL.GetUpdateSQL()+ " where name='Setting'",mySQL)==0)
|
||||
{
|
||||
db.ExecuteNonQuery(mySQL.GetInsertSQL(),mySQL);
|
||||
}
|
||||
}
|
||||
db.Free();
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置文件关联
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool SetFileAssociation(string ExtName, string sName, string AssDes,string filePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
RegistryKey LRoot = RegistryKey.OpenBaseKey(RegistryHive.ClassesRoot,RegistryView.Registry32);
|
||||
RegistryKey softwareRun = LRoot.OpenSubKey(ExtName + @"\shell\"+sName, true);
|
||||
if (softwareRun == null) { softwareRun = LRoot.CreateSubKey(ExtName + @"\shell\" + sName); }
|
||||
softwareRun.SetValue("", AssDes, RegistryValueKind.String);
|
||||
var Command= softwareRun.OpenSubKey("command",true);
|
||||
if (Command == null) { Command = softwareRun.CreateSubKey("command"); }
|
||||
Command.SetValue("","\""+ filePath+"\" open \"%1\"");
|
||||
Command.Close();
|
||||
softwareRun.Close();
|
||||
LRoot.Close();
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 判断文件关联是否存在
|
||||
/// </summary>
|
||||
/// <param name="ExtName"></param>
|
||||
/// <param name="sName"></param>
|
||||
/// <returns></returns>
|
||||
public bool GetFileAssociation(string ExtName, string sName)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = false;
|
||||
RegistryKey LRoot = RegistryKey.OpenBaseKey(RegistryHive.ClassesRoot, RegistryView.Registry32);
|
||||
RegistryKey softwareRun = LRoot.OpenSubKey(ExtName + @"\shell\"+sName, false);
|
||||
if (softwareRun != null)
|
||||
{
|
||||
softwareRun.Close();
|
||||
result = true;
|
||||
}
|
||||
LRoot.Close();
|
||||
return result;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除文件关联
|
||||
/// </summary>
|
||||
/// <param name="ExtName"></param>
|
||||
/// <param name="sName"></param>
|
||||
/// <returns></returns>
|
||||
public bool DelFileAssociation(string ExtName, string sName)
|
||||
{
|
||||
try
|
||||
{
|
||||
RegistryKey LRoot = RegistryKey.OpenBaseKey(RegistryHive.ClassesRoot, RegistryView.Registry32);
|
||||
RegistryKey softwareRun = LRoot.OpenSubKey(ExtName + @"\shell", false);
|
||||
if(softwareRun!=null)
|
||||
{
|
||||
var shell_name = softwareRun.OpenSubKey(sName,false);
|
||||
if(shell_name!=null)
|
||||
{
|
||||
shell_name.Close();
|
||||
softwareRun.DeleteSubKeyTree(sName);
|
||||
}
|
||||
softwareRun.Close();
|
||||
}
|
||||
LRoot.Close();
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
private void FrmSetting_Load(object sender, EventArgs e)
|
||||
{
|
||||
ChkAss_Ryp.Checked = GetFileAssociation(".ryp", "ryUSQ");
|
||||
ChkAss_Folder.Checked = GetFileAssociation("folder", "ryUSQ");
|
||||
DataProvider mydb = new DataProvider();
|
||||
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||||
if (db.ConnDb(Itrycn_Db.User_SQLConn) == 1)
|
||||
{
|
||||
var ds = db.ReadData("select * from Settings where name='Setting'");
|
||||
if(mydb.HaveData(ds))
|
||||
{
|
||||
var row = mydb.GetData(ds);
|
||||
ryCommon.Storage mStor = new ryCommon.Storage(row["value"].ToString());
|
||||
mStor.SelectNodeBySet();
|
||||
TxtCshapeBasePath.Text = mStor.GetAttrValue("CshapeBasePath");
|
||||
TxtReferenceDll.Text = mStor.GetAttrValue("ReferenceDll");
|
||||
TxtReactorPath.Text = mStor.GetAttrValue("ReactorPath");
|
||||
TxtWinRARPath.Text = mStor.GetAttrValue("WinRARPath");
|
||||
if(TxtWinRARPath.Text=="")
|
||||
{
|
||||
if(System.IO.File.Exists(@"C:\Program Files\WinRAR\WinRAR.exe"))
|
||||
{
|
||||
TxtWinRARPath.Text = @"C:\Program Files\WinRAR\WinRAR.exe";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
db.Free();
|
||||
}
|
||||
|
||||
private void BtnReactorPath_Click(object sender, EventArgs e)
|
||||
{
|
||||
folderBrowserDialog1.SelectedPath = TxtReactorPath.Text;
|
||||
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
TxtReactorPath.Text = folderBrowserDialog1.SelectedPath;
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnWinRARPath_Click(object sender, EventArgs e)
|
||||
{
|
||||
folderBrowserDialog1.SelectedPath = TxtWinRARPath.Text;
|
||||
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
TxtWinRARPath.Text = folderBrowserDialog1.SelectedPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>197, 17</value>
|
||||
</metadata>
|
||||
<metadata name="folderBrowserDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
+190
@@ -0,0 +1,190 @@
|
||||
namespace 开发辅助工具.Tools
|
||||
{
|
||||
partial class FrmToolsSearch
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.rySearch1 = new ryControls.rySearch();
|
||||
this.tableModel1 = new XPTable.Models.TableModel();
|
||||
this.columnModel1 = new XPTable.Models.ColumnModel();
|
||||
this.ColToolName = new XPTable.Models.TextColumn();
|
||||
this.ColKeys = new XPTable.Models.TextColumn();
|
||||
this.ColToolDes = new XPTable.Models.TextColumn();
|
||||
this.table1 = new XPTable.Models.Table();
|
||||
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.添加工具ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.修改工具ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.删除工具ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ctlMyPage1 = new MyPage.ctlMyPage();
|
||||
((System.ComponentModel.ISupportInitialize)(this.table1)).BeginInit();
|
||||
this.contextMenuStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// rySearch1
|
||||
//
|
||||
this.rySearch1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(236)))), ((int)(((byte)(239)))), ((int)(((byte)(244)))));
|
||||
this.rySearch1.EmptyText = "请输入工具名称、名称拼音首字母、工具描述进行搜索";
|
||||
this.rySearch1.ImeMode = System.Windows.Forms.ImeMode.Close;
|
||||
this.rySearch1.Location = new System.Drawing.Point(12, 12);
|
||||
this.rySearch1.Name = "rySearch1";
|
||||
this.rySearch1.Size = new System.Drawing.Size(388, 25);
|
||||
this.rySearch1.TabIndex = 1;
|
||||
this.rySearch1.OnSearch += new System.EventHandler(this.RySearch1_OnSearch);
|
||||
//
|
||||
// tableModel1
|
||||
//
|
||||
this.tableModel1.RowHeight = 25;
|
||||
//
|
||||
// columnModel1
|
||||
//
|
||||
this.columnModel1.Columns.AddRange(new XPTable.Models.Column[] {
|
||||
this.ColToolName,
|
||||
this.ColKeys,
|
||||
this.ColToolDes});
|
||||
//
|
||||
// ColToolName
|
||||
//
|
||||
this.ColToolName.Editable = false;
|
||||
this.ColToolName.Tag = null;
|
||||
this.ColToolName.Text = "工具名称";
|
||||
this.ColToolName.Width = 180;
|
||||
//
|
||||
// ColKeys
|
||||
//
|
||||
this.ColKeys.Editable = false;
|
||||
this.ColKeys.Tag = null;
|
||||
this.ColKeys.Text = "关键词";
|
||||
this.ColKeys.Width = 400;
|
||||
//
|
||||
// ColToolDes
|
||||
//
|
||||
this.ColToolDes.Editable = false;
|
||||
this.ColToolDes.Tag = null;
|
||||
this.ColToolDes.Text = "工具描述";
|
||||
this.ColToolDes.Width = 400;
|
||||
//
|
||||
// table1
|
||||
//
|
||||
this.table1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.table1.ColumnModel = this.columnModel1;
|
||||
this.table1.ContextMenuStrip = this.contextMenuStrip1;
|
||||
this.table1.FullRowSelect = true;
|
||||
this.table1.Location = new System.Drawing.Point(12, 43);
|
||||
this.table1.Name = "table1";
|
||||
this.table1.NoItemsText = "当前列表没有任何项";
|
||||
this.table1.Size = new System.Drawing.Size(1010, 555);
|
||||
this.table1.TabIndex = 2;
|
||||
this.table1.TableModel = this.tableModel1;
|
||||
this.table1.Text = "table1";
|
||||
//
|
||||
// contextMenuStrip1
|
||||
//
|
||||
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.添加工具ToolStripMenuItem,
|
||||
this.修改工具ToolStripMenuItem,
|
||||
this.删除工具ToolStripMenuItem});
|
||||
this.contextMenuStrip1.Name = "contextMenuStrip1";
|
||||
this.contextMenuStrip1.Size = new System.Drawing.Size(125, 70);
|
||||
//
|
||||
// 添加工具ToolStripMenuItem
|
||||
//
|
||||
this.添加工具ToolStripMenuItem.Name = "添加工具ToolStripMenuItem";
|
||||
this.添加工具ToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.添加工具ToolStripMenuItem.Text = "添加工具";
|
||||
this.添加工具ToolStripMenuItem.Click += new System.EventHandler(this.添加工具ToolStripMenuItem_Click);
|
||||
//
|
||||
// 修改工具ToolStripMenuItem
|
||||
//
|
||||
this.修改工具ToolStripMenuItem.Name = "修改工具ToolStripMenuItem";
|
||||
this.修改工具ToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.修改工具ToolStripMenuItem.Text = "修改工具";
|
||||
this.修改工具ToolStripMenuItem.Click += new System.EventHandler(this.修改工具ToolStripMenuItem_Click);
|
||||
//
|
||||
// 删除工具ToolStripMenuItem
|
||||
//
|
||||
this.删除工具ToolStripMenuItem.Name = "删除工具ToolStripMenuItem";
|
||||
this.删除工具ToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.删除工具ToolStripMenuItem.Text = "删除工具";
|
||||
this.删除工具ToolStripMenuItem.Click += new System.EventHandler(this.删除工具ToolStripMenuItem_Click);
|
||||
//
|
||||
// ctlMyPage1
|
||||
//
|
||||
this.ctlMyPage1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.ctlMyPage1.Location = new System.Drawing.Point(12, 604);
|
||||
this.ctlMyPage1.Name = "ctlMyPage1";
|
||||
this.ctlMyPage1.PageSize = 50;
|
||||
this.ctlMyPage1.RecordCount = 0;
|
||||
this.ctlMyPage1.Size = new System.Drawing.Size(506, 26);
|
||||
this.ctlMyPage1.SQLText = "";
|
||||
this.ctlMyPage1.SQLText2 = "";
|
||||
this.ctlMyPage1.T_FirstCaption = "首页";
|
||||
this.ctlMyPage1.T_LastCaption = "末页";
|
||||
this.ctlMyPage1.T_NextCaption = "下一页";
|
||||
this.ctlMyPage1.T_Parameters = null;
|
||||
this.ctlMyPage1.T_PreCaption = "上一页";
|
||||
this.ctlMyPage1.T_SkipCaption = "跳到";
|
||||
this.ctlMyPage1.T_TipCaption = "{pageindex}/{pagecount} 页,共 {recordcount} 条记录,每页 {pagesize} 条";
|
||||
this.ctlMyPage1.TabIndex = 31;
|
||||
this.ctlMyPage1.OnPageChange += new System.EventHandler(this.CtlMyPage1_OnPageChange);
|
||||
//
|
||||
// FrmToolsSearch
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1034, 633);
|
||||
this.Controls.Add(this.ctlMyPage1);
|
||||
this.Controls.Add(this.table1);
|
||||
this.Controls.Add(this.rySearch1);
|
||||
this.Name = "FrmToolsSearch";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "工具管理";
|
||||
this.Load += new System.EventHandler(this.FrmToolsSearch_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.table1)).EndInit();
|
||||
this.contextMenuStrip1.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ryControls.rySearch rySearch1;
|
||||
private XPTable.Models.TableModel tableModel1;
|
||||
private XPTable.Models.ColumnModel columnModel1;
|
||||
private XPTable.Models.TextColumn ColToolName;
|
||||
private XPTable.Models.TextColumn ColToolDes;
|
||||
private XPTable.Models.Table table1;
|
||||
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
|
||||
private System.Windows.Forms.ToolStripMenuItem 添加工具ToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem 修改工具ToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem 删除工具ToolStripMenuItem;
|
||||
private XPTable.Models.TextColumn ColKeys;
|
||||
private MyPage.ctlMyPage ctlMyPage1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
using ryCommon;
|
||||
using ryCommonDb;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using 开发辅助工具.Manager;
|
||||
|
||||
namespace 开发辅助工具.Tools
|
||||
{
|
||||
public partial class FrmToolsSearch : Form
|
||||
{
|
||||
public FrmToolsSearch()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
string orderSQL = "order by sort desc, addTime desc";
|
||||
string tableName = "Tools";
|
||||
private void 添加工具ToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Manager.FrmAddTools frm = new Manager.FrmAddTools()
|
||||
{
|
||||
Text = "添加工具",
|
||||
Icon = Icon,
|
||||
isAdd = 1
|
||||
};
|
||||
frm.mr = new ModalForm(this, frm);
|
||||
frm.mr.OnDialogResult += new ModalForm.DialogResultHandler((object t, DialogResult dg) => {
|
||||
if (dg == DialogResult.OK)
|
||||
{
|
||||
rySearch1.PerformClick();
|
||||
}
|
||||
});
|
||||
frm.mr.ShowModal();
|
||||
}
|
||||
private void GetRow(string id, int index)
|
||||
{
|
||||
#region 重新载入数据
|
||||
DataProvider mydb = new DataProvider();
|
||||
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||||
if (db.ConnDb(Itrycn_Db.Sys_SQLConn) == 1)
|
||||
{
|
||||
DataSet ds = db.ReadData("select * from " + tableName + " where id=" + id);
|
||||
if (mydb.HaveData(ds))
|
||||
{
|
||||
DataRow row = ds.Tables[0].Rows[0];
|
||||
XPTable.Models.Row itemList = tableModel1.Rows[index];
|
||||
//需要修改此处
|
||||
itemList.Cells[ColToolName.Index].Text = row["Name"].ToString();
|
||||
itemList.Cells[ColToolDes.Index].Text = row["Des"].ToString();
|
||||
itemList.Cells[ColKeys.Index].Text = row["Keys"].ToString();
|
||||
}
|
||||
db.Free();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
private void 修改工具ToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (table1.SelectedItems.Length == 0) { return; }
|
||||
string selectId = table1.SelectedItems[0].Tag.ToString();
|
||||
int index = table1.SelectedItems[0].Index;
|
||||
Manager.FrmAddTools frm = new Manager.FrmAddTools()
|
||||
{
|
||||
Text = "修改工具",
|
||||
Icon = Icon,
|
||||
isAdd = 0
|
||||
};
|
||||
frm.GetInfo(selectId);
|
||||
frm.mr = new ModalForm(this, frm);
|
||||
frm.mr.OnDialogResult += new ModalForm.DialogResultHandler((object t, DialogResult dg) => {
|
||||
if (dg == DialogResult.OK)
|
||||
{
|
||||
GetRow(selectId, index);
|
||||
}
|
||||
});
|
||||
frm.mr.ShowModal();
|
||||
}
|
||||
|
||||
private void CtlMyPage1_OnPageChange(object sender, EventArgs e)
|
||||
{
|
||||
#region 重新载入数据
|
||||
tableModel1.Rows.Clear();
|
||||
tableModel1.Selections.Clear();
|
||||
DataProvider mydb = new DataProvider();
|
||||
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||||
if (db.ConnDb(Itrycn_Db.Sys_SQLConn) == 1)
|
||||
{
|
||||
DataSet ds = db.ReadData(ctlMyPage1.GetSQLText, ctlMyPage1.T_Parameters);
|
||||
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
|
||||
{
|
||||
DataRow row = ds.Tables[0].Rows[i];
|
||||
XPTable.Models.Row itemList = new XPTable.Models.Row()
|
||||
{
|
||||
Tag = row["id"].ToString()
|
||||
};
|
||||
//需要修改此处
|
||||
itemList.Cells.Add(new XPTable.Models.Cell(row["Name"].ToString()));//示例
|
||||
itemList.Cells.Add(new XPTable.Models.Cell(row["Keys"].ToString()));
|
||||
itemList.Cells.Add(new XPTable.Models.Cell(row["Des"].ToString()));
|
||||
tableModel1.Rows.Add(itemList);
|
||||
}
|
||||
db.Free();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
public void LoadDb(string whereSQL)
|
||||
{
|
||||
string _whereSQL = whereSQL;
|
||||
DataProvider mydb = new DataProvider();
|
||||
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||||
if (db.ConnDb(Itrycn_Db.Sys_SQLConn) == 1)
|
||||
{
|
||||
#region 重新载入数据
|
||||
db.AddParameter("SearchText", "%" + rySearch1.Text + "%");
|
||||
ctlMyPage1.RecordCount = db.GetCount(tableName, _whereSQL);
|
||||
ctlMyPage1.T_Parameters = db.GetParameter();
|
||||
ctlMyPage1.SQLText = db.GetPageSQL(tableName, _whereSQL, orderSQL);
|
||||
ctlMyPage1.SQLText2 = db.GetPageSQL2(tableName, _whereSQL, orderSQL);
|
||||
ctlMyPage1.GotoPageIndex(1);
|
||||
db.Free();
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
private void RySearch1_OnSearch(object sender, EventArgs e)
|
||||
{
|
||||
LoadDb("(Name like @SearchText or Des like @SearchText or Keys like @SearchText or PY like @SearchText)");
|
||||
}
|
||||
|
||||
private void 删除工具ToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (table1.SelectedItems.Length == 0) { MessageBox.Show("请先选择要删除的项。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; }
|
||||
string selectId = table1.SelectedItems[0].Tag.ToString();
|
||||
if (MessageBox.Show("确定要删除该项吗?一旦删除将不可恢复。", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
|
||||
{
|
||||
return;
|
||||
}
|
||||
DataProvider mydb = new DataProvider();
|
||||
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||||
if (db.ConnDb(Itrycn_Db.Sys_SQLConn) == 1)
|
||||
{
|
||||
db.DelById(tableName, selectId);
|
||||
tableModel1.Rows.RemoveAt(table1.SelectedItems[0].Index);
|
||||
}
|
||||
}
|
||||
|
||||
private void FrmToolsSearch_Load(object sender, EventArgs e)
|
||||
{
|
||||
rySearch1.PerformClick();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="tableModel1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>15, 18</value>
|
||||
</metadata>
|
||||
<metadata name="columnModel1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>133, 16</value>
|
||||
</metadata>
|
||||
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>274, 16</value>
|
||||
</metadata>
|
||||
</root>
|
||||
@@ -0,0 +1,109 @@
|
||||
using ryCommonDb;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using static ryCommonDb.DataProvider;
|
||||
|
||||
namespace 开发辅助工具.Manager
|
||||
{
|
||||
public class Itrycn_Db
|
||||
{
|
||||
public static bool IsCloseConfirm = true;
|
||||
public static string Sys_SQLConn = "<app>\\SysDb\\Tools.dat|";
|
||||
public static string User_SQLConn = "<app>\\UserDb\\MyDb.dat|";
|
||||
public static ryCommonDb.DataProvider.DataProviderType dataType = ryCommonDb.DataProvider.DataProviderType.SQLiteDataProvider;
|
||||
public static IDbInterface CreateDataProvider(DataProviderType dataProviderType)
|
||||
{
|
||||
switch (dataProviderType)
|
||||
{
|
||||
//case DataProviderType.OdbcDataProvider:
|
||||
// return new OdbcDataProvider();
|
||||
//case DataProviderType.OleDbDataProvider:
|
||||
// return new OleDbDataProvider();
|
||||
//case DataProviderType.OracleDataProvider:
|
||||
// return new OracleDataProvider();
|
||||
case DataProviderType.SQLiteDataProvider:
|
||||
return new SQLiteDataProvider();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public static void DeleteFiles(string dir, string filter)
|
||||
{
|
||||
var files = System.IO.Directory.GetFiles(dir, filter);
|
||||
for (int i = 0; i < files.Length; i++)
|
||||
{
|
||||
ryCommon.RyFiles.DeleteFile(files[i]);
|
||||
}
|
||||
ryCommon.RyFiles.DeleteFile(dir + "\\" + filter);
|
||||
var dirs = System.IO.Directory.GetDirectories(dir);
|
||||
for (int i = 0; i < dirs.Length; i++)
|
||||
{
|
||||
DeleteFiles(dirs[i], filter);
|
||||
}
|
||||
}
|
||||
public static void CreateSysTable()
|
||||
{
|
||||
DataProvider mydb = new DataProvider();
|
||||
IDbInterface db = CreateDataProvider(dataType);
|
||||
if (db.ConnDb(Sys_SQLConn) == 1)
|
||||
{
|
||||
#region 工具表
|
||||
RyQuickSQL mySQL = new RyQuickSQL("Tools");
|
||||
mySQL.AddField("Name", "");
|
||||
mySQL.AddField("Des", "");
|
||||
mySQL.AddField("Keys", "");
|
||||
mySQL.AddField("Addr", "");
|
||||
mySQL.AddField("PY", "");
|
||||
mySQL.AddField("Sort", 0);
|
||||
mySQL.AddField("addTime",DateTime.Now);
|
||||
db.CreateDb(mySQL);
|
||||
#endregion
|
||||
//
|
||||
}
|
||||
}
|
||||
public static void CreateUserTable()
|
||||
{
|
||||
DataProvider mydb = new DataProvider();
|
||||
IDbInterface db = CreateDataProvider(dataType);
|
||||
if (db.ConnDb(User_SQLConn) == 1)
|
||||
{
|
||||
#region Url表
|
||||
RyQuickSQL mySQL = new RyQuickSQL("Urls");
|
||||
mySQL.AddField("Name", "");
|
||||
mySQL.AddField("Url", "");
|
||||
mySQL.AddField("Cookie", "");
|
||||
mySQL.AddField("Postdata", "");
|
||||
mySQL.AddField("Method", "");
|
||||
mySQL.AddField("Header", "");
|
||||
mySQL.AddField("Referer", "");
|
||||
mySQL.AddField("ContentType", "");
|
||||
mySQL.AddField("Encoding", "");
|
||||
mySQL.AddField("ClickCount", 0);//点击次数
|
||||
mySQL.AddField("editTime", DateTime.Now);
|
||||
mySQL.AddField("addTime", DateTime.Now);
|
||||
db.CreateDb(mySQL);
|
||||
#endregion
|
||||
#region 启动表
|
||||
mySQL.Clear();
|
||||
mySQL.TableName = "Starts"; ;
|
||||
mySQL.AddField("Addr", "");
|
||||
mySQL.AddField("Name", "");
|
||||
mySQL.AddField("ClickCount", 0);//点击次数
|
||||
mySQL.AddField("editTime", DateTime.Now);
|
||||
mySQL.AddField("addTime", DateTime.Now);
|
||||
db.CreateDb(mySQL);
|
||||
#endregion
|
||||
#region 设置表
|
||||
mySQL.Clear();
|
||||
mySQL.TableName = "Settings"; ;
|
||||
mySQL.AddField("Name", "");
|
||||
mySQL.AddField("Value", "");//值
|
||||
mySQL.AddField("addTime", DateTime.Now);
|
||||
db.CreateDb(mySQL);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace 开发辅助工具.Manager
|
||||
{
|
||||
public class Json
|
||||
{
|
||||
public static string ConvertJsonString(string str)
|
||||
{
|
||||
//格式化json字符串
|
||||
JsonSerializer serializer = new JsonSerializer();
|
||||
TextReader tr = new StringReader(str);
|
||||
JsonTextReader jtr = new JsonTextReader(tr);
|
||||
object obj = serializer.Deserialize(jtr);
|
||||
if (obj != null)
|
||||
{
|
||||
StringWriter textWriter = new StringWriter();
|
||||
JsonTextWriter jsonWriter = new JsonTextWriter(textWriter)
|
||||
{
|
||||
Formatting = Formatting.Indented,
|
||||
Indentation = 4,
|
||||
IndentChar = ' '
|
||||
};
|
||||
serializer.Serialize(jsonWriter, obj);
|
||||
return textWriter.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return str;
|
||||
}
|
||||
}
|
||||
public static bool IsArray(string str)
|
||||
{
|
||||
try
|
||||
{
|
||||
JArray jar = JArray.Parse(str);
|
||||
return true;
|
||||
}
|
||||
catch { return false; }
|
||||
}
|
||||
public static bool IsJson(string str)
|
||||
{
|
||||
try
|
||||
{
|
||||
var jo= (JObject)JsonConvert.DeserializeObject(str);
|
||||
return true;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{ return false; }
|
||||
//if (JsonSplit.IsJson(str))//传入的json串
|
||||
//{
|
||||
// return true;
|
||||
//}
|
||||
//return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,395 @@
|
||||
internal class JsonSplit
|
||||
{
|
||||
private static bool IsJsonStart(ref string json)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(json))
|
||||
{
|
||||
json = json.Trim('\r', '\n', ' ');
|
||||
if (json.Length > 1)
|
||||
{
|
||||
char s = json[0];
|
||||
char e = json[json.Length - 1];
|
||||
return (s == '{' && e == '}') || (s == '[' && e == ']');
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
internal static bool IsJson(string json)
|
||||
{
|
||||
int errIndex;
|
||||
return IsJson(json, out errIndex);
|
||||
}
|
||||
internal static bool IsJson(string json, out int errIndex)
|
||||
{
|
||||
errIndex = 0;
|
||||
if (IsJsonStart(ref json))
|
||||
{
|
||||
CharState cs = new CharState();
|
||||
char c;
|
||||
for (int i = 0; i < json.Length; i++)
|
||||
{
|
||||
c = json[i];
|
||||
if (SetCharState(c, ref cs) && cs.childrenStart)//设置关键符号状态。
|
||||
{
|
||||
string item = json.Substring(i);
|
||||
int err;
|
||||
int length = GetValueLength(item, true, out err);
|
||||
cs.childrenStart = false;
|
||||
if (err > 0)
|
||||
{
|
||||
errIndex = i + err;
|
||||
return false;
|
||||
}
|
||||
i = i + length - 1;
|
||||
}
|
||||
if (cs.isError)
|
||||
{
|
||||
errIndex = i;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return !cs.arrayStart && !cs.jsonStart;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取值的长度(当Json值嵌套以"{"或"["开头时)
|
||||
/// </summary>
|
||||
private static int GetValueLength(string json, bool breakOnErr, out int errIndex)
|
||||
{
|
||||
errIndex = 0;
|
||||
int len = 0;
|
||||
if (!string.IsNullOrEmpty(json))
|
||||
{
|
||||
CharState cs = new CharState();
|
||||
char c;
|
||||
for (int i = 0; i < json.Length; i++)
|
||||
{
|
||||
c = json[i];
|
||||
if (!SetCharState(c, ref cs))//设置关键符号状态。
|
||||
{
|
||||
if (!cs.jsonStart && !cs.arrayStart)//json结束,又不是数组,则退出。
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (cs.childrenStart)//正常字符,值状态下。
|
||||
{
|
||||
int length = GetValueLength(json.Substring(i), breakOnErr, out errIndex);//递归子值,返回一个长度。。。
|
||||
cs.childrenStart = false;
|
||||
cs.valueStart = 0;
|
||||
//cs.state = 0;
|
||||
i = i + length - 1;
|
||||
}
|
||||
if (breakOnErr && cs.isError)
|
||||
{
|
||||
errIndex = i;
|
||||
return i;
|
||||
}
|
||||
if (!cs.jsonStart && !cs.arrayStart)//记录当前结束位置。
|
||||
{
|
||||
len = i + 1;//长度比索引+1
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
/// <summary>
|
||||
/// 字符状态
|
||||
/// </summary>
|
||||
private class CharState
|
||||
{
|
||||
internal bool jsonStart = false;//以 "{"开始了...
|
||||
internal bool setDicValue = false;// 可以设置字典值了。
|
||||
internal bool escapeChar = false;//以"\"转义符号开始了
|
||||
/// <summary>
|
||||
/// 数组开始【仅第一开头才算】,值嵌套的以【childrenStart】来标识。
|
||||
/// </summary>
|
||||
internal bool arrayStart = false;//以"[" 符号开始了
|
||||
internal bool childrenStart = false;//子级嵌套开始了。
|
||||
/// <summary>
|
||||
/// 【0 初始状态,或 遇到“,”逗号】;【1 遇到“:”冒号】
|
||||
/// </summary>
|
||||
internal int state = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 【-1 取值结束】【0 未开始】【1 无引号开始】【2 单引号开始】【3 双引号开始】
|
||||
/// </summary>
|
||||
internal int keyStart = 0;
|
||||
/// <summary>
|
||||
/// 【-1 取值结束】【0 未开始】【1 无引号开始】【2 单引号开始】【3 双引号开始】
|
||||
/// </summary>
|
||||
internal int valueStart = 0;
|
||||
internal bool isError = false;//是否语法错误。
|
||||
|
||||
internal void CheckIsError(char c)//只当成一级处理(因为GetLength会递归到每一个子项处理)
|
||||
{
|
||||
if (keyStart > 1 || valueStart > 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//示例 ["aa",{"bbbb":123,"fff","ddd"}]
|
||||
switch (c)
|
||||
{
|
||||
case '{'://[{ "[{A}]":[{"[{B}]":3,"m":"C"}]}]
|
||||
isError = jsonStart && state == 0;//重复开始错误 同时不是值处理。
|
||||
break;
|
||||
case '}':
|
||||
isError = !jsonStart || (keyStart != 0 && state == 0);//重复结束错误 或者 提前结束{"aa"}。正常的有{}
|
||||
break;
|
||||
case '[':
|
||||
isError = arrayStart && state == 0;//重复开始错误
|
||||
break;
|
||||
case ']':
|
||||
isError = !arrayStart || jsonStart;//重复开始错误 或者 Json 未结束
|
||||
break;
|
||||
case '"':
|
||||
case '\'':
|
||||
isError = !(jsonStart || arrayStart); //json 或数组开始。
|
||||
if (!isError)
|
||||
{
|
||||
//重复开始 [""",{"" "}]
|
||||
isError = (state == 0 && keyStart == -1) || (state == 1 && valueStart == -1);
|
||||
}
|
||||
if (!isError && arrayStart && !jsonStart && c == '\'')//['aa',{}]
|
||||
{
|
||||
isError = true;
|
||||
}
|
||||
break;
|
||||
case ':':
|
||||
isError = !jsonStart || state == 1;//重复出现。
|
||||
break;
|
||||
case ',':
|
||||
isError = !(jsonStart || arrayStart); //json 或数组开始。
|
||||
if (!isError)
|
||||
{
|
||||
if (jsonStart)
|
||||
{
|
||||
isError = state == 0 || (state == 1 && valueStart > 1);//重复出现。
|
||||
}
|
||||
else if (arrayStart)//["aa,] [,] [{},{}]
|
||||
{
|
||||
isError = keyStart == 0 && !setDicValue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ' ':
|
||||
case '\r':
|
||||
case '\n'://[ "a",\r\n{} ]
|
||||
case '\0':
|
||||
case '\t':
|
||||
break;
|
||||
default: //值开头。。
|
||||
isError = (!jsonStart && !arrayStart) || (state == 0 && keyStart == -1) || (valueStart == -1 && state == 1);//
|
||||
break;
|
||||
}
|
||||
//if (isError)
|
||||
//{
|
||||
|
||||
//}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置字符状态(返回true则为关键词,返回false则当为普通字符处理)
|
||||
/// </summary>
|
||||
private static bool SetCharState(char c, ref CharState cs)
|
||||
{
|
||||
cs.CheckIsError(c);
|
||||
switch (c)
|
||||
{
|
||||
case '{'://[{ "[{A}]":[{"[{B}]":3,"m":"C"}]}]
|
||||
#region 大括号
|
||||
if (cs.keyStart <= 0 && cs.valueStart <= 0)
|
||||
{
|
||||
cs.keyStart = 0;
|
||||
cs.valueStart = 0;
|
||||
if (cs.jsonStart && cs.state == 1)
|
||||
{
|
||||
cs.childrenStart = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.state = 0;
|
||||
}
|
||||
cs.jsonStart = true;//开始。
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
break;
|
||||
case '}':
|
||||
#region 大括号结束
|
||||
if (cs.keyStart <= 0 && cs.valueStart < 2 && cs.jsonStart)
|
||||
{
|
||||
cs.jsonStart = false;//正常结束。
|
||||
cs.state = 0;
|
||||
cs.keyStart = 0;
|
||||
cs.valueStart = 0;
|
||||
cs.setDicValue = true;
|
||||
return true;
|
||||
}
|
||||
// cs.isError = !cs.jsonStart && cs.state == 0;
|
||||
#endregion
|
||||
break;
|
||||
case '[':
|
||||
#region 中括号开始
|
||||
if (!cs.jsonStart)
|
||||
{
|
||||
cs.arrayStart = true;
|
||||
return true;
|
||||
}
|
||||
else if (cs.jsonStart && cs.state == 1)
|
||||
{
|
||||
cs.childrenStart = true;
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
break;
|
||||
case ']':
|
||||
#region 中括号结束
|
||||
if (cs.arrayStart && !cs.jsonStart && cs.keyStart <= 2 && cs.valueStart <= 0)//[{},333]//这样结束。
|
||||
{
|
||||
cs.keyStart = 0;
|
||||
cs.valueStart = 0;
|
||||
cs.arrayStart = false;
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
break;
|
||||
case '"':
|
||||
case '\'':
|
||||
#region 引号
|
||||
if (cs.jsonStart || cs.arrayStart)
|
||||
{
|
||||
if (cs.state == 0)//key阶段,有可能是数组["aa",{}]
|
||||
{
|
||||
if (cs.keyStart <= 0)
|
||||
{
|
||||
cs.keyStart = (c == '"' ? 3 : 2);
|
||||
return true;
|
||||
}
|
||||
else if ((cs.keyStart == 2 && c == '\'') || (cs.keyStart == 3 && c == '"'))
|
||||
{
|
||||
if (!cs.escapeChar)
|
||||
{
|
||||
cs.keyStart = -1;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.escapeChar = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (cs.state == 1 && cs.jsonStart)//值阶段必须是Json开始了。
|
||||
{
|
||||
if (cs.valueStart <= 0)
|
||||
{
|
||||
cs.valueStart = (c == '"' ? 3 : 2);
|
||||
return true;
|
||||
}
|
||||
else if ((cs.valueStart == 2 && c == '\'') || (cs.valueStart == 3 && c == '"'))
|
||||
{
|
||||
if (!cs.escapeChar)
|
||||
{
|
||||
cs.valueStart = -1;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.escapeChar = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
break;
|
||||
case ':':
|
||||
#region 冒号
|
||||
if (cs.jsonStart && cs.keyStart < 2 && cs.valueStart < 2 && cs.state == 0)
|
||||
{
|
||||
if (cs.keyStart == 1)
|
||||
{
|
||||
cs.keyStart = -1;
|
||||
}
|
||||
cs.state = 1;
|
||||
return true;
|
||||
}
|
||||
// cs.isError = !cs.jsonStart || (cs.keyStart < 2 && cs.valueStart < 2 && cs.state == 1);
|
||||
#endregion
|
||||
break;
|
||||
case ',':
|
||||
#region 逗号 //["aa",{aa:12,}]
|
||||
|
||||
if (cs.jsonStart)
|
||||
{
|
||||
if (cs.keyStart < 2 && cs.valueStart < 2 && cs.state == 1)
|
||||
{
|
||||
cs.state = 0;
|
||||
cs.keyStart = 0;
|
||||
cs.valueStart = 0;
|
||||
//if (cs.valueStart == 1)
|
||||
//{
|
||||
// cs.valueStart = 0;
|
||||
//}
|
||||
cs.setDicValue = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (cs.arrayStart && cs.keyStart <= 2)
|
||||
{
|
||||
cs.keyStart = 0;
|
||||
//if (cs.keyStart == 1)
|
||||
//{
|
||||
// cs.keyStart = -1;
|
||||
//}
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
break;
|
||||
case ' ':
|
||||
case '\r':
|
||||
case '\n'://[ "a",\r\n{} ]
|
||||
case '\0':
|
||||
case '\t':
|
||||
if (cs.keyStart <= 0 && cs.valueStart <= 0) //cs.jsonStart &&
|
||||
{
|
||||
return true;//跳过空格。
|
||||
}
|
||||
break;
|
||||
default: //值开头。。
|
||||
if (c == '\\') //转义符号
|
||||
{
|
||||
if (cs.escapeChar)
|
||||
{
|
||||
cs.escapeChar = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.escapeChar = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.escapeChar = false;
|
||||
}
|
||||
if (cs.jsonStart || cs.arrayStart) // Json 或数组开始了。
|
||||
{
|
||||
if (cs.keyStart <= 0 && cs.state == 0)
|
||||
{
|
||||
cs.keyStart = 1;//无引号的
|
||||
}
|
||||
else if (cs.valueStart <= 0 && cs.state == 1 && cs.jsonStart)//只有Json开始才有值。
|
||||
{
|
||||
cs.valueStart = 1;//无引号的
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
|
||||
namespace 开发辅助工具.Manager
|
||||
{
|
||||
class ReactorXML
|
||||
{
|
||||
public ReactorXML()
|
||||
{
|
||||
|
||||
}
|
||||
private string xml_path = "";
|
||||
/// <summary>
|
||||
/// 加载xml
|
||||
/// </summary>
|
||||
/// <param name="_xml_path"></param>
|
||||
public void LoadXML(string _xml_path)
|
||||
{
|
||||
xml_path = _xml_path;
|
||||
}
|
||||
public void Save(string _xml_path,List<string> files)
|
||||
{
|
||||
if (files.Count == 0) { return; }
|
||||
System.Xml.XmlDocument xml = new System.Xml.XmlDocument();
|
||||
xml.Load(xml_path);
|
||||
var list = xml.SelectNodes(@"Reactor_Project/Assembly");
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
list[i].ParentNode.RemoveChild(list[i]);
|
||||
}
|
||||
//var node_Target_File = xml.SelectSingleNode(@"Reactor_Project//General_Settings//Target_File");
|
||||
//if (node_Target_File != null)
|
||||
//{
|
||||
// node_Target_File.InnerText = files[0];
|
||||
//}
|
||||
var node = xml.SelectSingleNode(@"Reactor_Project/Main_Assembly");
|
||||
if (node != null)
|
||||
{
|
||||
node.InnerText = files[0];
|
||||
}
|
||||
for (int i = 1; i < files.Count; i++)
|
||||
{
|
||||
var node2 = xml.SelectSingleNode(@"Reactor_Project");
|
||||
XmlNode childXmlNode = xml.CreateElement("Assembly");
|
||||
XmlNode childXmlNode2 = xml.CreateElement("Filename");
|
||||
childXmlNode2.InnerText = files[i];
|
||||
childXmlNode.AppendChild(childXmlNode2);
|
||||
node2.InsertAfter(childXmlNode, node);
|
||||
//node.AppendChild(childXmlNode);;
|
||||
}
|
||||
xml.Save(_xml_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,403 @@
|
||||
using ryCommon;
|
||||
using ryCommonDb;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
|
||||
namespace 开发辅助工具.Manager
|
||||
{
|
||||
class RyProject
|
||||
{
|
||||
/// <summary>
|
||||
/// C#基准项目路径
|
||||
/// </summary>
|
||||
public string CshapeBasePath { get; private set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 引用dll文件夹列表
|
||||
/// </summary>
|
||||
public string ReferenceDllPath { get; private set; } = "";
|
||||
/// <summary>
|
||||
/// 是否将dll复制到Bin目录,并修改引用
|
||||
/// </summary>
|
||||
public bool CopyDllToBin { get; set; } = false;
|
||||
/// <summary>
|
||||
/// Bin目录相对于项目文件所在的位置,可使用相对路径或绝对路径
|
||||
/// </summary>
|
||||
public string BinFolder { get; set; } = "..\\..\\Bin";
|
||||
/// <summary>
|
||||
/// 是否修改输出路径
|
||||
/// </summary>
|
||||
public bool ChangedOutputPath { get; set; } =true;
|
||||
public RyProject()
|
||||
{
|
||||
UpdateSetting();
|
||||
}
|
||||
/// <summary>
|
||||
/// 更新设置
|
||||
/// </summary>
|
||||
public void UpdateSetting()
|
||||
{
|
||||
DataProvider mydb = new DataProvider();
|
||||
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||||
if (db.ConnDb(Itrycn_Db.User_SQLConn) == 1)
|
||||
{
|
||||
var ds = db.ReadData("select * from Settings where name='Setting'");
|
||||
if (mydb.HaveData(ds))
|
||||
{
|
||||
var row = mydb.GetData(ds);
|
||||
ryCommon.Storage mStor = new ryCommon.Storage(row["value"].ToString());
|
||||
mStor.SelectNodeBySet();
|
||||
CshapeBasePath = mStor.GetAttrValue("CshapeBasePath");
|
||||
ReferenceDllPath = mStor.GetAttrValue("ReferenceDll");
|
||||
}
|
||||
}
|
||||
db.Free();
|
||||
}
|
||||
/// <summary>
|
||||
/// 通过dll名称来寻找dll路径
|
||||
/// </summary>
|
||||
/// <param name="_ReferenceDllPath"></param>
|
||||
/// <param name="dll_name"></param>
|
||||
/// <returns></returns>
|
||||
public string GetDllPath(string dll_name)
|
||||
{
|
||||
var path_list = ReferenceDllPath.Replace("\r", "").Split('\n');
|
||||
var find = false;
|
||||
var result = "";
|
||||
#region 在引用文件夹查找是否有该dll,有则使用引用文件夹里的dll
|
||||
for (int m = 0; m < path_list.Length; m++)
|
||||
{
|
||||
if (path_list[m].Trim() == "") { continue; }
|
||||
if (!System.IO.Directory.Exists(path_list[m])) { continue; }
|
||||
var files = System.IO.Directory.GetFiles(path_list[m]);
|
||||
for (int z = 0; z < files.Length; z++)
|
||||
{
|
||||
if (System.IO.Path.GetFileName(files[z]).ToLower() == dll_name.ToLower())
|
||||
{
|
||||
result = files[z];
|
||||
find = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (find) { break; }
|
||||
}
|
||||
#endregion
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 相对路径转绝对路径,相对项目文件的路径
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string RelToAbsPath(string project_path,string rel_path)
|
||||
{
|
||||
string folder = System.IO.Path.GetDirectoryName(project_path);
|
||||
var _rel_path = rel_path;
|
||||
while (true)
|
||||
{
|
||||
if (_rel_path.IndexOf("..\\") == 0)
|
||||
{
|
||||
folder = System.IO.Path.GetDirectoryName(folder.TrimEnd('\\'));
|
||||
_rel_path = _rel_path.Substring(3);
|
||||
}
|
||||
else { break; }
|
||||
if (folder == "") { break; }
|
||||
}
|
||||
return folder+"\\"+ _rel_path;
|
||||
}
|
||||
/// <summary>
|
||||
/// 绝对路径转相对路径,相对项目文件的路径
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string AbsToRelPath(string project_path, string abs_path)
|
||||
{
|
||||
string folder = System.IO.Path.GetDirectoryName(project_path);
|
||||
var _rel_path = "";
|
||||
var _rel_path2 = "";
|
||||
while (true)
|
||||
{
|
||||
if (abs_path.IndexOfEx(folder) == 0)
|
||||
{
|
||||
if (_rel_path2 == "")
|
||||
{ _rel_path = abs_path.Substring(folder.Length); }
|
||||
else
|
||||
{
|
||||
_rel_path = _rel_path2.TrimEnd('\\') + abs_path.Substring(folder.Length);
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
folder = System.IO.Path.GetDirectoryName(folder.TrimEnd('\\'));
|
||||
_rel_path2 += "..\\";
|
||||
}
|
||||
if (folder == "") { break; }
|
||||
}
|
||||
return _rel_path;
|
||||
}
|
||||
/// <summary>
|
||||
/// 更新dll版本,如果全部复制成功,则返回0,否则返回错误个数
|
||||
/// </summary>
|
||||
public int UpdateDlls(string folder,out string error_str)
|
||||
{
|
||||
error_str = "";
|
||||
var _error_str = "";
|
||||
int error = 0;
|
||||
Updates(folder);
|
||||
void Updates(string _path)
|
||||
{
|
||||
var files = System.IO.Directory.GetFiles(_path, "*.dll");
|
||||
for (int i = 0; i < files.Length; i++)
|
||||
{
|
||||
string filename = System.IO.Path.GetFileName(files[i]);
|
||||
var dllpath = GetDllPath(filename);
|
||||
if (dllpath != "")
|
||||
{
|
||||
if (RyFiles.CopyFile(dllpath, files[i]) != 0)
|
||||
{ _error_str += files[i]+ "\r\n"; error++; }
|
||||
var dll_xml_path = System.IO.Path.GetDirectoryName(dllpath) +"\\"+ System.IO.Path.GetFileNameWithoutExtension(dllpath) + ".xml";
|
||||
if (System.IO.File.Exists(dll_xml_path))
|
||||
{
|
||||
if (RyFiles.CopyFile(dll_xml_path, System.IO.Path.GetDirectoryName(files[i]) + "\\" + System.IO.Path.GetFileNameWithoutExtension(files[i]) + ".xml") != 0)
|
||||
{ _error_str += files[i] + "\r\n"; error++; }
|
||||
}
|
||||
}
|
||||
}
|
||||
var dirs = System.IO.Directory.GetDirectories(_path);
|
||||
for (int i = 0; i < dirs.Length; i++)
|
||||
{
|
||||
Updates(dirs[i]);
|
||||
}
|
||||
}
|
||||
error_str = _error_str;
|
||||
return error;
|
||||
}
|
||||
/// <summary>
|
||||
/// 更新项目引用,定向为本地dll,如果全部复制成功,则返回0,否则返回错误个数
|
||||
/// </summary>
|
||||
public int UpdateCSproj(string folder)
|
||||
{
|
||||
int error = 0;
|
||||
Updates(folder);
|
||||
void Updates(string _path)
|
||||
{
|
||||
var files = System.IO.Directory.GetFiles(_path, "*.csproj");
|
||||
for (int i = 0; i < files.Length; i++)
|
||||
{
|
||||
SetCSproj(files[i], "");
|
||||
}
|
||||
var dirs = System.IO.Directory.GetDirectories(_path);
|
||||
for (int i = 0; i < dirs.Length; i++)
|
||||
{
|
||||
Updates(dirs[i]);
|
||||
}
|
||||
}
|
||||
return error;
|
||||
}
|
||||
/// <summary>
|
||||
/// 自动设置csproj文件,将dll引用修改为指定区域的dll、修改命名空间
|
||||
/// </summary>
|
||||
/// <param name="path">项目文件(*.csproj)</param>
|
||||
/// <param name="_project_Eng_name">项目英文名</param>
|
||||
public void SetCSproj(string path, string _project_Eng_name)
|
||||
{
|
||||
System.Xml.XmlDocument xml = new System.Xml.XmlDocument();
|
||||
xml.Load(path);
|
||||
var xmlnsm = new XmlNamespaceManager(xml.NameTable);
|
||||
xmlnsm.AddNamespace("d", xml.DocumentElement.NamespaceURI);
|
||||
//var root = @"d:Project//d:ItemGroup//d:Reference";
|
||||
if (_project_Eng_name != "")
|
||||
{
|
||||
SetValue(@"d:Project//d:PropertyGroup//d:RootNamespace", _project_Eng_name.Replace(" ", ""));//命名空间名
|
||||
SetValue(@"d:Project//d:PropertyGroup//d:AssemblyName", _project_Eng_name.Replace(" ", ""));//程序集名称
|
||||
}
|
||||
var OutputPath = GetValue(@"d:Project//d:PropertyGroup[2]//d:OutputPath").TrimEnd('\\')+"\\";
|
||||
if (ChangedOutputPath)
|
||||
{
|
||||
SetValue(@"d:Project//d:PropertyGroup[2]//d:OutputPath", BinFolder.TrimEnd('\\') + "\\Debug\\"+ (_project_Eng_name==""?"": _project_Eng_name +"\\"));//Debug输出路径
|
||||
SetValue(@"d:Project//d:PropertyGroup[3]//d:OutputPath", BinFolder.TrimEnd('\\') + "\\Release\\" + (_project_Eng_name == "" ? "" : _project_Eng_name + "\\"));//Release输出路径
|
||||
}
|
||||
if (OutputPath == "") { OutputPath = BinFolder.TrimEnd('\\') + "\\Debug\\" + (_project_Eng_name == "" ? "" : _project_Eng_name + "\\"); }
|
||||
var list = xml.SelectNodes(@"d:Project//d:ItemGroup//d:Reference//d:HintPath", xmlnsm);
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
var HintPath = list[i].InnerText;
|
||||
var iPos = HintPath.LastIndexOf("\\");
|
||||
if (iPos > 0)
|
||||
{
|
||||
var Reference_Name = HintPath.Substring(iPos + 1);//引用的dll名称
|
||||
var dll_path = GetDllPath(Reference_Name);
|
||||
if (dll_path != "")
|
||||
{
|
||||
if (CopyDllToBin)
|
||||
{
|
||||
list[i].InnerText = OutputPath + Reference_Name;
|
||||
RyFiles.CopyFile(dll_path,RelToAbsPath(path, OutputPath + Reference_Name));
|
||||
}
|
||||
else
|
||||
{
|
||||
list[i].InnerText = dll_path;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var ProjectReference_list = xml.SelectNodes(@"d:Project//d:ItemGroup//d:ProjectReference", xmlnsm);//项目引用
|
||||
for (int i = 0; i < ProjectReference_list.Count; i++)
|
||||
{
|
||||
var element = (XmlElement)ProjectReference_list[i];
|
||||
var IncludePath = element.GetAttribute("Include");
|
||||
var iPos = IncludePath.LastIndexOf("\\");
|
||||
if (iPos > 0)
|
||||
{
|
||||
var Reference_FileName = IncludePath.Substring(iPos + 1).ToLower();//引用的项目文件名称
|
||||
string dll_name = "";
|
||||
if (Reference_FileName == "MyDbV4.csproj".ToLower())
|
||||
{ dll_name = "MyDb.dll"; }
|
||||
else if (Reference_FileName == "MyDb_SQLiteV4.csproj".ToLower())
|
||||
{ dll_name = "MyDb_SQLite.dll"; }
|
||||
else if (Reference_FileName == "ryControlsV4.csproj".ToLower())
|
||||
{ dll_name = "ryControls.dll"; }
|
||||
else if (Reference_FileName == "RyPrint.csproj".ToLower())
|
||||
{ dll_name = "RyPrint.dll"; }
|
||||
else if (Reference_FileName == "ryUpdateV4.csproj".ToLower())
|
||||
{ dll_name = "ryUpdate.dll"; }
|
||||
if (dll_name != "")
|
||||
{
|
||||
var dll_path = GetDllPath(dll_name);
|
||||
if (dll_path != "")
|
||||
{
|
||||
if (CopyDllToBin)
|
||||
{
|
||||
MoveReference(System.IO.Path.GetFileNameWithoutExtension(dll_name), OutputPath + dll_name);
|
||||
RyFiles.CopyFile(dll_path, RelToAbsPath(path, OutputPath + dll_name));
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveReference(System.IO.Path.GetFileNameWithoutExtension(dll_name), dll_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
//将项目引用转换为dll引用
|
||||
void MoveReference(string reference_name, string dll_path)
|
||||
{
|
||||
ProjectReference_list[i].ParentNode.RemoveChild(ProjectReference_list[i]);
|
||||
var node = xml.SelectSingleNode(@"d:Project//d:ItemGroup", xmlnsm);
|
||||
XmlNode childXmlNode = xml.CreateElement("Reference");
|
||||
XmlNode childXmlNode2 = xml.CreateElement("HintPath");
|
||||
childXmlNode2.InnerText = dll_path;
|
||||
childXmlNode.AppendChild(childXmlNode2);
|
||||
node.AppendChild(childXmlNode);
|
||||
XmlElement element2 = (XmlElement)childXmlNode;
|
||||
element2.SetAttribute("Include", reference_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
xml.InnerXml = xml.InnerXml.Replace(" xmlns=\"\"", "");
|
||||
xml.Save(path);
|
||||
string GetValue(string xpath)
|
||||
{
|
||||
var node = xml.SelectSingleNode(xpath, xmlnsm);
|
||||
if (node != null)
|
||||
{
|
||||
return node.InnerText;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
bool SetValue(string xpath, string value)
|
||||
{
|
||||
var node = xml.SelectSingleNode(xpath, xmlnsm);
|
||||
if (node != null)
|
||||
{
|
||||
node.InnerText = value; return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取版本号
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <returns></returns>
|
||||
public string GetAssemblyVersion(string path)
|
||||
{
|
||||
var AssemblyInfo_Path = System.IO.Path.GetDirectoryName(path) + "\\Properties\\AssemblyInfo.cs";
|
||||
if (System.IO.File.Exists(AssemblyInfo_Path))
|
||||
{
|
||||
var AssemblyInfo = ryCommon.RyFiles.ReadAllLines(AssemblyInfo_Path);
|
||||
for (int i = 0; i < AssemblyInfo.Length; i++)
|
||||
{
|
||||
if (AssemblyInfo[i].StartsWith("//")) { continue; }
|
||||
if (AssemblyInfo[i].StartsWith("[assembly: AssemblyVersion"))
|
||||
{
|
||||
return AssemblyInfo[i].GetStr("AssemblyVersion(\"", "\")");
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 更新版本号
|
||||
/// </summary>
|
||||
/// <param name="AssemblyInfo_Path"></param>
|
||||
public static void UpdateVer(string AssemblyInfo_Path)
|
||||
{
|
||||
string AssemblyInfo_path = AssemblyInfo_Path;
|
||||
if (System.IO.File.Exists(AssemblyInfo_path))
|
||||
{
|
||||
string[] AssemblyInfo_list = ryCommon.RyFiles.ReadAllLines(AssemblyInfo_path);
|
||||
string text = "";
|
||||
string Revision_Ver = DateTime.Now.ToString("yyMM");
|
||||
string Build_Ver = DateTime.Now.ToString("dd00");
|
||||
for (int i = 0; i < AssemblyInfo_list.Length; i++)
|
||||
{
|
||||
string item = AssemblyInfo_list[i];
|
||||
if (item.IndexOf("[assembly: AssemblyVersion(\"") == 0)
|
||||
{
|
||||
|
||||
ChangeVer("[assembly: AssemblyVersion(\"");
|
||||
}
|
||||
else if (item.IndexOf("[assembly: AssemblyFileVersion(\"") == 0)
|
||||
{
|
||||
ChangeVer("[assembly: AssemblyFileVersion(\"");
|
||||
}
|
||||
if (text != "") { text += "\r\n"; }
|
||||
text += item;
|
||||
void ChangeVer(string id)
|
||||
{
|
||||
string ver = item.GetStr(id, "\")]", 0, out int pos, "");
|
||||
if (ver != "")
|
||||
{
|
||||
string[] ver_list = ver.Split('.');
|
||||
if (ver_list.Length == 4)
|
||||
{
|
||||
if (ver_list[2] != Revision_Ver)
|
||||
{
|
||||
ver = ver_list[0] + "." + ver_list[1] + "." + Revision_Ver + "." + (Build_Ver.ToInt() + 1).ToString("0000");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ver_list[3].IndexOf(DateTime.Now.ToString("dd")) == 0)
|
||||
{
|
||||
ver = ver_list[0] + "." + ver_list[1] + "." + Revision_Ver + "." + (ver_list[3].ToInt() + 1).ToString("0000");
|
||||
}
|
||||
else
|
||||
{
|
||||
ver = ver_list[0] + "." + ver_list[1] + "." + Revision_Ver + "." + (Build_Ver.ToInt() + 1).ToString("0000");
|
||||
}
|
||||
}
|
||||
item = id + ver + "\")]";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ryCommon.RyFiles.WriteAllText(AssemblyInfo_path, text, Encoding.UTF8);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace 开发辅助工具.Manager
|
||||
{
|
||||
class TotalCount
|
||||
{
|
||||
/// <summary>
|
||||
/// 返回字节数
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
/// <returns></returns>
|
||||
public int GetByteLength(string s, out int HanziCount, out int engCount, out int NumCount)
|
||||
{
|
||||
int l = 0;
|
||||
char[] q = s.ToCharArray();
|
||||
HanziCount = 0;
|
||||
engCount = 0;
|
||||
NumCount = 0;
|
||||
for (int i = 0; i < q.Length; i++)
|
||||
{
|
||||
int qInt = (int)q[i];
|
||||
if (qInt >= 0x4E00 && qInt <= 0x9FA5) // 汉字
|
||||
{
|
||||
l += 2;
|
||||
HanziCount++;
|
||||
}
|
||||
else if ((qInt >= 97 && qInt <= 122) || (qInt >= 65 && qInt <= 90)) // 英文
|
||||
{
|
||||
l += 1;
|
||||
engCount++;
|
||||
}
|
||||
else if ((qInt >= 48 && qInt <= 57)) // 数字
|
||||
{
|
||||
l += 1;
|
||||
NumCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
l += 1;
|
||||
}
|
||||
}
|
||||
return l;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user