Skip to content
This repository has been archived by the owner on Aug 17, 2024. It is now read-only.

Commit

Permalink
游戏选择界面调整
Browse files Browse the repository at this point in the history
  • Loading branch information
Isayama-Kagura committed Apr 10, 2023
1 parent c9cf896 commit 1dcaa83
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 56 deletions.
10 changes: 2 additions & 8 deletions TsubakiTranslator/HookResultDisplay.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,10 @@
xmlns:local="clr-namespace:TsubakiTranslator"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d" >
<!--<ScrollViewer materialDesign:ScrollViewerAssist.IsAutoHideEnabled="True"
HorizontalScrollBarVisibility="Disabled"
Style="{StaticResource ScrollViewerStyle}">
<StackPanel x:Name="DisplayStackPanel">
</StackPanel>
</ScrollViewer>-->

<DataGrid x:Name="HookDataGrid" AutoGenerateColumns="False"
CanUserAddRows="False" Background="WhiteSmoke"
HeadersVisibility="All"
HeadersVisibility="All" SelectionMode="Single"
SelectionUnit="FullRow">

<DataGrid.Columns>
Expand Down
7 changes: 2 additions & 5 deletions TsubakiTranslator/HookResultDisplay.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,13 @@ public void UpdateHookResultItem(string hookcode, string content)
HookItemDict[hookcode].HookText = content;
else
{
HookData item = new HookData(hookcode, content);
HookItemDict.Add(hookcode, item);
//Dispatcher是一个线程控制器,要控制线程里跑的东西,就要经过它。
//WPF里面,有个所谓UI线程,后台代码不能直接操作UI控件,需要控制,就要通过这个Dispatcher。
App.Current.Dispatcher.Invoke((Action)(() =>
{
/// start 你的逻辑代码
//HookResultItem item = new HookResultItem(hookcode, content, translateWindow);
//HookItemDict.Add(hookcode, item);
//DisplayStackPanel.Children.Add(item);
HookData item = new HookData(hookcode, content);
HookItemDict.Add(hookcode, item);
HookDataSet.Add(item);
/// end
}));
Expand Down
2 changes: 1 addition & 1 deletion TsubakiTranslator/TsubakiTranslator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<Company>OTAKU Technology Co., Ltd.</Company>
<PackageProjectUrl>https://github.com/Isayama-Kagura/TsubakiTranslator</PackageProjectUrl>
<Copyright>© 2021 Tsubaki Translator</Copyright>
<Version>1.0.6.0</Version>
<Version>1.0.6.1</Version>
<Product>Tsubaki Translator</Product>
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>

Expand Down
85 changes: 46 additions & 39 deletions TsubakiTranslator/UserGamePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
but we can used the attached property based event to handle the response -->
<DockPanel LastChildFill="False" Grid.Row="0">
<Button Command="{x:Static materialDesign:DialogHost.OpenDialogCommand}"
IsEnabled="{Binding ElementName=GameList, Path=SelectedItems.Count}"
IsEnabled="{Binding ElementName=GameListDataGrid, Path=SelectedItems.Count}"
Click="OpenHistoryGame_Button_Click"
Width="60" Content="打开" Cursor="Hand" Margin="10">
<Button.CommandParameter>
Expand Down Expand Up @@ -86,7 +86,7 @@
Width="80" Content="打开" Cursor="Hand" Margin="5" IsEnabled="{Binding ElementName=GameList, Path=SelectedItems.Count}"/>-->

<Button Click="DeleteGame_Button_Click"
Width="60" Content="删除" Cursor="Hand" Margin="5" IsEnabled="{Binding ElementName=GameList, Path=SelectedItems.Count}"/>
Width="60" Content="删除" Cursor="Hand" Margin="5" IsEnabled="{Binding ElementName=GameListDataGrid, Path=SelectedItems.Count}"/>


<Button Command="{x:Static materialDesign:DialogHost.OpenDialogCommand}"
Expand Down Expand Up @@ -223,66 +223,73 @@

</DockPanel>

<ListView x:Name="GameList" ItemsSource="{Binding GameDatas, Mode=TwoWay}" Grid.Row="1"
ScrollViewer.CanContentScroll="True"
SelectionMode="Single">
<ListView.View>
<GridView>
<GridViewColumn DisplayMemberBinding="{Binding GameName, Mode=TwoWay}"
Header="游戏名" />
<GridViewColumn DisplayMemberBinding="{Binding HookCode, Mode=TwoWay}"
Header="特殊码" />
<GridViewColumn DisplayMemberBinding="{Binding DuplicateTimes, Mode=TwoWay}"
Header="重复字数" />

<GridViewColumn Header="正则替换规则">
<GridViewColumn.CellTemplate>
<DataTemplate>
<materialDesign:PopupBox x:Name="RegexPopBox" StaysOpen="True" Cursor="Hand" >
<StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" >
<Button Style="{StaticResource MaterialDesignFlatButton}" Cursor="Hand"
<DataGrid x:Name="GameListDataGrid" AutoGenerateColumns="False" ItemsSource="{Binding GameDatas, Mode=TwoWay}"
CanUserAddRows="False" Background="WhiteSmoke" Grid.Row="1"
HeadersVisibility="All" SelectionMode="Single"
SelectionUnit="FullRow">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding GameName, Mode=TwoWay}" IsReadOnly="True"
EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
Header="游戏名" />

<DataGridTextColumn Binding="{Binding HookCode, Mode=TwoWay}" IsReadOnly="True"
EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
Header="特殊码" />

<DataGridTextColumn Binding="{Binding DuplicateTimes, Mode=TwoWay}" IsReadOnly="True"
EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
Header="重复字数" />

<DataGridTemplateColumn Header="正则替换规则">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<materialDesign:PopupBox x:Name="RegexPopBox" StaysOpen="True" Cursor="Hand" >
<StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" >
<Button Style="{StaticResource MaterialDesignFlatButton}" Cursor="Hand"
Content="{materialDesign:PackIcon Kind=Plus }" ToolTip="添加表达式"
Click="AddRegexRule_Button_Click"/>
<Button Style="{StaticResource MaterialDesignFlatButton}" Cursor="Hand"
<Button Style="{StaticResource MaterialDesignFlatButton}" Cursor="Hand"
Content="{materialDesign:PackIcon Kind=DeleteOutline }" ToolTip="清空表达式"
Click="RemoveRegexRule_Button_Click" HorizontalAlignment="Center"/>
</StackPanel>
<DataGrid ItemsSource="{Binding RegexRuleItems, Mode=TwoWay}"

</StackPanel>
<DataGrid ItemsSource="{Binding RegexRuleItems, Mode=TwoWay}"
CanUserReorderColumns="False"
CanUserSortColumns="False"
AutoGenerateColumns="False"
SelectionUnit="Cell"
SelectionMode="Single">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding SourceRegex, Mode=TwoWay}"
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding SourceRegex, Mode=TwoWay}"
Header="匹配表达式"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}" />
<DataGridTextColumn Binding="{Binding DestinationRegex, Mode=TwoWay}"
<DataGridTextColumn Binding="{Binding DestinationRegex, Mode=TwoWay}"
Header="替换表达式"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}" />

</DataGrid.Columns>
</DataGrid>
</DataGrid.Columns>
</DataGrid>

<Button Style="{StaticResource MaterialDesignFlatButton}"
<Button Style="{StaticResource MaterialDesignFlatButton}"
Command="{x:Static materialDesign:PopupBox.ClosePopupCommand}"
HorizontalAlignment="Center" Margin="5"
Content="确定"/>
</StackPanel>
</StackPanel>

</materialDesign:PopupBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</materialDesign:PopupBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>

</GridView>
</ListView.View>
</ListView>

</DataGrid>
</Grid>
</materialDesign:DialogHost>
</UserControl>
6 changes: 3 additions & 3 deletions TsubakiTranslator/UserGamePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ public UserGamePage()

private void DeleteGame_Button_Click(object sender, System.Windows.RoutedEventArgs e)
{
GameData item = (GameData)GameList.SelectedItem;
GameData item = (GameData)GameListDataGrid.SelectedItem;
App.GamesConfig.GameDatas.Remove(item);
}

private void OpenHistoryGame_Button_Click(object sender, RoutedEventArgs e)
{
SetProcessItems();

GameData item = (GameData)GameList.SelectedItem;
GameData item = (GameData)GameListDataGrid.SelectedItem;

//刷新上下文
HistoryGameInfo.DataContext = null;
Expand All @@ -55,7 +55,7 @@ private void OpenHistoryGame_Button_Click(object sender, RoutedEventArgs e)
//历史游戏记录中打开游戏
private void AcceptGame_Button_Click(object sender, System.Windows.RoutedEventArgs e)
{
GameData item = (GameData)GameList.SelectedItem;
GameData item = (GameData)GameListDataGrid.SelectedItem;

item.GameName = HistoryGameName.Text;
item.HookCode = HistoryHookCode.Text;
Expand Down

0 comments on commit 1dcaa83

Please sign in to comment.