From 99b056506acfdc7520e06b8a9548e410b7161f85 Mon Sep 17 00:00:00 2001
From: AndromedaMelody <57533055+AndromedaMelody@users.noreply.github.com>
Date: Tue, 30 May 2023 20:06:33 +0800
Subject: [PATCH] Fix & Enhance - Use NuGet GeneratePathProperty - #24 - #181 -
#239
---
MisakaTranslator-WPF/MainWindow.xaml | 81 ++++++++-----------
MisakaTranslator-WPF/MainWindow.xaml.cs | 5 ++
.../MisakaTranslator-WPF.csproj | 26 +++---
.../Properties/LaunchSettings.json | 2 +-
.../Properties/Package.appxmanifest | 4 +-
MisakaTranslator-WPF/TranslateWindow.xaml.cs | 13 ++-
SQLHelperLibrary/GameLibraryHelper.cs | 35 +-------
SQLHelperLibrary/SQLHelperLibrary.csproj | 19 ++---
8 files changed, 80 insertions(+), 105 deletions(-)
diff --git a/MisakaTranslator-WPF/MainWindow.xaml b/MisakaTranslator-WPF/MainWindow.xaml
index 6678c3ae..2a6ddd6a 100644
--- a/MisakaTranslator-WPF/MainWindow.xaml
+++ b/MisakaTranslator-WPF/MainWindow.xaml
@@ -1,42 +1,21 @@
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -45,26 +24,35 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -104,7 +92,7 @@
-
+
@@ -134,4 +122,5 @@
-
\ No newline at end of file
+
+
diff --git a/MisakaTranslator-WPF/MainWindow.xaml.cs b/MisakaTranslator-WPF/MainWindow.xaml.cs
index c904e45f..6afb0dda 100644
--- a/MisakaTranslator-WPF/MainWindow.xaml.cs
+++ b/MisakaTranslator-WPF/MainWindow.xaml.cs
@@ -440,5 +440,10 @@ void GrowlDisableSwitch() {
this.Closing += (o, e) => gw.GetType().GetMethod("Close").Invoke(gw, null); // 关闭主窗口时关闭GrowlWindow否则程序无法退出
}
}
+
+ private void LanguageBtn_Click(object sender, RoutedEventArgs e)
+ {
+ LanguageContextMenu.IsOpen = true;
+ }
}
}
diff --git a/MisakaTranslator-WPF/MisakaTranslator-WPF.csproj b/MisakaTranslator-WPF/MisakaTranslator-WPF.csproj
index 55e535b2..95a181be 100644
--- a/MisakaTranslator-WPF/MisakaTranslator-WPF.csproj
+++ b/MisakaTranslator-WPF/MisakaTranslator-WPF.csproj
@@ -15,14 +15,15 @@
true
MSIX
true
- false
false
-
- false
- false
- false
- false
- false
+
+ $(CustomBeforeMicrosoftCommonTargets);
+ $(PkgMicrosoft_WindowsAppSDK)\build\Microsoft.Build.Msix.props
+
+
+ $(CustomAfterMicrosoftCommonTargets);
+ $(PkgMicrosoft_WindowsAppSDK)\build\Microsoft.Build.Msix.targets
+
@@ -55,14 +56,19 @@
-
+
+
-
- 10.0.14393.0
+ 10.0.14257.0
+
+
+
+
+ $(SupportedOSPlatformVersion)
diff --git a/MisakaTranslator-WPF/Properties/LaunchSettings.json b/MisakaTranslator-WPF/Properties/LaunchSettings.json
index 7567780c..1f3e41ca 100644
--- a/MisakaTranslator-WPF/Properties/LaunchSettings.json
+++ b/MisakaTranslator-WPF/Properties/LaunchSettings.json
@@ -1,6 +1,6 @@
{
"profiles": {
- "MisakaTranslator (Unpackaged)": {
+ "MisakaTranslator (Unpackage)": {
"commandName": "Project",
"nativeDebugging": true
},
diff --git a/MisakaTranslator-WPF/Properties/Package.appxmanifest b/MisakaTranslator-WPF/Properties/Package.appxmanifest
index a465022c..7f307017 100644
--- a/MisakaTranslator-WPF/Properties/Package.appxmanifest
+++ b/MisakaTranslator-WPF/Properties/Package.appxmanifest
@@ -23,8 +23,8 @@
-
-
+
+
diff --git a/MisakaTranslator-WPF/TranslateWindow.xaml.cs b/MisakaTranslator-WPF/TranslateWindow.xaml.cs
index 48a82704..4495bc56 100644
--- a/MisakaTranslator-WPF/TranslateWindow.xaml.cs
+++ b/MisakaTranslator-WPF/TranslateWindow.xaml.cs
@@ -451,7 +451,14 @@ private void UpdateSource(string repairedText)
stackPanel.Orientation = Orientation.Vertical;
stackPanel.Margin = new Thickness(10, 0, 0, 10);
- TextBlock textBlock = new TextBlock();
+ System.Windows.Controls.TextBox textBlock = new()
+ {
+ IsReadOnly = true,
+ Background = new SolidColorBrush(Colors.Transparent),
+ BorderBrush = new SolidColorBrush(Colors.Transparent),
+ Padding = new Thickness(0),
+ Margin = new Thickness(0)
+ };
if (!string.IsNullOrEmpty(SourceTextFont))
{
FontFamily fontFamily = new FontFamily(SourceTextFont);
@@ -771,6 +778,8 @@ private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs
dtimer.Stop();
_mecabHelper.Dispose();
+
+ Common.mainWin.Visibility = Visibility.Visible;
}
@@ -866,6 +875,8 @@ private void TransWin_Loaded(object sender, RoutedEventArgs e)
dtimer.Interval = TimeSpan.FromMilliseconds(10);
dtimer.Tick += dtimer_Tick;
dtimer.Start();
+
+ Common.mainWin.Visibility = Visibility.Collapsed;
}
void dtimer_Tick(object sender, EventArgs e)
diff --git a/SQLHelperLibrary/GameLibraryHelper.cs b/SQLHelperLibrary/GameLibraryHelper.cs
index e8b25748..5ba85781 100644
--- a/SQLHelperLibrary/GameLibraryHelper.cs
+++ b/SQLHelperLibrary/GameLibraryHelper.cs
@@ -83,17 +83,13 @@ public static class GameLibraryHelper
///
/// 创建一个新游戏列表库
///
- public static bool CreateNewGameList()
+ static GameLibraryHelper()
{
var id = sqlHelper.ExecuteSql("CREATE TABLE IF NOT EXISTS game_library(gameid INTEGER PRIMARY KEY AUTOINCREMENT,gamename TEXT,gamefilepath TEXT,transmode INTEGER,src_lang TEXT,dst_lang TEXT,repair_func TEXT,repair_param_a TEXT,repair_param_b TEXT,hookcode TEXT,isMultiHook TEXT,isx64 TEXT,hookcode_custom TEXT);");
if (id == -1)
{
- MessageBox.Show("新建游戏库时发生错误,错误代码:\n" + sqlHelper.GetLastError(), "数据库错误");
- return false;
- }
- else
- {
- return true;
+ MessageBox.Show($"初始化游戏库发生错误,数据库错误代码:\n{sqlHelper.GetLastError()}");
+ throw new Exception(sqlHelper.GetLastError());
}
}
@@ -105,15 +101,6 @@ public static bool CreateNewGameList()
/// 返回游戏ID
public static int GetGameID(string gamePath)
{
-
- if (File.Exists(Environment.CurrentDirectory + "\\MisakaGameLibrary.sqlite") == false)
- {
- if (CreateNewGameList() == false)
- {
- return -1;
- }
- }
-
var ls = sqlHelper.ExecuteReader_OneLine(
$"SELECT gameid FROM game_library WHERE gamefilepath = '{gamePath}';", 1);
@@ -140,14 +127,6 @@ public static int GetGameID(string gamePath)
///
public static List GetAllGameLibrary()
{
- if (File.Exists($"{Environment.CurrentDirectory}\\MisakaGameLibrary.sqlite") == false)
- {
- if (CreateNewGameList() == false)
- {
- return null;
- }
- }
-
var ls = sqlHelper.ExecuteReader("SELECT * FROM game_library;", 13);
if (ls == null)
@@ -199,14 +178,6 @@ public static List GetAllGameLibrary()
///
///
public static GameInfo GetGameInfoByID(int gameID) {
- if (File.Exists(Environment.CurrentDirectory + "\\MisakaGameLibrary.sqlite") == false)
- {
- if (CreateNewGameList() == false)
- {
- return null;
- }
- }
-
var ls = sqlHelper.ExecuteReader_OneLine($"SELECT * FROM game_library WHERE gameid = {gameID};", 13);
if (ls == null)
diff --git a/SQLHelperLibrary/SQLHelperLibrary.csproj b/SQLHelperLibrary/SQLHelperLibrary.csproj
index 0ac41788..8f3216f5 100644
--- a/SQLHelperLibrary/SQLHelperLibrary.csproj
+++ b/SQLHelperLibrary/SQLHelperLibrary.csproj
@@ -6,21 +6,14 @@
-
+
-
-
-
- runtimes\win-x86\native\e_sqlite3.dll
- PreserveNewest
-
-
- runtimes\win-x64\native\e_sqlite3.dll
- PreserveNewest
-
-
-
+
+
+
+
+