feat: add theme switching function

dev_deconstruction
DESKTOP-3BO4HSG\ksat 2 years ago
parent f14aac14a9
commit 4757fd5b68

@ -5,8 +5,7 @@
<Application.Resources> <Application.Resources>
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/STranslate;component/Style/DictionaryButtonDefault.xaml"/> <ResourceDictionary Source="pack://application:,,,/STranslate;component/Style/Default.xaml"/>
<ResourceDictionary Source="pack://application:,,,/STranslate;component/Style/DictionaryComboBoxDefault.xaml"/>
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
</ResourceDictionary> </ResourceDictionary>
</Application.Resources> </Application.Resources>

@ -4,7 +4,6 @@
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"
mc:Ignorable="d" mc:Ignorable="d"
Background="Transparent" Background="Transparent"
WindowStartupLocation="CenterScreen" WindowStartupLocation="CenterScreen"
@ -24,14 +23,7 @@
<vm:MainVM /> <vm:MainVM />
</Window.DataContext> </Window.DataContext>
<Window.Resources> <Border Style="{DynamicResource BorderMainStyle}">
<model:VisibilityConverter x:Key="String2VisibilityConverter"/>
</Window.Resources>
<Border Background="#fff"
BorderBrush="#acacac"
BorderThickness="1"
CornerRadius="10">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="*" /> <RowDefinition Height="*" />
@ -65,7 +57,13 @@
</ControlTemplate> </ControlTemplate>
</Button.Template> </Button.Template>
</Button> </Button>
<ComboBox Style="{StaticResource cmbstyle}" <Button Template="{DynamicResource ButtonTemplate}"
Width="30"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Margin="0,0,100,0"
Click="Button_Click"/>
<ComboBox Style="{DynamicResource cmbstyle}"
Margin="0,5,10,0" Margin="0,5,10,0"
ItemsSource="{Binding TranslationInterface}" ItemsSource="{Binding TranslationInterface}"
DisplayMemberPath="Name" DisplayMemberPath="Name"
@ -79,24 +77,10 @@
Margin="10,0,10,0"> Margin="10,0,10,0">
<!--输入框--> <!--输入框-->
<Border x:Name="BorderInput" <Border x:Name="BorderInput"
Background="#f6f6f6" Style="{DynamicResource BorderInOutputStyle}">
BorderThickness="0"
CornerRadius="4"
Margin="5">
<Grid> <Grid>
<TextBox x:Name="TextBoxInput" <TextBox x:Name="TextBoxInput"
Background="Transparent" Style="{DynamicResource TextBoxInputStyle}"
BorderBrush="{x:Null}"
Margin="10,10,5,35"
BorderThickness="0"
FontSize="16"
MinHeight="70"
MaxHeight="200"
TextWrapping="Wrap"
AcceptsReturn="True"
VerticalContentAlignment="Top"
HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Hidden"
Text="{Binding InputTxt,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"> Text="{Binding InputTxt,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}">
<TextBox.InputBindings> <TextBox.InputBindings>
<KeyBinding Command="{Binding TranslateCmd}" Key="Enter" /> <KeyBinding Command="{Binding TranslateCmd}" Key="Enter" />
@ -105,18 +89,15 @@
<StackPanel Orientation="Horizontal" <StackPanel Orientation="Horizontal"
Margin="10,5" Margin="10,5"
VerticalAlignment="Bottom"> VerticalAlignment="Bottom">
<Button Template="{StaticResource ButtonTemplate}" <Button Template="{DynamicResource ButtonTemplate}"
Visibility="{Binding InputTxt,Converter={StaticResource String2VisibilityConverter}}" Visibility="{Binding InputTxt,Converter={StaticResource String2VisibilityConverter}}"
Command="{Binding CopyInputCmd}"/> Command="{Binding CopyInputCmd}"/>
<Border Margin="10,0,0,2" <Border Style="{DynamicResource LanguageMarkBorderStyle}"
Background="#eaeaea" Visibility="{Binding IdentifyLanguage,Converter={StaticResource String2VisibilityConverter}}">
CornerRadius="8"
Visibility="{Binding IdentifyLanguage,Converter={StaticResource String2VisibilityConverter}}"
VerticalAlignment="Bottom">
<StackPanel Margin="5,2" <StackPanel Margin="5,2"
Orientation="Horizontal"> Orientation="Horizontal">
<TextBlock Text="识别为 " <TextBlock Text="识别为 "
Foreground="#999999"/> Style="{DynamicResource LanguageMarkTextBlockStyle}"/>
<TextBlock Text="{Binding IdentifyLanguage}" <TextBlock Text="{Binding IdentifyLanguage}"
Foreground="#3478f6"/> Foreground="#3478f6"/>
</StackPanel> </StackPanel>
@ -132,16 +113,16 @@
HorizontalAlignment="Center" HorizontalAlignment="Center"
Orientation="Horizontal"> Orientation="Horizontal">
<TextBlock Text="当前语言: " <TextBlock Text="当前语言: "
VerticalAlignment="Center"/> Style="{DynamicResource MidStyle}"/>
<ComboBox x:Name="InCombo" <ComboBox x:Name="InCombo"
Style="{StaticResource cmbstyle}" Style="{DynamicResource cmbstyle}"
ItemsSource="{Binding InputCombo}" ItemsSource="{Binding InputCombo}"
SelectedItem="{Binding InputComboSelected,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" /> SelectedItem="{Binding InputComboSelected,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
<Separator Margin="20,0"/> <Separator Margin="20,0"/>
<TextBlock Text="目标语言: " <TextBlock Text="目标语言: "
VerticalAlignment="Center"/> Style="{DynamicResource MidStyle}"/>
<ComboBox x:Name="OutCombo" <ComboBox x:Name="OutCombo"
Style="{StaticResource cmbstyle}" Style="{DynamicResource cmbstyle}"
ItemsSource="{Binding OutputCombo}" ItemsSource="{Binding OutputCombo}"
SelectedItem="{Binding OutputComboSelected,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" /> SelectedItem="{Binding OutputComboSelected,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
</StackPanel> </StackPanel>
@ -152,44 +133,31 @@
Grid.Row="3"> Grid.Row="3">
<!--输出框--> <!--输出框-->
<Border x:Name="BorderOutput" <Border x:Name="BorderOutput"
Background="#f6f6f6" Style="{DynamicResource BorderInOutputStyle}"
BorderThickness="0"
CornerRadius="4"
Margin="5"
Height="{Binding ElementName=Output, Path=Height}"> Height="{Binding ElementName=Output, Path=Height}">
<Grid> <Grid>
<TextBox x:Name="TextBoxOutput" <TextBox x:Name="TextBoxOutput"
Background="Transparent" Style="{DynamicResource TextBoxOutputStyle}"
BorderBrush="{x:Null}" Text="{Binding OutputTxt}"/>
BorderThickness="0"
IsReadOnly="True"
Margin="10,10,5,35"
MaxHeight="400"
FontSize="16"
TextWrapping="Wrap"
VerticalContentAlignment="Top"
HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Hidden"
Text="{Binding OutputTxt}"/>
<StackPanel Orientation="Horizontal" <StackPanel Orientation="Horizontal"
Margin="10,5" Margin="10,5"
VerticalAlignment="Bottom"> VerticalAlignment="Bottom">
<!--普通复制--> <!--普通复制-->
<Button Template="{StaticResource ButtonTemplate}" <Button Template="{DynamicResource ButtonTemplate}"
Visibility="{Binding OutputTxt,Converter={StaticResource String2VisibilityConverter}}" Visibility="{Binding OutputTxt,Converter={StaticResource String2VisibilityConverter}}"
Command="{Binding CopyResultCmd}"/> Command="{Binding CopyResultCmd}"/>
<!--蛇形复制--> <!--蛇形复制-->
<Button Margin="5,0" <Button Margin="5,0"
Template="{StaticResource ButtonTemplateSnakeCopy}" Template="{DynamicResource ButtonTemplateSnakeCopy}"
Visibility="{Binding SnakeRet,Converter={StaticResource String2VisibilityConverter}}" Visibility="{Binding SnakeRet,Converter={StaticResource String2VisibilityConverter}}"
Command="{Binding CopySnakeResultCmd}"/> Command="{Binding CopySnakeResultCmd}"/>
<!--小驼峰复制--> <!--小驼峰复制-->
<Button Template="{StaticResource ButtonTemplateSmallHumpCopy}" <Button Template="{DynamicResource ButtonTemplateSmallHumpCopy}"
Visibility="{Binding SmallHumpRet,Converter={StaticResource String2VisibilityConverter}}" Visibility="{Binding SmallHumpRet,Converter={StaticResource String2VisibilityConverter}}"
Command="{Binding CopySmallHumpResultCmd}"/> Command="{Binding CopySmallHumpResultCmd}"/>
<!--大驼峰复制--> <!--大驼峰复制-->
<Button Margin="5,0" <Button Margin="5,0"
Template="{StaticResource ButtonTemplateLargeHumpCopy}" Template="{DynamicResource ButtonTemplateLargeHumpCopy}"
Visibility="{Binding LargeHumpRet,Converter={StaticResource String2VisibilityConverter}}" Visibility="{Binding LargeHumpRet,Converter={StaticResource String2VisibilityConverter}}"
Command="{Binding CopyLargeHumpResultCmd}"/> Command="{Binding CopyLargeHumpResultCmd}"/>
</StackPanel> </StackPanel>

@ -282,5 +282,17 @@ namespace STranslate
private static readonly BitmapImage _Topmost = new BitmapImage(new Uri("pack://application:,,,/STranslate;component/Images/Button_Default/topmost.png")); private static readonly BitmapImage _Topmost = new BitmapImage(new Uri("pack://application:,,,/STranslate;component/Images/Button_Default/topmost.png"));
private static readonly BitmapImage _UnTopmost = new BitmapImage(new Uri("pack://application:,,,/STranslate;component/Images/Button_Default/untopmost.png")); private static readonly BitmapImage _UnTopmost = new BitmapImage(new Uri("pack://application:,,,/STranslate;component/Images/Button_Default/untopmost.png"));
private System.Windows.Forms.NotifyIcon notifyIcon = new System.Windows.Forms.NotifyIcon(); private System.Windows.Forms.NotifyIcon notifyIcon = new System.Windows.Forms.NotifyIcon();
private void Button_Click(object sender, RoutedEventArgs e)
{
if (Application.Current.Resources.MergedDictionaries[0].Source.ToString() == "pack://application:,,,/STranslate;component/Style/Dark.xaml")
{
Application.Current.Resources.MergedDictionaries[0].Source = new Uri("pack://application:,,,/STranslate;component/Style/Default.xaml");
}
else
{
Application.Current.Resources.MergedDictionaries[0].Source = new Uri("pack://application:,,,/STranslate;component/Style/Dark.xaml");
}
}
} }
} }

@ -108,11 +108,35 @@
<DependentUpon>MainWindow.xaml</DependentUpon> <DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Page Include="Style\DictionaryButtonDefault.xaml"> <Page Include="Style\Dark.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Style\Default.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Style\Dark\DictionaryButtonDark.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Style\Dark\DictionaryComboBoxDark.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Style\Dark\DictionaryCommonDark.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Style\Default\DictionaryButtonDefault.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Style\Default\DictionaryComboBoxDefault.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Style\DictionaryComboBoxDefault.xaml"> <Page Include="Style\Default\DictionaryCommonDefault.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>

@ -0,0 +1,9 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/STranslate;component/Style/Dark/DictionaryButtonDark.xaml"/>
<ResourceDictionary Source="pack://application:,,,/STranslate;component/Style/Dark/DictionaryComboBoxDark.xaml"/>
<ResourceDictionary Source="pack://application:,,,/STranslate;component/Style/Dark/DictionaryCommonDark.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

@ -0,0 +1,71 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ControlTemplate x:Key="ButtonTemplate" TargetType="Button">
<Border x:Name="border"
CornerRadius="5"
Padding="4"
MaxHeight="25">
<Image Source="pack://application:,,,/STranslate;component/Images/Button_Default/copy_default.png"/>
</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="ButtonTemplateSnakeCopy" TargetType="Button">
<Border x:Name="border"
CornerRadius="5"
Padding="4"
MaxHeight="25">
<Image Source="pack://application:,,,/STranslate;component/Images/Button_Default/copy_snake.png"/>
</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="ButtonTemplateSmallHumpCopy" TargetType="Button">
<Border x:Name="border"
CornerRadius="5"
Padding="4"
MaxHeight="25">
<Image Source="pack://application:,,,/STranslate;component/Images/Button_Default/copy_small_hump.png"/>
</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="ButtonTemplateLargeHumpCopy" TargetType="Button">
<Border x:Name="border"
CornerRadius="5"
Padding="4"
MaxHeight="25">
<Image Source="pack://application:,,,/STranslate;component/Images/Button_Default/copy_large_hump.png"/>
</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>
</ResourceDictionary>

@ -0,0 +1,176 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!--引入字体文件-->
<Style x:Key="IconStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="/STranslate;component/Images/#iconfont"/>
</Style>
<!--Combox-->
<Style TargetType="{x:Type ComboBox}" x:Key="cmbstyle">
<Setter Property="Background" Value="#282c34"/>
<Setter Property="Foreground" Value="WhiteSmoke"/>
<Setter Property="ItemContainerStyle">
<Setter.Value>
<!--ComBoxItem-->
<Style TargetType="ComboBoxItem">
<Setter Property="MinHeight" Value="22"/>
<Setter Property="MinWidth" Value="40"/>
<Setter Property="Foreground" Value="WhiteSmoke"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBoxItem">
<Border Name="Back"
CornerRadius="2"
Background="Transparent"
BorderThickness="0">
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5,0,0,0"></ContentPresenter>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Back" Property="Background" Value="#47484c"></Setter>
</Trigger>
<Trigger Property="IsHighlighted" Value="True">
<Setter TargetName="Back" Property="Background" Value="#47484c"></Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBox}">
<Border BorderThickness="0" CornerRadius="5" Width="80" Height="30" Background="{TemplateBinding Background}" >
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" x:Name="grid">
<ToggleButton
Width="{Binding ElementName=grid,Path=ActualWidth}"
Height="{Binding ElementName=grid, Path=ActualHeight}"
Content="{TemplateBinding Text}" VerticalAlignment="Center"
HorizontalAlignment="Left" Margin="5,0,0,0"
BorderThickness="0"
Foreground="{TemplateBinding Foreground}"
Background="{TemplateBinding Background}"
IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press">
<ToggleButton.Style >
<Style TargetType="ToggleButton">
<Setter Property="Background" Value="#282c34"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToggleButton">
<Border Background="{TemplateBinding Background}" BorderThickness="0" >
<TextBlock Foreground="{TemplateBinding Foreground}" Text="{TemplateBinding Content}" Margin="4 0 0 0" HorizontalAlignment="Left" VerticalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="White"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="False">
<Setter Property="Background" Value="White"/>
</Trigger>
</Style.Triggers>
</Style>
</ToggleButton.Style>
</ToggleButton>
</Grid>
<Grid Grid.Column="1" >
<ToggleButton IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
Foreground="{TemplateBinding Foreground}"
ClickMode="Press">
<ToggleButton.Style>
<Style TargetType="ToggleButton">
<Setter Property="Background" Value="#282c34"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToggleButton">
<Border Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}">
<Grid>
<TextBlock Foreground="{TemplateBinding Foreground}" x:Name="arrow_tb" Text="&#xe61d;" Style="{StaticResource IconStyle}" HorizontalAlignment="Center" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5">
<TextBlock.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</TextBlock.RenderTransform>
</TextBlock>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
</Trigger>
<EventTrigger RoutedEvent="Checked">
<BeginStoryboard>
<Storyboard >
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="arrow_tb" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
<EasingDoubleKeyFrame KeyTime="00:00:00.2000000" Value="180"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="Unchecked">
<BeginStoryboard>
<Storyboard >
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="arrow_tb" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="180"/>
<EasingDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ToggleButton.Style>
</ToggleButton>
</Grid>
<Popup IsOpen="{TemplateBinding IsDropDownOpen}"
Placement="Bottom" x:Name="Popup"
Focusable="False"
AllowsTransparency="True"
PopupAnimation="Slide">
<Border x:Name="DropDown"
CornerRadius="5"
MaxHeight="{TemplateBinding MaxDropDownHeight}"
MinWidth="{TemplateBinding ActualWidth}"
SnapsToDevicePixels="True">
<Border.Effect>
<DropShadowEffect Color="Black" BlurRadius="2" ShadowDepth="0" Opacity="0.5"/>
</Border.Effect>
<ScrollViewer Margin="4,6,4,6" MaxHeight="{TemplateBinding MaxDropDownHeight}" SnapsToDevicePixels="True" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" CanContentScroll="True">
<!-- StackPanel 用于显示子级,方法是将 IsItemsHost 设置为 True -->
<StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" Background="#282c34"/>
</ScrollViewer>
</Border>
</Popup>
</Grid>
<Border.Effect>
<DropShadowEffect ShadowDepth="-1" Opacity="0.3" Color="#FF969696" BlurRadius="2"/>
</Border.Effect>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

@ -0,0 +1,68 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:model="clr-namespace:STranslate.Model"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<model:VisibilityConverter x:Key="String2VisibilityConverter"/>
<Style x:Key="BorderMainStyle"
TargetType="Border">
<Setter Property="Background" Value="#2e323a"/>
<Setter Property="BorderBrush" Value="Gray"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="CornerRadius" Value="10"/>
</Style>
<Style x:Key="BorderInOutputStyle"
TargetType="Border">
<Setter Property="Background" Value="#282c34"/>
<Setter Property="BorderBrush" Value="{x:Null}"/>
<Setter Property="CornerRadius" Value="4"/>
<Setter Property="Margin" Value="5"/>
</Style>
<Style x:Key="TextBoxInputStyle"
TargetType="TextBox">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="WhiteSmoke"/>
<Setter Property="BorderBrush" Value="{x:Null}"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="FontSize" Value="16"/>
<Setter Property="MinHeight" Value="70"/>
<Setter Property="MaxHeight" Value="200"/>
<Setter Property="AcceptsReturn" Value="True"/>
<Setter Property="TextWrapping" Value="Wrap"/>
<Setter Property="VerticalContentAlignment" Value="Top"/>
<Setter Property="HorizontalScrollBarVisibility" Value="Disabled"/>
<Setter Property="VerticalScrollBarVisibility" Value="Hidden"/>
</Style>
<Style x:Key="LanguageMarkBorderStyle"
TargetType="Border">
<Setter Property="Background" Value="#999999"/>
<Setter Property="Margin" Value="10,0,0,2"/>
<Setter Property="CornerRadius" Value="8"/>
<Setter Property="VerticalAlignment" Value="Bottom"/>
</Style>
<Style x:Key="LanguageMarkTextBlockStyle"
TargetType="TextBlock">
<Setter Property="Foreground" Value="#eaeaea"/>
</Style>
<Style x:Key="TextBoxOutputStyle"
TargetType="TextBox">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="WhiteSmoke"/>
<Setter Property="BorderBrush" Value="{x:Null}"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="IsReadOnly" Value="True"/>
<Setter Property="Margin" Value="10,10,5,35"/>
<Setter Property="FontSize" Value="16"/>
<Setter Property="MaxHeight" Value="400"/>
<Setter Property="TextWrapping" Value="Wrap"/>
<Setter Property="VerticalContentAlignment" Value="Top"/>
<Setter Property="HorizontalScrollBarVisibility" Value="Disabled"/>
<Setter Property="VerticalScrollBarVisibility" Value="Hidden"/>
</Style>
<Style x:Key="MidStyle"
TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Foreground" Value="WhiteSmoke"/>
</Style>
</ResourceDictionary>

@ -0,0 +1,9 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/STranslate;component/Style/Default/DictionaryButtonDefault.xaml"/>
<ResourceDictionary Source="pack://application:,,,/STranslate;component/Style/Default/DictionaryComboBoxDefault.xaml"/>
<ResourceDictionary Source="pack://application:,,,/STranslate;component/Style/Default/DictionaryCommonDefault.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

@ -0,0 +1,64 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:model="clr-namespace:STranslate.Model"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<model:VisibilityConverter x:Key="String2VisibilityConverter"/>
<Style x:Key="BorderMainStyle"
TargetType="Border">
<Setter Property="Background" Value="#ffffff"/>
<Setter Property="BorderBrush" Value="#acacac"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="CornerRadius" Value="10"/>
</Style>
<Style x:Key="BorderInOutputStyle"
TargetType="Border">
<Setter Property="Background" Value="#f6f6f6"/>
<Setter Property="BorderBrush" Value="{x:Null}"/>
<Setter Property="CornerRadius" Value="4"/>
<Setter Property="Margin" Value="5"/>
</Style>
<Style x:Key="TextBoxInputStyle"
TargetType="TextBox">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="{x:Null}"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="FontSize" Value="16"/>
<Setter Property="MinHeight" Value="70"/>
<Setter Property="MaxHeight" Value="200"/>
<Setter Property="AcceptsReturn" Value="True"/>
<Setter Property="TextWrapping" Value="Wrap"/>
<Setter Property="VerticalContentAlignment" Value="Top"/>
<Setter Property="HorizontalScrollBarVisibility" Value="Disabled"/>
<Setter Property="VerticalScrollBarVisibility" Value="Hidden"/>
</Style>
<Style x:Key="LanguageMarkBorderStyle"
TargetType="Border">
<Setter Property="Background" Value="#eaeaea"/>
<Setter Property="Margin" Value="10,0,0,2"/>
<Setter Property="CornerRadius" Value="8"/>
<Setter Property="VerticalAlignment" Value="Bottom"/>
</Style>
<Style x:Key="LanguageMarkTextBlockStyle"
TargetType="TextBlock">
<Setter Property="Foreground" Value="#999999"/>
</Style>
<Style x:Key="TextBoxOutputStyle"
TargetType="TextBox">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="{x:Null}"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="IsReadOnly" Value="True"/>
<Setter Property="Margin" Value="10,10,5,35"/>
<Setter Property="FontSize" Value="16"/>
<Setter Property="MaxHeight" Value="400"/>
<Setter Property="TextWrapping" Value="Wrap"/>
<Setter Property="VerticalContentAlignment" Value="Top"/>
<Setter Property="HorizontalScrollBarVisibility" Value="Disabled"/>
<Setter Property="VerticalScrollBarVisibility" Value="Hidden"/>
</Style>
<Style x:Key="MidStyle"
TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</ResourceDictionary>

@ -15,7 +15,6 @@ namespace STranslate.ViewModel
public MainVM() public MainVM()
{ {
//初始化界面参数
InputCombo = LanguageEnumDict.Keys.ToList(); InputCombo = LanguageEnumDict.Keys.ToList();
InputComboSelected = LanguageEnum.AUTO.GetDescription(); InputComboSelected = LanguageEnum.AUTO.GetDescription();
OutputCombo = LanguageEnumDict.Keys.ToList(); OutputCombo = LanguageEnumDict.Keys.ToList();
@ -49,6 +48,10 @@ namespace STranslate.ViewModel
{ {
Clipboard.SetText(LargeHumpRet); Clipboard.SetText(LargeHumpRet);
}); });
ThemeConvertCmd = new RelayCommand((_) => true, (_) =>
{
});
//翻译 //翻译
TranslateCmd = new RelayCommand((_) => TranslateCmd = new RelayCommand((_) =>
@ -186,6 +189,7 @@ namespace STranslate.ViewModel
public ICommand CopySnakeResultCmd { get; private set; } public ICommand CopySnakeResultCmd { get; private set; }
public ICommand CopySmallHumpResultCmd { get; private set; } public ICommand CopySmallHumpResultCmd { get; private set; }
public ICommand CopyLargeHumpResultCmd { get; private set; } public ICommand CopyLargeHumpResultCmd { get; private set; }
public ICommand ThemeConvertCmd { get; private set; }
/// <summary> /// <summary>
/// 识别语种 /// 识别语种

Loading…
Cancel
Save