fix: fix handycontrol and add copy value manual

dev_without_third_libraries
ZGGSONG 2 years ago
parent 054336d85f
commit bc40050c9f

@ -6,6 +6,7 @@
<Application.Resources> <Application.Resources>
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml"/>
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml"/> <ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml"/>
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
</ResourceDictionary> </ResourceDictionary>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

@ -24,7 +24,7 @@
<vm:MainVM/> <vm:MainVM/>
</Window.DataContext> </Window.DataContext>
<Border BorderThickness="0" <Border BorderThickness="0"
Background="BlanchedAlmond" Background="#fff"
CornerRadius="10"> CornerRadius="10">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
@ -43,7 +43,9 @@
<Grid x:Name="Input" <Grid x:Name="Input"
Margin="10,10,10,0"> Margin="10,10,10,0">
<!--输入框--> <!--输入框-->
<Border x:Name="BorderInput" BorderBrush="#000" <Border x:Name="BorderInput"
Background="#f6f6f6"
BorderBrush="#000"
BorderThickness="1" BorderThickness="1"
CornerRadius="4" CornerRadius="4"
Margin="5" Margin="5"
@ -68,22 +70,35 @@
</Grid> </Grid>
<!--mid--> <!--mid-->
<StackPanel Grid.Row="1" <StackPanel Grid.Row="1"
Margin="10,0,10,0" HorizontalAlignment="Center"
Orientation="Horizontal"> Orientation="Horizontal">
<Label Content="翻译结果: "
VerticalAlignment="Center"
HorizontalAlignment="Left"/>
<Label Content="当前语言:" <Label Content="当前语言:"
Margin="10,0,0,0"/> Background="Transparent"
BorderThickness="0"/>
<ComboBox x:Name="InCombo" <ComboBox x:Name="InCombo"
Style="{StaticResource ComboBoxBaseStyle}" Background="#f6f6f6"
Style="{StaticResource ComboBox.Small}"
ItemsSource="{Binding InputCombo}" ItemsSource="{Binding InputCombo}"
SelectedItem="{Binding InputComboSelected}"/> SelectedItem="{Binding InputComboSelected}"/>
<Label Content="目标语言:"/> <Label Content="目标语言:"
Margin="10,0"
Background="Transparent"
BorderThickness="0"/>
<ComboBox x:Name="OutCombo" <ComboBox x:Name="OutCombo"
Style="{StaticResource ComboBoxBaseStyle}" Background="#f6f6f6"
Style="{StaticResource ComboBox.Small}"
ItemsSource="{Binding OutputCombo}" ItemsSource="{Binding OutputCombo}"
SelectedItem="{Binding OutputComboSelected}"/> SelectedItem="{Binding OutputComboSelected}"/>
<Button Margin="10,0,0,0"
Cursor="Hand"
Command="{Binding CopyTranslateResultCmd}">
<Image Source="/Images/copy.png"/>
<hc:FloatingBlock.ContentTemplate>
<DataTemplate>
<TextBlock Text="复制成功"/>
</DataTemplate>
</hc:FloatingBlock.ContentTemplate>
</Button>
</StackPanel> </StackPanel>
<!--output--> <!--output-->
<Grid Margin="10,0,10,10" <Grid Margin="10,0,10,10"
@ -91,24 +106,26 @@
Grid.Row="2"> Grid.Row="2">
<!--输出框--> <!--输出框-->
<Border x:Name="BorderOutput" <Border x:Name="BorderOutput"
Background="#f6f6f6"
BorderBrush="#000" BorderBrush="#000"
BorderThickness="1" BorderThickness="1"
CornerRadius="4" CornerRadius="4"
Margin="5" Margin="5"
Height="{Binding ElementName=Output, Path=Height}"> Height="{Binding ElementName=Output, Path=Height}">
<TextBox x:Name="TextBoxOutput" <hc:TextBox x:Name="TextBoxOutput"
Background="Transparent" hc:InfoElement.Placeholder="翻译"
BorderBrush="{x:Null}" Background="Transparent"
BorderThickness="0" BorderBrush="{x:Null}"
IsReadOnly="True" BorderThickness="0"
Margin="5" IsReadOnly="True"
FontSize="18" Margin="5"
Width="{Binding ElementName=BorderOutput, Path=ActualWidth}" FontSize="18"
Height="{Binding ElementName=BorderOutput, Path=Height}" Width="{Binding ElementName=BorderOutput, Path=ActualWidth}"
VerticalAlignment="Top" Height="{Binding ElementName=BorderOutput, Path=Height}"
HorizontalAlignment="Left" VerticalAlignment="Top"
TextWrapping="Wrap" HorizontalAlignment="Left"
Text="{Binding OutputTxt}"/> TextWrapping="Wrap"
Text="{Binding OutputTxt}"/>
</Border> </Border>
<!--<Button Content="复制" <!--<Button Content="复制"
Margin="0,0,10,0" Margin="0,0,10,0"

@ -28,13 +28,13 @@ namespace STranslate
protected override void OnSourceInitialized(EventArgs e) protected override void OnSourceInitialized(EventArgs e)
{ {
HotkeysUtil.InitialHook(this); HotkeysUtil.InitialHook(this);
#if true
HotkeysUtil.Regist(HotkeyModifiers.MOD_ALT, Key.A, () => HotkeysUtil.Regist(HotkeyModifiers.MOD_ALT, Key.A, () =>
{ {
this.Show(); this.Show();
this.Activate(); this.Activate();
this.TextBoxInput.Focus(); this.TextBoxInput.Focus();
}); });
#if false
HotkeysUtil.Regist(HotkeyModifiers.MOD_ALT, Key.D, () => HotkeysUtil.Regist(HotkeyModifiers.MOD_ALT, Key.D, () =>
{ {
//复制内容 //复制内容

@ -60,6 +60,16 @@ namespace STranslate.Properties {
} }
} }
/// <summary>
/// 查找 System.Byte[] 类型的本地化资源。
/// </summary>
internal static byte[] copy {
get {
object obj = ResourceManager.GetObject("copy", resourceCulture);
return ((byte[])(obj));
}
}
/// <summary> /// <summary>
/// 查找 System.Byte[] 类型的本地化资源。 /// 查找 System.Byte[] 类型的本地化资源。
/// </summary> /// </summary>

@ -118,6 +118,9 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="copy" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\images\copy.png;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="translate" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="translate" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\images\translate.svg;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>..\images\translate.svg;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data> </data>

@ -9,6 +9,7 @@
<ItemGroup> <ItemGroup>
<None Remove=".gitignore" /> <None Remove=".gitignore" />
<None Remove="Images\copy.png" />
<None Remove="Images\translate.ico" /> <None Remove="Images\translate.ico" />
<None Remove="Images\translate.svg" /> <None Remove="Images\translate.svg" />
<None Remove="Images\translate_x128.png" /> <None Remove="Images\translate_x128.png" />
@ -17,7 +18,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="HandyControls" Version="3.4.4" /> <PackageReference Include="HandyControl" Version="3.4.0" />
<PackageReference Include="YamlDotNet" Version="12.2.1" /> <PackageReference Include="YamlDotNet" Version="12.2.1" />
</ItemGroup> </ItemGroup>
@ -28,6 +29,9 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Resource Include="Images\copy.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\translate.ico"> <Resource Include="Images\translate.ico">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource> </Resource>

@ -29,6 +29,16 @@ namespace STranslate.ViewModel
config = ConfigUtil.ReadConfig(ConfigPath); config = ConfigUtil.ReadConfig(ConfigPath);
//手动复制翻译结果
CopyTranslateResultCmd = new RelayCommand((_) =>
{
return string.IsNullOrEmpty(OutputTxt) ? false : true;
}, (_) =>
{
System.Diagnostics.Debug.Print("手动复制翻译结果: " + OutputTxt);
Clipboard.SetText(OutputTxt);
});
TranslateCmd = new RelayCommand((_) => TranslateCmd = new RelayCommand((_) =>
{ {
@ -64,6 +74,7 @@ namespace STranslate.ViewModel
} }
public ICommand TranslateCmd { get; private set; } public ICommand TranslateCmd { get; private set; }
public ICommand CopyTranslateResultCmd { get; private set; }
private string _InputTxt; private string _InputTxt;
public string InputTxt { get => _InputTxt; set => UpdateProperty(ref _InputTxt, value); } public string InputTxt { get => _InputTxt; set => UpdateProperty(ref _InputTxt, value); }

Loading…
Cancel
Save