Skip to content
This repository was archived by the owner on Aug 22, 2023. It is now read-only.

Commit debef46

Browse files
committed
重构UI,添加搜索功能,优化程序性能。
1 parent 28c67a2 commit debef46

File tree

7 files changed

+597
-549
lines changed

7 files changed

+597
-549
lines changed

.idea/.idea.Minecraft Mods Translator/.idea/.name

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Translator/App.xaml

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
<Application x:Class="Translator.App"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4-
xmlns:local="clr-namespace:Translator"
54
StartupUri="MainWindow.xaml">
65
<Application.Resources>
76
<ResourceDictionary>
87
<ResourceDictionary.MergedDictionaries>
9-
<ResourceDictionary Source="pack://application:,,,/Panuon.UI.Silver;component/Control.xaml" />
8+
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
9+
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
10+
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
11+
<!-- Theme setting -->
12+
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml" />
1013
</ResourceDictionary.MergedDictionaries>
1114
</ResourceDictionary>
1215
</Application.Resources>

Translator/App.xaml.cs

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
namespace Translator
1+
namespace Translator;
2+
/// <summary>
3+
/// Interaction logic for App.xaml
4+
/// </summary>
5+
public partial class App
26
{
3-
/// <summary>
4-
/// Interaction logic for App.xaml
5-
/// </summary>
6-
public partial class App
7-
{
8-
}
97
}

Translator/MainWindow.xaml

+113-58
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
1-
<Window Title="Minecraft Mods Translator"
2-
Height="600"
3-
MinHeight="600"
4-
MinWidth="960"
5-
Width="960"
6-
x:Class="Translator.MainWindow"
7-
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
8-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
9-
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
10-
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
11-
xmlns:pu="clr-namespace:Panuon.UI.Silver;assembly=Panuon.UI.Silver" xmlns:avalonEdit="http://icsharpcode.net/sharpdevelop/avalonedit"
12-
mc:Ignorable="d">
1+
<mah:MetroWindow Title="Minecraft Mods Translator"
2+
Height="600"
3+
MinHeight="600"
4+
MinWidth="960"
5+
Width="960"
6+
x:Class="Translator.MainWindow"
7+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
8+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
9+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
10+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
11+
xmlns:avalonEdit="http://icsharpcode.net/sharpdevelop/avalonedit"
12+
xmlns:mah="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
13+
xmlns:hltb="clr-namespace:HighlightTextBlock;assembly=HighlightTextBlock"
14+
xmlns:translator="clr-namespace:Translator"
15+
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
16+
mc:Ignorable="d">
1317
<Window.Resources>
1418
<RoutedUICommand x:Key="onCtrlSPress"/>
1519
<Style TargetType="{x:Type Button}" x:Key="LeftButtonStyle">
1620
<Setter Property="Height" Value="60" />
17-
<Setter Property="Background" Value="#BDBDBD" />
21+
<Setter Property="Background" Value="WhiteSmoke" />
1822
<Setter Property="FontSize" Value="20" />
1923
<Setter Property="BorderThickness" Value="0" />
2024
<Setter Property="Foreground" Value="White"></Setter>
@@ -50,6 +54,17 @@
5054
Command="{StaticResource onCtrlSPress}"
5155
Executed="CtrlSOnExecuted"/>
5256
</Window.CommandBindings>
57+
58+
<mah:MetroWindow.RightWindowCommands>
59+
<mah:WindowCommands>
60+
<Button Click="OpenGithubSite" ToolTip="打开Github页面">
61+
<iconPacks:Unicons Width="22"
62+
Height="22"
63+
Kind="Github" />
64+
</Button>
65+
</mah:WindowCommands>
66+
</mah:MetroWindow.RightWindowCommands>
67+
5368
<Grid Loaded="Grid_Loaded">
5469
<Grid.ColumnDefinitions>
5570
<ColumnDefinition Width="*" />
@@ -58,7 +73,7 @@
5873
</Grid.ColumnDefinitions>
5974

6075
<TextBlock
61-
Text="版本:0.1.4"
76+
Text="版本:0.2"
6277
Grid.Column="2"
6378
HorizontalAlignment="Right"
6479
VerticalAlignment="Bottom"
@@ -70,19 +85,20 @@
7085
Margin="10">
7186
<StackPanel
7287
VerticalAlignment="Top"
73-
Background="#BDBDBD"
88+
Background="WhiteSmoke"
7489
>
75-
<Button Content="打开" Style="{StaticResource LeftButtonStyle}" Click="OpenFileOnClick"/>
76-
<Button Content="保存" Style="{StaticResource LeftButtonStyle}" Click="SaveFileOnClick"/>
90+
<Button Content="打开" Foreground="Black" Style="{StaticResource LeftButtonStyle}" Click="OpenFileOnClick"/>
91+
<Button Content="保存" Foreground="Black" Style="{StaticResource LeftButtonStyle}" Click="SaveFileOnClick"/>
7792
</StackPanel>
7893
<Separator Opacity="0" Height="20"/>
7994
<StackPanel
8095
HorizontalAlignment="Center">
81-
<CheckBox x:Name="ReviewCheckBox">审阅模式</CheckBox>
96+
<mah:ToggleSwitch x:Name="ReviewCheckBox">审阅模式</mah:ToggleSwitch>
8297
<Separator Opacity="0" Height="10"/>
83-
<CheckBox x:Name="MarkCheckBox" Checked="MarkCheckBox_OnChecked" Unchecked="MarkCheckBox_OnUnchecked">标记中英文重复</CheckBox>
98+
<mah:ToggleSwitch x:Name="MarkCheckBox" Toggled="MarkCheckBox_OnToggled">标记中英文重复</mah:ToggleSwitch>
99+
<Separator Opacity="0" Height="10"/>
100+
<mah:ToggleSwitch x:Name="TransCheckBox" Toggled="TransCheckBox_OnToggled">机翻</mah:ToggleSwitch>
84101
<Separator Opacity="0" Height="10"/>
85-
<CheckBox x:Name="TransCheckBox" Checked="TransCheckBox_OnChecked" Unchecked="TransCheckBox_OnUnchecked">机翻</CheckBox>
86102
</StackPanel>
87103
</StackPanel>
88104
<Border
@@ -136,7 +152,8 @@
136152
IsReadOnly="True"
137153
BorderBrush="Gray"
138154
BorderThickness="1"
139-
ShowLineNumbers="True"/>
155+
ShowLineNumbers="True"
156+
ScrollViewer.HorizontalScrollBarVisibility="Hidden"/>
140157
</Grid>
141158
<Grid Grid.Row="2">
142159
<Grid.RowDefinitions>
@@ -151,14 +168,15 @@
151168
BorderBrush="Gray"
152169
BorderThickness="1"
153170
ShowLineNumbers="True"
171+
ScrollViewer.HorizontalScrollBarVisibility="Hidden"
154172
TextChanged="AvalonEditor_OnTextChanged"/>
155173
</Grid>
156174
<Grid Grid.Row="3" Visibility="Hidden" x:Name="TransHidden1">
157175
<Grid.RowDefinitions>
158176
<RowDefinition Height="*"></RowDefinition>
159177
<RowDefinition Height="2*"></RowDefinition>
160178
</Grid.RowDefinitions>
161-
<Label Grid.Row="0" Content="系统推荐翻译(点击选择)" Background="White" FontSize="11"></Label>
179+
<Label Grid.Row="0" Content="系统翻译(点击选择)" Background="White" FontSize="11"></Label>
162180
<ItemsControl x:Name="TranslateSelector" Grid.Row="1">
163181
<ItemsControl.ItemsPanel>
164182
<ItemsPanelTemplate>
@@ -178,8 +196,6 @@
178196
Foreground="Black"
179197
BorderThickness="0"
180198
FontFamily="misans"
181-
pu:ButtonHelper.HoverBackground="#6CBCEA"
182-
pu:ButtonHelper.HoverForeground="White"
183199
Click="TransSelectClick"/>
184200
</DataTemplate>
185201
</ItemsControl.ItemTemplate>
@@ -210,57 +226,96 @@
210226
<RowDefinition Height="*"></RowDefinition>
211227
</Grid.RowDefinitions>
212228
<Button Grid.Row="0" BorderThickness="1" Content="提交" Click="SubmitOnClick" Margin="0,5"
213-
Background="#6CBCEA"
214-
Foreground="White"
215-
pu:ButtonHelper.CornerRadius="3"
216-
pu:ShadowHelper.Direction="240"/>
229+
Background="WhiteSmoke"
230+
Foreground="Black"/>
217231
<Button Grid.Row="1" BorderThickness="1" Content="跳过" Click="SkipOnClick" Margin="0,5"
218-
Background="#6CBCEA"
219-
Foreground="White"
220-
pu:ButtonHelper.CornerRadius="3"
221-
pu:ShadowHelper.Direction="240"/>
232+
Background="WhiteSmoke"
233+
Foreground="Black"/>
222234
<Button Grid.Row="2" BorderThickness="1" Content="上一个" Click="LastOnClick" Margin="0,5"
223-
Background="#5CACDA"
224-
Foreground="White"
225-
pu:ButtonHelper.CornerRadius="3"
226-
pu:ShadowHelper.Direction="240"/>
235+
Background="WhiteSmoke"
236+
Foreground="Black"/>
227237
</Grid>
228238

229239
</Grid>
230240

231241

232242

233243

234-
<Grid Grid.Row="0" Grid.Column="0" Background="#8FBC8F" x:Name="WordListLayout" Margin="10,10">
244+
<Grid Grid.Row="0" Grid.Column="0" Background="White" x:Name="WordListLayout" Margin="10,10">
235245
<Grid.RowDefinitions>
236-
<RowDefinition Height="2*"></RowDefinition>
246+
<RowDefinition Height="0.8*"></RowDefinition>
247+
<RowDefinition Height="1.2*"></RowDefinition>
237248
<RowDefinition Height="11*"></RowDefinition>
238249
</Grid.RowDefinitions>
239-
<Label Grid.Row="0" Background="#8FBC8F" Content="模组词库列表" FontFamily="misans" FontSize="20" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White" x:Name="ViewCount"/>
240-
<ListBox Grid.Row="1" Background="#AFDCAF" x:Name="TransWordList" SelectionChanged="TransWordList_OnSelectionChanged">
250+
<Label Grid.Row="0" Background="White" Content="模组词库列表" FontFamily="misans" FontSize="20" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Black" x:Name="ViewCount"/>
251+
<TextBox Grid.Row="1" Height="40" Margin="0,0,40,10" VerticalContentAlignment="Center" x:Name="SearchBox" TextChanged="SearchBox_OnTextChanged"/>
252+
<Button Grid.Row="1" HorizontalAlignment="Right" Height="40" Width="40" Margin="0,0,0,10">🔍</Button>
253+
<Border Grid.Row="2" BorderBrush="Gainsboro" BorderThickness="1">
254+
<ListBox Background="White" x:Name="TransWordList" SelectionChanged="TransWordList_OnSelectionChanged" ScrollViewer.HorizontalScrollBarVisibility="Hidden">
255+
<ListBox.ItemTemplate>
256+
<DataTemplate>
257+
<Border BorderBrush="Beige" BorderThickness="1">
258+
<StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch" Background="White">
259+
<TextBlock
260+
VerticalAlignment="Center"
261+
Foreground="{Binding Color}"
262+
Text="{Binding Judge}"/>
263+
<StackPanel>
264+
<TextBlock
265+
Text="{Binding EnText}"
266+
Margin="5,0"
267+
Height="20"
268+
Foreground="{Binding Background}"/>
269+
<TextBlock
270+
Text="{Binding ZhText}"
271+
Margin="5,0"
272+
Height="20"
273+
Foreground="{Binding Background}"/>
274+
</StackPanel>
275+
</StackPanel>
276+
</Border>
277+
</DataTemplate>
278+
</ListBox.ItemTemplate>
279+
</ListBox>
280+
</Border>
281+
<ListBox Grid.Row="2" Background="White" x:Name="SearchWordList" ScrollViewer.HorizontalScrollBarVisibility="Hidden" Visibility="Hidden" SelectionChanged="SearchWordList_OnSelectionChanged">
241282
<ListBox.ItemTemplate>
242283
<DataTemplate>
243-
<StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch">
244-
<TextBlock
245-
VerticalAlignment="Center"
246-
Foreground="{Binding Color}"
247-
Text="{Binding Judge}"/>
248-
<StackPanel>
249-
<TextBlock
250-
Text="{Binding EnText}"
251-
Margin="5,0"
252-
Height="20"
253-
Foreground="{Binding Background}"/>
254-
<TextBlock
255-
Text="{Binding ZhText}"
256-
Margin="5,0"
257-
Height="20"
258-
Foreground="{Binding Background}"/>
284+
<Border BorderBrush="Beige" BorderThickness="1">
285+
<StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch" Background="WhiteSmoke">
286+
<TextBlock
287+
VerticalAlignment="Center"
288+
Foreground="{Binding Color}"
289+
Text="{Binding Judge}"/>
290+
<StackPanel>
291+
<TextBlock
292+
Text="{Binding EnText}"
293+
hltb:HighlightTextBlock.HightlightText="{Binding ElementName=SearchBox,Path=Text}"
294+
hltb:HighlightTextBlock.HighlightBrush="Bisque"
295+
hltb:HighlightTextBlock.HighlightTextBrush="Black"
296+
hltb:HighlightTextBlock.Bold="True"
297+
Margin="5,0"
298+
Height="20"
299+
Foreground="{Binding Background}"/>
300+
<TextBlock
301+
Text="{Binding ZhText}"
302+
hltb:HighlightTextBlock.HightlightText="{Binding ElementName=SearchBox,Path=Text}"
303+
hltb:HighlightTextBlock.HighlightBrush="Bisque"
304+
hltb:HighlightTextBlock.HighlightTextBrush="Black"
305+
hltb:HighlightTextBlock.Bold="True"
306+
Margin="5,0"
307+
Height="20"
308+
Foreground="{Binding Background}"/>
309+
</StackPanel>
259310
</StackPanel>
260-
</StackPanel>
311+
</Border>
261312
</DataTemplate>
262313
</ListBox.ItemTemplate>
263314
</ListBox>
264315
</Grid>
316+
317+
<Grid Grid.ColumnSpan="3" Background="White" x:Name="FirstPage">
318+
<Button Height="40" Width="80" Click="OpenFileOnClick">打开文件</Button>
319+
</Grid>
265320
</Grid>
266-
</Window>
321+
</mah:MetroWindow>

0 commit comments

Comments
 (0)