Skip to content

Commit

Permalink
KeyBindingDefinition add DisplayName
Browse files Browse the repository at this point in the history
  • Loading branch information
MikiraSora committed Oct 28, 2024
1 parent ae46db4 commit e178576
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private static ModifierKeys GetActualModifiers(Key key, ModifierKeys modifiers)

public void ChangeKeyBinding(KeyBindingDefinition definition, Key newKey, ModifierKeys newModifier)
{
Log.LogInfo($"[{definition.Name}] {KeyBindingDefinition.FormatToExpression(definition.Key, definition.Modifiers)} --> {KeyBindingDefinition.FormatToExpression(newKey, newModifier)}");
Log.LogInfo($"[{definition.DisplayName}] {KeyBindingDefinition.FormatToExpression(definition.Key, definition.Modifiers)} --> {KeyBindingDefinition.FormatToExpression(newKey, newModifier)}");

definition.Key = newKey;
definition.Modifiers = newModifier;
Expand Down
2 changes: 2 additions & 0 deletions OngekiFumenEditor/Kernel/KeyBinding/KeyBindingDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class KeyBindingDefinition : PropertyChangedBase

public string Name => Resources.ResourceManager.GetString(resourceName);

public string DisplayName => $"[{Resources.ResourceManager.GetString($"kbd_layer_{Layer}")}]{Name}";

public KeyBindingDefinition(string resourceName, Key defaultKey, KeyBindingLayer layer = KeyBindingLayer.Normal) : this(resourceName, ModifierKeys.None, defaultKey, layer)
{ }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private void Button_Click_1(object sender, RoutedEventArgs e)
{
if (ConflictDefinition is not null)
{
if (MessageBox.Show($"你绑定的键位和 {ConflictDefinition.Name} 冲突, 如果继续绑定则清空对方冲突的键位, 是否继续?", "警告", MessageBoxButton.YesNo) != MessageBoxResult.Yes)
if (MessageBox.Show($"你绑定的键位和 {ConflictDefinition.DisplayName} 冲突, 如果继续绑定则清空对方冲突的键位, 是否继续?", "警告", MessageBoxButton.YesNo) != MessageBoxResult.Yes)
return;
}
UpdateExpression();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public KeyBindingSettingViewModel()
{
keybindingManager = IoC.Get<IKeyBindingManager>();

definitions = keybindingManager.KeyBindingDefinations.ToArray();
definitions = keybindingManager.KeyBindingDefinations.OrderBy(x => x.DisplayName).ToArray();
UpdateDisplayList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,46 @@
<UserControl.Resources>
<valueconverters:ShowKeybindExpressionValueConverter x:Key="ShowKeybindExpressionValueConverter" />
</UserControl.Resources>
<Grid >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Margin="15,15,15,0" >
<StackPanel Margin="15,15,15,0">
<StackPanel Orientation="Horizontal">
<TextBlock VerticalAlignment="Center" Text="{markup:Translate [Filter],StringFormat={}:}" FontSize="15"/>
<TextBox cal:Message.Attach="UpdateDisplayList()" Padding="0,4" Text="{Binding FilterKeywords}" Width="200" Margin="10,0"/>
<TextBlock
VerticalAlignment="Center"
FontSize="15"
Text="{markup:Translate [Filter],
StringFormat={}:}" />
<TextBox
Width="200"
Margin="10,0"
Padding="0,4"
cal:Message.Attach="UpdateDisplayList()"
Text="{Binding FilterKeywords}" />
</StackPanel>
<StackPanel Margin="0,5,0,15" Orientation="Horizontal">
<CheckBox IsChecked="{Binding IsShowNotAssignOnly}" Content="{markup:Translate [ShowNotAssignKeybindingOnly]}" cal:Message.Attach="UpdateDisplayList()" VerticalAlignment="Center"/>
<Button
VerticalAlignment="Center"
Margin="10,0"
Padding="10,5"
cal:Message.Attach="ResetAllDefinitions()"
Content="{markup:Translate [ResetAllKeybindings]}" />
<CheckBox
VerticalAlignment="Center"
cal:Message.Attach="UpdateDisplayList()"
Content="{markup:Translate [ShowNotAssignKeybindingOnly]}"
IsChecked="{Binding IsShowNotAssignOnly}" />
<Button
Margin="10,0"
Padding="10,5"
VerticalAlignment="Center"
cal:Message.Attach="ResetAllDefinitions()"
Content="{markup:Translate [ResetAllKeybindings]}" />
</StackPanel>
<Border Background="Gray" Height="1"/>
<Border Height="1" Background="Gray" />
</StackPanel>
<ItemsControl Grid.Row="1"
ItemsSource="{Binding Definitions}"
ScrollViewer.CanContentScroll="True"
VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.VirtualizationMode="Recycling">
<ItemsControl
Grid.Row="1"
ItemsSource="{Binding Definitions}"
ScrollViewer.CanContentScroll="True"
VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.VirtualizationMode="Recycling">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Margin="5">
Expand All @@ -51,11 +65,14 @@
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock VerticalAlignment="Center" Text="{Binding Name}" TextWrapping="WrapWithOverflow"/>
<TextBlock
VerticalAlignment="Center"
Text="{Binding DisplayName}"
TextWrapping="WrapWithOverflow" />
<Label
Grid.Column="1"
VerticalAlignment="Center"
FontWeight="Black">
Grid.Column="1"
VerticalAlignment="Center"
FontWeight="Black">
<Label.Content>
<MultiBinding Converter="{StaticResource ShowKeybindExpressionValueConverter}">
<Binding Path="Key" />
Expand All @@ -64,11 +81,11 @@
</Label.Content>
</Label>
<Button
Grid.Column="2"
Margin="30,3,3,3"
Padding="10,5"
cal:Message.Attach="ChangeKeybind($executionContext)"
Content="{markup:Translate [Change]}" />
Grid.Column="2"
Margin="30,3,3,3"
Padding="10,5"
cal:Message.Attach="ChangeKeybind($executionContext)"
Content="{markup:Translate [Change]}" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
Expand Down
27 changes: 27 additions & 0 deletions OngekiFumenEditor/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion OngekiFumenEditor/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1871,7 +1871,7 @@
</data>
<data name="InvalidColorId" xml:space="preserve">
<value>Invalid ColorId: {0}</value>
</data>
</data>
<data name="kbd_batch_ModeWallLeft" xml:space="preserve">
<value>Batch: Wall Left</value>
</data>
Expand Down Expand Up @@ -1983,4 +1983,13 @@
<data name="CannotBatchInputClipboardNotBrushable" xml:space="preserve">
<value>The clipboard contents are not brushable</value>
</data>
<data name="kbd_layer_Normal" xml:space="preserve">
<value>Normal</value>
</data>
<data name="kbd_layer_Global" xml:space="preserve">
<value>Global</value>
</data>
<data name="kbd_layer_Batch" xml:space="preserve">
<value>Batch</value>
</data>
</root>
9 changes: 9 additions & 0 deletions OngekiFumenEditor/Properties/Resources.zh-Hans.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1866,4 +1866,13 @@
<data name="InvalidColorId" xml:space="preserve">
<value>颜色Id(ColorId)值无效: {0}</value>
</data>
<data name="kbd_layer_Normal" xml:space="preserve">
<value>通常模式</value>
</data>
<data name="kbd_layer_Global" xml:space="preserve">
<value>全局</value>
</data>
<data name="kbd_layer_Batch" xml:space="preserve">
<value>批量模式</value>
</data>
</root>

0 comments on commit e178576

Please sign in to comment.