fix: hot keys conflict message

perf: add keydown keyup
main
DESKTOP-3BO4HSG\ksat 2 years ago
parent 5fbfc19ec3
commit 74eb8755a5

@ -20,11 +20,6 @@ namespace STranslate.View
vm.Mainwin = this;
InitialTray();
//if (HotKeys.InputTranslate.Conflict || HotKeys.CrosswordTranslate.Conflict || HotKeys.ScreenShotTranslate.Conflict)
//{
// MessageBox.Show("全局快捷键有冲突...");
//}
}
/// <summary>
@ -57,6 +52,11 @@ namespace STranslate.View
{
vm.OpenMainWin();
});
if (Hotkeys.InputTranslate.Conflict || Hotkeys.CrosswordTranslate.Conflict || Hotkeys.ScreenShotTranslate.Conflict || Hotkeys.OpenMainWindow.Conflict)
{
MessageBox.Show("全局快捷键有冲突,请前往软件首选项中修改...");
}
}
private MainVM vm = MainVM.Instance;
@ -77,18 +77,18 @@ namespace STranslate.View
NotifyIcon.ShowBalloonTip(500);
NotifyIcon.MouseDoubleClick += InputTranslateMenuItem_Click;
var inputTranslateMenuItemBtn = new MenuItem("输入翻译\tAlt+A");
var inputTranslateMenuItemBtn = new MenuItem("输入翻译");
inputTranslateMenuItemBtn.Click += InputTranslateMenuItem_Click;
var screenshotTranslateMenuItemBtn = new MenuItem("截图翻译\tAlt+S");
var screenshotTranslateMenuItemBtn = new MenuItem("截图翻译");
screenshotTranslateMenuItemBtn.Click += ScreenshotTranslateMenuItem_Click;
var crossWordTranslateMenuItemBtn = new MenuItem("划词翻译\tAlt+D");
var crossWordTranslateMenuItemBtn = new MenuItem("划词翻译");
//CrossWordTranslateMenuItemBTN.Click += CrossWordTranslateMenuItem_Click;
//当失去焦点后无法从托盘处获取选中文本
crossWordTranslateMenuItemBtn.Enabled = false;
var openMainWinBtn = new MenuItem("显示主界面\tAlt+G");
var openMainWinBtn = new MenuItem("显示主界面");
openMainWinBtn.Click += OpenMainWin_Click;
var preferenceBtn = new MenuItem("首选项");

@ -15,12 +15,12 @@
TargetType="Button">
<Border x:Name="border"
CornerRadius="5"
Padding="4"
Padding="5"
Background="#dedfde"
MaxHeight="25">
<TextBlock VerticalAlignment="Center"
HorizontalAlignment="Center"
Text="检查更新"/>
Text="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
@ -113,7 +113,7 @@
</TabItem>
<!--
<TabItem Header="控制"
Padding="10,2">
@ -139,7 +139,8 @@
Grid.Row="1"
Grid.Column="0"
Margin="0,5,0,0" />
<TextBox Cursor="Arrow"
<TextBox x:Name="CrossWord_TextBox"
Cursor="Arrow"
Width="200"
Grid.Row="1"
Grid.Column="1"
@ -147,12 +148,16 @@
CaretBrush="Transparent"
VerticalContentAlignment="Center"
InputMethod.IsInputMethodEnabled="False">
<i:Interaction.Triggers>
<i:EventTrigger EventName="">
<i:InvokeCommandAction Command="{Binding }"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBox>
<i:Interaction.Triggers>
<i:EventTrigger EventName="PreviewKeyDown">
<i:InvokeCommandAction Command="{Binding PreviewKeyDownCmd}"
CommandParameter="{Binding ElementName=CrossWord_TextBox}"/>
</i:EventTrigger>
<i:EventTrigger EventName="KeyUp">
<i:InvokeCommandAction Command="{Binding CrossWordKeyUpCmd}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBox>
<Label Grid.Row="1"
Grid.Column="2"
Margin="0,5,0,0"
@ -240,7 +245,7 @@
</StackPanel>
</TabItem>
-->
<TabItem Header="服务"
Visibility="Collapsed"
@ -251,7 +256,8 @@
</GroupBox>
</TabItem>
<TabItem Header="关于"
<TabItem Header="关于"
Padding="10,2">
<ScrollViewer VerticalScrollBarVisibility="Auto">

@ -72,6 +72,12 @@ namespace STranslate.ViewModel
(o as Window)?.Close();
});
//重置热键
ResetHotKeysCmd = new RelayCommand((_) => true, (_) =>
{
System.Diagnostics.Debug.Print("重置快捷键");
});
OpenUrlCmd = new RelayCommand((_) => true, (o) =>
{
try
@ -85,6 +91,16 @@ namespace STranslate.ViewModel
MessageBox.Show($"未找到默认应用\n{ex.Message}");
}
});
PreviewKeyDownCmd = new RelayCommand((_) => true, (o) =>
{
System.Diagnostics.Debug.Print($"Press key, control: {o}");
});
CrossWordKeyUpCmd = new RelayCommand((_) => true, (_) =>
{
System.Diagnostics.Debug.Print($"Key up");
});
}
@ -108,6 +124,13 @@ namespace STranslate.ViewModel
public ICommand UpdateCmd { get; private set; }
public ICommand StartupCmd { get; private set; }
public ICommand EscCmd { get; private set; }
public ICommand ResetHotKeysCmd { get; private set; }
/// <summary>
/// 按键按下事件
/// </summary>
public ICommand PreviewKeyDownCmd { get; private set; }
public ICommand CrossWordKeyUpCmd { get; private set; }
private static SettingsVM _instance;
public static SettingsVM Instance => _instance ?? (_instance = new SettingsVM());

Loading…
Cancel
Save