Merge branch 'main' into dev_split_view_vm

dev_split_view_vm
DESKTOP-3BO4HSG\ksat 2 years ago
commit cbcee3eb0a

@ -4,9 +4,18 @@
</a>
</p>
<p align="center">
<a href="https://github.com/ZGGSONG/STranslate/blob/main/LICENSE" target="_self">
<img alt="Latest GitHub release" src="https://img.shields.io/github/license/ZGGSONG/STranslate" />
</a>
<a href="https://github.com/ZGGSONG/STranslate/releases/latest" target="_blank">
<img alt="Latest GitHub release" src="https://img.shields.io/github/release/ZGGSONG/STranslate.svg" />
</a>
<a href="https://github.com/ZGGSONG/STranslate" target="_self">
<img alt="GitHub last commit" src="https://img.shields.io/github/last-commit/ZGGSONG/STranslate" />
</a>
<a href="https://github.com/ZGGSONG/STranslate" target="_self">
<img alt="GitHub repo size" src="https://img.shields.io/github/repo-size/ZGGSONG/STranslate" />
</a>
</p>
<h1 align="center">STranslate</h1>
@ -24,6 +33,7 @@
- [x] 添加开机自启
- [x] 添加亮/暗主题
- [x] 添加 UI 设置缓存(用户目录下 `AppData\Local\STranslate`)
- [x] 添加语音合成
- [ ] 添加 OCR 翻译
- [ ] 添加翻译记录缓存功能

Binary file not shown.

@ -71,6 +71,9 @@
<StackPanel Orientation="Horizontal"
Margin="10,5"
VerticalAlignment="Bottom">
<Button Template="{DynamicResource ButtonTemplateSpeak}"
Visibility="{Binding InputTxt,Converter={StaticResource String2VisibilityConverter}}"
Command="{Binding SourceSpeakCmd}"/>
<Button Template="{DynamicResource ButtonTemplate}"
Visibility="{Binding InputTxt,Converter={StaticResource String2VisibilityConverter}}"
Command="{Binding CopyInputCmd}"/>
@ -99,6 +102,7 @@
<ComboBox x:Name="InCombo"
Style="{DynamicResource cmbstyle}"
ItemsSource="{Binding InputCombo}"
SelectionChanged="SelectionChanged"
SelectedItem="{Binding InputComboSelected,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
<Separator Margin="20,0"/>
<TextBlock Text="目标语言: "
@ -106,6 +110,7 @@
<ComboBox x:Name="OutCombo"
Style="{DynamicResource cmbstyle}"
ItemsSource="{Binding OutputCombo}"
SelectionChanged="SelectionChanged"
SelectedItem="{Binding OutputComboSelected,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
@ -124,6 +129,9 @@
<StackPanel Orientation="Horizontal"
Margin="10,5"
VerticalAlignment="Bottom">
<Button Template="{DynamicResource ButtonTemplateSpeak}"
Visibility="{Binding OutputTxt,Converter={StaticResource String2VisibilityConverter}}"
Command="{Binding TargetSpeakCmd}"/>
<!--普通复制-->
<Button Template="{DynamicResource ButtonTemplate}"
Visibility="{Binding OutputTxt,Converter={StaticResource String2VisibilityConverter}}"

@ -169,6 +169,7 @@ namespace STranslate
{
if (!_IsTopmost)
{
vm.Speech.SpeakAsyncCancelAll();
this.Hide();
}
}
@ -282,5 +283,14 @@ namespace STranslate
private bool _IsTopmost { get; set; }
private readonly string _TopmostTemplateName = "ButtonTemplateTopmost";
private readonly string _UnTopmostTemplateName = "ButtonTemplateUnTopmost";
private void SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
if (!string.IsNullOrEmpty(vm?.InputTxt))
{
vm.IdentifyLanguage = string.Empty;
_ = vm?.Translate();
}
}
}
}

@ -47,6 +47,6 @@ using System.Windows;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.2.0")]
[assembly: AssemblyFileVersion("0.1.2.0")]
[assembly: AssemblyVersion("0.1.4.0")]
[assembly: AssemblyFileVersion("0.1.4.0")]
[assembly: Guid("CE252DD8-179F-4544-9989-453F5DEA378D")]

@ -19,7 +19,7 @@ namespace STranslate.Properties {
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {

@ -62,6 +62,7 @@
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Speech" />
<Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />

@ -81,6 +81,29 @@
</ControlTemplate.Triggers>
</ControlTemplate>
<!--speak-->
<ControlTemplate x:Key="ButtonTemplateSpeak" TargetType="Button">
<Border x:Name="border"
CornerRadius="5"
Margin="0,0,5,0"
Padding="4"
MaxHeight="25">
<TextBlock Style="{StaticResource IconStyle}"
FontSize="17"
VerticalAlignment="Center"
Text="&#xe610;"
Foreground="WhiteSmoke"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="border" Property="Background" Value="#47484c"></Setter>
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter TargetName="border" Property="Background" Value="#35333c"></Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<!--普通复制-->
<ControlTemplate x:Key="ButtonTemplate" TargetType="Button">
<Border x:Name="border"

@ -81,6 +81,29 @@
</ControlTemplate.Triggers>
</ControlTemplate>
<!--speak-->
<ControlTemplate x:Key="ButtonTemplateSpeak" TargetType="Button">
<Border x:Name="border"
CornerRadius="5"
Margin="0,0,5,0"
Padding="4"
MaxHeight="25">
<TextBlock Style="{StaticResource IconStyle}"
FontSize="17"
VerticalAlignment="Center"
Text="&#xe610;"
Foreground="#515151"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="border" Property="Background" Value="#eaeaea"></Setter>
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter TargetName="border" Property="Background" Value="#dddddd"></Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<!--普通复制-->
<ControlTemplate x:Key="ButtonTemplate" TargetType="Button">
<Border x:Name="border"

@ -11,6 +11,7 @@ using System.Windows.Media;
using System.Text.RegularExpressions;
using System.Security.Cryptography;
using STranslate.Util;
using System.Speech.Synthesis;
namespace STranslate.ViewModel
{
@ -28,6 +29,16 @@ namespace STranslate.ViewModel
InputCombo = LanguageEnumDict.Keys.ToList();
OutputCombo = LanguageEnumDict.Keys.ToList();
//source speak
SourceSpeakCmd = new RelayCommand((_) => true, (_) =>
{
Speech.SpeakAsync(InputTxt);
});
//target speak
TargetSpeakCmd = new RelayCommand((_) => true, (_) =>
{
Speech.SpeakAsync(OutputTxt);
});
//复制输入
CopyInputCmd = new RelayCommand((_) => true, (_) =>
{
@ -233,12 +244,15 @@ namespace STranslate.ViewModel
public void Dispose()
{
Speech.Dispose();
WriteConfig();
}
#endregion handle
#region Params
private string translateResp;
public ICommand SourceSpeakCmd { get; private set; }
public ICommand TargetSpeakCmd { get; private set; }
public ICommand TranslateCmd { get; private set; }
public ICommand CopyInputCmd { get; private set; }
public ICommand CopyResultCmd { get; private set; }
@ -300,6 +314,12 @@ namespace STranslate.ViewModel
private Server _SelectedTranslationInterface;
public Server SelectedTranslationInterface { get => _SelectedTranslationInterface; set => UpdateProperty(ref _SelectedTranslationInterface, value); }
private static Dictionary<string, LanguageEnum> LanguageEnumDict { get => Util.Util.GetEnumList<LanguageEnum>(); }
/// <summary>
/// 语音
/// </summary>
public readonly SpeechSynthesizer Speech = new SpeechSynthesizer();
private static readonly string _ThemeDark = "pack://application:,,,/STranslate;component/Style/Dark.xaml";
private static readonly string _ThemeDefault = "pack://application:,,,/STranslate;component/Style/Default.xaml";
#endregion Params

Binary file not shown.

Before

Width:  |  Height:  |  Size: 241 KiB

After

Width:  |  Height:  |  Size: 618 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 262 KiB

After

Width:  |  Height:  |  Size: 267 KiB

Loading…
Cancel
Save