feat: add toast

main
SONGE9B3\song_pd_win11 2 years ago
parent 0bdd7757ce
commit 7eaa02503c

Binary file not shown.

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

@ -212,12 +212,12 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="tessdata\eng.traineddata">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Resource Include="Images\iconfont.ttf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<None Include="tessdata\eng.traineddata">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>

@ -15,6 +15,7 @@
WindowStyle="None"
SizeToContent="Height"
Width="400"
FontFamily="{DynamicResource {x:Static SystemFonts.CaptionFontFamilyKey}}"
Icon="/Images/translate.ico">
<Window.InputBindings>
@ -101,10 +102,11 @@
Visibility="{Binding InputTxt, Converter={StaticResource String2VisibilityConverter}}"
Command="{Binding SourceSpeakCmd}"/>
<Button Template="{DynamicResource ButtonTemplate}"
Click="Copy_Click"
Visibility="{Binding InputTxt, Converter={StaticResource String2VisibilityConverter}}"
Command="{Binding CopyInputCmd}">
<Button.ToolTip>
<ToolTip x:Name="复制" Template="{DynamicResource ToolTipTemplate}"/>
<ToolTip x:Name="复制输入内容" Template="{DynamicResource ToolTipTemplate}"/>
</Button.ToolTip>
</Button>
<Border Style="{DynamicResource LanguageMarkBorderStyle}"
@ -122,6 +124,32 @@
</Border>
</Grid>
<!--toast-->
<Border x:Name="Toast"
CornerRadius="12"
Grid.Row="0"
Grid.RowSpan="2"
VerticalAlignment="Top"
Visibility="Visible"
Margin="0,-40"
Width="{Binding ElementName=toastTxt, Path=ActualWidth}"
BorderBrush="Transparent"
Background="#65c248">
<WrapPanel Orientation="Horizontal">
<!--<TextBlock Text="&#xe632;"
Foreground="White"
Padding="10,10"
Style="{StaticResource IconStyle}"/>-->
<TextBlock x:Name="toastTxt"
Background="Transparent"
Foreground="#fff"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Padding="10,5,10,5"
FontSize="16"/>
</WrapPanel>
</Border>
<!--mid-->
<StackPanel x:Name="MidArea"
Grid.Row="2"
@ -175,36 +203,40 @@
Command="{Binding TargetSpeakCmd}"/>
<!--普通复制-->
<Button Template="{DynamicResource ButtonTemplate}"
Click="Copy_Click"
Visibility="{Binding OutputTxt, Converter={StaticResource String2VisibilityConverter}}"
Command="{Binding CopyResultCmd}">
<Button.ToolTip>
<ToolTip x:Name="直接复制" Template="{DynamicResource ToolTipTemplate}"/>
<ToolTip x:Name="直接复制结果" Template="{DynamicResource ToolTipTemplate}"/>
</Button.ToolTip>
</Button>
<!--蛇形复制-->
<Button Margin="5,0"
Click="Copy_Click"
Template="{DynamicResource ButtonTemplateSnakeCopy}"
Visibility="{Binding SnakeRet, Converter={StaticResource String2VisibilityConverter}}"
Command="{Binding CopySnakeResultCmd}">
<Button.ToolTip>
<ToolTip x:Name="蛇形复制" Template="{DynamicResource ToolTipTemplate}"/>
<ToolTip x:Name="复制为蛇形字符串" Template="{DynamicResource ToolTipTemplate}"/>
</Button.ToolTip>
</Button>
<!--小驼峰复制-->
<Button Template="{DynamicResource ButtonTemplateSmallHumpCopy}"
Click="Copy_Click"
Visibility="{Binding SmallHumpRet, Converter={StaticResource String2VisibilityConverter}}"
Command="{Binding CopySmallHumpResultCmd}">
<Button.ToolTip>
<ToolTip x:Name="小驼峰复制" Template="{DynamicResource ToolTipTemplate}"/>
<ToolTip x:Name="复制为小驼峰字符串" Template="{DynamicResource ToolTipTemplate}"/>
</Button.ToolTip>
</Button>
<!--大驼峰复制-->
<Button Margin="5,0"
Click="Copy_Click"
Template="{DynamicResource ButtonTemplateLargeHumpCopy}"
Visibility="{Binding LargeHumpRet, Converter={StaticResource String2VisibilityConverter}}"
Command="{Binding CopyLargeHumpResultCmd}">
<Button.ToolTip>
<ToolTip x:Name="大驼峰复制" Template="{DynamicResource ToolTipTemplate}"/>
<ToolTip x:Name="复制为大驼峰字符串" Template="{DynamicResource ToolTipTemplate}"/>
</Button.ToolTip>
</Button>
</StackPanel>

@ -4,6 +4,8 @@ using System;
using System.IO;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Media.Animation;
using System.Windows.Media;
using Application = System.Windows.Application;
using MessageBox = System.Windows.MessageBox;
@ -69,6 +71,26 @@ namespace STranslate.View
}
}
private void Copy_Click(object sender, RoutedEventArgs e)
{
var o = sender as System.Windows.Controls.Button;
toastTxt.Text = (o.ToolTip as System.Windows.Controls.ToolTip).Name;
//创建一个一个对象,对两个值在时间线上进行动画处理(移动距离,移动到的位置)
var da = new DoubleAnimation();
//设定动画时间线
da.Duration = new Duration(TimeSpan.FromSeconds(0.8));
//设定移动动画的结束值控件向下移动60个像素向上移动则是-60
da.To = 50;
da.From = 0;
da.AccelerationRatio = 0;
da.DecelerationRatio = 1;
da.AutoReverse = true;
//btnFlash要进行动画操作的控件名
Toast.RenderTransform = new TranslateTransform();
//开始进行动画处理
Toast.RenderTransform.BeginAnimation(TranslateTransform.YProperty, da);
}
private MainVM vm = MainVM.Instance;
public readonly NotifyIcon NotifyIcon = new NotifyIcon();
@ -175,5 +197,6 @@ namespace STranslate.View
}
#endregion
}
}
Loading…
Cancel
Save