feat: add handyconftrol

master
ZGGSONG 2 years ago
parent 319087825d
commit 7a3b4a5f16

@ -4,6 +4,10 @@
xmlns:local="clr-namespace:STranslate" xmlns:local="clr-namespace:STranslate"
StartupUri="MainWindow.xaml"> StartupUri="MainWindow.xaml">
<Application.Resources> <Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources> </Application.Resources>
</Application> </Application>

@ -5,6 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:STranslate" xmlns:local="clr-namespace:STranslate"
xmlns:vm="clr-namespace:STranslate.ViewModel" xmlns:vm="clr-namespace:STranslate.ViewModel"
xmlns:hc="https://handyorg.github.io/handycontrol"
mc:Ignorable="d" mc:Ignorable="d"
Background="Transparent" Background="Transparent"
WindowStartupLocation="CenterScreen" WindowStartupLocation="CenterScreen"
@ -30,6 +31,12 @@
<RowDefinition Height="5*"/> <RowDefinition Height="5*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<hc:NotifyIcon Text="STranslate"
Click="NotifyIcon_Click"
IsBlink="False"
Visibility="Visible"
Icon="/Images/translate.ico"/>
<!--input--> <!--input-->
<Grid Margin="10"> <Grid Margin="10">
<!--输入框--> <!--输入框-->
@ -45,6 +52,8 @@
FontSize="18" FontSize="18"
MinHeight="35" MinHeight="35"
TextWrapping="Wrap" TextWrapping="Wrap"
VerticalAlignment="Top"
HorizontalAlignment="Left"
Text="{Binding InputTxt,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"> Text="{Binding InputTxt,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}">
<TextBox.InputBindings> <TextBox.InputBindings>
<KeyBinding Command="{Binding TranslateCmd}" Key="Enter"/> <KeyBinding Command="{Binding TranslateCmd}" Key="Enter"/>
@ -55,7 +64,9 @@
<!--output--> <!--output-->
<Grid Margin="10" <Grid Margin="10"
Grid.Row="1"> Grid.Row="1">
<Label Content="翻译结果: "/> <Label Content="翻译结果: "
VerticalAlignment="Top"
HorizontalAlignment="Left"/>
<!--输出框--> <!--输出框-->
<Border BorderBrush="#000" <Border BorderBrush="#000"
@ -70,10 +81,11 @@
Margin="5" Margin="5"
FontSize="18" FontSize="18"
MinHeight="35" MinHeight="35"
VerticalAlignment="Top"
HorizontalAlignment="Left"
TextWrapping="Wrap" TextWrapping="Wrap"
Text="{Binding OutputTxt}"/> Text="{Binding OutputTxt}"/>
</Border> </Border>
<!--<Button Content="复制" <!--<Button Content="复制"
Margin="0,0,10,0" Margin="0,0,10,0"
VerticalAlignment="Top" VerticalAlignment="Top"

@ -48,10 +48,10 @@ namespace STranslate
Topmost = Topmost != true; Topmost = Topmost != true;
Opacity = Topmost ? 1 : 0.9; Opacity = Topmost ? 1 : 0.9;
} }
//最小化 Ctrl+M //最小化 Esc
if (e.Key == Key.Escape) if (e.Key == Key.Escape)
{ {
WindowState = WindowState.Minimized; this.Hide();
} }
//退出 Ctrl+Q //退出 Ctrl+Q
if (e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Control) && e.Key == Key.Q) if (e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Control) && e.Key == Key.Q)
@ -85,5 +85,10 @@ namespace STranslate
Height = 450; Height = 450;
} }
} }
private void NotifyIcon_Click(object sender, RoutedEventArgs e)
{
this.Show();
}
} }
} }

@ -17,6 +17,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="HandyControls" Version="3.4.4" />
<PackageReference Include="YamlDotNet" Version="12.2.1" /> <PackageReference Include="YamlDotNet" Version="12.2.1" />
</ItemGroup> </ItemGroup>