Signed-off-by: 高源 <3056440880@qq.com>
Dev
高源 2 years ago
parent f0dc16fc75
commit 9444d53350

@ -1,190 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WpfApp1.WinOcr;
using WpfApp1.ScnToJson;
using WpfApp1.translationKey;
using WpfApp1.transToNet;
namespace testRjgc
{
internal class AllClassAndInterfaceWellBeManipulatedInThisFileAndCallThroughFunction
{
public AllClassAndInterfaceWellBeManipulatedInThisFileAndCallThroughFunction() { }
TranslationPrivateIn trin = new TranslationPrivateIn();
TranslationApiStr trstr = new translationPrivateOut();
TranslationApiInt trint = new translationPublic();
TranslationScnToJson scnjson = new TranslationScnToJson();
Sofia sof = new OcrSofia();
Messiah jsonnet = new jsonNet();
public void InputPrivateBaidu(string name, string id, string key)
{
trin.InputBaiduPrivate(name, id, key);
}
public void InPutPrivateA(string name, List<string> list)
{
trin.InPutPrivate(name, list);
}
public List<string> OutputNameList()
{
List<string> list = trstr.OutputTranslationNameList();
return list;
}
public List<string> OutputStr(string id)
{
List<string> li = trstr.OutputTranslationS(id);
return li;
}
public List<string> OutputChoicPublic(int id)
{
List<string> li = trint.OutputTranslationI(id);
return li;
}
public void StartSCNTransJSON()
{
scnjson.StartTrans();
}
public void StartTransOneself(string spa, string dps)
{
scnjson.StopTrans(spa, dps);
}
public string WindowsOcrToGetString(string name)
{
return sof.WindowsOcrToGetStringAndTranslate(name);
}
public string NetBaiDu(string input)
{
return jsonnet.RequestJsonBaiDu(input);
}
public string NetAllBaiDu(string input, string srcl, string dstl, string aid, string kkey)
{
return jsonnet.RequestJsonPrivateBaiDu(input, srcl, dstl, aid, kkey);
}
public string NetLanBaiDu(string input, string srcl, string dstl)
{
return jsonnet.RequestJsonLanguageChangeBaiDu(input, srcl, dstl);
}
public string NetXunFei(string input)
{
return jsonnet.RequestJsonXunFei(input);
}
public string NetLanXunFei(string input, string srcl, string dstl)
{
return jsonnet.RequestJsonLanguageChangeXunFei(input, srcl, dstl);
}
public string NetAllXunFei(string input, string srcl, string dstl, string xid, string xsecret, string xkey)
{
return jsonnet.RequestJsonPrivateXunFei(input, srcl, dstl, xid, xsecret, xkey);
}
}
}
/*
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace OCRConsoleApp
{
class Program
{
static void Main(string[] args)
{
using IHost host = CreateHostBuilder(args).Build();
var ocrService = host.Services.GetRequiredService<IOcrService>();
// 截图并保存到本地文件
var bitmap = ocrService.CaptureScreen();
bitmap.Save("screenshot.png", ImageFormat.Png);
// 识别图片中的文字
var text = ocrService.RecognizeText(bitmap);
Console.WriteLine(text);
}
private static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureLogging(logging =>
{
logging.ClearProviders();
logging.AddConsole();
})
.ConfigureServices((hostContext, services) =>
{
services.AddHostedService<Worker>();
services.AddSingleton<IOcrService>(new OcrService());
});
}
public interface IOcrService
{
Bitmap CaptureScreen();
string RecognizeText(Bitmap bitmap);
}
public class OcrService : IOcrService
{
public Bitmap CaptureScreen()
{
var screenBounds = ScreenHelper.GetScreenBounds();
var bitmap = new Bitmap(screenBounds.Width, screenBounds.Height);
using (var graphics = Graphics.FromImage(bitmap))
graphics.CopyFromScreen(screenBounds.X, screenBounds.Y, 0, 0, screenBounds.Size);
return bitmap;
}
public string RecognizeText(Bitmap bitmap)
{
var ocrEngine = new IronOcr.AutoOcr();
var result = ocrEngine.Read(bitmap);
return result.Text;
}
}
public static class ScreenHelper
{
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern bool GetCursorPos(out Point lpPoint);
public static Rectangle GetScreenBounds()
{
GetCursorPos(out Point point);
var screenBounds = Screen.FromPoint(point).Bounds;
return screenBounds;
}
}
}
*/

@ -1,65 +0,0 @@
using System.Diagnostics;
namespace WpfApp1.ScnToJson
{
internal class TranslationScnToJson
{
//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 =
{
FileName = "PowerShell.exe",
Arguments = "/c " + cmdHandle + "\n" + voice,
UseShellExecute = false,
CreateNoWindow = false,
}
};
p.Start();
p.WaitForExit();
p.Close();
}
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;
var p = new Process
{
StartInfo =
{
FileName = "PowerShell.exe",
Arguments = "/c " + cmdHandle + "\n" + tempVoice,
UseShellExecute = false,
CreateNoWindow = false,
}
};
p.Start();
p.WaitForExit();
p.Close();
}
}
}

@ -1,32 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
<appSettings>
<!-- When using an API key to access Google spreadsheets -->
<add key="GoogleApiKey" value="" />
<!-- Instead of using an API key, you can also use a service account. This way, you don't have to make your spreadsheet public. -->
<!-- To use a service account, download its private key and store it in a file called "google-service-account.json" -->
<add key="MonospaceCharactersPerLine" value="50" />
<add key="ProportionalFontName" value="Franklin Gothic Book" />
<add key="ProportionalFontSize" value="40" />
<add key="ProportionalFontBold" value="false" />
<add key="ProportionalLineWidth" value="1000" />
<add key="SecondaryProportionalLineWidth" value="670" />
</appSettings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

@ -1,2 +0,0 @@
<?xml version="1.0"?>
<names xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />

@ -1,7 +0,0 @@
Excel:
VNTextPatch extractlocal <folder containing original game files> script.xlsx
VNTextPatch insertlocal <folder containing original game files> script.xlsx <folder to receive patched game files>
JSON:
VNTextPatch extractlocal <folder containing original game files> <folder to receive .json files>
VNTextPatch insertlocal <folder containing original game files> <folder containing .json files> <folder to receive patched game files>

@ -1,107 +0,0 @@
using System.Drawing;
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.InteropServices;
//using System.Windows.Forms;
namespace WpfApp1.WinOcr
{
internal class OcrSofia : Sofia
{
static string path = Directory.GetCurrentDirectory() + "\\TempImage";
public OcrSofia() { }
public string WindowsOcrToGetStringAndTranslate(string name)
{
string retxt = "";
this.DirExists();
//Image image = null;
/*
MODI.Document modiDocument = new MODI.Document();
modiDocument.Create(path + "\\" + name + ".jpg");
modiDocument.OCR(MODI.MiLANGUAGES.miLANG_CHINESE_SIMPLIFIED, true, true);
MODI.Image modiImage = (MODI.Image)modiDocument.Images[0];
retxt = modiImage.Layout.Text;
*/
return retxt;
/*
string processName = "notepad"; // 替换为要跟踪的进程名称
Process[] processes = Process.GetProcessesByName(processName);
if (processes.Length > 0)
{
Process process = processes[0];
IntPtr hwnd = process.MainWindowHandle;
var Ocr = new IronTesseract();
OcrResult Result = null;
Ocr.TextAvailable += (s, e) =>
{
Console.WriteLine(e.Text);
Result = e.Result;
};
while (true)
{
if (hwnd != IntPtr.Zero)
{
int length = GetWindowTextLength(hwnd);
if (length > 0)
{
IntPtr buffer = Marshal.AllocHGlobal(length + 1);
GetWindowText(hwnd, buffer, length + 1);
string text = Marshal.PtrToStringAnsi(buffer);
Marshal.FreeHGlobal(buffer);
Ocr.Read(text);
}
}
}
}
else
{
Console.WriteLine("找不到进程:{0}", processName);
}
*/
}
public void DirExists()
{
if(Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
}
/*
internal class OcrSofia : Sofia
{
public OcrSofia() { }
public string WindowsOcrToGetStringAndTranslate()
{
string result = "";
// 获取剪贴板中的图像
Image image = Clipboard.GetImage();
// 将图像保存到临时文件中
string tempFile = Path.GetTempFileName();
image.Save(tempFile, ImageFormat.Tiff);
// 使用Windows OCR引擎识别图像中的文本
MODI.Document modiDocument = new MODI.Document();
modiDocument.Create(tempFile);
modiDocument.OCR(MODI.MiLANGUAGES.miLANG_CHINESE_SIMPLIFIED, true, true);
MODI.Image modiImage = (MODI.Image)modiDocument.Images[0];
result = modiImage.Layout.Text;
// 删除临时文件
File.Delete(tempFile);
return result;
}
}
*/
}
}

@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WpfApp1.WinOcr
{
internal interface Sofia
{
public abstract string WindowsOcrToGetStringAndTranslate(string name);
}
}

@ -1,22 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WpfApp1.translationKey
{
interface TranslationApiStr//Mohammed
{
public abstract List<string> OutputTranslationS(string id);
public abstract List<string> OutputTranslationNameList();
}
interface TranslationApiInt
{
public abstract List<string> OutputTranslationI(int id);
}
}

@ -1,61 +0,0 @@
namespace WpfApp1.translationKey
{
class TranslationPrivateIn
{
private static string pathTemp = Directory.GetCurrentDirectory() + "\\translationResource";
private static string txtPath = Directory.GetCurrentDirectory() + "\\translationResource\\ListPrivate.txt";
public TranslationPrivateIn() { }
public void InPutPrivate(string name, List<string> list)
{
if (Directory.Exists(pathTemp))
{
Directory.CreateDirectory(pathTemp);
}
string temppathTemp = pathTemp + "\\" + name + ".txt";
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();
}
public void InputTranslationId(string id, StreamWriter sw)
{
sw.WriteLine(id);
}
public void InputTranslationKey(string key, StreamWriter sw)
{
sw.WriteLine(key);
}
}
}

@ -1,109 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WpfApp1.translationKey
{
class translationPrivateOut : TranslationApiStr
{
private static string path = Directory.GetCurrentDirectory() + "\\translationResource";
private static string txtPath = Directory.GetCurrentDirectory() + "\\translationResource\\ListPrivate.txt";
private String getTranslationPrivateApi(StreamReader sr)
{
String temp = sr.ReadLine();
if(temp != null)
{
return temp;
}
else
{
return "ERROR";
}
}
private String getTranslationPrivateKey(StreamReader sr)
{
String temp = sr.ReadLine();
if (temp != null)
{
return temp;
}
else
{
return "ERROR";
}
}
public string getpath(string id)
{
return path + "\\" + id + ".txt";
}
public string gettxt()
{
return txtPath;
}
public List<string> OutputTranslationS(string id)
{
string temppath = path + "\\" + id + ".txt";
List<string> temp = new List<string> { };
if (Directory.Exists(temppath))//若不存在
{
temp.Add("尚未输入!!!");
return temp;
}
StreamReader sr = new StreamReader(temppath);
temp.Add(this.getTranslationPrivateApi(sr));
temp.Add(this.getTranslationPrivateKey(sr));
sr.Close();
return temp;
}
public List<string> OutputTranslationNameList()
{
List<string> temp = new List<string> { };
string temptxtpath = txtPath;
if(Directory.Exists(temptxtpath))
{
temp.Add("ERROR");
return temp;
}
StreamReader sr = new StreamReader(temptxtpath);
string temp2 = sr.ReadLine();
if (temp2 == null)
{
temp.Add("ERROR");
}
else
{
while (temp2 != null)
{
temp.Add(temp2);
temp2 = sr.ReadLine();
}
}
sr.Close();
return temp;
}
}
}

@ -1,46 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WpfApp1.translationKey
{
class translationPublic : TranslationApiInt
{
public List<string> OutputTranslationI(int id)
{
var temp = new List<string> { };
switch (id)
{
case 0://讯飞
{
temp.Add("1299c840");//id
temp.Add("M2Q4YzkzZTIwZjNkMGE2ZjkwZWMxNzZk");//APISecret
temp.Add("828cb2dc915d28464a904bda5d7b01b3");//APIKey
break;
}
case 1://百度
{
temp.Add("20230923001827495");//APIAppid
temp.Add("yjvMNY33Qc1TYSBjTQYQ");//APIKey
break;
}
case 2://百度2
{
temp.Add("20230925001829663");
temp.Add("f7ZHpw28izQ1VU_ixoY5");
break;
}
case 3://google
{
temp.Add("UNSET!");//NULL,空
temp.Add("UNSET!");//APIKey
break;
}
}
return temp;
}
}
}
Loading…
Cancel
Save