Skip to content

Commit

Permalink
2.0.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
x-nas committed Dec 21, 2024
1 parent d700dd6 commit 0dab372
Show file tree
Hide file tree
Showing 8 changed files with 20,093 additions and 18,051 deletions.
5 changes: 3 additions & 2 deletions WPELibrary/Lib/MultiLanguage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static class MultiLanguage
public static string[] MutiLan_26 = { "查找", "Search" };
public static string[] MutiLan_27 = { "机器人 {0}", "Robot {0}" };
public static string[] MutiLan_28 = { "数据加载出错!", "Data loading error!" };
public static string[] MutiLan_29 = { "两个文本相同", "The two texts are the same" };
public static string[] MutiLan_29 = { "两个数据相同!", "The two data are the same!" };
public static string[] MutiLan_30 = { "请正确设置查找内容!", "Please set the Find content correctly!" };
public static string[] MutiLan_31 = { "已发送: {0} 已接收: {1}", "Sent: {0} Bytes Received: {1} Bytes" };
public static string[] MutiLan_32 = { "发送 - [{0}]", "Send - [{0}]" };
Expand Down Expand Up @@ -145,7 +145,7 @@ public static class MultiLanguage
public static string[] MutiLan_133 = { "快捷键: Ctrl + Alt + {0} 注册失败!", "HotKey: Ctrl + Alt + {0} registration failed!" };
public static string[] MutiLan_134 = { "原始数据 ( 长度 {0} )", "Raw Data ( Length {0} )" };
public static string[] MutiLan_135 = { "修改后数据 ( 长度 {0} )", "Modified Data ( Length {0} )" };
public static string[] MutiLan_136 = { "数据修改 - [{0}]", "Data Modify - [{0}]" };
public static string[] MutiLan_136 = { "查看数据修改 - 序号 [{0}]", "Show Data Modify - ID [{0}]" };
public static string[] MutiLan_137 = { "代理服务器IP地址: [ {0} ]", "Proxy server IP address: [ {0} ]" };
public static string[] MutiLan_138 = { "< 请求数据 >", "< Request >" };
public static string[] MutiLan_139 = { "< 响应数据 >", "< Response >" };
Expand All @@ -164,6 +164,7 @@ public static class MultiLanguage
public static string[] MutiLan_152 = { "不支持的命令!", "Unsupported command!" };
public static string[] MutiLan_153 = { "{0} 请求数据: {1} 字节", "{0} Request: {1} bytes" };
public static string[] MutiLan_154 = { "{0} 响应数据: {1} 字节", "{0} Response: {1} bytes" };
public static string[] MutiLan_155 = { "正在进行数据比对,请稍候 . . .", "Data comparison is in progress, please wait . . ." };

#endregion

Expand Down
170 changes: 89 additions & 81 deletions WPELibrary/Lib/Socket_Operation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1322,132 +1322,140 @@ public static TreeNode FindNodeByName(TreeNodeCollection nodes, string Name)

#region//数据对比

public static void CompareData(RichTextBox rtbCompare, string sText_A, string sText_B)
public static string CompareData(Font font, string sText_A, string sText_B)
{
string sReturn = string.Empty;

try
{
rtbCompare.Clear();
RichTextBox rtbCompare = new RichTextBox();
rtbCompare.Font = font;

if (sText_A == sText_B)
{
Socket_Operation.AppendColoredText(rtbCompare, MultiLanguage.GetDefaultLanguage(MultiLanguage.MutiLan_29), Color.Blue);
return;
Socket_Operation.AppendColoredText(rtbCompare, MultiLanguage.GetDefaultLanguage(MultiLanguage.MutiLan_29), Color.Blue);
}
else
{
string[] linesA = sText_A.Split('\n').Select(s => s.Trim()).ToArray();
string[] linesB = sText_B.Split('\n').Select(s => s.Trim()).ToArray();

string[] linesA = sText_A.Split('\n').Select(s => s.Trim()).ToArray();
string[] linesB = sText_B.Split('\n').Select(s => s.Trim()).ToArray();

int la = 0;
int lb = 0;
int la = 0;
int lb = 0;

while (la < linesA.Length)
{
if (lb >= linesB.Length)
while (la < linesA.Length)
{
Socket_Operation.AppendColoredText(rtbCompare, linesA[la], Socket_Operation.col_Del);
}
else if (linesA[la] == linesB[lb])
{
Socket_Operation.AppendColoredText(rtbCompare, linesA[la], rtbCompare.ForeColor);
}
else
{
if ((lb + 1 < linesB.Length) && (linesA[la] == linesB[lb + 1]))
if (lb >= linesB.Length)
{
Socket_Operation.AppendColoredText(rtbCompare, linesB[lb], Socket_Operation.col_Add);
Socket_Operation.AppendColoredText(rtbCompare, "\n" + linesA[la], rtbCompare.ForeColor);

lb++;
Socket_Operation.AppendColoredText(rtbCompare, linesA[la], Socket_Operation.col_Del);
}
else if ((la + 1 < linesA.Length) && (linesA[la + 1] == linesB[lb]))
else if (linesA[la] == linesB[lb])
{
Socket_Operation.AppendColoredText(rtbCompare, linesA[la], Socket_Operation.col_Del);
Socket_Operation.AppendColoredText(rtbCompare, "\n" + linesB[lb], rtbCompare.ForeColor);

la++;
Socket_Operation.AppendColoredText(rtbCompare, linesA[la], rtbCompare.ForeColor);
}
else
{
string[] wordsA = linesA[la].Split(' ').Select(s => s.Trim()).ToArray();
string[] wordsB = linesB[lb].Split(' ').Select(s => s.Trim()).ToArray();
if ((lb + 1 < linesB.Length) && (linesA[la] == linesB[lb + 1]))
{
Socket_Operation.AppendColoredText(rtbCompare, linesB[lb], Socket_Operation.col_Add);
Socket_Operation.AppendColoredText(rtbCompare, "\n" + linesA[la], rtbCompare.ForeColor);

int wa = 0;
int wb = 0;
while (wa < wordsA.Length)
lb++;
}
else if ((la + 1 < linesA.Length) && (linesA[la + 1] == linesB[lb]))
{
if (wb >= wordsB.Length)
{
Socket_Operation.AppendColoredText(rtbCompare, wordsA[wa], Socket_Operation.col_Del);
}
else if (wordsA[wa] == wordsB[wb])
{
Socket_Operation.AppendColoredText(rtbCompare, wordsA[wa], rtbCompare.ForeColor);
}
else
Socket_Operation.AppendColoredText(rtbCompare, linesA[la], Socket_Operation.col_Del);
Socket_Operation.AppendColoredText(rtbCompare, "\n" + linesB[lb], rtbCompare.ForeColor);

la++;
}
else
{
string[] wordsA = linesA[la].Split(' ').Select(s => s.Trim()).ToArray();
string[] wordsB = linesB[lb].Split(' ').Select(s => s.Trim()).ToArray();

int wa = 0;
int wb = 0;
while (wa < wordsA.Length)
{
if ((wb + 1 < wordsB.Length) && (wordsA[wa] == wordsB[wb + 1]))
if (wb >= wordsB.Length)
{
Socket_Operation.AppendColoredText(rtbCompare, wordsB[wb], Socket_Operation.col_Add);
Socket_Operation.AppendColoredText(rtbCompare, " " + wordsA[wa], rtbCompare.ForeColor);

wb++;
Socket_Operation.AppendColoredText(rtbCompare, wordsA[wa], Socket_Operation.col_Del);
}
else if ((wa + 1 < wordsA.Length) && (wordsA[wa + 1] == wordsB[wb]))
else if (wordsA[wa] == wordsB[wb])
{
Socket_Operation.AppendColoredText(rtbCompare, wordsA[wa], Socket_Operation.col_Del);
Socket_Operation.AppendColoredText(rtbCompare, " " + wordsB[wb], rtbCompare.ForeColor);

wa++;
Socket_Operation.AppendColoredText(rtbCompare, wordsA[wa], rtbCompare.ForeColor);
}
else
{
Socket_Operation.AppendColoredText(rtbCompare, wordsA[wa], Socket_Operation.col_Del);
Socket_Operation.AppendColoredText(rtbCompare, wordsB[wb], Socket_Operation.col_Add);
if ((wb + 1 < wordsB.Length) && (wordsA[wa] == wordsB[wb + 1]))
{
Socket_Operation.AppendColoredText(rtbCompare, wordsB[wb], Socket_Operation.col_Add);
Socket_Operation.AppendColoredText(rtbCompare, " " + wordsA[wa], rtbCompare.ForeColor);

wb++;
}
else if ((wa + 1 < wordsA.Length) && (wordsA[wa + 1] == wordsB[wb]))
{
Socket_Operation.AppendColoredText(rtbCompare, wordsA[wa], Socket_Operation.col_Del);
Socket_Operation.AppendColoredText(rtbCompare, " " + wordsB[wb], rtbCompare.ForeColor);

wa++;
}
else
{
Socket_Operation.AppendColoredText(rtbCompare, wordsA[wa], Socket_Operation.col_Del);
Socket_Operation.AppendColoredText(rtbCompare, wordsB[wb], Socket_Operation.col_Add);
}
}
}
if (wa + 1 < wordsA.Length) Socket_Operation.AppendColoredText(rtbCompare, " ", rtbCompare.ForeColor);
if (wa + 1 < wordsA.Length) Socket_Operation.AppendColoredText(rtbCompare, " ", rtbCompare.ForeColor);

if ((wordsB.Length >= wordsA.Length) && (wa + 1 == wordsA.Length))
{
while (wb + 1 < wordsB.Length)
if ((wordsB.Length >= wordsA.Length) && (wa + 1 == wordsA.Length))
{
wb++;
while (wb + 1 < wordsB.Length)
{
wb++;

Socket_Operation.AppendColoredText(rtbCompare, " ", rtbCompare.ForeColor);
Socket_Operation.AppendColoredText(rtbCompare, wordsB[wb], Socket_Operation.col_Add);
Socket_Operation.AppendColoredText(rtbCompare, " ", rtbCompare.ForeColor);
Socket_Operation.AppendColoredText(rtbCompare, wordsB[wb], Socket_Operation.col_Add);
}
}
}

wa++;
wb++;
wa++;
wb++;
}
}
}
}

if (la + 1 < linesA.Length)
{
Socket_Operation.AppendColoredText(rtbCompare, "\n", rtbCompare.ForeColor);
}
if (la + 1 < linesA.Length)
{
Socket_Operation.AppendColoredText(rtbCompare, "\n", rtbCompare.ForeColor);
}

if ((linesB.Length >= linesA.Length) && (la + 1 == linesA.Length))
{
while (lb + 1 < linesB.Length)
if ((linesB.Length >= linesA.Length) && (la + 1 == linesA.Length))
{
lb++;
while (lb + 1 < linesB.Length)
{
lb++;

Socket_Operation.AppendColoredText(rtbCompare, "\n", rtbCompare.ForeColor);
Socket_Operation.AppendColoredText(rtbCompare, linesB[lb], Socket_Operation.col_Add);
Socket_Operation.AppendColoredText(rtbCompare, "\n", rtbCompare.ForeColor);
Socket_Operation.AppendColoredText(rtbCompare, linesB[lb], Socket_Operation.col_Add);
}
}
}

la++;
lb++;
la++;
lb++;
}
}

sReturn = rtbCompare.Rtf;
}
catch (Exception ex)
{
Socket_Operation.DoLog(MethodBase.GetCurrentMethod().Name, ex.Message);
}

return sReturn;
}

private static void AppendColoredText(RichTextBox box, string text, Color color)
Expand Down
39 changes: 30 additions & 9 deletions WPELibrary/Socket_CompareForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0dab372

Please sign in to comment.