Skip to content

Commit

Permalink
1. performance optimize
Browse files Browse the repository at this point in the history
2. Expression optimize
3. Notice optimize
  • Loading branch information
shadlc committed Jun 4, 2022
1 parent ee4bb54 commit 0d3f421
Show file tree
Hide file tree
Showing 58 changed files with 2,788 additions and 102 deletions.
21 changes: 12 additions & 9 deletions BrailleArtist/Assets/Langs/en-US.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
<sys:String x:Key="ImportHelpText">Drag in or click to import image</sys:String>
<sys:String x:Key="MsgBoxImportErrorText">This file is not supported or be occupied!</sys:String>
<sys:String x:Key="MsgBoxImportErrorTitle">Import Failed</sys:String>
<sys:String x:Key="MsgBoxImportErrorOK">OK</sys:String>
<sys:String x:Key="MsgBoxCopySuccessText">The braille art has copied to the clipboard successfully!</sys:String>
<sys:String x:Key="MsgBoxCopySuccessTitle">Copy Braille Art</sys:String>
<sys:String x:Key="MsgBoxOK">OK</sys:String>
<sys:String x:Key="ImgChooseTitle">Import Image</sys:String>
<sys:String x:Key="ImgChooseType">Image File</sys:String>
<sys:String x:Key="Processing">Processing...</sys:String>
Expand All @@ -21,18 +23,19 @@
<sys:String x:Key="AntiClockwise">Rotate AntiClockwise</sys:String>
<sys:String x:Key="FlipHorizontally">Flip Horizontally</sys:String>
<sys:String x:Key="FlipVertically">Flip Vertically</sys:String>
<sys:String x:Key="Size">Size</sys:String>
<sys:String x:Key="Size">Size: </sys:String>
<sys:String x:Key="RatioLock">Lock Aspect Ratio</sys:String>
<sys:String x:Key="Width_ToolTip">Braille Art's Width =This / 2</sys:String>
<sys:String x:Key="Height_ToolTip">Braille Art's Height =This / 4</sys:String>
<sys:String x:Key="Level">Level:</sys:String>
<sys:String x:Key="Width_ToolTip">Braille Art's Width =This / 2(Max: 2000)</sys:String>
<sys:String x:Key="Height_ToolTip">Braille Art's Height =This / 4(Max: 2000)</sys:String>
<sys:String x:Key="Level">Level: </sys:String>
<sys:String x:Key="Level_ToolTip">Small picture may draw out automatically</sys:String>
<sys:String x:Key="Reset">Reset</sys:String>
<sys:String x:Key="Reset_ToolTip">Reset All Operations</sys:String>
<sys:String x:Key="Reset_ToolTip">Reset All Operations(Del)</sys:String>
<sys:String x:Key="Draw">Draw</sys:String>
<sys:String x:Key="Draw_ToolTip">Repaint The Braille Art</sys:String>
<sys:String x:Key="Draw_ToolTip">Repaint The Braille Art(Enter)</sys:String>
<sys:String x:Key="Copy">Copy</sys:String>
<sys:String x:Key="Copy_ToolTip">Copy The Entire Braille Art To The Clipboard</sys:String>
<sys:String x:Key="FontSize">FontSize</sys:String>
<sys:String x:Key="Copy_ToolTip">Copy The Entire Braille Art To The Clipboard(Ctrl+C)</sys:String>
<sys:String x:Key="FontSize: ">FontSize</sys:String>
<sys:String x:Key="Source">Source</sys:String>
<sys:String x:Key="Introduction">Software: Braille Artist Programming Language: C# dotNet WPF Open Source Protocol: GPL Copyright 2021 © Shadlc&#x0a;&#x0a;Introduction&#x0a;This is a braille ASCII art generator. The traditional ASCII art generator is inefficient in space utilization. This software can use one braille as 8 pixels to generate ASCII art and display high-quality pictures in the text-only environment.&#x0a;&#x0a;Help&#x0a;Click or drag the file into the box which is in the upper left corner to import the image, then adjust the settings in the lower left corner. The level slider allows users to customize the brightness of the braille art for different effects. After that, click the draw button to generate the braille art. The slider in the upper right side can adjust the fontsize of the braille art for the best display size. You can also press Ctrl and scroll the mouse wheel on the braille art to zoom the size. Finally click the copy button to copy the entire braille art to clipboard.</sys:String>
</ResourceDictionary>
17 changes: 10 additions & 7 deletions BrailleArtist/Assets/Langs/zh-CN.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
<sys:String x:Key="ImportHelpText">拖入或点击此处导入图片</sys:String>
<sys:String x:Key="MsgBoxImportErrorText">不支持该文件或文件被占用!</sys:String>
<sys:String x:Key="MsgBoxImportErrorTitle">导入失败</sys:String>
<sys:String x:Key="MsgBoxImportErrorOK">好的</sys:String>
<sys:String x:Key="MsgBoxCopySuccessText">字符画已成功导入到剪切板!</sys:String>
<sys:String x:Key="MsgBoxCopySuccessTitle">复制字符画</sys:String>
<sys:String x:Key="MsgBoxOK">好的</sys:String>
<sys:String x:Key="ImgChooseTitle">导入图片</sys:String>
<sys:String x:Key="ImgChooseType">图片文件</sys:String>
<sys:String x:Key="Processing">处理中...</sys:String>
Expand All @@ -23,16 +25,17 @@
<sys:String x:Key="FlipVertically">上下翻转</sys:String>
<sys:String x:Key="Size">大小:</sys:String>
<sys:String x:Key="RatioLock">锁定长宽比</sys:String>
<sys:String x:Key="Width_ToolTip">字符画宽 = 此框数值 / 2</sys:String>
<sys:String x:Key="Height_ToolTip">字符画高 = 此框数值 / 4</sys:String>
<sys:String x:Key="Width_ToolTip">字符画宽 = 此框数值 / 2(最大值:2000)</sys:String>
<sys:String x:Key="Height_ToolTip">字符画高 = 此框数值 / 4(最大值:2000)</sys:String>
<sys:String x:Key="Level">着色度:</sys:String>
<sys:String x:Key="Level_ToolTip">较小图片可以自动绘制</sys:String>
<sys:String x:Key="Reset">重置</sys:String>
<sys:String x:Key="Reset_ToolTip">重置所有操作</sys:String>
<sys:String x:Key="Reset_ToolTip">重置所有操作(Del)</sys:String>
<sys:String x:Key="Draw">绘制</sys:String>
<sys:String x:Key="Draw_ToolTip">重新绘制像素画</sys:String>
<sys:String x:Key="Draw_ToolTip">重新绘制像素画(Enter)</sys:String>
<sys:String x:Key="Copy">复制</sys:String>
<sys:String x:Key="Copy_ToolTip">将整个字符画复制到剪贴板</sys:String>
<sys:String x:Key="FontSize">字号</sys:String>
<sys:String x:Key="Copy_ToolTip">将整个字符画复制到剪贴板(Ctrl+C)</sys:String>
<sys:String x:Key="FontSize">字号</sys:String>
<sys:String x:Key="Source">源代码</sys:String>
<sys:String x:Key="Introduction">软件名:盲文字符画生成器 编程语言:C# dotNet WPF 开源协议:GPL Copyright 2021 © 似然可绘&#x0a;&#x0a;软件介绍&#x0a;这是一款图形界面的盲文字符画生成器,传统的字符画生成器空间利用低效,此软件能够利用一个盲文字符作为八个像素点生成字符画,在纯文本环境下展示高质量图片。&#x0a;&#x0a;使用帮助&#x0a;点击或将文件拖入软件左上角的大框进行图片的导入,调整左下角的设置与参数。着色度滑条让用户能够自定义字符画颜色的深浅实现不同的效果,点击绘制按钮生成字符画。右侧上方的滑条能够调整展示字符画的字号,以供最佳的展示大小,也可以在字符画上按住Ctrl然后滚动鼠标滚轮进行缩放,最后点击复制按钮将整个字符画复制到剪贴板。</sys:String>
</ResourceDictionary>
28 changes: 28 additions & 0 deletions BrailleArtist/Assets/Styles/DefaultStyle.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,34 @@
</EasingDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="WindowAppearAnimation">
<DoubleAnimation Duration="0:0:0.2" From="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="MainGrid"/>
<DoubleAnimation Duration="0:0:0.4" From="0.9" To="1" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)" Storyboard.TargetName="MainGrid">
<DoubleAnimation.EasingFunction>
<BackEase EasingMode="EaseOut" Amplitude="0.5"/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
<DoubleAnimation Duration="0:0:0.4" From="0.9" To="1" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)" Storyboard.TargetName="MainGrid">
<DoubleAnimation.EasingFunction>
<BackEase EasingMode="EaseOut" Amplitude="0.5"/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>
<Storyboard x:Key="WindowDisappearAnimation">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="MainGrid" BeginTime="0:0:.2">
<EasingDoubleKeyFrame KeyTime="0:0:.2" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimation Duration="0:0:0.4" From="1" To="0.8" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)" Storyboard.TargetName="MainGrid">
<DoubleAnimation.EasingFunction>
<BackEase EasingMode="EaseIn" Amplitude="0.3"/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
<DoubleAnimation Duration="0:0:0.4" From="1" To="0.8" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)" Storyboard.TargetName="MainGrid">
<DoubleAnimation.EasingFunction>
<BackEase EasingMode="EaseIn" Amplitude="0.3"/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>

<!--TextBox-->
<Style x:Key="MyTextBox" TargetType="{x:Type TextBox}">
Expand Down
3 changes: 2 additions & 1 deletion BrailleArtist/Common/GValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public static class GValues
public static Bitmap Image = null;
public static string ImgName = null;
public static float PixelAverage = 0;
public static float WidthDHeight = 0;
public static float Ratio = 0;
public static float MinAutoDrawSize = 200000;
}
}
6 changes: 3 additions & 3 deletions BrailleArtist/View/IMessageBox.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
<ResourceDictionary Source="../Assets/Styles/DefaultStyle.xaml"/>
</Window.Resources>
<Window.Effect>
<DropShadowEffect ShadowDepth="0" BlurRadius="8" Opacity=".5" Color="Gray"/>
<DropShadowEffect ShadowDepth="0" BlurRadius="8" Color="Gray"/>
</Window.Effect>
<Window.Triggers>
<EventTrigger RoutedEvent="Loaded">
<BeginStoryboard Storyboard="{StaticResource WindowAppearAnimation}"/>
</EventTrigger>
</Window.Triggers>
<Border x:Name="MainGrid" CornerRadius="10,10,10,10" Background="White" RenderTransformOrigin="0.5,0.5">
<Border x:Name="MainGrid" CornerRadius="8" Background="White" RenderTransformOrigin="0.5,0.5">
<Border.RenderTransform>
<ScaleTransform/>
</Border.RenderTransform>
Expand All @@ -27,7 +27,7 @@
<RowDefinition Height="30"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Border CornerRadius="10,10,0,0" Background="{DynamicResource ThemeColor}" MouseLeftButtonDown="WindowMove">
<Border CornerRadius="8,8,0,0" Background="{DynamicResource ThemeColor}" MouseLeftButtonDown="WindowMove">
<Grid x:Name="ConrtolBox">
<Button HorizontalAlignment="Right" Style="{DynamicResource WindowControlButton}" Foreground="{DynamicResource ControlColor}" Content="&#xE604;" ToolTip="关闭" Click="CloseButton_Click"/>
<TextBlock x:Name="TitleLabel" HorizontalAlignment="Center" VerticalAlignment="Center" Text="Title" Foreground="{DynamicResource ControlColor}" TextAlignment="Center"/>
Expand Down
24 changes: 16 additions & 8 deletions BrailleArtist/View/MainView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:BrailleArtist"
xmlns:viewmodel="clr-namespace:BrailleArtist.ViewModel" d:DataContext="{d:DesignInstance Type=viewmodel:MainViewModel}"
mc:Ignorable="d"
x:Name="window" Title="{DynamicResource WindowTitle}" MinHeight="464" MinWidth="676" Height="464" Width="676" WindowStyle="None" ResizeMode="NoResize"
WindowStartupLocation="CenterScreen" FontSize="14" Background="Transparent" Icon="../icon.ico" KeyDown="OnKeyDown" ContentRendered="Window_ContentRendered">
Expand Down Expand Up @@ -117,19 +118,19 @@
<CheckBox x:Name="RatioLock" Grid.Column="2" Content="&#xe605;" ToolTip="{DynamicResource RatioLock}" IsChecked="{Binding IsRatioLock}"/>
<TextBox x:Name="Height_TextBox" Grid.Column="3" VerticalAlignment="Stretch" Style="{StaticResource MyTextBox}" ToolTip="{DynamicResource Height_ToolTip}" Text="{Binding Height}" TextChanged="Size_Changed"/>
</Grid>
<Grid Grid.Row="2">
<Grid Grid.Row="2" MouseUp="MiddleBright_MouseUp">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock VerticalAlignment="Center" Text="{DynamicResource Level}"/>
<Slider VerticalAlignment="Center" Grid.Column="1" Value="{Binding MiddleBright}" ValueChanged="MiddleBright_Changed"/>
<Slider VerticalAlignment="Center" Grid.Column="1" Value="{Binding MiddleBright}" ToolTip="{DynamicResource Level_ToolTip}" ValueChanged="MiddleBright_Changed"/>
</Grid>
<Grid Grid.Row="3">
<UniformGrid Columns="3" Margin="0,2">
<Button Style="{StaticResource MyButton}" Content="{DynamicResource Reset}" Command="{Binding MyCommand}" CommandParameter="Reset" ToolTip="{DynamicResource Reset_ToolTip}" Margin="2,0"/>
<Button Style="{StaticResource MyButton}" Content="{DynamicResource Draw}" Command="{Binding MyCommand}" CommandParameter="Draw" ToolTip="{DynamicResource Draw_ToolTip}" Margin="2,0"/>
<Button Style="{StaticResource MyButton}" Content="{DynamicResource Copy}" Command="{Binding MyCommand}" CommandParameter="Copy" ToolTip="{DynamicResource Copy_ToolTip}" Margin="2,0"/>
<Button Style="{StaticResource MyButton}" Content="{DynamicResource Reset}" ToolTip="{DynamicResource Reset_ToolTip}" Margin="2,0" Click="Reset_Button_Click"/>
<Button Style="{StaticResource MyButton}" Content="{DynamicResource Draw}" ToolTip="{DynamicResource Draw_ToolTip}" Margin="2,0" Click="Draw_Button_Click"/>
<Button Style="{StaticResource MyButton}" Content="{DynamicResource Copy}" ToolTip="{DynamicResource Copy_ToolTip}" Margin="2,0" Click="Copy_Button_Click"/>
</UniformGrid>
</Grid>
</Grid>
Expand All @@ -140,13 +141,20 @@
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Slider Maximum="30" Minimum="1" SmallChange="1" AutoToolTipPrecision="0" AutoToolTipPlacement="BottomRight" ToolTip="{DynamicResource FontSize}" Value="{Binding ViewFontSize}" Margin="10,5"/>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="{DynamicResource FontSize}"/>
<Slider Grid.Column="1" Maximum="30" Minimum="1" SmallChange="1" AutoToolTipPrecision="0" AutoToolTipPlacement="BottomRight" Value="{Binding ViewFontSize}" Margin="10,5"/>
</Grid>
<Border Grid.Row="1" Background="White" BorderBrush="#233" BorderThickness="2" CornerRadius="5">
<Border.Effect>
<DropShadowEffect ShadowDepth="0" BlurRadius="10" Opacity=".5" Color="Gray"/>
</Border.Effect>
<ScrollViewer Margin="1" HorizontalScrollBarVisibility="Auto">
<TextBox x:Name="BrailleView" VerticalAlignment="Center" HorizontalAlignment="Center" BorderThickness="0" IsReadOnly="True" FontSize="{Binding ViewFontSize}" Text="{Binding BrailleDraw}" PreviewMouseWheel="ViewScale_Change"/>
<ScrollViewer Margin="1" HorizontalScrollBarVisibility="Auto" PreviewMouseWheel="ViewScale_Change">
<TextBox x:Name="BrailleView" VerticalAlignment="Center" HorizontalAlignment="Center" BorderThickness="0" IsReadOnly="True" FontSize="{Binding ViewFontSize}" Text="{Binding BrailleDraw}"/>
</ScrollViewer>
</Border>
</Grid>
Expand Down
Loading

0 comments on commit 0d3f421

Please sign in to comment.