feat: add change hotkeys func

main
DESKTOP-3BO4HSG\ksat 2 years ago
parent 84ea248601
commit 471cc632b2

@ -6,41 +6,6 @@ using static STranslate.Helper.NativeMethodHelper;
namespace STranslate.Helper
{
public static class Hotkeys
{
public static class InputTranslate
{
public static byte Modifiers = (byte)KeyModifiers.MOD_ALT;
public static int Key = 65;
public static String Text = "A";
public static bool Conflict = false;
}
public static class CrosswordTranslate
{
public static byte Modifiers = (byte)KeyModifiers.MOD_ALT;
public static int Key = 68;
public static String Text = "D";
public static bool Conflict = false;
}
#if true
public static class ScreenShotTranslate
{
public static byte Modifiers = (byte)KeyModifiers.MOD_ALT;
public static int Key = 83;
public static String Text = "S";
public static bool Conflict = false;
}
#endif
public static class OpenMainWindow
{
public static byte Modifiers = (byte)KeyModifiers.MOD_ALT;
public static int Key = 71;
public static String Text = "G";
public static bool Conflict = false;
}
}
internal class HotkeysHelper
{
@ -107,31 +72,31 @@ namespace STranslate.Helper
{
HotkeysHelper.mainFormHandle = mainFormHandle;
InputTranslateModifiers = Hotkeys.InputTranslate.Modifiers;
InputTranslateKey = Hotkeys.InputTranslate.Key;
CrosswordTranslateModifiers = Hotkeys.CrosswordTranslate.Modifiers;
CrosswordTranslateKey = Hotkeys.CrosswordTranslate.Key;
InputTranslateModifiers = ViewModel.MainVM.Instance.NHotkeys.InputTranslate.Modifiers;
InputTranslateKey = ViewModel.MainVM.Instance.NHotkeys.InputTranslate.Key;
CrosswordTranslateModifiers = ViewModel.MainVM.Instance.NHotkeys.CrosswordTranslate.Modifiers;
CrosswordTranslateKey = ViewModel.MainVM.Instance.NHotkeys.CrosswordTranslate.Key;
#if true
ScreenShotTranslateModifiers = Hotkeys.ScreenShotTranslate.Modifiers;
ScreenShotTranslateKey = Hotkeys.ScreenShotTranslate.Key;
if (Hotkeys.ScreenShotTranslate.Key != 0)
ScreenShotTranslateModifiers = ViewModel.MainVM.Instance.NHotkeys.ScreenShotTranslate.Modifiers;
ScreenShotTranslateKey = ViewModel.MainVM.Instance.NHotkeys.ScreenShotTranslate.Key;
if (ViewModel.MainVM.Instance.NHotkeys.ScreenShotTranslate.Key != 0)
{
Hotkeys.ScreenShotTranslate.Conflict = !NativeMethodHelper.RegisterHotKey(mainFormHandle, ScreenShotTranslateId, Hotkeys.ScreenShotTranslate.Modifiers, Hotkeys.ScreenShotTranslate.Key);
ViewModel.MainVM.Instance.NHotkeys.ScreenShotTranslate.Conflict = !NativeMethodHelper.RegisterHotKey(mainFormHandle, ScreenShotTranslateId, ViewModel.MainVM.Instance.NHotkeys.ScreenShotTranslate.Modifiers, ViewModel.MainVM.Instance.NHotkeys.ScreenShotTranslate.Key);
}
#endif
if (Hotkeys.InputTranslate.Key != 0)
if (ViewModel.MainVM.Instance.NHotkeys.InputTranslate.Key != 0)
{
Hotkeys.InputTranslate.Conflict = !NativeMethodHelper.RegisterHotKey(mainFormHandle, InputTranslateId, Hotkeys.InputTranslate.Modifiers, Hotkeys.InputTranslate.Key);
ViewModel.MainVM.Instance.NHotkeys.InputTranslate.Conflict = !NativeMethodHelper.RegisterHotKey(mainFormHandle, InputTranslateId, ViewModel.MainVM.Instance.NHotkeys.InputTranslate.Modifiers, ViewModel.MainVM.Instance.NHotkeys.InputTranslate.Key);
}
if (Hotkeys.CrosswordTranslate.Key != 0)
if (ViewModel.MainVM.Instance.NHotkeys.CrosswordTranslate.Key != 0)
{
Hotkeys.CrosswordTranslate.Conflict = !NativeMethodHelper.RegisterHotKey(mainFormHandle, CrosswordTranslateId, Hotkeys.CrosswordTranslate.Modifiers, Hotkeys.CrosswordTranslate.Key);
ViewModel.MainVM.Instance.NHotkeys.CrosswordTranslate.Conflict = !NativeMethodHelper.RegisterHotKey(mainFormHandle, CrosswordTranslateId, ViewModel.MainVM.Instance.NHotkeys.CrosswordTranslate.Modifiers, ViewModel.MainVM.Instance.NHotkeys.CrosswordTranslate.Key);
}
if (Hotkeys.OpenMainWindow.Key != 0)
if (ViewModel.MainVM.Instance.NHotkeys.OpenMainWindow.Key != 0)
{
Hotkeys.OpenMainWindow.Conflict = !NativeMethodHelper.RegisterHotKey(mainFormHandle, OpenMainWindowId, Hotkeys.OpenMainWindow.Modifiers, Hotkeys.OpenMainWindow.Key);
ViewModel.MainVM.Instance.NHotkeys.OpenMainWindow.Conflict = !NativeMethodHelper.RegisterHotKey(mainFormHandle, OpenMainWindowId, ViewModel.MainVM.Instance.NHotkeys.OpenMainWindow.Modifiers, ViewModel.MainVM.Instance.NHotkeys.OpenMainWindow.Key);
}
}
@ -153,59 +118,59 @@ namespace STranslate.Helper
/// </summary>
public static void ReRegisterHotKey()
{
if (Hotkeys.InputTranslate.Key == 0)
if (ViewModel.MainVM.Instance.NHotkeys.InputTranslate.Key == 0)
{
UnregisterHotKey(mainFormHandle, InputTranslateId);
}
else if (InputTranslateModifiers != Hotkeys.InputTranslate.Modifiers || InputTranslateKey != Hotkeys.InputTranslate.Key)
else if (InputTranslateModifiers != ViewModel.MainVM.Instance.NHotkeys.InputTranslate.Modifiers || InputTranslateKey != ViewModel.MainVM.Instance.NHotkeys.InputTranslate.Key)
{
{
UnregisterHotKey(mainFormHandle, InputTranslateId);
Hotkeys.InputTranslate.Conflict = !NativeMethodHelper.RegisterHotKey(mainFormHandle, InputTranslateId, Hotkeys.InputTranslate.Modifiers, Hotkeys.InputTranslate.Key);
ViewModel.MainVM.Instance.NHotkeys.InputTranslate.Conflict = !NativeMethodHelper.RegisterHotKey(mainFormHandle, InputTranslateId, ViewModel.MainVM.Instance.NHotkeys.InputTranslate.Modifiers, ViewModel.MainVM.Instance.NHotkeys.InputTranslate.Key);
}
}
InputTranslateModifiers = Hotkeys.InputTranslate.Modifiers;
InputTranslateKey = Hotkeys.InputTranslate.Key;
InputTranslateModifiers = ViewModel.MainVM.Instance.NHotkeys.InputTranslate.Modifiers;
InputTranslateKey = ViewModel.MainVM.Instance.NHotkeys.InputTranslate.Key;
if (Hotkeys.CrosswordTranslate.Key == 0)
if (ViewModel.MainVM.Instance.NHotkeys.CrosswordTranslate.Key == 0)
{
UnregisterHotKey(mainFormHandle, CrosswordTranslateId);
}
else if (CrosswordTranslateModifiers != Hotkeys.CrosswordTranslate.Modifiers || CrosswordTranslateKey != Hotkeys.CrosswordTranslate.Key)
else if (CrosswordTranslateModifiers != ViewModel.MainVM.Instance.NHotkeys.CrosswordTranslate.Modifiers || CrosswordTranslateKey != ViewModel.MainVM.Instance.NHotkeys.CrosswordTranslate.Key)
{
{
UnregisterHotKey(mainFormHandle, CrosswordTranslateId);
Hotkeys.CrosswordTranslate.Conflict = !NativeMethodHelper.RegisterHotKey(mainFormHandle, CrosswordTranslateId, Hotkeys.CrosswordTranslate.Modifiers, Hotkeys.CrosswordTranslate.Key);
ViewModel.MainVM.Instance.NHotkeys.CrosswordTranslate.Conflict = !NativeMethodHelper.RegisterHotKey(mainFormHandle, CrosswordTranslateId, ViewModel.MainVM.Instance.NHotkeys.CrosswordTranslate.Modifiers, ViewModel.MainVM.Instance.NHotkeys.CrosswordTranslate.Key);
}
}
CrosswordTranslateModifiers = Hotkeys.CrosswordTranslate.Modifiers;
CrosswordTranslateKey = Hotkeys.CrosswordTranslate.Key;
CrosswordTranslateModifiers = ViewModel.MainVM.Instance.NHotkeys.CrosswordTranslate.Modifiers;
CrosswordTranslateKey = ViewModel.MainVM.Instance.NHotkeys.CrosswordTranslate.Key;
#if true
if (Hotkeys.ScreenShotTranslate.Key == 0)
if (ViewModel.MainVM.Instance.NHotkeys.ScreenShotTranslate.Key == 0)
{
UnregisterHotKey(mainFormHandle, ScreenShotTranslateId);
}
else if (ScreenShotTranslateModifiers != Hotkeys.ScreenShotTranslate.Modifiers || ScreenShotTranslateKey != Hotkeys.ScreenShotTranslate.Key)
else if (ScreenShotTranslateModifiers != ViewModel.MainVM.Instance.NHotkeys.ScreenShotTranslate.Modifiers || ScreenShotTranslateKey != ViewModel.MainVM.Instance.NHotkeys.ScreenShotTranslate.Key)
{
UnregisterHotKey(mainFormHandle, ScreenShotTranslateId);
Hotkeys.ScreenShotTranslate.Conflict = !NativeMethodHelper.RegisterHotKey(mainFormHandle, ScreenShotTranslateId, Hotkeys.ScreenShotTranslate.Modifiers, Hotkeys.ScreenShotTranslate.Key);
ViewModel.MainVM.Instance.NHotkeys.ScreenShotTranslate.Conflict = !NativeMethodHelper.RegisterHotKey(mainFormHandle, ScreenShotTranslateId, ViewModel.MainVM.Instance.NHotkeys.ScreenShotTranslate.Modifiers, ViewModel.MainVM.Instance.NHotkeys.ScreenShotTranslate.Key);
}
ScreenShotTranslateModifiers = Hotkeys.ScreenShotTranslate.Modifiers;
ScreenShotTranslateKey = Hotkeys.ScreenShotTranslate.Key;
ScreenShotTranslateModifiers = ViewModel.MainVM.Instance.NHotkeys.ScreenShotTranslate.Modifiers;
ScreenShotTranslateKey = ViewModel.MainVM.Instance.NHotkeys.ScreenShotTranslate.Key;
#endif
if (Hotkeys.OpenMainWindow.Key == 0)
if (ViewModel.MainVM.Instance.NHotkeys.OpenMainWindow.Key == 0)
{
UnregisterHotKey(mainFormHandle, OpenMainWindowId);
}
else if (OpenMainWindowModifiers != Hotkeys.OpenMainWindow.Modifiers || OpenMainWindowKey != Hotkeys.OpenMainWindow.Key)
else if (OpenMainWindowModifiers != ViewModel.MainVM.Instance.NHotkeys.OpenMainWindow.Modifiers || OpenMainWindowKey != ViewModel.MainVM.Instance.NHotkeys.OpenMainWindow.Key)
{
UnregisterHotKey(mainFormHandle, OpenMainWindowId);
Hotkeys.OpenMainWindow.Conflict = !NativeMethodHelper.RegisterHotKey(mainFormHandle, OpenMainWindowId, Hotkeys.OpenMainWindow.Modifiers, Hotkeys.OpenMainWindow.Key);
ViewModel.MainVM.Instance.NHotkeys.OpenMainWindow.Conflict = !NativeMethodHelper.RegisterHotKey(mainFormHandle, OpenMainWindowId, ViewModel.MainVM.Instance.NHotkeys.OpenMainWindow.Modifiers, ViewModel.MainVM.Instance.NHotkeys.OpenMainWindow.Key);
}
OpenMainWindowModifiers = Hotkeys.OpenMainWindow.Modifiers;
OpenMainWindowKey = Hotkeys.OpenMainWindow.Key;
OpenMainWindowModifiers = ViewModel.MainVM.Instance.NHotkeys.OpenMainWindow.Modifiers;
OpenMainWindowKey = ViewModel.MainVM.Instance.NHotkeys.OpenMainWindow.Key;
}
}
}

@ -41,6 +41,37 @@ namespace STranslate.Model
Name = "local",
Api = "http://127.0.0.1:8000/translate"
}
},
Hotkeys = new Hotkeys
{
InputTranslate = new InputTranslate
{
Modifiers = 1,
Key = 65,
Text = "Alt + A",
Conflict = false,
},
CrosswordTranslate = new CrosswordTranslate
{
Modifiers = 1,
Key = 68,
Text = "Alt + D",
Conflict = false,
},
ScreenShotTranslate = new ScreenShotTranslate
{
Modifiers = 1,
Key = 83,
Text = "Alt + S",
Conflict = false,
},
OpenMainWindow = new OpenMainWindow
{
Modifiers = 1,
Key = 71,
Text = "Alt + G",
Conflict = false,
},
}
};
}
@ -81,8 +112,56 @@ namespace STranslate.Model
[JsonProperty("servers")]
public Server[] Servers { get; set; }
/// <summary>
/// 热键
/// </summary>
[JsonProperty("hotkeys")]
public Hotkeys Hotkeys { get; set; }
}
public class Hotkeys
{
[JsonProperty("inputTranslate")]
public InputTranslate InputTranslate { get; set; }
[JsonProperty("crosswordTranslate")]
public CrosswordTranslate CrosswordTranslate { get; set; }
[JsonProperty("screenShotTranslate")]
public ScreenShotTranslate ScreenShotTranslate { get; set; }
[JsonProperty("openMainWindow")]
public OpenMainWindow OpenMainWindow { get; set; }
}
public class InputTranslate
{
public byte Modifiers { get; set; }
public int Key { get; set; }
public String Text { get; set; }
public bool Conflict { get; set; }
}
public class CrosswordTranslate
{
public byte Modifiers { get; set; }
public int Key { get; set; }
public String Text { get; set; }
public bool Conflict { get; set; }
}
public class ScreenShotTranslate
{
public byte Modifiers { get; set; }
public int Key { get; set; }
public String Text { get; set; }
public bool Conflict { get; set; }
}
public class OpenMainWindow
{
public byte Modifiers { get; set; }
public int Key { get; set; }
public String Text { get; set; }
public bool Conflict { get; set; }
}
public class Server
{
[JsonProperty("name")]

@ -53,7 +53,10 @@ namespace STranslate.View
vm.OpenMainWin();
});
if (Hotkeys.InputTranslate.Conflict || Hotkeys.CrosswordTranslate.Conflict || Hotkeys.ScreenShotTranslate.Conflict || Hotkeys.OpenMainWindow.Conflict)
if (ViewModel.MainVM.Instance.NHotkeys.InputTranslate.Conflict
|| ViewModel.MainVM.Instance.NHotkeys.CrosswordTranslate.Conflict
|| ViewModel.MainVM.Instance.NHotkeys.ScreenShotTranslate.Conflict
|| ViewModel.MainVM.Instance.NHotkeys.OpenMainWindow.Conflict)
{
MessageBox.Show("全局快捷键有冲突,请前往软件首选项中修改...");
}

@ -6,7 +6,8 @@
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:local="clr-namespace:STranslate.View"
mc:Ignorable="d"
SizeToContent="Height"
SizeToContent="WidthAndHeight"
Loaded="window_Loaded"
WindowStartupLocation="CenterScreen"
Icon="/Images/translate.ico"
Title="STranslate 首选项" Height="450" Width="450">
@ -139,7 +140,8 @@
Grid.Row="1"
Grid.Column="0"
Margin="0,5,0,0" />
<TextBox Cursor="Arrow"
<TextBox x:Name="CrossWordTextBox"
Cursor="Arrow"
Width="200"
Grid.Row="1"
Grid.Column="1"
@ -149,7 +151,8 @@
InputMethod.IsInputMethodEnabled="False"
PreviewKeyDown="HotKeyTextBox_PreviewKeyDown"
KeyUp="CrossWord_KeyUp"/>
<Label Grid.Row="1"
<Label x:Name="CrossWordHotKeyConflictLabel"
Grid.Row="1"
Grid.Column="2"
Margin="0,5,0,0"
Content="热键冲突"
@ -163,15 +166,19 @@
Grid.Row="2"
Grid.Column="0"
Margin="0,5,0,0" />
<TextBox Cursor="Arrow"
<TextBox x:Name="ScreenshotTextBox"
Cursor="Arrow"
Width="200"
Grid.Row="2"
Grid.Column="1"
Margin="0,5,0,0"
CaretBrush="Transparent"
VerticalContentAlignment="Center"
InputMethod.IsInputMethodEnabled="False"/>
<Label Grid.Row="2"
InputMethod.IsInputMethodEnabled="False"
PreviewKeyDown="HotKeyTextBox_PreviewKeyDown"
KeyUp="Screenshot_KeyUp"/>
<Label x:Name="ScreenshotHotKeyConflictLabel"
Grid.Row="2"
Grid.Column="2"
Margin="0,5,0,0"
Content="热键冲突"
@ -185,15 +192,19 @@
Grid.Row="3"
Grid.Column="0"
Margin="0,5,0,0" />
<TextBox Cursor="Arrow"
<TextBox x:Name="InputTextBox"
Cursor="Arrow"
Width="200"
Grid.Row="3"
Grid.Column="1"
Margin="0,5,0,0"
CaretBrush="Transparent"
VerticalContentAlignment="Center"
InputMethod.IsInputMethodEnabled="False"/>
<Label Grid.Row="3"
InputMethod.IsInputMethodEnabled="False"
PreviewKeyDown="HotKeyTextBox_PreviewKeyDown"
KeyUp="Input_KeyUp"/>
<Label x:Name="InputHotKeyConflictLabel"
Grid.Row="3"
Grid.Column="2"
Margin="0,5,0,0"
Content="热键冲突"
@ -207,15 +218,19 @@
Grid.Row="4"
Grid.Column="0"
Margin="0,5,0,0" />
<TextBox Cursor="Arrow"
<TextBox x:Name="ShowMainwinTextBox"
Cursor="Arrow"
Width="200"
Grid.Row="4"
Grid.Column="1"
Margin="0,5,0,0"
CaretBrush="Transparent"
VerticalContentAlignment="Center"
InputMethod.IsInputMethodEnabled="False"/>
<Label Grid.Row="4"
InputMethod.IsInputMethodEnabled="False"
PreviewKeyDown="HotKeyTextBox_PreviewKeyDown"
KeyUp="ShowMainwin_KeyUp"/>
<Label x:Name="ShowMainwinHotKeyConflictLabel"
Grid.Row="4"
Grid.Column="2"
Margin="0,5,0,0"
Content="热键冲突"

@ -1,4 +1,5 @@
using System;
using STranslate.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -30,6 +31,15 @@ namespace STranslate.View
DataContext = ViewModel.SettingsVM.Instance;
}
private void window_Loaded(object sender, RoutedEventArgs e)
{
this.InputTextBox.Text = ViewModel.MainVM.Instance.NHotkeys.InputTranslate.Text;
this.CrossWordTextBox.Text = ViewModel.MainVM.Instance.NHotkeys.CrosswordTranslate.Text;
this.ScreenshotTextBox.Text = ViewModel.MainVM.Instance.NHotkeys.ScreenShotTranslate.Text;
this.ShowMainwinTextBox.Text = ViewModel.MainVM.Instance.NHotkeys.OpenMainWindow.Text;
HotKeyConflictCheck();
}
private byte _hotkeysModifiers;
private int _hotkeysKey;
private string _hotkeysText = string.Empty;
@ -77,7 +87,74 @@ namespace STranslate.View
}
private void CrossWord_KeyUp(object sender, KeyEventArgs e)
{
Key key = (e.Key == Key.System ? e.SystemKey : e.Key);
if (key == Key.LeftShift || key == Key.RightShift
|| key == Key.LeftCtrl || key == Key.RightCtrl
|| key == Key.LeftAlt || key == Key.RightAlt
|| key == Key.LWin || key == Key.RWin)
{
return;
}
ViewModel.MainVM.Instance.NHotkeys.CrosswordTranslate.Modifiers = _hotkeysModifiers;
ViewModel.MainVM.Instance.NHotkeys.CrosswordTranslate.Key = _hotkeysKey;
ViewModel.MainVM.Instance.NHotkeys.CrosswordTranslate.Text = _hotkeysText.ToString();
HotkeysHelper.ReRegisterHotKey();
HotKeyConflictCheck();
}
private void Input_KeyUp(object sender, KeyEventArgs e)
{
Key key = (e.Key == Key.System ? e.SystemKey : e.Key);
if (key == Key.LeftShift || key == Key.RightShift
|| key == Key.LeftCtrl || key == Key.RightCtrl
|| key == Key.LeftAlt || key == Key.RightAlt
|| key == Key.LWin || key == Key.RWin)
{
return;
}
ViewModel.MainVM.Instance.NHotkeys.InputTranslate.Modifiers = _hotkeysModifiers;
ViewModel.MainVM.Instance.NHotkeys.InputTranslate.Key = _hotkeysKey;
ViewModel.MainVM.Instance.NHotkeys.InputTranslate.Text = _hotkeysText.ToString();
HotkeysHelper.ReRegisterHotKey();
HotKeyConflictCheck();
}
private void Screenshot_KeyUp(object sender, KeyEventArgs e)
{
Key key = (e.Key == Key.System ? e.SystemKey : e.Key);
if (key == Key.LeftShift || key == Key.RightShift
|| key == Key.LeftCtrl || key == Key.RightCtrl
|| key == Key.LeftAlt || key == Key.RightAlt
|| key == Key.LWin || key == Key.RWin)
{
return;
}
ViewModel.MainVM.Instance.NHotkeys.ScreenShotTranslate.Modifiers = _hotkeysModifiers;
ViewModel.MainVM.Instance.NHotkeys.ScreenShotTranslate.Key = _hotkeysKey;
ViewModel.MainVM.Instance.NHotkeys.ScreenShotTranslate.Text = _hotkeysText.ToString();
HotkeysHelper.ReRegisterHotKey();
HotKeyConflictCheck();
}
private void ShowMainwin_KeyUp(object sender, KeyEventArgs e)
{
Key key = (e.Key == Key.System ? e.SystemKey : e.Key);
if (key == Key.LeftShift || key == Key.RightShift
|| key == Key.LeftCtrl || key == Key.RightCtrl
|| key == Key.LeftAlt || key == Key.RightAlt
|| key == Key.LWin || key == Key.RWin)
{
return;
}
ViewModel.MainVM.Instance.NHotkeys.OpenMainWindow.Modifiers = _hotkeysModifiers;
ViewModel.MainVM.Instance.NHotkeys.OpenMainWindow.Key = _hotkeysKey;
ViewModel.MainVM.Instance.NHotkeys.OpenMainWindow.Text = _hotkeysText.ToString();
HotkeysHelper.ReRegisterHotKey();
HotKeyConflictCheck();
}
private void HotKeyConflictCheck()
{
this.CrossWordHotKeyConflictLabel.Visibility = ViewModel.MainVM.Instance.NHotkeys.CrosswordTranslate.Conflict ? Visibility.Visible : Visibility.Hidden;
this.ScreenshotHotKeyConflictLabel.Visibility = ViewModel.MainVM.Instance.NHotkeys.ScreenShotTranslate.Conflict ? Visibility.Visible : Visibility.Hidden;
this.InputHotKeyConflictLabel.Visibility = ViewModel.MainVM.Instance.NHotkeys.InputTranslate.Conflict ? Visibility.Visible : Visibility.Hidden;
this.ShowMainwinHotKeyConflictLabel.Visibility = ViewModel.MainVM.Instance.NHotkeys.OpenMainWindow.Conflict ? Visibility.Visible : Visibility.Hidden;
}
}
}

@ -234,6 +234,40 @@ namespace STranslate.ViewModel
{
_globalConfig = ConfigHelper.Instance.ReadConfig<ConfigModel>();
#region 读取热键
NHotkeys = _globalConfig.Hotkeys ?? new Hotkeys
{
InputTranslate = new InputTranslate
{
Modifiers = 1,
Key = 65,
Text = "Alt + A",
Conflict = false,
},
CrosswordTranslate = new CrosswordTranslate
{
Modifiers = 1,
Key = 68,
Text = "Alt + D",
Conflict = false,
},
ScreenShotTranslate = new ScreenShotTranslate
{
Modifiers = 1,
Key = 83,
Text = "Alt + S",
Conflict = false,
},
OpenMainWindow = new OpenMainWindow
{
Modifiers = 1,
Key = 71,
Text = "Alt + G",
Conflict = false,
},
};
#endregion
//读取历史记录数量
var count = _globalConfig.MaxHistoryCount;
SettingsVM.Instance.MaxHistoryCount = (count <= 0 || count >= 1000) ? 100 : count;
@ -290,6 +324,7 @@ namespace STranslate.ViewModel
TargetLanguage = OutputComboSelected,
SelectServer = TranslationInterface.FindIndex(x => x == SelectedTranslationInterface),
Servers = _globalConfig.Servers,
Hotkeys = NHotkeys,
});
}
catch (Exception ex)
@ -442,6 +477,7 @@ namespace STranslate.ViewModel
private static MainVM _instance;
public static MainVM Instance => _instance ?? (_instance = new MainVM());
public Hotkeys NHotkeys;
private bool IsTopmost { get; set; }
private const string TopmostTemplateName = "ButtonTemplateTopmost";
private const string UnTopmostTemplateName = "ButtonTemplateUnTopmost";

Loading…
Cancel
Save