perf: update ui and stringconverter by original code

dev_without_third_libraries 0.06
DESKTOP-3BO4HSG\ksat 2 years ago
parent cf420e72f3
commit ccdad1fb04

@ -4,6 +4,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:STranslate.ViewModel" xmlns:vm="clr-namespace:STranslate.ViewModel"
xmlns:model="clr-namespace:STranslate.Model"
xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:hc="https://handyorg.github.io/handycontrol"
mc:Ignorable="d" mc:Ignorable="d"
Background="Transparent" Background="Transparent"
@ -23,7 +24,7 @@
<vm:MainVM /> <vm:MainVM />
</Window.DataContext> </Window.DataContext>
<Window.Resources> <Window.Resources>
<hc:String2VisibilityConverter x:Key="String2VisibilityConverter"/> <model:VisibilityConverter x:Key="String2VisibilityConverter"/>
</Window.Resources> </Window.Resources>
<Border BorderThickness="0" <Border BorderThickness="0"
Background="#fff" Background="#fff"
@ -36,33 +37,6 @@
<RowDefinition Height="7*" /> <RowDefinition Height="7*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!--托盘相关-->
<!--<hc:NotifyIcon Text="STranslate"
IsBlink="False"
Visibility="Visible"
Icon="/Images/translate.ico">
<hc:NotifyIcon.ContextMenu>
<ContextMenu Style="{StaticResource InputElementBaseStyle}"
Width="120">
<MenuItem x:Name="CrossWordTranslateMenuItem"
Click="CrossWordTranslateMenuItem_Click"
Header="划词翻译" />
<MenuItem x:Name="ScreenshotTranslateMenuItem"
Click="ScreenshotTranslateMenuItem_Click"
Header="截图翻译" />
<MenuItem x:Name="InputTranslateMenuItem"
Click="InputTranslateMenuItem_Click"
Header="输入翻译" />
<Separator />
<MenuItem Command="hc:ControlCommands.PushMainWindow2Top"
Header="显示主界面" />
<Separator />
<MenuItem Command="hc:ControlCommands.ShutdownApp"
Header="退出" />
</ContextMenu>
</hc:NotifyIcon.ContextMenu>
</hc:NotifyIcon>-->
<!--header--> <!--header-->
<Grid x:Name="Header"> <Grid x:Name="Header">
<Button Margin="5,0" <Button Margin="5,0"
@ -94,7 +68,7 @@
Margin="5,5,5,35" Margin="5,5,5,35"
BorderThickness="0" BorderThickness="0"
FontSize="16" FontSize="16"
MinHeight="80" MinHeight="70"
MaxHeight="200" MaxHeight="200"
TextWrapping="Wrap" TextWrapping="Wrap"
AcceptsReturn="True" AcceptsReturn="True"
@ -107,12 +81,14 @@
</TextBox.InputBindings> </TextBox.InputBindings>
</TextBox> </TextBox>
<StackPanel Orientation="Horizontal" <StackPanel Orientation="Horizontal"
Margin="5"> Margin="10"
VerticalAlignment="Bottom">
<Button Cursor="Hand" <Button Cursor="Hand"
Margin="5,0,0,5"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Visibility="{Binding InputTxt,Converter={StaticResource String2VisibilityConverter}}" Visibility="{Binding InputTxt,Converter={StaticResource String2VisibilityConverter}}"
MaxHeight="22"
Padding="2"
Background="Transparent"
BorderThickness="0"
Command="{Binding CopyInputCmd}"> Command="{Binding CopyInputCmd}">
<Image Source="/Images/copy2.png"/> <Image Source="/Images/copy2.png"/>
<hc:FloatingBlock.ContentTemplate> <hc:FloatingBlock.ContentTemplate>
@ -121,11 +97,10 @@
</DataTemplate> </DataTemplate>
</hc:FloatingBlock.ContentTemplate> </hc:FloatingBlock.ContentTemplate>
</Button> </Button>
<Border Margin="10,0,0,8" <Border Margin="10,0,0,0"
Background="#eaeaea" Background="#eaeaea"
CornerRadius="10" CornerRadius="10"
Visibility="{Binding IdentifyLanguage,Converter={StaticResource String2VisibilityConverter}}" Visibility="{Binding IdentifyLanguage,Converter={StaticResource String2VisibilityConverter}}"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"> VerticalAlignment="Bottom">
<StackPanel Margin="5,2" <StackPanel Margin="5,2"
Orientation="Horizontal"> Orientation="Horizontal">
@ -183,7 +158,7 @@
BorderBrush="{x:Null}" BorderBrush="{x:Null}"
BorderThickness="0" BorderThickness="0"
IsReadOnly="True" IsReadOnly="True"
Margin="5,5,5,35" Margin="5,5,5,30"
MaxHeight="400" MaxHeight="400"
FontSize="16" FontSize="16"
TextWrapping="Wrap" TextWrapping="Wrap"
@ -192,9 +167,14 @@
VerticalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"
Text="{Binding OutputTxt}"/> Text="{Binding OutputTxt}"/>
<StackPanel Orientation="Horizontal" <StackPanel Orientation="Horizontal"
Margin="5"> Margin="10,5"
VerticalAlignment="Bottom">
<!--普通复制--> <!--普通复制-->
<Button Cursor="Hand" <Button Cursor="Hand"
MaxHeight="22"
Padding="2"
Background="Transparent"
BorderThickness="0"
HorizontalAlignment="Left" HorizontalAlignment="Left"
VerticalAlignment="Bottom" VerticalAlignment="Bottom"
Visibility="{Binding OutputTxt,Converter={StaticResource String2VisibilityConverter}}" Visibility="{Binding OutputTxt,Converter={StaticResource String2VisibilityConverter}}"
@ -209,6 +189,10 @@
<!--蛇形复制--> <!--蛇形复制-->
<Button Cursor="Hand" <Button Cursor="Hand"
Margin="5,0" Margin="5,0"
MaxHeight="22"
Padding="2"
Background="Transparent"
BorderThickness="0"
HorizontalAlignment="Left" HorizontalAlignment="Left"
VerticalAlignment="Bottom" VerticalAlignment="Bottom"
Visibility="{Binding SnakeRet,Converter={StaticResource String2VisibilityConverter}}" Visibility="{Binding SnakeRet,Converter={StaticResource String2VisibilityConverter}}"
@ -222,6 +206,10 @@
</Button> </Button>
<!--驼峰复制--> <!--驼峰复制-->
<Button Cursor="Hand" <Button Cursor="Hand"
MaxHeight="22"
Padding="2"
Background="Transparent"
BorderThickness="0"
HorizontalAlignment="Left" HorizontalAlignment="Left"
VerticalAlignment="Bottom" VerticalAlignment="Bottom"
Visibility="{Binding SmallHumpRet,Converter={StaticResource String2VisibilityConverter}}" Visibility="{Binding SmallHumpRet,Converter={StaticResource String2VisibilityConverter}}"
@ -236,6 +224,10 @@
<!--驼峰复制--> <!--驼峰复制-->
<Button Cursor="Hand" <Button Cursor="Hand"
Margin="5,0" Margin="5,0"
MaxHeight="22"
Padding="2"
Background="Transparent"
BorderThickness="0"
HorizontalAlignment="Left" HorizontalAlignment="Left"
VerticalAlignment="Bottom" VerticalAlignment="Bottom"
Visibility="{Binding LargeHumpRet,Converter={StaticResource String2VisibilityConverter}}" Visibility="{Binding LargeHumpRet,Converter={StaticResource String2VisibilityConverter}}"

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
namespace STranslate.Model
{
public class VisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return string.IsNullOrEmpty((string)value) ? Visibility.Collapsed : Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return value != null && (Visibility)value == Visibility.Collapsed;
}
}
}

@ -86,6 +86,7 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</ApplicationDefinition> </ApplicationDefinition>
<Compile Include="Model\VisibilityConverter.cs" />
<Compile Include="Properties\Resources.Designer.cs"> <Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>

@ -3,4 +3,4 @@ baidu:
appid: appid:
secretKey: secretKey:
deepl: deepl:
url: http://127.0.0.1:8000/translate url: https://zggsong.cn/tt

Loading…
Cancel
Save