diff --git a/STranslate.Model/ConfigModel.cs b/STranslate.Model/ConfigModel.cs
index 7d3ffb29..8886b2c9 100644
--- a/STranslate.Model/ConfigModel.cs
+++ b/STranslate.Model/ConfigModel.cs
@@ -92,6 +92,11 @@ public partial class ConfigModel : ObservableObject
///
public string CustomFont { get; set; } = ConstStr.DEFAULTFONTNAME;
+ ///
+ /// 鼠标划词取消后是否保留置顶
+ ///
+ public bool IsKeepTopmostAfterMousehook { get; set; } = false;
+
///
/// 服务
///
diff --git a/STranslate/Helper/ConfigHelper.cs b/STranslate/Helper/ConfigHelper.cs
index b75de983..fdad4507 100644
--- a/STranslate/Helper/ConfigHelper.cs
+++ b/STranslate/Helper/ConfigHelper.cs
@@ -160,7 +160,7 @@ public bool WriteConfig(CommonViewModel model)
CurrentConfig.IsRemoveLineBreakGettingWords = model.IsRemoveLineBreakGettingWords;
CurrentConfig.DoubleTapTrayFunc = model.DoubleTapTrayFunc;
CurrentConfig.CustomFont = model.CustomFont;
-
+ CurrentConfig.IsKeepTopmostAfterMousehook = model.IsKeepTopmostAfterMousehook;
WriteConfig(CurrentConfig);
isSuccess = true;
}
@@ -258,6 +258,7 @@ private ConfigModel InitialConfig()
IsRemoveLineBreakGettingWords = false,
DoubleTapTrayFunc = DoubleTapFuncEnum.InputFunc,
CustomFont = ConstStr.DEFAULTFONTNAME,
+ IsKeepTopmostAfterMousehook = false,
SourceLanguage = LanguageEnum.AUTO.GetDescription(),
TargetLanguage = LanguageEnum.AUTO.GetDescription(),
Services =
diff --git a/STranslate/ViewModels/MainViewModel.cs b/STranslate/ViewModels/MainViewModel.cs
index 4cfe6d1c..ac53ddaa 100644
--- a/STranslate/ViewModels/MainViewModel.cs
+++ b/STranslate/ViewModels/MainViewModel.cs
@@ -209,9 +209,12 @@ private void MouseHook(Window view)
}
else
{
- view.Topmost = false;
- IsTopMost = ConstStr.TAGFALSE;
- TopMostContent = ConstStr.UNTOPMOSTCONTENT;
+ if (!(Singleton.Instance.CurrentConfig?.IsKeepTopmostAfterMousehook ?? false))
+ {
+ view.Topmost = false;
+ IsTopMost = ConstStr.TAGFALSE;
+ TopMostContent = ConstStr.UNTOPMOSTCONTENT;
+ }
Singleton.Instance.MouseHookStop();
Singleton.Instance.OnGetwordsHandler -= OnGetwordsHandlerChanged;
ToastHelper.Show("关闭鼠标划词");
diff --git a/STranslate/ViewModels/Preference/CommonViewModel.cs b/STranslate/ViewModels/Preference/CommonViewModel.cs
index 173eac8c..b87daa17 100644
--- a/STranslate/ViewModels/Preference/CommonViewModel.cs
+++ b/STranslate/ViewModels/Preference/CommonViewModel.cs
@@ -55,6 +55,7 @@ private void Reset()
IsRemoveLineBreakGettingWords = Singleton.Instance.CurrentConfig?.IsRemoveLineBreakGettingWords ?? false;
DoubleTapTrayFunc = Singleton.Instance.CurrentConfig?.DoubleTapTrayFunc ?? DoubleTapFuncEnum.InputFunc;
CustomFont = Singleton.Instance.CurrentConfig?.CustomFont ?? ConstStr.DEFAULTFONTNAME;
+ IsKeepTopmostAfterMousehook = Singleton.Instance.CurrentConfig?.IsKeepTopmostAfterMousehook ?? false;
ToastHelper.Show("重置配置", WindowType.Preference);
if (IsStartup)
@@ -213,5 +214,8 @@ public string CustomFont
}
}
}
+
+ [ObservableProperty]
+ private bool isKeepTopmostAfterMousehook = Singleton.Instance.CurrentConfig?.IsKeepTopmostAfterMousehook ?? false;
}
}
diff --git a/STranslate/Views/Preference/CommonPage.xaml b/STranslate/Views/Preference/CommonPage.xaml
index ff2d189d..2261099d 100644
--- a/STranslate/Views/Preference/CommonPage.xaml
+++ b/STranslate/Views/Preference/CommonPage.xaml
@@ -80,7 +80,7 @@
-
+
@@ -91,7 +91,7 @@
-
+
@@ -121,6 +121,12 @@
+
+
+
+
+
+