From b00e0d0f2407aa35c71e07607613432396a7e92e Mon Sep 17 00:00:00 2001 From: lilium-saber Date: Mon, 16 Oct 2023 10:06:18 +0800 Subject: [PATCH] 0 Signed-off-by: lilium-saber --- ...pulatedInThisFileAndCallThroughFunction.cs | 52 +++++++++++++++++-- src/Network/GrapeToJsonTrans.cs | 2 +- src/Network/TransNetworkApi.cs | 8 +-- src/Network/jsonNet.cs | 18 +++++-- src/ScnToJson/TranslationScnToJson.cs | 20 +++++-- src/translationKey/translationPrivateIn.cs | 26 +++++++++- src/translationKey/translationPrivateOut.cs | 2 +- 7 files changed, 107 insertions(+), 21 deletions(-) diff --git a/src/AllClassAndInterfaceWellBeManipulatedInThisFileAndCallThroughFunction.cs b/src/AllClassAndInterfaceWellBeManipulatedInThisFileAndCallThroughFunction.cs index 5b18b5a..123d489 100644 --- a/src/AllClassAndInterfaceWellBeManipulatedInThisFileAndCallThroughFunction.cs +++ b/src/AllClassAndInterfaceWellBeManipulatedInThisFileAndCallThroughFunction.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using WpfApp1.WinOcr; using WpfApp1.ScnToJson; using WpfApp1.translationKey; +using WpfApp1.transToNet; namespace testRjgc { @@ -13,13 +14,19 @@ namespace testRjgc { AllClassAndInterfaceWellBeManipulatedInThisFileAndCallThroughFunction() { } - public void InputPrivate(string name, string id, string key) + public void InputPrivateBaidu(string name, string id, string key) { TranslationPrivateIn tr = new TranslationPrivateIn(); - tr.InputTranslationPrivate(name, id, key); + tr.InputBaiduPrivate(name, id, key); } - public List OutputNameList(string id) + public void InPutPrivateA(string name, List list) + { + TranslationPrivateIn tr = new TranslationPrivateIn(); + tr.InPutPrivate(name, list); + } + + public List OutputNameList() { TranslationApiStr tr = new translationPrivateOut(); List list = tr.OutputTranslationNameList(); @@ -33,7 +40,7 @@ namespace testRjgc return li; } - public List OutputPub(int id) + public List OutputChoicPublic(int id) { TranslationApiInt sin = new translationPublic(); List li = sin.OutputTranslationI(id); @@ -59,5 +66,42 @@ namespace testRjgc return temp; } + public string NetBaiDu(string input) + { + Messiah me = new jsonNet(); + return me.RequestJsonBaiDu(input); + } + + public string NetAllBaiDu(string input, string srcl, string dstl, string aid, string kkey) + { + Messiah me = new jsonNet(); + return me.RequestJsonPrivateBaiDu(input, srcl, dstl, aid, kkey); + } + + public string NetLanBaiDu(string input, string srcl, string dstl) + { + Messiah me = new jsonNet(); + return me.RequestJsonLanguageChangeBaiDu(input, srcl, dstl); + } + + public string NetXunFei(string input) + { + Messiah me = new jsonNet(); + return me.RequestJsonXunFei(input); + } + + public string NetLanXunFei(string input, string srcl, string dstl) + { + Messiah me = new jsonNet(); + return me.RequestJsonLanguageChangeXunFei(input, srcl, dstl); + } + + public string NetAllXunFei(string input, string srcl, string dstl, string xid, string xsecret, string xkey) + { + Messiah me = new jsonNet(); + return me.RequestJsonPrivateXunFei(input, srcl, dstl, xid, xsecret, xkey); + } + + } } diff --git a/src/Network/GrapeToJsonTrans.cs b/src/Network/GrapeToJsonTrans.cs index b81a1bd..fad3531 100644 --- a/src/Network/GrapeToJsonTrans.cs +++ b/src/Network/GrapeToJsonTrans.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace testRjgc.transToNet +namespace WpfApp1.transToNet { /* internal class GrapeToJsonTrans : GrapeToJson diff --git a/src/Network/TransNetworkApi.cs b/src/Network/TransNetworkApi.cs index ef60641..62455f5 100644 --- a/src/Network/TransNetworkApi.cs +++ b/src/Network/TransNetworkApi.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace testRjgc.transToNet +namespace WpfApp1.transToNet { interface Messiah { @@ -14,10 +14,10 @@ namespace testRjgc.transToNet public abstract string RequestJsonBaiDu(string input); - public abstract string RequestJsonXunFei(string input); - - public abstract string RequestJsonPrivateXunFei(string input, string srcl, string dstl, string xid, string xkey); + //以下接口暂时废弃 + public abstract string RequestJsonXunFei(string input); + public abstract string RequestJsonPrivateXunFei(string input, string srcl, string dstl, string xid, string xsecret, string xkey); public abstract string RequestJsonLanguageChangeXunFei(string input, string srcl, string dstl); } diff --git a/src/Network/jsonNet.cs b/src/Network/jsonNet.cs index 783029f..49ee3b7 100644 --- a/src/Network/jsonNet.cs +++ b/src/Network/jsonNet.cs @@ -14,7 +14,7 @@ using System.Text; using System.Threading.Tasks; using System.Web; -namespace testRjgc.transToNet +namespace WpfApp1.transToNet { internal class jsonNet : Messiah { @@ -53,8 +53,16 @@ namespace testRjgc.transToNet Console.WriteLine($"{jsonResponse}\n"); } */ + private HttpClient HttpRequestC(string url) + { + HttpClient httpClient = new HttpClient() + { + BaseAddress = new Uri(url) + }; + return httpClient; + } - public static string EncryptString(string str)//百度MD5加密计算方式 + private static string EncryptString(string str)//百度MD5加密计算方式 { MD5 md5 = MD5.Create(); // 将字符串转换成字节数组 @@ -152,7 +160,7 @@ namespace testRjgc.transToNet return "error"; } - public string RequestJsonPrivateXunFei(string input, string srcl, string dstl, string xid, string xkey) + public string RequestJsonPrivateXunFei(string input, string srcl, string dstl, string xid, string xse , string xkey) { return "error"; } @@ -162,12 +170,12 @@ namespace testRjgc.transToNet return "error"; } } - public class Trans_result + class Trans_result { public string src { get; set; } public string dst { get; set; } } - public class tempC2 + class tempC2 { public List trans_result { get; set; } } diff --git a/src/ScnToJson/TranslationScnToJson.cs b/src/ScnToJson/TranslationScnToJson.cs index 6cf2cfe..a997f27 100644 --- a/src/ScnToJson/TranslationScnToJson.cs +++ b/src/ScnToJson/TranslationScnToJson.cs @@ -4,13 +4,17 @@ namespace WpfApp1.ScnToJson { internal class TranslationScnToJson { - private string spath;//scn路径 - private string dpath;//json + //private string spath;//scn路径 + //private string dpath;//json + private string cmdHandle = "cd " + Directory.GetCurrentDirectory() + "\\VNT\\VNTextPatch"; private string voice = ".\\VNTextPatch extractlocal " + Directory.GetCurrentDirectory() + "\\VNT\\p1 " + Directory.GetCurrentDirectory() + "\\VNT\\p2"; public void StartTrans() { + this.DirExsis("VNT\\p1"); + this.DirExsis("VNT\\p2"); + var p = new Process { StartInfo = @@ -27,9 +31,17 @@ namespace WpfApp1.ScnToJson } - public void StopTrans(string spa, string dps) + public void DirExsis(string id) + { + if(Directory.Exists(Directory.GetCurrentDirectory() + "\\" + id)) + { + Directory.CreateDirectory(Directory.GetCurrentDirectory() + "\\" + id); + } + } + + public void StopTrans(string spa, string dps)//自选路径 { - string tempVoice = ".\\VNTextPatch extractlocal " + spa + dps; + string tempVoice = ".\\VNTextPatch extractlocal " + spa + " " + dps; var p = new Process { diff --git a/src/translationKey/translationPrivateIn.cs b/src/translationKey/translationPrivateIn.cs index 8398ec3..b50a068 100644 --- a/src/translationKey/translationPrivateIn.cs +++ b/src/translationKey/translationPrivateIn.cs @@ -15,9 +15,9 @@ namespace WpfApp1.translationKey public TranslationPrivateIn() { } - public void InputTranslationPrivate(string name, string id, string key)//目前仅百度支持 + public void InPutPrivate(string name, List list) { - if(Directory.Exists(pathTemp)) + if (Directory.Exists(pathTemp)) { Directory.CreateDirectory(pathTemp); } @@ -26,8 +26,30 @@ namespace WpfApp1.translationKey StreamWriter sw = new StreamWriter(temppathTemp); StreamWriter sw2 = new StreamWriter(txtPath); + foreach (string s in list) + { + sw.WriteLine(s); + } + + sw2.WriteLine(name); + sw.Close(); + sw2.Close(); + } + + public void InputBaiduPrivate(string name, string id, string key)//该函数仅百度支持 + { + if(Directory.Exists(pathTemp)) + { + Directory.CreateDirectory(pathTemp); + } + + string temppathTemp = pathTemp + "\\" + name + ".txt"; + StreamWriter sw = new StreamWriter(temppathTemp); + StreamWriter sw2 = new StreamWriter(txtPath); + InputTranslationId(id,sw); InputTranslationKey(key,sw); + sw2.WriteLine(name); sw.Close(); sw2.Close(); diff --git a/src/translationKey/translationPrivateOut.cs b/src/translationKey/translationPrivateOut.cs index c0e1154..1900399 100644 --- a/src/translationKey/translationPrivateOut.cs +++ b/src/translationKey/translationPrivateOut.cs @@ -58,7 +58,7 @@ namespace WpfApp1.translationKey List temp = new List { }; - if (Directory.Exists(temppath))//诺不存在 + if (Directory.Exists(temppath))//若不存在 { temp.Add("尚未输入!!!"); return temp;