fix: fix handycontrol and add copy value manual

master
ZGGSONG 2 years ago
parent 054336d85f
commit bc40050c9f

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

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

@ -28,13 +28,13 @@ namespace STranslate
protected override void OnSourceInitialized(EventArgs e)
{
HotkeysUtil.InitialHook(this);
#if true
HotkeysUtil.Regist(HotkeyModifiers.MOD_ALT, Key.A, () =>
{
this.Show();
this.Activate();
this.TextBoxInput.Focus();
});
#if false
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>
/// 查找 System.Byte[] 类型的本地化资源。
/// </summary>

@ -118,6 +118,9 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<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">
<value>..\images\translate.svg;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>

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

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