├── .github
├── ISSUE_TEMPLATE
│ ├── Bug_Report.md
│ ├── Feature_Request.md
│ └── TODO.md
└── workflows
│ └── build.yml
├── .gitignore
├── About.jpg
├── AliyunRequestHandler
├── .gitignore
├── index.js
├── package-lock.json
├── package.json
└── test.js
├── ArtificialTransHelperLibrary
├── ArtificialTransHelper.cs
├── ArtificialTransHelperLibrary.csproj
└── Properties
│ └── AssemblyInfo.cs
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── DictionaryHelperLibrary
├── DictionaryHelperLibrary.csproj
├── IDict.cs
├── Properties
│ └── AssemblyInfo.cs
└── XxgJpzhDict.cs
├── KeyboardMouseHookLibrary
├── FindWindowInfo.cs
├── GlobalHook.cs
├── GlobalHotKey.cs
├── KeyboardMouseHook.cs
├── KeyboardMouseHookLibrary.csproj
└── Properties
│ └── AssemblyInfo.cs
├── KeyboardMouseMonitor
├── KeyboardMouseMonitor.cpp
├── KeyboardMouseMonitor.vcxproj
├── KeyboardMouseMonitor.vcxproj.filters
├── pch.cpp
└── pch.h
├── LICENSE
├── MecabHelperLibrary
├── MecabHelper.cs
├── MecabHelperLibrary.csproj
├── NoWordSplit.cs
├── Properties
│ └── AssemblyInfo.cs
└── WordSpliter.cs
├── MisakaPatchPackager
├── AesEncrypt.cs
├── App.config
├── IEncrypter.cs
├── MisakaPatchPackager.csproj
├── NopEncrypter.cs
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
├── XorEncrypt.cs
└── packages.config
├── MisakaTranslator-WPF
├── AddOptWindow.xaml
├── AddOptWindow.xaml.cs
├── App.config
├── App.xaml
├── App.xaml.cs
├── Appearance.xaml
├── ArtificialTransAddWindow.xaml
├── ArtificialTransAddWindow.xaml.cs
├── ComicTranslator
│ ├── ComicTransMainWindow.xaml
│ ├── ComicTransMainWindow.xaml.cs
│ ├── ImageProcWindow.xaml
│ └── ImageProcWindow.xaml.cs
├── Common.cs
├── DictResWindow.xaml
├── DictResWindow.xaml.cs
├── GameGuideWindow.xaml
├── GameGuideWindow.xaml.cs
├── GlobalOCRWindow.xaml
├── GlobalOCRWindow.xaml.cs
├── GuidePages
│ ├── ChooseLanguagePage.xaml
│ ├── ChooseLanguagePage.xaml.cs
│ ├── Completation.png
│ ├── CompletationPage.xaml
│ ├── CompletationPage.xaml.cs
│ ├── Hook
│ │ ├── ChooseGamePage.xaml
│ │ ├── ChooseGamePage.xaml.cs
│ │ ├── ChooseHookFuncPage.xaml
│ │ ├── ChooseHookFuncPage.xaml.cs
│ │ ├── ChooseTextRepairFuncPage.xaml
│ │ ├── ChooseTextRepairFuncPage.xaml.cs
│ │ ├── ReChooseHookFuncPage.xaml
│ │ └── ReChooseHookFuncPage.xaml.cs
│ ├── OCR
│ │ ├── ChooseHandleFuncPage.xaml
│ │ ├── ChooseHandleFuncPage.xaml.cs
│ │ ├── ChooseHotKeyPage.xaml
│ │ ├── ChooseHotKeyPage.xaml.cs
│ │ ├── ChooseOCRAreaPage.xaml
│ │ └── ChooseOCRAreaPage.xaml.cs
│ └── PageChangeRoutedEventArgs.cs
├── IAppSettings.cs
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── MisakaTranslator-WPF.csproj
├── Properties
│ └── AssemblyInfo.cs
├── PublishATWindow.xaml
├── PublishATWindow.xaml.cs
├── RemoteATWindow.xaml
├── RemoteATWindow.xaml.cs
├── ScreenCaptureWindow.xaml
├── ScreenCaptureWindow.xaml.cs
├── SettingsPages
│ ├── AboutPage.xaml
│ ├── AboutPage.xaml.cs
│ ├── Aboutv2.jpg
│ ├── ArtificialTransSettingsPage.xaml
│ ├── ArtificialTransSettingsPage.xaml.cs
│ ├── DictionaryPages
│ │ ├── XxgJpZhDictPage.xaml
│ │ └── XxgJpZhDictPage.xaml.cs
│ ├── HookSettingsPage.xaml
│ ├── HookSettingsPage.xaml.cs
│ ├── LESettingsPage.xaml
│ ├── LESettingsPage.xaml.cs
│ ├── OCRPages
│ │ ├── BaiduOCRSettingsPage.xaml
│ │ ├── BaiduOCRSettingsPage.xaml.cs
│ │ ├── OCRGeneralSettingsPage.xaml
│ │ ├── OCRGeneralSettingsPage.xaml.cs
│ │ ├── TesseractOCR5SettingsPage.xaml
│ │ └── TesseractOCR5SettingsPage.xaml.cs
│ ├── SoftwareSettingsPage.xaml
│ ├── SoftwareSettingsPage.xaml.cs
│ ├── TTSSettingsPage.xaml
│ ├── TTSSettingsPage.xaml.cs
│ └── TranslatorPages
│ │ ├── BaiduTransSettingsPage.xaml
│ │ ├── BaiduTransSettingsPage.xaml.cs
│ │ ├── CaiyunTransSettingsPage.xaml
│ │ ├── CaiyunTransSettingsPage.xaml.cs
│ │ ├── DreyeTransSettingsPage.xaml
│ │ ├── DreyeTransSettingsPage.xaml.cs
│ │ ├── JbeijingTransSettingsPage.xaml
│ │ ├── JbeijingTransSettingsPage.xaml.cs
│ │ ├── KingsoftFAITTransSettingsPage.xaml
│ │ ├── KingsoftFAITTransSettingsPage.xaml.cs
│ │ ├── LocalTransSettingsPage.xaml
│ │ ├── LocalTransSettingsPage.xaml.cs
│ │ ├── TencentFYJTransSettingsPage.xaml
│ │ ├── TencentFYJTransSettingsPage.xaml.cs
│ │ ├── TencentOldTransSettingsPage.xaml
│ │ ├── TencentOldTransSettingsPage.xaml.cs
│ │ ├── TranslatorGeneralSettingsPage.xaml
│ │ ├── TranslatorGeneralSettingsPage.xaml.cs
│ │ ├── XiaoniuTransSettingsPage.xaml
│ │ └── XiaoniuTransSettingsPage.xaml.cs
├── SettingsWindow.xaml
├── SettingsWindow.xaml.cs
├── TransWinSettingsWindow.xaml
├── TransWinSettingsWindow.xaml.cs
├── TranslateWindow.xaml
├── TranslateWindow.xaml.cs
├── UserControls
│ ├── GameNameDialog.xaml
│ ├── GameNameDialog.xaml.cs
│ ├── SelectTransLangDialog.xaml
│ └── SelectTransLangDialog.xaml.cs
├── Utils.cs
├── app.manifest
├── lang
│ ├── en-US.xaml
│ └── zh-CN.xaml
├── logo.ico
└── textRepairPlugins
│ ├── __init__.py
│ └── example.py
├── MisakaTranslator.sln
├── OCRLibrary
├── BaiduGeneralOCR.cs
├── ImageProcFunc.cs
├── OCRCommon.cs
├── OCREngine.cs
├── OCRLibrary.csproj
├── Properties
│ └── AssemblyInfo.cs
├── ScreenCapture.cs
├── Tesseract5OCR.cs
└── TesseractOCR.cs
├── README.md
├── README_EN.md
├── SQLHelperLibrary
├── App.config
├── GameLibraryHelper.cs
├── Properties
│ └── AssemblyInfo.cs
├── SQLHelper.cs
└── SQLHelperLibrary.csproj
├── THANKLIST.MD
├── TTSHelperLibrary
├── Properties
│ └── AssemblyInfo.cs
├── TTSHelperLibrary.csproj
└── TextSpeechHelper.cs
├── TextHookLibrary
├── ClipboardNotification.cs
├── ProcessHelper.cs
├── Properties
│ └── AssemblyInfo.cs
├── RecvEventArgs.cs
├── TextHookHandle.cs
├── TextHookHandle_DLL.cs
├── TextHookLibrary.csproj
└── TextHostLib.cs
├── TextRepairLibrary
├── Properties
│ └── AssemblyInfo.cs
├── TextRepair.cs
└── TextRepairLibrary.csproj
├── TransOptimizationLibrary
├── AfterTransHandle.cs
├── BeforeTransHandle.cs
├── NounTransOptimization.cs
├── Properties
│ └── AssemblyInfo.cs
└── TransOptimizationLibrary.csproj
├── TranslatorLibrary
├── AlapiTranslator.cs
├── ArtificialTranslator.cs
├── BaiduTranslator.cs
├── CaiyunTranslator.cs
├── CommonFunction.cs
├── DreyeTranslator.cs
├── GoogleCNTranslator.cs
├── ITranslator.cs
├── JBeijingTranslator.cs
├── KingsoftFastAITTranslator.cs
├── Properties
│ └── AssemblyInfo.cs
├── TencentFYJTranslator.cs
├── TencentOldTranslator.cs
├── TranslatorLibrary.csproj
├── XiaoniuTranslator.cs
├── YoudaoTranslator.cs
└── app.config
├── background.png
└── index.html
/.github/ISSUE_TEMPLATE/Bug_Report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug Report
3 | about: Bug 反馈
4 | title: ''
5 | labels: bug
6 | assignees: ''
7 |
8 | ---
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | **关于哪一项功能**
17 |
18 |
19 | **问题描述**
20 |
21 |
22 |
23 | **应用版本**
24 |
25 |
26 |
27 | **系统信息**
28 |
29 |
30 |
31 | **错误信息**
32 |
33 |
34 |
35 |
36 | **附加截图**
37 |
38 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/Feature_Request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature Request
3 | about: 功能建议
4 | title: ''
5 | labels: enhancement
6 | assignees: ''
7 |
8 | ---
9 |
10 | **关于哪一项功能**
11 |
12 |
13 |
14 | **期望的效果**
15 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/TODO.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: TODO
3 | about: 待办事项
4 | title: ''
5 | labels: todo
6 | assignees: ''
7 |
8 | ---
9 |
10 | **要实现的功能**
11 |
12 |
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 | on: push
3 |
4 | jobs:
5 | build:
6 | runs-on: windows-latest
7 | steps:
8 | - uses: actions/checkout@v2
9 | - uses: microsoft/setup-msbuild@v1
10 | - run: msbuild -v:m -r
11 |
--------------------------------------------------------------------------------
/About.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jsc6924/MisakaPatcher/aed7035179a799608a350c5ec3bfc75c56015a12/About.jpg
--------------------------------------------------------------------------------
/AliyunRequestHandler/.gitignore:
--------------------------------------------------------------------------------
1 | api-token
2 | node_modules/
--------------------------------------------------------------------------------
/AliyunRequestHandler/index.js:
--------------------------------------------------------------------------------
1 | var getRawBody = require('raw-body');
2 | var getFormBody = require('body/form');
3 | var body = require('body');
4 | var axios = require('axios');
5 | var fs = require('fs');
6 |
7 |
8 | /*
9 | To enable the initializer feature (https://help.aliyun.com/document_detail/156876.html)
10 | please implement the initializer function as below:
11 | exports.initializer = (context, callback) => {
12 | console.log('initializing');
13 | callback(null, '');
14 | };
15 | */
16 |
17 | exports.handler = (req, resp, context) => {
18 | var api_token = fs.readFileSync('api-token', 'utf8').trim();
19 |
20 | var params = {
21 | path: req.path,
22 | queries: req.queries,
23 | headers: req.headers,
24 | method : req.method,
25 | requestURI : req.url,
26 | clientIP : req.clientIP,
27 | }
28 |
29 | getRawBody(req, async function(err, body) {
30 | for (var key in req.queries) {
31 | var value = req.queries[key];
32 | resp.setHeader(key, value);
33 | }
34 | try {
35 | const strBody = body;
36 | body = JSON.parse(body);
37 | console.log(body);
38 | const owner = "jsc723";
39 | const repo = "misaka-patches-headers";
40 | const fileName = `${body['game']}|${body['author']}|${body['md5']}`
41 | const path = `headers/${fileName}`;
42 | const content = Buffer.from(strBody, 'utf-8').toString('base64');
43 |
44 | const result = await axios.post(`https://gitee.com/api/v5/repos/${owner}/${repo}/contents/${path}`, {
45 | access_token: api_token,
46 | content: content,
47 | message: 'create patch for' + body['game']
48 | });
49 | console.log(result.data);
50 | resp.send("success");
51 | } catch (error) {
52 | if (error.response) {
53 | // The request was made and the server responded with a status code
54 | // that falls out of the range of 2xx
55 | console.log(error.response.data);
56 | console.log(error.response.status);
57 | console.log(error.response.headers);
58 | resp.send("error: " + error.response.data.message);
59 | } else if (error.request) {
60 | // The request was made but no response was received
61 | // `error.request` is an instance of XMLHttpRequest in the browser and an instance of
62 | // http.ClientRequest in node.js
63 | console.log(error.request);
64 | resp.send("error: " + error.request);
65 | } else {
66 | // Something happened in setting up the request that triggered an Error
67 | console.log('Error', error.message);
68 | resp.send("error: " + error.message);
69 | }
70 | }
71 | });
72 |
73 | /*
74 | getFormBody(req, function(err, formBody) {
75 | for (var key in req.queries) {
76 | var value = req.queries[key];
77 | resp.setHeader(key, value);
78 | }
79 | params.body = formBody;
80 | console.log(formBody);
81 | resp.send(JSON.stringify(params));
82 | });
83 | */
84 | }
--------------------------------------------------------------------------------
/AliyunRequestHandler/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ServerlessRequestHandler",
3 | "lockfileVersion": 2,
4 | "requires": true,
5 | "packages": {
6 | "": {
7 | "dependencies": {
8 | "axios": "^0.21.1"
9 | }
10 | },
11 | "node_modules/axios": {
12 | "version": "0.21.1",
13 | "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz",
14 | "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==",
15 | "dependencies": {
16 | "follow-redirects": "^1.10.0"
17 | }
18 | },
19 | "node_modules/follow-redirects": {
20 | "version": "1.13.3",
21 | "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.3.tgz",
22 | "integrity": "sha512-DUgl6+HDzB0iEptNQEXLx/KhTmDb8tZUHSeLqpnjpknR70H0nC2t9N73BK6fN4hOvJ84pKlIQVQ4k5FFlBedKA==",
23 | "funding": [
24 | {
25 | "type": "individual",
26 | "url": "https://github.com/sponsors/RubenVerborgh"
27 | }
28 | ],
29 | "engines": {
30 | "node": ">=4.0"
31 | },
32 | "peerDependenciesMeta": {
33 | "debug": {
34 | "optional": true
35 | }
36 | }
37 | }
38 | },
39 | "dependencies": {
40 | "axios": {
41 | "version": "0.21.1",
42 | "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz",
43 | "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==",
44 | "requires": {
45 | "follow-redirects": "^1.10.0"
46 | }
47 | },
48 | "follow-redirects": {
49 | "version": "1.13.3",
50 | "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.3.tgz",
51 | "integrity": "sha512-DUgl6+HDzB0iEptNQEXLx/KhTmDb8tZUHSeLqpnjpknR70H0nC2t9N73BK6fN4hOvJ84pKlIQVQ4k5FFlBedKA=="
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/AliyunRequestHandler/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "dependencies": {
3 | "axios": "^0.21.1"
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/AliyunRequestHandler/test.js:
--------------------------------------------------------------------------------
1 | const axios = require('axios');
2 | var fs = require('fs');
3 | async function f1() {
4 | const owner = "jsc723";
5 | const repo = "misaka-patches-headers";
6 | const path = "headers/test3";
7 | const plain = "你好";
8 | const api_token = fs.readFileSync('api-token', 'utf8').trim();
9 | const buffer = Buffer.from(plain, 'utf-8').toString('base64');
10 |
11 | try {
12 | var result = await axios.post(`https://gitee.com/api/v5/repos/${owner}/${repo}/contents/${path}`, {
13 | access_token: api_token,
14 | content: buffer,
15 | message: 'test'
16 | });
17 | console.log(result.status);
18 | console.log(result.data);
19 | } catch (error) {
20 | if (error.response) {
21 | // The request was made and the server responded with a status code
22 | // that falls out of the range of 2xx
23 | console.log(error.response.data);
24 | console.log(error.response.status);
25 | console.log(error.response.headers);
26 | } else if (error.request) {
27 | // The request was made but no response was received
28 | // `error.request` is an instance of XMLHttpRequest in the browser and an instance of
29 | // http.ClientRequest in node.js
30 | console.log(error.request);
31 | } else {
32 | // Something happened in setting up the request that triggered an Error
33 | console.log('Error', error.message);
34 | }
35 | console.log(error.config);
36 | }
37 | return result;
38 | }
39 |
40 | var a = f1();
41 |
--------------------------------------------------------------------------------
/ArtificialTransHelperLibrary/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("ArtificialTransHelperLibrary")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ArtificialTransHelperLibrary")]
13 | [assembly: AssemblyCopyright("Copyright © 2020")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 会使此程序集中的类型
18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("a6568552-a4d0-4546-ace5-d8a710ee7e0e")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
33 | //通过使用 "*",如下所示:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # 我该如何为这个项目作出贡献?
2 |
3 | ## 反馈BUG
4 |
5 | 请[新建Issue](https://github.com/hanmin0822/MisakaTranslator/issues/new/choose),并选择Bug Report模板,按照模板中的说明反馈BUG。
6 |
7 | ## 功能建议
8 |
9 | 请[新建Issue](https://github.com/hanmin0822/MisakaTranslator/issues/new/choose),并选择Feature Request模板,按照模板中的说明提交功能建议。
10 |
11 | ## 贡献代码
12 |
13 | 您可以直接Fork本项目,并且进行修改和编译,建议使用Visual Studio。
14 |
15 | 在修改时请注意,2.0beta3之前的版本运行时需要调用Textractor的CLI版本读输出,但原版的控制台输出可能导致本软件无法读取或读取存在问题,针对CLI版本的修改如下,请自行编译后使用。
16 |
17 | * [hanmin0822/Textractor](https://github.com/hanmin0822/Textractor)
18 |
19 | ### 代码规范
20 |
21 | 本项目代码质量并不高,代码风格也不要求统一,但请尽量追求清晰易读。
22 |
23 | 编码规范可以参考[C#编码规范](https://gist.github.com/zhuqling/a2700703d088b8746f0c)
24 |
25 | ### 提交Pull Requset
26 |
27 | 本项目不要求特定的PR格式,在正文中写清楚所做的更改即可。
28 |
--------------------------------------------------------------------------------
/DictionaryHelperLibrary/IDict.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace DictionaryHelperLibrary
8 | {
9 | public interface IDict
10 | {
11 | ///
12 | /// 字典API初始化
13 | ///
14 | /// 参数一 一般是appID或者路径(为路径时参数二无效)
15 | /// 参数二 一般是密钥
16 | void DictInit(string param1, string param2);
17 |
18 | ///
19 | /// 查询一次辞典
20 | ///
21 | /// 源单词
22 | /// 查询结果,如果查询有错误会返回空,可以通过GetLastError来获取错误
23 | string SearchInDict(string sourceWord);
24 |
25 | ///
26 | /// 返回最后一次错误的ID或原因
27 | ///
28 | ///
29 | string GetLastError();
30 |
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/DictionaryHelperLibrary/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("DictionaryHelperLibrary")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("DictionaryHelperLibrary")]
13 | [assembly: AssemblyCopyright("Copyright © 2020")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 会使此程序集中的类型
18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("ebe31abb-efb0-4a46-a8e0-655f614f88d9")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
33 | //通过使用 "*",如下所示:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/DictionaryHelperLibrary/XxgJpzhDict.cs:
--------------------------------------------------------------------------------
1 | using SQLHelperLibrary;
2 | using System;
3 | using System.Linq;
4 | using System.Text.RegularExpressions;
5 |
6 | namespace DictionaryHelperLibrary
7 | {
8 | ///
9 | /// 小学馆日中词典
10 | ///
11 | public class XxgJpzhDict : IDict
12 | {
13 | private SQLHelper _sqlHelper;
14 | private string _errorInfo;
15 |
16 | public string GetLastError()
17 | {
18 | return _errorInfo;
19 | }
20 |
21 | public string SearchInDict(string sourceWord)
22 | {
23 | var lst = _sqlHelper.ExecuteReader($"SELECT explanation FROM xiaoxueguanrizhong WHERE word LIKE '%{sourceWord}%';", 1);
24 |
25 | if (lst != null) return lst.Aggregate(string.Empty, (current, t) => current + t[0] + "\n");
26 | _errorInfo = "DB Error:" + _sqlHelper.GetLastError();
27 | return null;
28 |
29 | }
30 |
31 | public void DictInit(string param1, string param2)
32 | {
33 | _sqlHelper = new SQLHelper(param1);
34 | }
35 |
36 | ///
37 | /// 去掉HTML标记,改为换行
38 | ///
39 | ///
40 | ///
41 | public static string RemoveHTML(string src)
42 | {
43 | if (src == null)
44 | {
45 | return null;
46 | }
47 |
48 | var tmp = Regex.Replace(src, "<[^>]+>", string.Empty);
49 | tmp = Regex.Replace(tmp, "&[^;]+;", string.Empty);
50 |
51 | var arr = tmp.Split(new[] { "\\n" }, StringSplitOptions.None);
52 |
53 | return arr.Aggregate(string.Empty, (current, s) => current + s + "\n");
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/KeyboardMouseHookLibrary/FindWindowInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace KeyboardMouseHookLibrary
9 | {
10 | public class FindWindowInfo
11 | {
12 | [DllImport("user32.dll", EntryPoint = "WindowFromPoint")]//指定坐标处窗体句柄
13 | public static extern int WindowFromPoint(
14 | int xPoint,
15 | int yPoint
16 | );
17 |
18 | [DllImport("user32.dll", EntryPoint = "GetWindowText")]
19 | public static extern int GetWindowText(
20 | int hWnd,
21 | StringBuilder lpString,
22 | int nMaxCount
23 | );
24 |
25 | [DllImport("user32.dll", EntryPoint = "GetClassName")]
26 | public static extern int GetClassName(
27 | int hWnd,
28 | StringBuilder lpString,
29 | int nMaxCont
30 | );
31 |
32 | [DllImport("User32.dll", CharSet = CharSet.Auto)]
33 | public static extern int GetWindowThreadProcessId(
34 | IntPtr hwnd,
35 | out int ID
36 | );
37 |
38 | ///
39 | /// 获取指定坐标处窗口的句柄
40 | ///
41 | ///
42 | ///
43 | ///
44 | public static int GetWindowHWND(int mouseX, int mouseY)
45 | {
46 |
47 | int hwnd = WindowFromPoint(mouseX, mouseY);
48 | return hwnd;
49 | }
50 |
51 | ///
52 | /// 根据HWND获得窗口标题
53 | ///
54 | ///
55 | ///
56 | public static string GetWindowName(int hwnd)
57 | {
58 | StringBuilder name = new StringBuilder(256);
59 | GetWindowText(hwnd, name, 256);
60 | return name.ToString();
61 | }
62 |
63 | ///
64 | /// 根据HWND获得类名
65 | ///
66 | ///
67 | ///
68 | public static string GetWindowClassName(int hwnd)
69 | {
70 | StringBuilder name = new StringBuilder(256);
71 | GetClassName(hwnd, name, 256);
72 | return name.ToString();
73 | }
74 |
75 | ///
76 | /// 根据HWND获得进程ID
77 | ///
78 | ///
79 | ///
80 | public static int GetProcessIDByHWND(int hwnd)
81 | {
82 | int oo;
83 | IntPtr ip = new IntPtr(hwnd);
84 | GetWindowThreadProcessId(ip, out oo);
85 | return oo;
86 | }
87 |
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/KeyboardMouseHookLibrary/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("KeyboardMouseHookLibrary")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("KeyboardMouseHookLibrary")]
13 | [assembly: AssemblyCopyright("Copyright © 2020")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 会使此程序集中的类型
18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("1ae9ea11-9fa0-4d30-b16e-ecf7183dec7a")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
33 | //通过使用 "*",如下所示:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/KeyboardMouseMonitor/KeyboardMouseMonitor.cpp:
--------------------------------------------------------------------------------
1 | /*************************************************
2 | * 由于.NET下使用全局键盘鼠标钩子总是会出现回调事件
3 | * 没有反应的情况,故使用C++单写一个进程,C#中调用
4 | * 这个EXE并进行通信,获取键鼠钩子事件。
5 | * 启动传参为: 钩子类型(1=鼠标 2=键盘) 指定键值(见代码)
6 | * 当指定键动作时输出一行返回值
7 | * 使用时将这个项目单独编译,生成的EXE文件放入lib中即可
8 | *************************************************/
9 |
10 | #include "pch.h"
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 |
17 | using namespace std;
18 |
19 | int keyCode;
20 |
21 | LRESULT CALLBACK mymouse(int nCode, WPARAM wParam, LPARAM lParam)
22 | {
23 | MOUSEHOOKSTRUCT *mhookstruct = (MOUSEHOOKSTRUCT*)lParam;
24 | POINT pt = mhookstruct->pt;
25 |
26 | if (keyCode == 1) {
27 | if (wParam == WM_LBUTTONUP) {
28 | cout << "MouseAction " << pt.x << " " << pt.y << endl;
29 | }
30 | }
31 | else if (keyCode == 2) {
32 | if (wParam == WM_RBUTTONUP) {
33 | cout << "MouseAction " << pt.x << " " << pt.y << endl;
34 | }
35 | }
36 |
37 | return CallNextHookEx(NULL, nCode, wParam, lParam);
38 | }
39 |
40 | LRESULT CALLBACK mykeyboard(int nCode, WPARAM wParam, LPARAM lParam)
41 | {
42 | PKBDLLHOOKSTRUCT pKeyboardHookStruct = (PKBDLLHOOKSTRUCT)lParam;
43 |
44 | if (wParam == WM_KEYUP) {
45 | if (pKeyboardHookStruct->vkCode == keyCode) {
46 | cout << "KeyboardAction" << endl;
47 | }
48 | }
49 |
50 | return CallNextHookEx(NULL, nCode, wParam, lParam);
51 | }
52 |
53 |
54 | int main(int argc, char* argv[])
55 | {
56 |
57 | if (argc != 3) {
58 | return -1;
59 | }
60 |
61 | HHOOK hook = 0;
62 | int actID = atoi(argv[1]);
63 | keyCode = atoi(argv[2]);
64 | if (actID == 1) {
65 | //鼠标 keyCode=1代表左键 keyCode=2代表右键
66 | hook = SetWindowsHookEx(WH_MOUSE_LL, mymouse, 0, 0);
67 | }
68 | else if (actID == 2) {
69 | //键盘 keyCode代表对应键的ASCII码
70 | hook = SetWindowsHookEx(WH_KEYBOARD_LL, mykeyboard, 0, 0);
71 | }
72 |
73 | if (hook == NULL) {
74 | cout << "hookFailed" << endl;
75 | }
76 |
77 | MSG msg;
78 | while (GetMessage(&msg, NULL, NULL, NULL))
79 | {
80 | }
81 | UnhookWindowsHookEx(hook);
82 | return 0;
83 | }
84 |
85 |
--------------------------------------------------------------------------------
/KeyboardMouseMonitor/KeyboardMouseMonitor.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 头文件
20 |
21 |
22 |
23 |
24 | 源文件
25 |
26 |
27 | 源文件
28 |
29 |
30 |
--------------------------------------------------------------------------------
/KeyboardMouseMonitor/pch.cpp:
--------------------------------------------------------------------------------
1 | // pch.cpp: 与预编译标头对应的源文件;编译成功所必需的
2 |
3 | #include "pch.h"
4 |
5 | // 一般情况下,忽略此文件,但如果你使用的是预编译标头,请保留它。
6 |
--------------------------------------------------------------------------------
/KeyboardMouseMonitor/pch.h:
--------------------------------------------------------------------------------
1 | // 入门提示:
2 | // 1. 使用解决方案资源管理器窗口添加/管理文件
3 | // 2. 使用团队资源管理器窗口连接到源代码管理
4 | // 3. 使用输出窗口查看生成输出和其他消息
5 | // 4. 使用错误列表窗口查看错误
6 | // 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目
7 | // 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件
8 |
9 | #ifndef PCH_H
10 | #define PCH_H
11 |
12 | // TODO: 添加要在此处预编译的标头
13 |
14 | #endif //PCH_H
15 |
--------------------------------------------------------------------------------
/MecabHelperLibrary/MecabHelper.cs:
--------------------------------------------------------------------------------
1 | using MeCab;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace MecabHelperLibrary
9 | {
10 | public class MecabHelper : WordSpliter
11 | {
12 | private MeCabParam Parameter;
13 | private MeCabTagger Tagger;
14 |
15 | public MecabHelper() {
16 | Parameter = new MeCabParam();
17 | Tagger = MeCabTagger.Create(Parameter);
18 | }
19 |
20 | public void Dispose()
21 | {
22 | Tagger.Dispose();
23 | }
24 |
25 | ///
26 | /// 处理句子,对句子进行分词,得到结果
27 | ///
28 | ///
29 | ///
30 | public List SentenceHandle(string sentence) {
31 |
32 | List ret = new List();
33 |
34 | foreach (var node in Tagger.ParseToNodes(sentence))
35 | {
36 | if (node.CharType > 0)
37 | {
38 | var features = node.Feature.Split(',');
39 |
40 | WordInfo mwi = new WordInfo {
41 | Word = node.Surface,
42 | PartOfSpeech = features[0],
43 | Description = features[1],
44 | Feature = node.Feature
45 | };
46 |
47 | //加这一步是为了防止乱码进入分词导致无法读取假名
48 | if (features.Length >= 8)
49 | {
50 | mwi.Kana = features[7];
51 | }
52 |
53 | ret.Add(mwi);
54 | }
55 | }
56 |
57 | return ret;
58 | }
59 |
60 |
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/MecabHelperLibrary/NoWordSplit.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace MecabHelperLibrary
8 | {
9 |
10 | public class NoWordSplit : WordSpliter
11 | {
12 | public List SentenceHandle(string sentence)
13 | {
14 | List ret = new List(1);
15 | WordInfo info = new WordInfo();
16 | info.Word = sentence;
17 | ret.Add(info);
18 | return ret;
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/MecabHelperLibrary/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("MecabHelperLibrary")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("MecabHelperLibrary")]
13 | [assembly: AssemblyCopyright("Copyright © 2020")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 会使此程序集中的类型
18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("82fde770-321e-4433-8e05-8803850f24db")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
33 | //通过使用 "*",如下所示:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/MecabHelperLibrary/WordSpliter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace MecabHelperLibrary
8 | {
9 | public interface WordSpliter
10 | {
11 | List SentenceHandle(string sentence);
12 | }
13 |
14 | public struct WordInfo
15 | {
16 |
17 | ///
18 | /// 单词
19 | ///
20 | public string Word;
21 |
22 | ///
23 | /// 词性
24 | ///
25 | public string PartOfSpeech;
26 |
27 | ///
28 | /// 词性说明
29 | ///
30 | public string Description;
31 |
32 | ///
33 | /// 假名
34 | ///
35 | public string Kana;
36 |
37 | ///
38 | /// Mecab能提供的关于这个词的详细信息 CSV表示
39 | ///
40 | public string Feature;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/MisakaPatchPackager/AesEncrypt.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Text;
4 | using System.Security.Cryptography;
5 |
6 | namespace MisakaPatchPackager
7 | {
8 | class AesEncrypt : IEncrypter
9 | {
10 | static byte[] iv = new byte[] { 6, 3, 2, 4, 4, 7, 2, 9, 0, 1, 0, 3, 6, 6, 8, 2 };
11 | static string Key = "7y41ca4o)pa2ea233bU^[0q4315a*+16";
12 | static Aes aes;
13 | static AesEncrypt()
14 | {
15 | aes = Aes.Create();
16 | aes.IV = iv;
17 | aes.Key = Encoding.UTF8.GetBytes(Key);
18 | }
19 | public string EncryptString(string plainText)
20 | {
21 | byte[] array;
22 |
23 | ICryptoTransform encryptor = aes.CreateEncryptor(aes.Key, aes.IV);
24 |
25 | using (MemoryStream memoryStream = new MemoryStream())
26 | {
27 | using (CryptoStream cryptoStream = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write))
28 | {
29 | using (StreamWriter streamWriter = new StreamWriter(cryptoStream))
30 | {
31 | streamWriter.Write(plainText);
32 | }
33 |
34 | array = memoryStream.ToArray();
35 | }
36 | }
37 |
38 | return Convert.ToBase64String(array);
39 | }
40 |
41 | public string DecryptString(string cipherText)
42 | {
43 | byte[] buffer = Convert.FromBase64String(cipherText);
44 |
45 | ICryptoTransform decryptor = aes.CreateDecryptor(aes.Key, aes.IV);
46 |
47 | using (MemoryStream memoryStream = new MemoryStream(buffer))
48 | {
49 | using (CryptoStream cryptoStream = new CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read))
50 | {
51 | using (StreamReader streamReader = new StreamReader(cryptoStream))
52 | {
53 | return streamReader.ReadToEnd();
54 | }
55 | }
56 | }
57 | }
58 | }
59 | }
--------------------------------------------------------------------------------
/MisakaPatchPackager/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/MisakaPatchPackager/IEncrypter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace MisakaPatchPackager
8 | {
9 | public interface IEncrypter
10 | {
11 | string EncryptString(string plainText);
12 | string DecryptString(string cipherText);
13 |
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/MisakaPatchPackager/NopEncrypter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace MisakaPatchPackager
8 | {
9 | class NopEncrypter: IEncrypter
10 | {
11 | public string EncryptString(string plainText)
12 | {
13 | return plainText;
14 | }
15 | public string DecryptString(string cipherText)
16 | {
17 | return cipherText;
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/MisakaPatchPackager/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("MisakaPatchPackager")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("MisakaPatchPackager")]
13 | [assembly: AssemblyCopyright("Copyright © 2021")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 会使此程序集中的类型
18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("38796814-f08e-4468-a3de-dcdb876b326a")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
33 | //通过使用 "*",如下所示:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/MisakaPatchPackager/XorEncrypt.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.IO;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Diagnostics;
8 | using System.Globalization;
9 |
10 | namespace MisakaPatchPackager
11 | {
12 | class XorEncrypt : IEncrypter
13 | {
14 | static byte[] key = new byte[] { 0x26, 0x3f, 0xa5, 0xbb, 0x4c, 0xf7, 0x9c, 0x19 };
15 | public string EncryptString(string plainText)
16 | {
17 | byte[] array;
18 |
19 | using (MemoryStream memoryStream = new MemoryStream())
20 | {
21 | using (StreamWriter streamWriter = new StreamWriter(memoryStream))
22 | {
23 | streamWriter.Write(plainText);
24 | }
25 | array = memoryStream.ToArray();
26 | Xor(array);
27 | }
28 | return Convert.ToBase64String(array);
29 | }
30 |
31 | public string DecryptString(string cipherText)
32 | {
33 | byte[] buffer = Convert.FromBase64String(cipherText);
34 | Xor(buffer);
35 | using (MemoryStream memoryStream = new MemoryStream(buffer))
36 | {
37 | using (StreamReader streamReader = new StreamReader(memoryStream))
38 | {
39 | return streamReader.ReadToEnd();
40 | }
41 | }
42 | }
43 |
44 | private static void Xor(byte[] array)
45 | {
46 | int i = 3;
47 | for(int j = 0; j < array.Length; j++)
48 | {
49 | array[j] ^= key[i];
50 | i = (i + 1) % key.Length;
51 | }
52 | }
53 | }
54 | }
--------------------------------------------------------------------------------
/MisakaPatchPackager/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/AddOptWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/AddOptWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Shapes;
14 | using TransOptimizationLibrary;
15 |
16 | namespace MisakaTranslator_WPF
17 | {
18 | ///
19 | /// AddOptWindow.xaml 的交互逻辑
20 | ///
21 | public partial class AddOptWindow : Window
22 | {
23 | public AddOptWindow(string src = "")
24 | {
25 | InitializeComponent();
26 | this.Topmost = true;
27 |
28 | List wordtype = new List()
29 | {
30 | "人名",
31 | "地名"
32 | };
33 |
34 | srcText.Text = src;
35 | wordTypeCombox.ItemsSource = wordtype;
36 | }
37 |
38 | private void ConfirmBtn_Click(object sender, RoutedEventArgs e)
39 | {
40 | if (srcWord.Text != "" && dstWord.Text != "" && wordTypeCombox.SelectedIndex != -1)
41 | {
42 | NounTransOptimization opt = new NounTransOptimization("" + Common.GameID, Common.UsingSrcLang, Common.UsingDstLang);
43 | bool res = opt.AddNounTrans(srcWord.Text, wordTypeCombox.SelectedIndex + 1, dstWord.Text);
44 | if (res)
45 | {
46 | HandyControl.Controls.Growl.InfoGlobal(Application.Current.Resources["AddOptWin_Success_Hint"].ToString());
47 | }
48 | else {
49 | HandyControl.Controls.Growl.ErrorGlobal(Application.Current.Resources["AddOptWin_Error_Hint"].ToString());
50 | }
51 | }
52 | }
53 | }
54 | }
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/Appearance.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/ArtificialTransAddWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/ArtificialTransAddWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using ArtificialTransHelperLibrary;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 | using System.Windows.Controls;
9 | using System.Windows.Data;
10 | using System.Windows.Documents;
11 | using System.Windows.Input;
12 | using System.Windows.Media;
13 | using System.Windows.Media.Imaging;
14 | using System.Windows.Shapes;
15 |
16 | namespace MisakaTranslator_WPF
17 | {
18 | ///
19 | /// ArtificialTransAddWindow.xaml 的交互逻辑
20 | ///
21 | public partial class ArtificialTransAddWindow : Window
22 | {
23 | private string secondTransRes;
24 |
25 | public ArtificialTransAddWindow(string src,string trans,string secondTrans)
26 | {
27 | InitializeComponent();
28 |
29 | srcText.Text = src;
30 | transText.Text = trans;
31 |
32 | secondTransRes = secondTrans;
33 |
34 | this.Topmost = true;
35 | }
36 |
37 | private void ConfirmBtn_Click(object sender, RoutedEventArgs e)
38 | {
39 | ArtificialTransHelper ath = new ArtificialTransHelper(Convert.ToString(Common.GameID));
40 |
41 | bool res = ath.UpdateTrans(srcText.Text,transText.Text);
42 | if (res)
43 | {
44 | HandyControl.Controls.Growl.InfoGlobal(Application.Current.Resources["ArtificialTransWin_Success_Hint"].ToString());
45 | }
46 | else
47 | {
48 | HandyControl.Controls.Growl.ErrorGlobal(Application.Current.Resources["ArtificialTransWin_Error_Hint"].ToString());
49 | }
50 | }
51 |
52 | private void ResetBtn_Click(object sender, RoutedEventArgs e)
53 | {
54 | transText.Text = "";
55 | }
56 |
57 | private void SecondTransBtn_Click(object sender, RoutedEventArgs e)
58 | {
59 | transText.Text = secondTransRes;
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/ComicTranslator/ImageProcWindow.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/DictResWindow.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/DictResWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using DictionaryHelperLibrary;
2 | using HandyControl.Controls;
3 | using MecabHelperLibrary;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows;
10 | using System.Windows.Controls;
11 | using System.Windows.Data;
12 | using System.Windows.Documents;
13 | using System.Windows.Input;
14 | using System.Windows.Media;
15 | using System.Windows.Media.Imaging;
16 | using System.Windows.Shapes;
17 | using TTSHelperLibrary;
18 |
19 | namespace MisakaTranslator_WPF
20 | {
21 | ///
22 | /// DictResWindow.xaml 的交互逻辑
23 | ///
24 | public partial class DictResWindow : System.Windows.Window
25 | {
26 | private string sourceWord;
27 | private TextSpeechHelper _textSpeechHelper;
28 | private IDict _dict;
29 |
30 | public DictResWindow(string word,string kana = "----", TextSpeechHelper tsh = null)
31 | {
32 | sourceWord = word;
33 | InitializeComponent();
34 | if (tsh == null)
35 | {
36 | _textSpeechHelper = new TextSpeechHelper();
37 | }
38 | else {
39 | _textSpeechHelper = tsh;
40 | }
41 |
42 |
43 | if (Common.appSettings.ttsVoice == "")
44 | {
45 | Growl.InfoGlobal(Application.Current.Resources["TranslateWin_NoTTS_Hint"].ToString());
46 | }
47 | else
48 | {
49 | _textSpeechHelper.SetTTSVoice(Common.appSettings.ttsVoice);
50 | _textSpeechHelper.SetVolume(Common.appSettings.ttsVolume);
51 | _textSpeechHelper.SetRate(Common.appSettings.ttsRate);
52 | }
53 |
54 | if (Common.appSettings.xxgPath != string.Empty)
55 | {
56 | _dict = new XxgJpzhDict();
57 | _dict.DictInit(Common.appSettings.xxgPath, string.Empty);
58 | }
59 |
60 | string ret = _dict.SearchInDict(sourceWord);
61 |
62 | SourceWord.Text = sourceWord;
63 |
64 | Kana.Text = kana;
65 |
66 | this.Topmost = true;
67 | DicResText.Text = XxgJpzhDict.RemoveHTML(ret);
68 | }
69 |
70 | ~DictResWindow() {
71 | _textSpeechHelper = null;
72 | _dict = null;
73 | }
74 |
75 | private void TTS_Btn_Click(object sender, RoutedEventArgs e)
76 | {
77 | _textSpeechHelper.SpeakAsync(sourceWord);
78 | }
79 |
80 | private void Search_Btn_Click(object sender, RoutedEventArgs e)
81 | {
82 | System.Diagnostics.Process.Start("https://www.baidu.com/s?wd=" + sourceWord);
83 | }
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/GameGuideWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/GlobalOCRWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/GuidePages/ChooseLanguagePage.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
25 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/GuidePages/Completation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jsc6924/MisakaPatcher/aed7035179a799608a350c5ec3bfc75c56015a12/MisakaTranslator-WPF/GuidePages/Completation.png
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/GuidePages/CompletationPage.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/GuidePages/CompletationPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 |
16 | namespace MisakaTranslator_WPF.GuidePages
17 | {
18 | ///
19 | /// CompletationPage.xaml 的交互逻辑
20 | ///
21 | public partial class CompletationPage : Page
22 | {
23 | public CompletationPage()
24 | {
25 | InitializeComponent();
26 | }
27 |
28 | private void ConfirmBtn_Click(object sender, RoutedEventArgs e)
29 | {
30 | //使用路由事件机制通知窗口来完成下一步操作
31 | PageChangeRoutedEventArgs args = new PageChangeRoutedEventArgs(PageChange.PageChangeRoutedEvent, this);
32 | args.XamlPath = "1";//表示完成
33 | this.RaiseEvent(args);
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/GuidePages/Hook/ChooseGamePage.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/GuidePages/Hook/ChooseGamePage.xaml.cs:
--------------------------------------------------------------------------------
1 | using SQLHelperLibrary;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 | using System.Windows.Controls;
9 | using System.Windows.Data;
10 | using System.Windows.Documents;
11 | using System.Windows.Input;
12 | using System.Windows.Media;
13 | using System.Windows.Media.Imaging;
14 | using System.Windows.Navigation;
15 | using System.Windows.Shapes;
16 | using TextHookLibrary;
17 |
18 | namespace MisakaTranslator_WPF.GuidePages.Hook
19 | {
20 | ///
21 | /// ChooseGamePage.xaml 的交互逻辑
22 | ///
23 | public partial class ChooseGamePage : Page
24 | {
25 | private Dictionary lstProcess;
26 | private int GamePid;
27 | private List SameNameGameProcessList;
28 |
29 | public ChooseGamePage()
30 | {
31 | InitializeComponent();
32 | GamePid = -1;
33 | lstProcess = ProcessHelper.GetProcessList_Name_PID();
34 | GameProcessCombox.ItemsSource = lstProcess.Keys;
35 | }
36 |
37 | private void GameProcessCombox_SelectionChanged(object sender, SelectionChangedEventArgs e)
38 | {
39 | GamePid = lstProcess[(string)GameProcessCombox.SelectedValue];
40 | SameNameGameProcessList = ProcessHelper.FindSameNameProcess(GamePid);
41 | AutoHookTag.Text = Application.Current.Resources["ChooseGamePage_AutoHookTag_Begin"].ToString() + SameNameGameProcessList.Count + Application.Current.Resources["ChooseGamePage_AutoHookTag_End"].ToString();
42 | }
43 |
44 | private void ConfirmButton_Click(object sender, RoutedEventArgs e)
45 | {
46 | if (GamePid != -1)
47 | {
48 | if (SameNameGameProcessList.Count == 1)
49 | {
50 | Common.textHooker = new TextHookHandle(lstProcess[(string)GameProcessCombox.SelectedValue]);
51 | }
52 | else
53 | {
54 | Common.textHooker = new TextHookHandle(SameNameGameProcessList);
55 | }
56 |
57 | Common.textHooker.Init(!(bool)x64GameCheckBox.IsChecked);
58 |
59 |
60 | Common.GameID = -1;
61 | string filepath = Common.FindProcessPath(GamePid);
62 | if (filepath != "") {
63 | Common.GameID = GameLibraryHelper.GetGameID(filepath);
64 | }
65 | SQLHelper sqliteH = new SQLHelper();
66 | sqliteH.ExecuteSql(
67 | $"UPDATE game_library SET isx64 = '{x64GameCheckBox.IsChecked}' WHERE gameid = {Common.GameID};");
68 |
69 |
70 | //使用路由事件机制通知窗口来完成下一步操作
71 | PageChangeRoutedEventArgs args = new PageChangeRoutedEventArgs(PageChange.PageChangeRoutedEvent, this);
72 | args.XamlPath = "GuidePages/Hook/ChooseHookFuncPage.xaml";
73 | this.RaiseEvent(args);
74 | }
75 | else {
76 | HandyControl.Controls.Growl.Error(Application.Current.Resources["ChooseGamePage_NextErrorHint"].ToString());
77 | }
78 |
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/GuidePages/Hook/ReChooseHookFuncPage.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/GuidePages/Hook/ReChooseHookFuncPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 | using System.Windows.Controls;
9 | using System.Windows.Data;
10 | using System.Windows.Documents;
11 | using System.Windows.Input;
12 | using System.Windows.Media;
13 | using System.Windows.Media.Imaging;
14 | using System.Windows.Navigation;
15 | using System.Windows.Shapes;
16 | using TextHookLibrary;
17 |
18 | namespace MisakaTranslator_WPF.GuidePages.Hook
19 | {
20 | ///
21 | /// ReChooseHookFuncPage.xaml 的交互逻辑
22 | ///
23 | public partial class ReChooseHookFuncPage : Page
24 | {
25 | BindingList lstData = new BindingList();
26 | int sum = 0;
27 |
28 | public ReChooseHookFuncPage()
29 | {
30 | InitializeComponent();
31 | HookFunListView.ItemsSource = lstData;
32 | sum = 0;
33 | Common.textHooker.HFRSevent += DataRecvEventHandler;
34 | Common.textHooker.StartHook(Convert.ToBoolean(Common.appSettings.AutoHook));
35 | var task_1 = System.Threading.Tasks.Task.Run(async delegate
36 | {
37 | await System.Threading.Tasks.Task.Delay(3000);
38 | Common.textHooker.Auto_AddHookToGame();
39 | });
40 |
41 | }
42 |
43 | public void DataRecvEventHandler(object sender, HookSelectRecvEventArgs e)
44 | {
45 | Application.Current.Dispatcher.BeginInvoke((Action)(() =>
46 | {
47 | if (e.Index < sum)
48 | {
49 | lstData[e.Index] = e.Data;
50 | }
51 | else
52 | {
53 | lstData.Add(e.Data);
54 | sum++;
55 | }
56 | }));
57 | }
58 |
59 | private void ConfirmBtn_Click(object sender, RoutedEventArgs e)
60 | {
61 | if (HookFunListView.SelectedIndex != -1)
62 | {
63 | //先关闭对本窗口的输出
64 | Common.textHooker.HFRSevent -= DataRecvEventHandler;
65 |
66 | Common.textHooker.MisakaCodeList.Add(lstData[HookFunListView.SelectedIndex].MisakaHookCode);
67 |
68 | //Common.textHooker.DetachUnrelatedHookWhenDataRecv = Convert.ToBoolean(Common.appSettings.AutoDetach);
69 | //用户开启了自动卸载
70 | if (Convert.ToBoolean(Common.appSettings.AutoDetach) == true)
71 | {
72 | List usedHook = new List();
73 | usedHook.Add(lstData[HookFunListView.SelectedIndex].HookAddress);
74 | Common.textHooker.DetachUnrelatedHooks(lstData[HookFunListView.SelectedIndex].GamePID, usedHook);
75 | }
76 |
77 |
78 | //使用路由事件机制通知窗口来完成下一步操作
79 | PageChangeRoutedEventArgs args = new PageChangeRoutedEventArgs(PageChange.PageChangeRoutedEvent, this);
80 | args.XamlPath = "GuidePages/CompletationPage.xaml";
81 | this.RaiseEvent(args);
82 | }
83 |
84 | }
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/GuidePages/OCR/ChooseOCRAreaPage.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/GuidePages/PageChangeRoutedEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 |
9 | namespace MisakaTranslator_WPF.GuidePages
10 | {
11 | public class PageChangeRoutedEventArgs : RoutedEventArgs
12 | {
13 | public PageChangeRoutedEventArgs(RoutedEvent routedEvent, object source) : base(routedEvent, source) { }
14 |
15 | ///
16 | /// 下一页的XAML地址
17 | ///
18 | public string XamlPath { get; set; }
19 |
20 | ///
21 | /// 部分方法需要用到的额外参数
22 | ///
23 | public object ExtraArgs;
24 | }
25 |
26 | public class PageChange
27 | {
28 | public string XamlPath;
29 |
30 | //声明和注册路由事件
31 | public static readonly RoutedEvent PageChangeRoutedEvent =
32 | EventManager.RegisterRoutedEvent("PageChange", RoutingStrategy.Bubble, typeof(EventHandler), typeof(PageChange));
33 |
34 | }
35 |
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 | using System.Windows;
4 |
5 | [assembly : AssemblyTitle("MisakaTranslator_WPF")]
6 | [assembly : AssemblyDescription("")]
7 | [assembly : AssemblyConfiguration("")]
8 | [assembly : AssemblyCompany("")]
9 | [assembly : AssemblyProduct("MisakaTranslator_WPF")]
10 | [assembly : AssemblyCopyright("Copyright © MisakaTranslator")]
11 | [assembly : AssemblyTrademark("")]
12 | [assembly : AssemblyCulture("")]
13 | [assembly : ComVisible(false)]
14 | [assembly : ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
15 | [assembly : AssemblyVersion("2.7.0.0")]
16 | [assembly : AssemblyFileVersion("2.7.0.0")]
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/ScreenCaptureWindow.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
14 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/AboutPage.xaml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
24 |
30 |
36 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/AboutPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 |
16 | namespace MisakaTranslator_WPF.SettingsPages
17 | {
18 | ///
19 | /// AboutPage.xaml 的交互逻辑
20 | ///
21 | public partial class AboutPage : Page
22 | {
23 | public AboutPage()
24 | {
25 | InitializeComponent();
26 | }
27 |
28 | private void BtnHelp_Click(object sender, RoutedEventArgs e)
29 | {
30 | System.Windows.MessageBox.Show("请发送反馈至ja235711@gmail.com");
31 | }
32 |
33 | private void BtnGithub_Click(object sender, RoutedEventArgs e)
34 | {
35 | System.Diagnostics.Process.Start("https://github.com/hanmin0822/MisakaTranslator");
36 | }
37 |
38 | private void BtnGithubEX_Click(object sender, RoutedEventArgs e)
39 | {
40 | System.Diagnostics.Process.Start("https://github.com/jsc723/MisakaPatcher");
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/Aboutv2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jsc6924/MisakaPatcher/aed7035179a799608a350c5ec3bfc75c56015a12/MisakaTranslator-WPF/SettingsPages/Aboutv2.jpg
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/ArtificialTransSettingsPage.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/DictionaryPages/XxgJpZhDictPage.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/DictionaryPages/XxgJpZhDictPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 | using DictionaryHelperLibrary;
16 |
17 | namespace MisakaTranslator_WPF.SettingsPages.DictionaryPages
18 | {
19 | ///
20 | /// XxgJpZhDictPage.xaml 的交互逻辑
21 | ///
22 | public partial class XxgJpZhDictPage : Page
23 | {
24 | public XxgJpZhDictPage()
25 | {
26 | InitializeComponent();
27 | PathBox.Text = Common.appSettings.xxgPath;
28 | }
29 |
30 | private void ChoosePathBtn_Click(object sender, RoutedEventArgs e)
31 | {
32 |
33 | System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog
34 | {
35 | Multiselect = false,
36 | Title = Application.Current.Resources["XxgJpZhDictPage_ChoosePathHint"].ToString(),
37 | Filter = "所有文件(*.*)|*.*"
38 | };
39 | if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
40 | {
41 | if (string.IsNullOrEmpty(dialog.FileName))
42 | {
43 | HandyControl.Controls.Growl.Error(Application.Current.Resources["FilePath_Null_Hint"].ToString());
44 | }
45 | else
46 | {
47 | PathBox.Text = dialog.FileName;
48 | Common.appSettings.xxgPath = PathBox.Text;
49 | }
50 | }
51 | }
52 |
53 | private void TestBtn_Click(object sender, RoutedEventArgs e)
54 | {
55 | IDict dict = new XxgJpzhDict();
56 |
57 | dict.DictInit(Common.appSettings.xxgPath, "");
58 |
59 | string ret = dict.SearchInDict(TestSrcText.Text);
60 | if (ret != null)
61 | {
62 | DictResWindow dictResWindow = new DictResWindow(TestSrcText.Text);
63 | dictResWindow.Show();
64 | }
65 | else
66 | {
67 | HandyControl.Controls.Growl.Error($"查询错误!{dict.GetLastError()}");
68 | }
69 |
70 | }
71 | }
72 | }
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/HookSettingsPage.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/HookSettingsPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 |
5 | namespace MisakaTranslator_WPF.SettingsPages
6 | {
7 | ///
8 | /// HookSettingsPage.xaml 的交互逻辑
9 | ///
10 | public partial class HookSettingsPage : Page
11 | {
12 | public HookSettingsPage()
13 | {
14 | InitializeComponent();
15 |
16 | AutoHookCheckBox.IsChecked = Convert.ToBoolean(Common.appSettings.AutoHook);
17 | AutoDetachCheckBox.IsChecked = Convert.ToBoolean(Common.appSettings.AutoDetach);
18 | }
19 |
20 | private void AutoHookCheckBox_Click(object sender, RoutedEventArgs e)
21 | {
22 | Common.appSettings.AutoHook = Convert.ToString(AutoHookCheckBox.IsChecked);
23 | }
24 |
25 | private void AutoDetachCheckBox_Click(object sender, RoutedEventArgs e)
26 | {
27 | Common.appSettings.AutoDetach = Convert.ToString(AutoDetachCheckBox.IsChecked);
28 | }
29 |
30 | private void Button_Click(object sender, RoutedEventArgs e)
31 | {
32 | if (Common.ExportTextractorHistory())
33 | {
34 | HandyControl.Controls.Growl.Success(Application.Current.Resources["HookSettingsPage_SuccessHint"].ToString());
35 | }
36 | else
37 | {
38 | HandyControl.Controls.Growl.Error(Application.Current.Resources["HookSettingsPage_ErrorHint"].ToString());
39 | }
40 | }
41 |
42 | }
43 | }
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/LESettingsPage.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/LESettingsPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 |
16 | namespace MisakaTranslator_WPF.SettingsPages
17 | {
18 | ///
19 | /// LESettingsPage.xaml 的交互逻辑
20 | ///
21 | public partial class LESettingsPage : Page
22 | {
23 | public LESettingsPage()
24 | {
25 | InitializeComponent();
26 |
27 | PathBox.Text = Common.appSettings.LEPath;
28 | }
29 |
30 | private void ChoosePathBtn_Click(object sender, RoutedEventArgs e)
31 | {
32 | System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog
33 | {
34 | Description = Application.Current.Resources["LESettingsPage_ChooseFilePathHint"].ToString()
35 | };
36 | if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
37 | {
38 | if (string.IsNullOrEmpty(dialog.SelectedPath))
39 | {
40 | HandyControl.Controls.Growl.Error(Application.Current.Resources["FilePath_Null_Hint"].ToString());
41 | }
42 | else
43 | {
44 | PathBox.Text = dialog.SelectedPath;
45 | Common.appSettings.LEPath = PathBox.Text;
46 | }
47 | }
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/OCRPages/BaiduOCRSettingsPage.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/OCRPages/BaiduOCRSettingsPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 | using OCRLibrary;
16 |
17 | namespace MisakaTranslator_WPF.SettingsPages.OCRPages
18 | {
19 | ///
20 | /// BaiduOCRPage.xaml 的交互逻辑
21 | ///
22 | public partial class BaiduOCRPage : Page
23 | {
24 | public BaiduOCRPage()
25 | {
26 | InitializeComponent();
27 | APIKEYBox.Text = Common.appSettings.BDOCR_APIKEY;
28 | SecretKeyBox.Text = Common.appSettings.BDOCR_SecretKey;
29 | }
30 |
31 | private void AuthTestBtn_Click(object sender, RoutedEventArgs e)
32 | {
33 | Common.appSettings.BDOCR_APIKEY = APIKEYBox.Text;
34 | Common.appSettings.BDOCR_SecretKey = SecretKeyBox.Text;
35 |
36 | BaiduGeneralOCR bgocr = new BaiduGeneralOCR();
37 |
38 | bool ret = bgocr.OCR_Init(APIKEYBox.Text, SecretKeyBox.Text);
39 |
40 | if (ret == true)
41 | {
42 | HandyControl.Controls.Growl.Success($"百度OCR {Application.Current.Resources["APITest_Success_Hint"]}");
43 | }
44 | else
45 | {
46 | HandyControl.Controls.Growl.Error($"百度OCR {Application.Current.Resources["APITest_Error_Hint"]}\n{bgocr.GetLastError()}");
47 | }
48 | }
49 |
50 | private void ApplyBtn_Click(object sender, RoutedEventArgs e)
51 | {
52 | System.Diagnostics.Process.Start(BaiduGeneralOCR.GetUrl_allpyAPI());
53 | }
54 |
55 | private void DocBtn_Click(object sender, RoutedEventArgs e)
56 | {
57 | System.Diagnostics.Process.Start(BaiduGeneralOCR.GetUrl_Doc());
58 | }
59 |
60 | private void BillBtn_Click(object sender, RoutedEventArgs e)
61 | {
62 | System.Diagnostics.Process.Start(BaiduGeneralOCR.GetUrl_bill());
63 | }
64 | }
65 | }
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/OCRPages/OCRGeneralSettingsPage.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/OCRPages/TesseractOCR5SettingsPage.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/SoftwareSettingsPage.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/SoftwareSettingsPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 |
16 | namespace MisakaTranslator_WPF.SettingsPages
17 | {
18 | ///
19 | /// SoftwareSettingsPage.xaml 的交互逻辑
20 | ///
21 | public partial class SoftwareSettingsPage : Page
22 | {
23 | public SoftwareSettingsPage()
24 | {
25 | InitializeComponent();
26 |
27 | var appSettingsOnClickCloseButton = Common.appSettings.OnClickCloseButton;
28 | switch (appSettingsOnClickCloseButton)
29 | {
30 | case "Minimization":
31 | MinimizationRadioButton.IsChecked = true;
32 | break;
33 | case "Exit":
34 | ExitRadioButton.IsChecked = true;
35 | break;
36 | }
37 | }
38 |
39 | private void RadioButtonBase_OnClick(object sender, RoutedEventArgs e)
40 | {
41 | var radioButton = sender as RadioButton;
42 | switch (radioButton.Name)
43 | {
44 | case "MinimizationRadioButton":
45 | Common.appSettings.OnClickCloseButton = "Minimization";
46 | break;
47 | case "ExitRadioButton":
48 | Common.appSettings.OnClickCloseButton = "Exit";
49 | break;
50 | }
51 | }
52 | }
53 | }
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/TTSSettingsPage.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/TTSSettingsPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 | using TTSHelperLibrary;
16 |
17 | namespace MisakaTranslator_WPF.SettingsPages
18 | {
19 | ///
20 | /// TTSSettingsPage.xaml 的交互逻辑
21 | ///
22 | public partial class TTSSettingsPage : Page
23 | {
24 | TextSpeechHelper tsh;
25 |
26 | public TTSSettingsPage()
27 | {
28 | tsh = new TextSpeechHelper();
29 | InitializeComponent();
30 |
31 | List lst = tsh.GetAllTTSEngine();
32 | TTSSourceCombox.ItemsSource = lst;
33 |
34 | for (int i = 0; i < lst.Count; i++)
35 | {
36 | if (lst[i] == Common.appSettings.ttsVoice)
37 | {
38 | TTSSourceCombox.SelectedIndex = i;
39 | break;
40 | }
41 | }
42 | VolumeBar.Value = Common.appSettings.ttsVolume;
43 | RateBar.Value = Common.appSettings.ttsRate;
44 | }
45 |
46 | private void TTSSourceCombox_SelectionChanged(object sender, SelectionChangedEventArgs e)
47 | {
48 | tsh.SetTTSVoice((string) TTSSourceCombox.SelectedValue);
49 | }
50 |
51 | private void TestBtn_Click(object sender, RoutedEventArgs e)
52 | {
53 | tsh.SpeakAsync(TestSrcText.Text);
54 | Common.appSettings.ttsVoice = (string) TTSSourceCombox.SelectedValue;
55 | Common.appSettings.ttsVolume = (int) VolumeBar.Value;
56 | Common.appSettings.ttsRate = (int) RateBar.Value;
57 | }
58 |
59 | private void VolumeBar_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
60 | {
61 | tsh.SetVolume((int) VolumeBar.Value);
62 | }
63 |
64 | private void RateBar_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
65 | {
66 | tsh.SetRate((int) RateBar.Value);
67 | }
68 | }
69 | }
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/TranslatorPages/BaiduTransSettingsPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 | using TranslatorLibrary;
16 |
17 | namespace MisakaTranslator_WPF.SettingsPages.TranslatorPages
18 | {
19 | ///
20 | /// BaiduTransSettingsPage.xaml 的交互逻辑
21 | ///
22 | public partial class BaiduTransSettingsPage : Page
23 | {
24 | public BaiduTransSettingsPage()
25 | {
26 | InitializeComponent();
27 | BDTransAppIDBox.Text = Common.appSettings.BDappID;
28 | BDTransSecretKeyBox.Text = Common.appSettings.BDsecretKey;
29 | }
30 |
31 | private void AuthTestBtn_Click(object sender, RoutedEventArgs e)
32 | {
33 | Common.appSettings.BDappID = BDTransAppIDBox.Text;
34 | Common.appSettings.BDsecretKey = BDTransSecretKeyBox.Text;
35 | ITranslator BDTrans = new BaiduTranslator();
36 | BDTrans.TranslatorInit(BDTransAppIDBox.Text, BDTransSecretKeyBox.Text);
37 |
38 | if (BDTrans.Translate("apple", "zh", "en") != null)
39 | {
40 | HandyControl.Controls.Growl.Success($"百度翻译{Application.Current.Resources["APITest_Success_Hint"]}");
41 | }
42 | else
43 | {
44 | HandyControl.Controls.Growl.Error($"百度翻译{Application.Current.Resources["APITest_Error_Hint"]}\n{BDTrans.GetLastError()}");
45 | }
46 | }
47 |
48 | private void ApplyBtn_Click(object sender, RoutedEventArgs e)
49 | {
50 | System.Diagnostics.Process.Start(BaiduTranslator.GetUrl_allpyAPI());
51 | }
52 |
53 | private void DocBtn_Click(object sender, RoutedEventArgs e)
54 | {
55 | System.Diagnostics.Process.Start(BaiduTranslator.GetUrl_Doc());
56 | }
57 |
58 | private void BillBtn_Click(object sender, RoutedEventArgs e)
59 | {
60 | System.Diagnostics.Process.Start(BaiduTranslator.GetUrl_bill());
61 | }
62 |
63 | private void TransTestBtn_Click(object sender, RoutedEventArgs e)
64 | {
65 | ITranslator BDTrans = new BaiduTranslator();
66 | BDTrans.TranslatorInit(Common.appSettings.BDappID, Common.appSettings.BDsecretKey);
67 | string res = BDTrans.Translate(TestSrcText.Text, TestDstLang.Text, TestSrcLang.Text);
68 |
69 | if (res != null)
70 | {
71 | HandyControl.Controls.MessageBox.Show(res, Application.Current.Resources["MessageBox_Result"].ToString());
72 | }
73 | else
74 | {
75 | HandyControl.Controls.Growl.Error(
76 | $"百度翻译{Application.Current.Resources["APITest_Error_Hint"]}\n{BDTrans.GetLastError()}");
77 | }
78 | }
79 | }
80 | }
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/TranslatorPages/CaiyunTransSettingsPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 | using TranslatorLibrary;
16 |
17 | namespace MisakaTranslator_WPF.SettingsPages.TranslatorPages
18 | {
19 | ///
20 | /// CaiyunTransSettingsPage.xaml 的交互逻辑
21 | ///
22 | public partial class CaiyunTransSettingsPage : Page
23 | {
24 | public CaiyunTransSettingsPage()
25 | {
26 | InitializeComponent();
27 | TransTokenBox.Text = Common.appSettings.CaiyunToken;
28 | }
29 |
30 | private void AuthTestBtn_Click(object sender, RoutedEventArgs e)
31 | {
32 | Common.appSettings.CaiyunToken = TransTokenBox.Text;
33 | ITranslator Trans = new CaiyunTranslator();
34 | Trans.TranslatorInit(TransTokenBox.Text, "");
35 | if (Trans.Translate("apple", "zh", "en") != null)
36 | {
37 | HandyControl.Controls.Growl.Success($"彩云小译{Application.Current.Resources["APITest_Success_Hint"]}");
38 | }
39 | else
40 | {
41 | HandyControl.Controls.Growl.Error($"彩云小译{Application.Current.Resources["APITest_Error_Hint"]}\n{Trans.GetLastError()}");
42 | }
43 | }
44 |
45 | private void ApplyBtn_Click(object sender, RoutedEventArgs e)
46 | {
47 | System.Diagnostics.Process.Start(CaiyunTranslator.GetUrl_allpyAPI());
48 | }
49 |
50 | private void DocBtn_Click(object sender, RoutedEventArgs e)
51 | {
52 | System.Diagnostics.Process.Start(CaiyunTranslator.GetUrl_Doc());
53 | }
54 |
55 | private void BillBtn_Click(object sender, RoutedEventArgs e)
56 | {
57 | System.Diagnostics.Process.Start(CaiyunTranslator.GetUrl_bill());
58 | }
59 |
60 | private void TransTestBtn_Click(object sender, RoutedEventArgs e)
61 | {
62 | ITranslator Trans = new CaiyunTranslator();
63 | Trans.TranslatorInit(Common.appSettings.CaiyunToken, "");
64 | string res = Trans.Translate(TestSrcText.Text, TestDstLang.Text, TestSrcLang.Text);
65 | if (res != null)
66 | {
67 | HandyControl.Controls.MessageBox.Show(res, Application.Current.Resources["MessageBox_Result"].ToString());
68 | }
69 | else
70 | {
71 | HandyControl.Controls.Growl.Error($"彩云小译{Application.Current.Resources["APITest_Error_Hint"]}\n{Trans.GetLastError()}");
72 | }
73 | }
74 | }
75 | }
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/TranslatorPages/DreyeTransSettingsPage.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/TranslatorPages/DreyeTransSettingsPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 | using TranslatorLibrary;
16 |
17 | namespace MisakaTranslator_WPF.SettingsPages.TranslatorPages
18 | {
19 | ///
20 | /// DreyeTransSettingsPage.xaml 的交互逻辑
21 | ///
22 | public partial class DreyeTransSettingsPage : Page
23 | {
24 | public DreyeTransSettingsPage()
25 | {
26 | InitializeComponent();
27 | PathBox.Text = Common.appSettings.DreyePath;
28 | }
29 |
30 | private void ChoosePathBtn_Click(object sender, RoutedEventArgs e)
31 | {
32 | System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog();
33 | dialog.Description = Application.Current.Resources["DreyeTransSettingsPage_ChoosePathHint"].ToString();
34 | if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
35 | {
36 | if (string.IsNullOrEmpty(dialog.SelectedPath))
37 | {
38 | HandyControl.Controls.Growl.Error(Application.Current.Resources["FilePath_Null_Hint"].ToString());
39 | }
40 | else
41 | {
42 | PathBox.Text = dialog.SelectedPath;
43 | Common.appSettings.DreyePath = PathBox.Text;
44 | }
45 | }
46 | }
47 |
48 | private void TransTestBtn_Click(object sender, RoutedEventArgs e)
49 | {
50 | ITranslator Trans = new DreyeTranslator();
51 | Trans.TranslatorInit(Common.appSettings.DreyePath, "");
52 | string res = Trans.Translate(TestSrcText.Text, "zh", TestSrcLang.Text);
53 | if (res != null)
54 | {
55 | HandyControl.Controls.MessageBox.Show(res, Application.Current.Resources["MessageBox_Result"].ToString());
56 | }
57 | else
58 | {
59 | HandyControl.Controls.Growl.Error(
60 | $"译典通翻译{Application.Current.Resources["APITest_Error_Hint"]}\n{Trans.GetLastError()}");
61 | }
62 | }
63 | }
64 | }
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/TranslatorPages/JbeijingTransSettingsPage.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/TranslatorPages/JbeijingTransSettingsPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 | using TranslatorLibrary;
16 |
17 | namespace MisakaTranslator_WPF.SettingsPages.TranslatorPages
18 | {
19 | ///
20 | /// JbeijingTransSettingsPage.xaml 的交互逻辑
21 | ///
22 | public partial class JbeijingTransSettingsPage : Page
23 | {
24 | public JbeijingTransSettingsPage()
25 | {
26 | InitializeComponent();
27 | PathBox.Text = Common.appSettings.JBJCTDllPath;
28 | }
29 |
30 | private void TransTestBtn_Click(object sender, RoutedEventArgs e)
31 | {
32 | ITranslator Trans = new JBeijingTranslator();
33 | Trans.TranslatorInit(Common.appSettings.JBJCTDllPath, "");
34 | string res = Trans.Translate(TestSrcText.Text, "", "");
35 | if (res != null)
36 | {
37 | HandyControl.Controls.MessageBox.Show(res, Application.Current.Resources["MessageBox_Result"].ToString());
38 | }
39 | else
40 | {
41 | HandyControl.Controls.Growl.Error(
42 | $"JBeijing翻译{Application.Current.Resources["APITest_Error_Hint"]}\n{Trans.GetLastError()}");
43 | }
44 | }
45 |
46 | private void ChoosePathBtn_Click(object sender, RoutedEventArgs e)
47 | {
48 | System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog();
49 | dialog.Description = Application.Current.Resources["JbeijingTransSettingsPage_ChoosePathHint"].ToString();
50 | if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
51 | {
52 | if (string.IsNullOrEmpty(dialog.SelectedPath))
53 | {
54 | HandyControl.Controls.Growl.Error(Application.Current.Resources["FilePath_Null_Hint"].ToString());
55 | }
56 | else
57 | {
58 | PathBox.Text = dialog.SelectedPath;
59 | Common.appSettings.JBJCTDllPath = PathBox.Text;
60 | }
61 | }
62 | }
63 | }
64 | }
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/TranslatorPages/KingsoftFAITTransSettingsPage.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/TranslatorPages/KingsoftFAITTransSettingsPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 | using TranslatorLibrary;
16 |
17 | namespace MisakaTranslator_WPF.SettingsPages.TranslatorPages
18 | {
19 | ///
20 | /// KingsoftFAITTransSettingsPage.xaml 的交互逻辑
21 | ///
22 | public partial class KingsoftFAITTransSettingsPage : Page
23 | {
24 | public KingsoftFAITTransSettingsPage()
25 | {
26 | InitializeComponent();
27 | PathBox.Text = Common.appSettings.KingsoftFastAITPath;
28 | }
29 |
30 | private void ChoosePathBtn_Click(object sender, RoutedEventArgs e)
31 | {
32 | System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog
33 | {
34 | Description = Application.Current.Resources["KingsoftFAITTransSettingsPage_ChoosePathHint"]
35 | .ToString()
36 | };
37 | if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
38 | {
39 | if (string.IsNullOrEmpty(dialog.SelectedPath))
40 | {
41 | HandyControl.Controls.Growl.Error(Application.Current.Resources["FilePath_Null_Hint"].ToString());
42 | }
43 | else
44 | {
45 | PathBox.Text = dialog.SelectedPath;
46 | Common.appSettings.KingsoftFastAITPath = PathBox.Text;
47 | }
48 | }
49 | }
50 |
51 | private void TransTestBtn_Click(object sender, RoutedEventArgs e)
52 | {
53 | ITranslator Trans = new KingsoftFastAITTranslator();
54 | Trans.TranslatorInit(Common.appSettings.KingsoftFastAITPath, "");
55 | string res = Trans.Translate(TestSrcText.Text, "zh", TestSrcLang.Text);
56 | if (res != null)
57 | {
58 | HandyControl.Controls.MessageBox.Show(res, Application.Current.Resources["MessageBox_Result"].ToString());
59 | }
60 | else
61 | {
62 | HandyControl.Controls.Growl.Error(
63 | $"金山快译翻译{Application.Current.Resources["APITest_Error_Hint"]}\n{Trans.GetLastError()}");
64 | }
65 | }
66 | }
67 | }
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/TranslatorPages/LocalTransSettingsPage.xaml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/TranslatorPages/LocalTransSettingsPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 | using TranslatorLibrary;
16 |
17 | namespace MisakaTranslator_WPF.SettingsPages.TranslatorPages
18 | {
19 | ///
20 | /// JbeijingTransSettingsPage.xaml 的交互逻辑
21 | ///
22 | public partial class LocalTransSettingsPage : Page
23 | {
24 | Dictionary modeLst = new Dictionary()
25 | {
26 | { "低", "low" },
27 | { "中", "medium" },
28 | { "高", "high" }
29 | };
30 | public LocalTransSettingsPage()
31 | {
32 | InitializeComponent();
33 | modeComboBox.ItemsSource = modeLst.Keys;
34 | var lst = modeLst.Values.ToList();
35 | modeComboBox.SelectedIndex = lst.IndexOf(Common.appSettings.LocalTransMode);
36 | }
37 |
38 | private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
39 | {
40 | Common.appSettings.LocalTransMode = modeLst[(string)modeComboBox.SelectedValue];
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/TranslatorPages/TencentFYJTransSettingsPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 | using TranslatorLibrary;
16 |
17 | namespace MisakaTranslator_WPF.SettingsPages.TranslatorPages
18 | {
19 | ///
20 | /// TencentFYJTransSettingsPage.xaml 的交互逻辑
21 | ///
22 | public partial class TencentFYJTransSettingsPage : Page
23 | {
24 | public TencentFYJTransSettingsPage()
25 | {
26 | InitializeComponent();
27 | TransAppIDBox.Text = Common.appSettings.TXappID;
28 | TransSecretKeyBox.Text = Common.appSettings.TXappKey;
29 | }
30 |
31 | private void AuthTestBtn_Click(object sender, RoutedEventArgs e)
32 | {
33 | Common.appSettings.TXappID = TransAppIDBox.Text;
34 | Common.appSettings.TXappKey = TransSecretKeyBox.Text;
35 | ITranslator Trans = new TencentFYJTranslator();
36 | Trans.TranslatorInit(TransAppIDBox.Text, TransSecretKeyBox.Text);
37 | if (Trans.Translate("apple", "zh", "en") != null)
38 | {
39 | HandyControl.Controls.Growl.Success($"翻译君{Application.Current.Resources["APITest_Success_Hint"]}");
40 | }
41 | else
42 | {
43 | HandyControl.Controls.Growl.Error($"翻译君{Application.Current.Resources["APITest_Error_Hint"]}\n{Trans.GetLastError()}");
44 | }
45 | }
46 |
47 | private void ApplyBtn_Click(object sender, RoutedEventArgs e)
48 | {
49 | System.Diagnostics.Process.Start(TencentFYJTranslator.GetUrl_allpyAPI());
50 | }
51 |
52 | private void DocBtn_Click(object sender, RoutedEventArgs e)
53 | {
54 | System.Diagnostics.Process.Start(TencentFYJTranslator.GetUrl_Doc());
55 | }
56 |
57 | private void BillBtn_Click(object sender, RoutedEventArgs e)
58 | {
59 | System.Diagnostics.Process.Start(TencentFYJTranslator.GetUrl_bill());
60 | }
61 |
62 | private void TransTestBtn_Click(object sender, RoutedEventArgs e)
63 | {
64 | ITranslator Trans = new TencentFYJTranslator();
65 | Trans.TranslatorInit(Common.appSettings.TXappID, Common.appSettings.TXappKey);
66 | string res = Trans.Translate(TestSrcText.Text, TestDstLang.Text, TestSrcLang.Text);
67 | if (res != null)
68 | {
69 | HandyControl.Controls.MessageBox.Show(res, Application.Current.Resources["MessageBox_Result"].ToString());
70 | }
71 | else
72 | {
73 | HandyControl.Controls.Growl.Error($"翻译君{Application.Current.Resources["APITest_Error_Hint"]}\n{Trans.GetLastError()}");
74 | }
75 | }
76 | }
77 | }
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/TranslatorPages/TencentOldTransSettingsPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 | using TranslatorLibrary;
16 |
17 | namespace MisakaTranslator_WPF.SettingsPages.TranslatorPages
18 | {
19 | ///
20 | /// TencentOldTransSettingsPage.xaml 的交互逻辑
21 | ///
22 | public partial class TencentOldTransSettingsPage : Page
23 | {
24 | public TencentOldTransSettingsPage()
25 | {
26 | InitializeComponent();
27 | TransAppIDBox.Text = Common.appSettings.TXOSecretId;
28 | TransSecretKeyBox.Text = Common.appSettings.TXOSecretKey;
29 | }
30 |
31 | private void AuthTestBtn_Click(object sender, RoutedEventArgs e)
32 | {
33 | Common.appSettings.TXOSecretId = TransAppIDBox.Text;
34 | Common.appSettings.TXOSecretKey = TransSecretKeyBox.Text;
35 | ITranslator Trans = new TencentOldTranslator();
36 | Trans.TranslatorInit(TransAppIDBox.Text, TransSecretKeyBox.Text);
37 | if (Trans.Translate("apple", "zh", "en") != null)
38 | {
39 | HandyControl.Controls.Growl.Success($"腾讯私人{Application.Current.Resources["APITest_Success_Hint"]}");
40 | }
41 | else
42 | {
43 | HandyControl.Controls.Growl.Error($"腾讯私人{Application.Current.Resources["APITest_Error_Hint"]}\n{Trans.GetLastError()}");
44 | }
45 | }
46 |
47 | private void ApplyBtn_Click(object sender, RoutedEventArgs e)
48 | {
49 | System.Diagnostics.Process.Start(TencentOldTranslator.GetUrl_allpyAPI());
50 | }
51 |
52 | private void DocBtn_Click(object sender, RoutedEventArgs e)
53 | {
54 | System.Diagnostics.Process.Start(TencentOldTranslator.GetUrl_Doc());
55 | }
56 |
57 | private void BillBtn_Click(object sender, RoutedEventArgs e)
58 | {
59 | System.Diagnostics.Process.Start(TencentOldTranslator.GetUrl_bill());
60 | }
61 |
62 | private void TransTestBtn_Click(object sender, RoutedEventArgs e)
63 | {
64 | ITranslator Trans = new TencentOldTranslator();
65 | Trans.TranslatorInit(Common.appSettings.TXOSecretId, Common.appSettings.TXOSecretKey);
66 | string res = Trans.Translate(TestSrcText.Text, TestDstLang.Text, TestSrcLang.Text);
67 | if (res != null)
68 | {
69 | HandyControl.Controls.MessageBox.Show(res, Application.Current.Resources["MessageBox_Result"].ToString());
70 | }
71 | else
72 | {
73 | HandyControl.Controls.Growl.Error($"腾讯私人{Application.Current.Resources["APITest_Error_Hint"]}\n{Trans.GetLastError()}");
74 | }
75 | }
76 | }
77 | }
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/TranslatorPages/TranslatorGeneralSettingsPage.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/TranslatorPages/TranslatorGeneralSettingsPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 | using TranslatorLibrary;
16 |
17 | namespace MisakaTranslator_WPF.SettingsPages
18 | {
19 | ///
20 | /// TranslatorGeneralSettingsPage.xaml 的交互逻辑
21 | ///
22 | public partial class TranslatorGeneralSettingsPage : Page
23 | {
24 | private List TranslatorList;
25 |
26 | private List WordSpliterList;
27 |
28 | public TranslatorGeneralSettingsPage()
29 | {
30 | InitializeComponent();
31 | TranslatorList = CommonFunction.GetTranslatorList();
32 | WordSpliterList = CommonFunction.GetWordSpliterList();
33 | FirstTransCombox.ItemsSource = TranslatorList;
34 | //SecondTransCombox.ItemsSource = TranslatorList;
35 | WordSplitorCombox.ItemsSource = WordSpliterList;
36 |
37 | FirstTransCombox.SelectedIndex = CommonFunction.GetTranslatorIndex(Common.appSettings.FirstTranslator);
38 | //SecondTransCombox.SelectedIndex = CommonFunction.GetTranslatorIndex(Common.appSettings.SecondTranslator);
39 |
40 | EachRowTransCheckBox.IsChecked = Convert.ToBoolean(Common.appSettings.EachRowTrans);
41 |
42 | TransLimitBox.Value = Common.appSettings.TransLimitNums;
43 | }
44 |
45 | private void FirstTransCombox_SelectionChanged(object sender, SelectionChangedEventArgs e)
46 | {
47 | Common.appSettings.FirstTranslator = CommonFunction.lstTranslator[(string)FirstTransCombox.SelectedValue];
48 | }
49 |
50 | //private void SecondTransCombox_SelectionChanged(object sender, SelectionChangedEventArgs e)
51 | //{
52 | // Common.appSettings.SecondTranslator = CommonFunction.lstTranslator[(string)SecondTransCombox.SelectedValue];
53 | //}
54 | private void WordSpliterCombox_SelectionChanged(object sender, SelectionChangedEventArgs e)
55 | {
56 | Common.appSettings.WordSpliter = CommonFunction.lstWordSpliter[(string)WordSplitorCombox.SelectedValue];
57 | }
58 |
59 | private void EachRowTransCheckBox_Click(object sender, RoutedEventArgs e)
60 | {
61 | Common.appSettings.EachRowTrans = Convert.ToString(EachRowTransCheckBox.IsChecked);
62 | }
63 |
64 | private void TransLimitBox_ValueChanged(object sender, HandyControl.Data.FunctionEventArgs e)
65 | {
66 | Common.appSettings.TransLimitNums = (int)TransLimitBox.Value;
67 | }
68 | }
69 | }
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/TranslatorPages/XiaoniuTransSettingsPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 | using TranslatorLibrary;
16 |
17 | namespace MisakaTranslator_WPF.SettingsPages.TranslatorPages
18 | {
19 | ///
20 | /// XiaoniuTransSettingsPage.xaml 的交互逻辑
21 | ///
22 | public partial class XiaoniuTransSettingsPage : Page
23 | {
24 | public XiaoniuTransSettingsPage()
25 | {
26 | InitializeComponent();
27 | TransTokenBox.Text = Common.appSettings.xiaoniuApiKey;
28 | }
29 |
30 | private void AuthTestBtn_Click(object sender, RoutedEventArgs e)
31 | {
32 | Common.appSettings.xiaoniuApiKey = TransTokenBox.Text;
33 | ITranslator Trans = new XiaoniuTranslator();
34 | Trans.TranslatorInit(TransTokenBox.Text, "");
35 | if (Trans.Translate("apple", "zh", "en") != null)
36 | {
37 | HandyControl.Controls.Growl.Success($"小牛翻译{Application.Current.Resources["APITest_Success_Hint"]}");
38 | }
39 | else
40 | {
41 | HandyControl.Controls.Growl.Error($"小牛翻译{Application.Current.Resources["APITest_Error_Hint"]}\n{Trans.GetLastError()}");
42 | }
43 | }
44 |
45 | private void ApplyBtn_Click(object sender, RoutedEventArgs e)
46 | {
47 | System.Diagnostics.Process.Start(XiaoniuTranslator.GetUrl_allpyAPI());
48 | }
49 |
50 | private void DocBtn_Click(object sender, RoutedEventArgs e)
51 | {
52 | System.Diagnostics.Process.Start(XiaoniuTranslator.GetUrl_Doc());
53 | }
54 |
55 | private void BillBtn_Click(object sender, RoutedEventArgs e)
56 | {
57 | System.Diagnostics.Process.Start(XiaoniuTranslator.GetUrl_bill());
58 | }
59 |
60 | private void TransTestBtn_Click(object sender, RoutedEventArgs e)
61 | {
62 | ITranslator Trans = new XiaoniuTranslator();
63 | Trans.TranslatorInit(Common.appSettings.xiaoniuApiKey, "");
64 | string res = Trans.Translate(TestSrcText.Text, TestDstLang.Text, TestSrcLang.Text);
65 | if (res != null)
66 | {
67 | HandyControl.Controls.MessageBox.Show(res, Application.Current.Resources["MessageBox_Result"].ToString());
68 | }
69 | else
70 | {
71 | HandyControl.Controls.Growl.Error($"小牛翻译{Application.Current.Resources["APITest_Error_Hint"]}\n{Trans.GetLastError()}");
72 | }
73 | }
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/UserControls/GameNameDialog.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/UserControls/GameNameDialog.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 | using HandyControl.Controls;
5 | using SQLHelperLibrary;
6 |
7 | namespace MisakaTranslator_WPF
8 | {
9 | ///
10 | /// GameNameDialog.xaml 的交互逻辑
11 | ///
12 | public partial class GameNameDialog : UserControl
13 | {
14 | List gameInfolst;
15 | int gid; //当前选中的顺序,并非游戏ID
16 | public GameNameDialog(List gameInfo, int id)
17 | {
18 | InitializeComponent();
19 | gameInfolst = gameInfo;
20 | gid = id;
21 | }
22 |
23 | private void Button_Click(object sender, RoutedEventArgs e)
24 | {
25 | if (nameBox.Text != "")
26 | {
27 | GameLibraryHelper.UpdateGameNameByID(gameInfolst[gid].GameID, nameBox.Text);
28 | HandyControl.Controls.MessageBox.Show("已修改,重启后生效!", "提示");
29 | }
30 |
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/UserControls/SelectTransLangDialog.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/UserControls/SelectTransLangDialog.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 | using TranslatorLibrary;
16 |
17 | namespace MisakaTranslator_WPF.UserControls
18 | {
19 | ///
20 | /// SelectTransLangDialog.xaml 的交互逻辑
21 | ///
22 | public partial class SelectTransLangDialog : UserControl
23 | {
24 | private readonly List _langList;
25 | ComicTranslator.ComicTransMainWindow _win;
26 |
27 | public SelectTransLangDialog(ComicTranslator.ComicTransMainWindow win)
28 | {
29 | InitializeComponent();
30 |
31 | _win = win;
32 |
33 | _langList = CommonFunction.lstLanguage.Keys.ToList();
34 | SrcLangCombox.ItemsSource = _langList;
35 | DstLangCombox.ItemsSource = _langList;
36 |
37 | SrcLangCombox.SelectedIndex = 2;
38 | DstLangCombox.SelectedIndex = 0;
39 | }
40 |
41 | private void Button_Click(object sender, RoutedEventArgs e)
42 | {
43 | _win.SrcLang = CommonFunction.lstLanguage[_langList[SrcLangCombox.SelectedIndex]];
44 | _win.DstLang = CommonFunction.lstLanguage[_langList[DstLangCombox.SelectedIndex]];
45 |
46 | if (_win.SrcLang == "" || _win.DstLang == "" || _win.SrcLang == _win.DstLang)
47 | {
48 | HandyControl.Controls.Growl.ErrorGlobal(Application.Current.Resources["ChooseLanguagePage_NextErrorHint"].ToString());
49 | _win.Close();
50 | }
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/Utils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Security.Cryptography;
7 | using System.IO;
8 | using System.Net.Http;
9 |
10 | namespace MisakaTranslator_WPF
11 | {
12 | class Utils
13 | {
14 | private static readonly HttpClient HttpClient = new HttpClient();
15 | public static string CalculateMD5(string filename)
16 | {
17 | using (var md5 = MD5.Create())
18 | {
19 | using (var stream = File.OpenRead(filename))
20 | {
21 | var hash = md5.ComputeHash(stream);
22 | return BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
23 | }
24 | }
25 | }
26 | public static HttpClient GetHttpClient()
27 | {
28 | return HttpClient;
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
51 |
58 |
59 |
60 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/logo.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jsc6924/MisakaPatcher/aed7035179a799608a350c5ec3bfc75c56015a12/MisakaTranslator-WPF/logo.ico
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/textRepairPlugins/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jsc6924/MisakaPatcher/aed7035179a799608a350c5ec3bfc75c56015a12/MisakaTranslator-WPF/textRepairPlugins/__init__.py
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/textRepairPlugins/example.py:
--------------------------------------------------------------------------------
1 | # coding=utf-8
2 | # 不加上面那行就不能写中文注释
3 | import re
4 | def process(source):
5 | #去除HTML标签
6 | source = re.sub("<[^>]+>", "", source)
7 | source = re.sub("&[^;]+;", "", source)
8 | #句子去重(根据空格分割句子,取最后一段)
9 | parts = [p for p in source.split(" ") if len(p) > 0]
10 | return parts[-1] if len(parts) != 0 else ""
--------------------------------------------------------------------------------
/OCRLibrary/OCRCommon.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace OCRLibrary
8 | {
9 | public class OCRCommon
10 | {
11 | public static List lstOCR = new List()
12 | {
13 | "BaiduOCR",
14 | "TesseractOCR",
15 | "Tesseract5"
16 | };
17 |
18 | public static List GetOCRList()
19 | {
20 | return lstOCR;
21 | }
22 |
23 | public static OCREngine OCRAuto(string ocr) {
24 | switch (ocr)
25 | {
26 | case "BaiduOCR":
27 | return new BaiduGeneralOCR(); ;
28 | case "TesseractOCR":
29 | return new TesseractOCR(); ;
30 | case "Tesseract5":
31 | return new Tesseract5OCR();
32 | default:
33 | return null;
34 | }
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/OCRLibrary/OCREngine.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace OCRLibrary
9 | {
10 | public abstract class OCREngine
11 | {
12 | protected string errorInfo;
13 | private IntPtr WinHandle;
14 | private Rectangle OCRArea;
15 | private bool isAllWin;
16 | private string imgProc;
17 | private int imgProcParam1;
18 | private int imgProcParam2;
19 | ///
20 | /// OCR处理,将图片上的文字提取得到一句话
21 | ///
22 | /// 欲处理的图片
23 | /// 返回识别结果,如果为空可通过GetLastError得到错误提示
24 | public abstract string OCRProcess(Bitmap img);
25 |
26 | ///
27 | /// OCR处理,根据设定的截图区域自动截图后识别
28 | ///
29 | /// 返回识别结果,如果为空可通过GetLastError得到错误提示
30 | public string OCRProcess()
31 | {
32 | if (OCRArea != null)
33 | {
34 | Bitmap img = new Bitmap(ScreenCapture.GetWindowRectCapture(WinHandle, OCRArea, isAllWin));
35 | Bitmap processedImg = ImageProcFunc.Auto_Thresholding(img, imgProc, imgProcParam1, imgProcParam2);
36 | return OCRProcess(new Bitmap(processedImg));
37 | }
38 | else
39 | {
40 | errorInfo = "未设置截图区域";
41 | return null;
42 | }
43 | }
44 |
45 | ///
46 | /// 设定截图区域
47 | ///
48 | /// (窗口模式)窗口句柄
49 | /// 截图区域
50 | /// 是否全屏截取
51 | public void SetOCRArea(IntPtr handle, Rectangle rec, bool AllWin)
52 | {
53 | WinHandle = handle;
54 | OCRArea = rec;
55 | isAllWin = AllWin;
56 | }
57 |
58 | ///
59 | /// 得到OCR区域截图
60 | ///
61 | ///
62 | public Image GetOCRAreaCap()
63 | {
64 | return ScreenCapture.GetWindowRectCapture(WinHandle, OCRArea, isAllWin);
65 | }
66 |
67 | ///
68 | /// 设置OCR源语言
69 | ///
70 | /// 指定目标语言 OCR识别语言 jpn=日语 eng=英语
71 | public abstract void SetOCRSourceLang(string lang);
72 |
73 | ///
74 | /// 设置OCR图像预处理方法
75 | ///
76 | /// 指定处理方法 ImgFunc_NoDeal=不处理 ImgFunc_OTSU=OTSU二值化处理
77 | public void SetOCRSourceImgProc(string imgProc, int param1, int param2)
78 | {
79 | this.imgProc = imgProc;
80 | this.imgProcParam1 = param1;
81 | this.imgProcParam2 = param2;
82 | }
83 |
84 | ///
85 | /// OCR初始化,对于在线API,参数1和参数2有效
86 | ///
87 | /// 参数一 一般是appID
88 | /// 参数二 一般是密钥
89 | public abstract bool OCR_Init(string param1, string param2);
90 |
91 | ///
92 | /// 返回最后一次错误的ID或原因
93 | ///
94 | public string GetLastError()
95 | {
96 | return errorInfo;
97 | }
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/OCRLibrary/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("OCRLibrary")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("OCRLibrary")]
13 | [assembly: AssemblyCopyright("Copyright © 2020")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 会使此程序集中的类型
18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("b66d98ec-fe39-45b4-9808-ac737c1a49fb")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
33 | //通过使用 "*",如下所示:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/OCRLibrary/Tesseract5OCR.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Drawing;
5 | using System.IO;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace OCRLibrary
11 | {
12 | public class Tesseract5OCR : OCREngine
13 | {
14 | public string srcLangCode;//OCR识别语言 jpn=日语 eng=英语
15 | private string path;
16 | private string args;
17 |
18 | public override string OCRProcess(Bitmap img)
19 | {
20 | Bitmap processedImg = (Bitmap)img.Clone();
21 | try
22 | {
23 | processedImg.Save(Environment.CurrentDirectory + "\\temp\\tmp.png", System.Drawing.Imaging.ImageFormat.Png);
24 | Process p = new Process();
25 | // Redirect the output stream of the child process.
26 | p.StartInfo.UseShellExecute = false;
27 | p.StartInfo.RedirectStandardOutput = true;
28 | p.StartInfo.RedirectStandardError = true;
29 | p.StartInfo.CreateNoWindow = true;
30 | p.StartInfo.FileName = path;
31 | p.StartInfo.Arguments = "temp\\tmp.png temp\\outputbase " + args;
32 | p.Start();
33 | // Wait for the child process to exit before
34 | // reading to the end of its redirected stream.
35 | p.WaitForExit();
36 | // Read the output stream first and then wait.
37 | string output = p.StandardOutput.ReadToEnd(); // usually empty
38 | string err = p.StandardError.ReadToEnd(); // information is all here
39 | if (err.ToLower().Contains("error"))
40 | {
41 | throw new Exception(err);
42 | }
43 | byte[] bs = System.IO.File.ReadAllBytes(Environment.CurrentDirectory + "\\temp\\outputbase.txt");
44 | string result = Encoding.UTF8.GetString(bs);
45 | return result;
46 | }
47 | catch (Exception ex)
48 | {
49 | errorInfo = ex.Message;
50 | return null;
51 | }
52 | }
53 |
54 | public override bool OCR_Init(string path, string args)
55 | {
56 | this.path = path;
57 | this.args = args;
58 | try
59 | {
60 | Directory.CreateDirectory(Environment.CurrentDirectory + "\\temp");
61 | return true;
62 | }
63 | catch (Exception ex)
64 | {
65 | errorInfo = ex.Message;
66 | return false;
67 | }
68 | }
69 |
70 | public override void SetOCRSourceLang(string lang)
71 | {
72 | srcLangCode = lang;
73 | }
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/OCRLibrary/TesseractOCR.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using Tesseract;
8 |
9 | namespace OCRLibrary
10 | {
11 | public class TesseractOCR : OCREngine
12 | {
13 | public string srcLangCode;//OCR识别语言 jpn=日语 eng=英语
14 | private TesseractEngine TessOCR;
15 |
16 | public override string OCRProcess(Bitmap img)
17 | {
18 | try {
19 | var page = TessOCR.Process(img);
20 | string res = page.GetText();
21 | page.Dispose();
22 | return res;
23 | }
24 | catch (Exception ex) {
25 | errorInfo = ex.Message;
26 | return null;
27 | }
28 | }
29 |
30 | public override bool OCR_Init(string param1 = "", string param2 = "")
31 | {
32 | try
33 | {
34 | TessOCR = new TesseractEngine(Environment.CurrentDirectory + "\\tessdata", srcLangCode, EngineMode.Default);
35 | return true;
36 | }
37 | catch(Exception ex)
38 | {
39 | errorInfo = ex.Message;
40 | return false;
41 | }
42 | }
43 | public override void SetOCRSourceLang(string lang)
44 | {
45 | srcLangCode = lang;
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/SQLHelperLibrary/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/SQLHelperLibrary/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("SQLHelperLibrary")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("SQLHelperLibrary")]
13 | [assembly: AssemblyCopyright("Copyright © 2020")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 会使此程序集中的类型
18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("08a96f84-775c-4f7e-90b0-b54780a4ddb9")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
33 | //通过使用 "*",如下所示:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/THANKLIST.MD:
--------------------------------------------------------------------------------
1 | # 贡献者名单
2 |
3 | ## 感谢所有对本软件提供反馈、建议和在制作过程中提供帮助的人
4 |
5 | ### 以下是资助作者开发的网友(排名不分先后)
6 |
7 | * 樱桦
8 | * 昔日
9 | * (空白名)
10 | * 莎狗芙芙
11 | * F+*
12 | * 凌枫Haku
13 | * 镜花╰ァ水月
14 | * WSHCK
15 | * 余悸
16 | * 平野宿地
17 | * 约定的彼方
18 | * Disviel
19 | * 陈旧
20 | * 金风
21 | * 神代杏は勇者である
22 |
23 | ### 以下是热心提供反馈和建议的网友(排名不分先后)
24 |
25 | * Disviel
26 | * 幽寂
27 | * 禦滝尹の介
28 | * 陈旧
29 | * 梓柒
30 | * unlsycn
31 | * woctordho
32 | * lgztx
33 | * 洛奚
34 | * 夜夜
35 | * 神代杏は勇者である
36 | * 迷の子
37 |
38 |
39 |
40 | 如果您也对本软件提供了支持却没有出现在名单上,请联系作者处理,对您造成的不便表示歉意。
41 |
--------------------------------------------------------------------------------
/TTSHelperLibrary/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("TTSHelperLibrary")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("TTSHelperLibrary")]
13 | [assembly: AssemblyCopyright("Copyright © 2020")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 会使此程序集中的类型
18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("dd77c61b-af8a-44be-bac7-745381f84753")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
33 | //通过使用 "*",如下所示:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/TTSHelperLibrary/TTSHelperLibrary.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {DD77C61B-AF8A-44BE-BAC7-745381F84753}
8 | Library
9 | Properties
10 | TTSHelperLibrary
11 | TTSHelperLibrary
12 | v4.6.1
13 | 512
14 | true
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | none
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 | bin\Lite-Release\
35 | TRACE
36 | true
37 | AnyCPU
38 | 7.3
39 | prompt
40 |
41 |
42 | true
43 | bin\Lite-Debug\
44 | DEBUG;TRACE
45 | full
46 | AnyCPU
47 | 7.3
48 | prompt
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/TTSHelperLibrary/TextSpeechHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Speech.Synthesis;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace TTSHelperLibrary
9 | {
10 | public class TextSpeechHelper
11 | {
12 | private SpeechSynthesizer synth;
13 |
14 | public TextSpeechHelper() {
15 | synth = new SpeechSynthesizer();
16 | }
17 |
18 | ~TextSpeechHelper() {
19 | synth = null;
20 | }
21 |
22 | ///
23 | /// 获得当前所有可用的TTS引擎
24 | ///
25 | /// 返回引擎信息的集合
26 | public List GetAllTTSEngine() {
27 | List res = new List();
28 |
29 | foreach (InstalledVoice iv in synth.GetInstalledVoices())
30 | {
31 | res.Add(iv.VoiceInfo.Name);
32 | }
33 |
34 | if (res.Count > 0)
35 | {
36 | return res;
37 | }
38 | else
39 | {
40 | return null;
41 | }
42 | }
43 |
44 | ///
45 | /// 设置TTS语音的音量
46 | ///
47 | /// 音量大小 0-100之间
48 | public void SetVolume(int vol) {
49 | synth.Volume = vol;
50 | }
51 |
52 | ///
53 | /// 设置TTS语音的语速
54 | ///
55 | /// 语速的值 -10~10之间 值越小速度越慢
56 | public void SetRate(int ra)
57 | {
58 | synth.Rate = ra;
59 | }
60 |
61 | ///
62 | /// 设置TTS的语音
63 | ///
64 | /// 通过GetAllTTSEngine()得到的VoiceInfo对象的Name属性
65 | public void SetTTSVoice(string name) {
66 | if (name != null && name != "") {
67 | synth.SelectVoice(name);
68 | }
69 | }
70 |
71 | ///
72 | /// 以同步方式说出字符串的内容。
73 | ///
74 | /// 要说的字符串
75 | public void Speak(string text) {
76 | if (text == null)
77 | return;
78 | synth.Speak(text);
79 | }
80 |
81 | ///
82 | /// 以异步方式说出字符串的内容。
83 | ///
84 | /// 要说的字符串
85 | public void SpeakAsync(string text) {
86 | if (text == null)
87 | return;
88 | synth.SpeakAsync(text);
89 | }
90 |
91 | ///
92 | /// 取消所有排队、 异步语音合成操作。
93 | ///
94 | public void CancelAllSpeakAsync() {
95 | synth.SpeakAsyncCancelAll();
96 | }
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/TextHookLibrary/ClipboardNotification.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows.Forms;
8 |
9 | namespace TextHookLibrary
10 | {
11 | public class ClipboardNotification
12 | {
13 | [DllImport("User32.dll", CharSet = CharSet.Auto)]
14 | public static extern IntPtr SetClipboardViewer(IntPtr hWnd);
15 |
16 | [DllImport("User32.dll", CharSet = CharSet.Auto)]
17 | public static extern bool ChangeClipboardChain(IntPtr hWndRemove, IntPtr hWndNewNext);
18 |
19 | IntPtr winHandle;
20 | IntPtr ClipboardViewerNext;
21 |
22 | public ClipboardNotification(IntPtr winH)
23 | {
24 | winHandle = winH;
25 | }
26 |
27 | public void RegisterClipboardViewer()
28 | {
29 | ClipboardViewerNext = SetClipboardViewer(winHandle);
30 | }
31 |
32 | public void UnregisterClipboardViewer()
33 | {
34 | ChangeClipboardChain(winHandle, ClipboardViewerNext);
35 | }
36 | }
37 |
38 |
39 | ///
40 | /// 剪贴板更新事件
41 | ///
42 | /// 更新的文本
43 | public delegate void ClipboardUpdateEventHandler(string ClipboardText);
44 |
45 | ///
46 | /// 使用一个隐藏窗口来接受窗口消息,对外就是剪贴板监视类
47 | ///
48 | public class ClipboardMonitor : Form
49 | {
50 | public event ClipboardUpdateEventHandler onClipboardUpdate;
51 | private IntPtr hWnd;
52 | public ClipboardNotification cn;
53 |
54 | public ClipboardMonitor(ClipboardUpdateEventHandler onClipboardUpdate)
55 | {
56 | this.onClipboardUpdate = onClipboardUpdate;
57 | this.hWnd = this.Handle;
58 | cn = new ClipboardNotification(hWnd);
59 | cn.RegisterClipboardViewer();
60 | }
61 |
62 | ~ClipboardMonitor()
63 | {
64 | cn.UnregisterClipboardViewer();
65 | }
66 |
67 | protected override void WndProc(ref Message m)
68 | {
69 | switch ((int)m.Msg)
70 | {
71 | case 0x308: //WM_DRAWCLIPBOARD
72 | {
73 | IDataObject iData = Clipboard.GetDataObject();
74 | if (iData != null)
75 | {
76 | string str = (string)iData.GetData(DataFormats.Text);
77 | this.onClipboardUpdate(str);
78 | }
79 | else {
80 | this.onClipboardUpdate("剪贴板更新失败 ClipBoard Update Failed");
81 | }
82 | break;
83 | }
84 | default:
85 | {
86 | base.WndProc(ref m);
87 | break;
88 | }
89 | }
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/TextHookLibrary/ProcessHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace TextHookLibrary
9 | {
10 | public class ProcessHelper
11 | {
12 |
13 | ///
14 | /// 获得当前系统进程列表 形式:直接用于显示的字串和进程PID
15 | ///
16 | ///
17 | public static Dictionary GetProcessList_Name_PID()
18 | {
19 | Dictionary ret = new Dictionary();
20 |
21 | //获取系统进程列表
22 | Process[] ps = Process.GetProcesses();
23 | for (int i = 0; i < ps.Length; i++)
24 | {
25 | Process p = ps[i];
26 | if (p.MainWindowHandle != IntPtr.Zero)
27 | {
28 | string info = "";
29 | info = p.ProcessName + "—" + p.Id;
30 | ret.Add(info, p.Id);
31 | }
32 | }
33 | return ret;
34 | }
35 |
36 | ///
37 | /// 查找同名进程并返回一个进程PID列表
38 | ///
39 | ///
40 | ///
41 | public static List FindSameNameProcess(int pid)
42 | {
43 | List res = new List();
44 | Process[] ps = Process.GetProcesses();
45 | string DesProcessName = "";
46 |
47 | for (int i = 0; i < ps.Length; i++)
48 | {
49 | if (ps[i].Id == pid)
50 | {
51 | DesProcessName = ps[i].ProcessName;
52 | break;
53 | }
54 | }
55 |
56 | for (int i = 0; i < ps.Length; i++)
57 | {
58 | if (ps[i].ProcessName == DesProcessName)
59 | {
60 | res.Add(ps[i]);
61 | }
62 | }
63 |
64 | return res;
65 | }
66 |
67 | ///
68 | /// 根据进程PID找到程序所在路径
69 | ///
70 | ///
71 | ///
72 | public static string FindProcessPath(int pid)
73 | {
74 | string filepath = "";
75 | Process[] ps = Process.GetProcesses();
76 | for (int i = 0; i < ps.Length; i++)
77 | {
78 | if (ps[i].Id == pid)
79 | {
80 | try
81 | {
82 | filepath = ps[i].MainModule.FileName;
83 | }
84 | catch (System.ComponentModel.Win32Exception)
85 | {
86 | continue;
87 | //这个地方直接跳过,是因为32位程序确实会读到64位的系统进程,而系统进程是不能被访问的
88 | //throw ex;
89 | }
90 | break;
91 | }
92 | }
93 | return filepath;
94 | }
95 |
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/TextHookLibrary/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("TextHookLibrary")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("TextHookLibrary")]
13 | [assembly: AssemblyCopyright("Copyright © 2020")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 会使此程序集中的类型
18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("a976d07e-0b39-41b6-b6f7-7022bbfbd3ff")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
33 | //通过使用 "*",如下所示:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/TextHookLibrary/RecvEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace TextHookLibrary
8 | {
9 | ///
10 | /// TextHook数据结构体
11 | ///
12 | public class TextHookData{
13 | ///
14 | /// 游戏进程ID
15 | ///
16 | public int GamePID { set; get; }
17 |
18 | ///
19 | /// Hook入口地址
20 | ///
21 | public string HookAddress { set; get; }
22 |
23 | ///
24 | /// 通用特殊码
25 | ///
26 | public string HookCode { set; get; }
27 |
28 | ///
29 | /// MisakaTranslator专用特殊码
30 | /// 注意 本软件单独处理一套特殊码规则:即Textrator输出的从进程到方法名之间的三组数字做记录
31 | /// 格式如下:特殊码【值1:值2:值3】(值1即HookAddress)
32 | ///
33 | public string MisakaHookCode { set; get; }
34 |
35 | ///
36 | /// Hook方法名
37 | ///
38 | public string HookFunc { set; get; }
39 |
40 | ///
41 | /// 实际内容
42 | ///
43 | public string Data { set; get; }
44 | }
45 |
46 |
47 | ///
48 | /// Hook功能选择界面提供的数据收到事件,满足条件:任何一个不重复的输出都将触发此事件
49 | ///
50 | ///
51 | ///
52 | public delegate void HookFunSelectDataRecvEventHandler(object sender, HookSelectRecvEventArgs e);
53 |
54 | ///
55 | /// Hook功能重新选择界面提供的数据收到事件,满足条件:特殊码满足,但附加特殊码不重复的输出都将触发此事件
56 | ///
57 | ///
58 | ///
59 | public delegate void HookFunReSelectDataRecvEventHandler(object sender, HookSelectRecvEventArgs e);
60 |
61 | ///
62 | /// 翻译界面或文本去重界面提供的数据收到事件,满足条件:特殊码满足,且附加特殊码满足或为NoMulti将触发此事件
63 | ///
64 | ///
65 | ///
66 | public delegate void SolvedDataRecvEventHandler(object sender, SolvedDataRecvEventArgs e);
67 |
68 | public class HookSelectRecvEventArgs : EventArgs
69 | {
70 | //方法序号(仅在HookFunSelectDataRecvEventHandler和HookFunReSelectDataRecvEventHandler事件中有效)
71 | //这个序号可以直接用于ListView
72 | public int Index { get; set;}
73 | public TextHookData Data { get; set; }
74 | }
75 |
76 | public class SolvedDataRecvEventArgs : EventArgs
77 | {
78 | public TextHookData Data { get; set; }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/TextHookLibrary/TextHostLib.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace TextHookLibrary
9 | {
10 | public class TextHostLib
11 | {
12 | public delegate void ProcessEvent(Int32 processId);
13 | public delegate void OnCreateThreadFunc(Int64 threadId,
14 | UInt32 processId,
15 | Int64 address,
16 | Int64 context,
17 | Int64 subcontext,
18 | [MarshalAs(UnmanagedType.LPWStr)] string name,
19 | [MarshalAs(UnmanagedType.LPWStr)] string hookCode
20 | );
21 | public delegate void OnRemoveThreadFunc(Int64 threadId);
22 | public delegate void OnOutputFunc(Int64 threadId, [MarshalAs(UnmanagedType.LPWStr)] string data);
23 |
24 | [DllImport("texthost.dll")]
25 | public static extern Int32 TextHostInit(ProcessEvent OnConnect,
26 | ProcessEvent OnDisconnect,
27 | OnCreateThreadFunc OnCreateThread,
28 | OnRemoveThreadFunc OnRemoveThread,
29 | OnOutputFunc OnOutput
30 | );
31 |
32 | [DllImport("texthost.dll")]
33 | public static extern Int32 InsertHook(UInt32 processId, [MarshalAs(UnmanagedType.LPWStr)] string hookCode);
34 |
35 | [DllImport("texthost.dll")]
36 | public static extern Int32 RemoveHook(UInt32 processId, Int64 address);
37 |
38 | [DllImport("texthost.dll")]
39 | public extern static Int32 InjectProcess(UInt32 processId);
40 |
41 | [DllImport("texthost.dll")]
42 | public extern static Int32 DetachProcess(UInt32 processId);
43 |
44 | [DllImport("texthost.dll")]
45 | public extern static Int32 AddClipboardThread(IntPtr windowHandle);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/TextRepairLibrary/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("TextRepairLibrary")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("TextRepairLibrary")]
13 | [assembly: AssemblyCopyright("Copyright © 2020")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 会使此程序集中的类型
18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("722c0650-3d77-42b2-a754-50f2cb3f4c8b")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
33 | //通过使用 "*",如下所示:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/TransOptimizationLibrary/AfterTransHandle.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace TransOptimizationLibrary
8 | {
9 | public class AfterTransHandle
10 | {
11 | BeforeTransHandle bth;
12 |
13 | public AfterTransHandle(BeforeTransHandle b)
14 | {
15 | bth = b;
16 | }
17 |
18 | ///
19 | /// 外部调用的共用方法,自动进行翻译后处理
20 | ///
21 | /// 通过翻译接口翻译后的句子
22 | /// 处理后句子
23 | public string AutoHandle(string text)
24 | {
25 | if (text == null || text == "")
26 | {
27 | return "";
28 | }
29 |
30 | //目前只支持名词的预处理,处理后检查是否有对话人名,如果有则加上
31 | if (bth.GetPeopleChatName() != "") {
32 | text = bth.GetPeopleChatName() + ": " + text;
33 | }
34 |
35 | return text;
36 | }
37 |
38 |
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/TransOptimizationLibrary/BeforeTransHandle.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace TransOptimizationLibrary
9 | {
10 | public class BeforeTransHandle
11 | {
12 |
13 | NounTransOptimization nto;
14 |
15 |
16 |
17 | public BeforeTransHandle(string gameName,string srcLang,string dstLang) {
18 | if (!Directory.Exists(Environment.CurrentDirectory + "\\TransOptimization"))
19 | Directory.CreateDirectory(Environment.CurrentDirectory + "\\TransOptimization");
20 |
21 | nto = new NounTransOptimization(gameName,srcLang,dstLang);
22 | }
23 |
24 | ///
25 | /// 外部调用的共用方法,自动进行翻译前处理
26 | ///
27 | /// Hook或OCR得到的原句
28 | /// 处理后句子
29 | public string AutoHandle(string text) {
30 | if (text == null || text == "") {
31 | return "";
32 | }
33 |
34 | //暂支持人名地名预处理
35 | return nto.ReplacePeoPleLocNameInSentence(text);
36 |
37 | }
38 |
39 | ///
40 | /// 显示在结果中的对话人名 以 人名:对话 的形式展示
41 | ///
42 | ///
43 | public string GetPeopleChatName() {
44 | return nto.PeopleChatName;
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/TransOptimizationLibrary/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("TransOptimizationLibrary")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("TransOptimizationLibrary")]
13 | [assembly: AssemblyCopyright("Copyright © 2020")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 会使此程序集中的类型
18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("a17b385f-8e6e-4b7d-b3ef-ec08c7a8d115")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
33 | //通过使用 "*",如下所示:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/TranslatorLibrary/ITranslator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace TranslatorLibrary
8 | {
9 | public interface ITranslator
10 | {
11 | ///
12 | /// 翻译API初始化
13 | ///
14 | /// 参数一 一般是appID或者路径(为路径时参数二无效)
15 | /// 参数二 一般是密钥
16 | void TranslatorInit(string param1,string param2);
17 |
18 | ///
19 | /// 翻译一条语句
20 | ///
21 | /// 源文本
22 | /// 目标语言
23 | /// 源语言
24 | /// 翻译后的语句,如果翻译有错误会返回空,可以通过GetLastError来获取错误
25 | string Translate(string sourceText, string desLang, string srcLang);
26 |
27 | ///
28 | /// 返回最后一次错误的ID或原因
29 | ///
30 | ///
31 | string GetLastError();
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/TranslatorLibrary/JBeijingTranslator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace TranslatorLibrary
9 | {
10 | public class JBeijingTranslator : ITranslator
11 | {
12 | /*
13 | * 根据猜测得到的DLL函数 来源 https://github.com/Artikash/VNR-Core/blob/6ed038bda9dcd35696040bd45d31afa6a30e8978/py/libs/jbeijing/jbjct.py
14 | int __cdecl JC_Transfer_Unicode(
15 | HWND hwnd,
16 | UINT fromCodePage,
17 | UINT toCodePage,
18 | int unknown,
19 | int unknown,
20 | LPCWSTR from,
21 | LPWSTR to,
22 | int &toCapacity,
23 | LPWSTR buffer,
24 | int &bufferCapacity)
25 | */
26 |
27 | [DllImport("JBJCT.dll", EntryPoint = "JC_Transfer_Unicode", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
28 | private static extern int JC_Transfer_Unicode(
29 | int hwnd,
30 | uint fromCodePage,
31 | uint toCodePage,
32 | int unknown,
33 | int unknown1,
34 | IntPtr from,
35 | IntPtr to,
36 | ref int toCapacity,
37 | IntPtr buffer,
38 | ref int bufferCapacity);
39 |
40 | public string JBJCTDllPath;//DLL路径
41 | private string errorInfo;//错误信息
42 |
43 | public string GetLastError()
44 | {
45 | return errorInfo;
46 | }
47 |
48 | public string Translate(string sourceText, string desLang, string srcLang)
49 | {
50 | string JBeijingTranslatorPath = JBJCTDllPath;
51 |
52 | if (JBeijingTranslatorPath == "")
53 | {
54 | return null;
55 | }
56 |
57 | /*
58 | CP932 SAP Shift-JIS
59 | CP950 SAP 繁体中文
60 | CP936 SAP 简体中文
61 | */
62 |
63 | string path = Environment.CurrentDirectory;
64 | Environment.CurrentDirectory = JBeijingTranslatorPath;
65 |
66 | IntPtr jp = Marshal.StringToHGlobalUni(sourceText);
67 |
68 | IntPtr jp2 = Marshal.AllocHGlobal(3000);
69 | IntPtr jp3 = Marshal.AllocHGlobal(3000);
70 |
71 | int p1 = 1500;
72 | int p2 = 1500;
73 |
74 | try
75 | {
76 | int a = JC_Transfer_Unicode(0, 932, 936, 1, 1, jp, jp2, ref p1, jp3, ref p2);
77 | }
78 | catch (Exception ex)
79 | {
80 | errorInfo = ex.Message;
81 | return null;
82 | }
83 |
84 | Environment.CurrentDirectory = path;
85 |
86 | string ret = Marshal.PtrToStringAuto(jp2);
87 |
88 | Marshal.FreeHGlobal(jp);
89 | Marshal.FreeHGlobal(jp2);
90 | Marshal.FreeHGlobal(jp3);
91 |
92 | return ret;
93 | }
94 |
95 | public void TranslatorInit(string param1, string param2 = "")
96 | {
97 | JBJCTDllPath = param1;
98 | }
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/TranslatorLibrary/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("TranslatorLibrary")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("TranslatorLibrary")]
13 | [assembly: AssemblyCopyright("Copyright © 2020")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 会使此程序集中的类型
18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("bbebcf78-7bbb-4b19-99ee-87ddea4f3793")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
33 | //通过使用 "*",如下所示:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/TranslatorLibrary/YoudaoTranslator.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Net;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace TranslatorLibrary
11 | {
12 | public class YoudaoTranslator : ITranslator
13 | {
14 | private string errorInfo;//错误信息
15 |
16 | public string GetLastError()
17 | {
18 | return errorInfo;
19 | }
20 |
21 | public string Translate(string sourceText, string desLang, string srcLang)
22 | {
23 | if (sourceText == "" || desLang == "" || srcLang == "")
24 | {
25 | errorInfo = "Param Missing";
26 | return null;
27 | }
28 |
29 | if (desLang == "zh")
30 | desLang = "zh_cn";
31 | if (srcLang == "zh")
32 | srcLang = "zh_cn";
33 |
34 | if (desLang == "jp")
35 | desLang = "ja";
36 | if (srcLang == "jp")
37 | srcLang = "ja";
38 |
39 | // 原文
40 | string q = sourceText;
41 | string retString;
42 |
43 | string trans_type = srcLang + "2" + desLang;
44 | trans_type = trans_type.ToUpper();
45 | string url = "https://fanyi.youdao.com/translate?&doctype=json&type=" + trans_type + "&i=" + q;
46 |
47 | var hc = CommonFunction.GetHttpClient();
48 | try
49 | {
50 | retString = hc.GetStringAsync(url).GetAwaiter().GetResult();
51 | }
52 | catch (System.Net.Http.HttpRequestException ex)
53 | {
54 | errorInfo = ex.Message;
55 | return null;
56 | }
57 | catch (System.Threading.Tasks.TaskCanceledException ex)
58 | {
59 | errorInfo = ex.Message;
60 | return null;
61 | }
62 |
63 | YoudaoTransResult oinfo = JsonConvert.DeserializeObject(retString);
64 |
65 | if (oinfo.errorCode == 0)
66 | {
67 | //得到翻译结果
68 | if (oinfo.translateResult.Count == 1)
69 | {
70 | return string.Join("", oinfo.translateResult[0].Select(x => x.tgt));
71 | }
72 | else
73 | {
74 | errorInfo = "UnknownError";
75 | return null;
76 | }
77 | }
78 | else
79 | {
80 | errorInfo = "ErrorID:" + oinfo.errorCode;
81 | return null;
82 | }
83 | }
84 |
85 | public void TranslatorInit(string param1 = "", string param2 = "")
86 | {
87 | //不用初始化
88 | }
89 | }
90 |
91 | class YoudaoTransResult
92 | {
93 | public string type { get; set; }
94 | public int errorCode { get; set; }
95 | public int elapsedTime { get; set; }
96 | public List> translateResult { get; set; }
97 | }
98 |
99 | class YoudaoTransData {
100 | public string src { get; set; }
101 | public string tgt { get; set; }
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/TranslatorLibrary/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jsc6924/MisakaPatcher/aed7035179a799608a350c5ec3bfc75c56015a12/background.png
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 | This is AutoUpdateCheck's Page.
2 | LatestVersion[2.7.0.0]
3 | DownloadPath[https://hanmin0822.lanzous.com/iSmTQeri98b]
4 |
--------------------------------------------------------------------------------