fix: 消除使用Alt+Key作为快捷键时放大自家窗口产生的哔哔声

This commit is contained in:
刘旭 2022-05-01 19:40:11 +08:00
commit 7dbdec4e93
6 changed files with 38 additions and 13 deletions

View file

@ -8,6 +8,7 @@
mc:Ignorable="d"
Icon="{DynamicResource Logo}"
Title="{x:Static props:Resources.UI_Main_Title}" ResizeMode="CanMinimize" WindowStartupLocation="CenterScreen"
KeyDown="Window_KeyDown"
Closing="Window_Closing" SourceInitialized="Window_SourceInitialized" StateChanged="Window_StateChanged" HorizontalAlignment="Left" VerticalAlignment="Top" SizeToContent="WidthAndHeight" Deactivated="Window_Deactivated">
<StackPanel Margin="19.5,19,19.5,19">
<Grid>
@ -18,7 +19,7 @@
</Grid.ColumnDefinitions>
<Label Margin="0" Content="{x:Static props:Resources.UI_Main_Hotkey}" HorizontalAlignment="Right" VerticalAlignment="Center" Padding="0,5,5,5"/>
<TextBox x:Name="txtHotkey" Grid.Column="1" Margin="10,0" VerticalAlignment="Center" Padding="1,3" TextChanged="TxtHotkey_TextChanged" MinWidth="100" >
<TextBox x:Name="txtHotkey" Grid.Column="1" Margin="10,0" VerticalAlignment="Center" Padding="1,3" TextChanged="TxtHotkey_TextChanged" MinWidth="100">
<TextBox.ContextMenu>
<ContextMenu/>
</TextBox.ContextMenu>

View file

@ -1,16 +1,16 @@
using Gma.System.MouseKeyHook;
using Magpie.Options;
using Magpie.Properties;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Interop;
using System.Windows.Threading;
using System.Windows.Media;
using System.Windows.Forms;
using Magpie.Properties;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Linq;
using Magpie.Options;
using System.Windows.Threading;
namespace Magpie {
@ -98,7 +98,7 @@ namespace Magpie {
// 捕获模式选择项对应的值存在 Tag 属性里
bool found = false;
foreach (object i in cbbCaptureMethod.Items) {
if((uint)((FrameworkElement)i).Tag == Settings.Default.CaptureMode) {
if ((uint)((FrameworkElement)i).Tag == Settings.Default.CaptureMode) {
cbbCaptureMethod.SelectedItem = i;
found = true;
break;
@ -438,11 +438,17 @@ namespace Magpie {
private void CbbCaptureMethod_SelectionChanged(object sender, SelectionChangedEventArgs e) {
FrameworkElement si = (FrameworkElement)cbbCaptureMethod.SelectedItem;
if(si == null) {
if (si == null) {
return;
}
Settings.Default.CaptureMode = (uint)si.Tag;
}
private void Window_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) {
if (e.Key == System.Windows.Input.Key.System) {
e.Handled = true;
}
}
}
}

View file

@ -8,15 +8,20 @@
xmlns:resx="clr-namespace:Magpie.Properties"
mc:Ignorable="d"
Icon="{DynamicResource Logo}"
Title="{x:Static p:Resources.UI_Options_About_Licenses_Title}" Height="400" Width="550" ResizeMode="NoResize">
Title="{x:Static p:Resources.UI_Options_About_Licenses_Title}" Height="400" Width="550" ResizeMode="NoResize"
KeyDown="Window_KeyDown">
<Grid Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="171*"/>
<ColumnDefinition Width="359*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Text="{x:Static p:Resources.UI_Options_About_Licenses_Header}" />
<TextBox x:Name="tbLicenses" VerticalScrollBarVisibility="Auto" UndoLimit="0" Grid.Row="1" AllowDrop="False" IsTabStop="False" Margin="0,10,0,0" TextWrapping="Wrap" IsUndoEnabled="False" IsReadOnly="True" />
<Button Content="{x:Static p:Resources.UI_Options_About_Licenses_Close}" Grid.Row="2" HorizontalAlignment="Right" Margin="0,10,0,0" Padding="10,5" IsDefault="True" Click="BtnOK_Click" />
<TextBlock Text="{x:Static p:Resources.UI_Options_About_Licenses_Header}" Grid.ColumnSpan="2" />
<TextBox x:Name="tbLicenses" VerticalScrollBarVisibility="Auto" UndoLimit="0" Grid.Row="1" AllowDrop="False" IsTabStop="False" Margin="0,10,0,37" TextWrapping="Wrap" IsUndoEnabled="False" IsReadOnly="True" Grid.ColumnSpan="2" Grid.RowSpan="2" />
<Button Content="{x:Static p:Resources.UI_Options_About_Licenses_Close}" Grid.Row="2" HorizontalAlignment="Right" Margin="0,10,0,0" Padding="10,5" IsDefault="True" Click="BtnOK_Click" Grid.Column="1" />
</Grid>
</Window>

View file

@ -27,5 +27,11 @@ namespace Magpie.Options {
private void BtnOK_Click(object sender, RoutedEventArgs e) {
Close();
}
private void Window_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) {
if (e.Key == System.Windows.Input.Key.System) {
e.Handled = true;
}
}
}
}

View file

@ -7,7 +7,8 @@
xmlns:p="clr-namespace:Magpie.Properties;assembly=Magpie"
mc:Ignorable="d"
Icon="{DynamicResource Logo}"
Title="{x:Static p:Resources.UI_Options_Title}" Height="400" Width="650" Deactivated="Window_Deactivated">
Title="{x:Static p:Resources.UI_Options_Title}" Height="400" Width="650" Deactivated="Window_Deactivated"
KeyDown="Window_KeyDown">
<DockPanel>
<ListBox x:Name="lbxOptionsPage" Margin="0" SelectionChanged="LxbOptionsPage_SelectionChanged" Padding="0" BorderThickness="0,0,1,0" Grid.IsSharedSizeScope="True">
<ListBox.Resources>

View file

@ -37,5 +37,11 @@ namespace Magpie.Options {
private void Window_Deactivated(object sender, EventArgs e) {
Settings.Default.Save();
}
private void Window_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) {
if (e.Key == System.Windows.Input.Key.System) {
e.Handled = true;
}
}
}
}