Browse Source

Add a hint to shortcuts window

Equbuxu 3 years ago
parent
commit
85a44d7dd6

+ 3 - 3
PixiEditor/Models/Commands/Attributes/Commands/DebugAttribute.cs

@@ -4,12 +4,12 @@
     {
         public class DebugAttribute : BasicAttribute
         {
-            public DebugAttribute(string name, string display, string description) : base($"#DEBUG#{name}", display, description)
+            public DebugAttribute(string internalName, string displayName, string description) : base($"#DEBUG#{internalName}", displayName, description)
             {
             }
 
-            public DebugAttribute(string name, object parameter, string display, string description)
-                : base($"#DEBUG#{name}", parameter, display, description)
+            public DebugAttribute(string internalName, object parameter, string displayName, string description)
+                : base($"#DEBUG#{internalName}", parameter, displayName, description)
             {
             }
         }

+ 4 - 4
PixiEditor/Models/Commands/Attributes/Commands/GroupAttribute.cs

@@ -10,12 +10,12 @@
             public string DisplayName { get; }
 
             /// <summary>
-            /// Groups all commands that start with the name <paramref name="name"/>
+            /// Groups all commands that start with the name <paramref name="internalName"/>
             /// </summary>
-            public GroupAttribute(string name, string display)
+            public GroupAttribute(string internalName, string displayName)
             {
-                InternalName = name;
-                DisplayName = display;
+                InternalName = internalName;
+                DisplayName = displayName;
             }
         }
     }

+ 3 - 3
PixiEditor/Models/Commands/CommandCollection.cs

@@ -28,7 +28,7 @@ namespace PixiEditor.Models.Commands
 
         public void Add(Command item)
         {
-            _commandInternalNames.Add(item.Name, item);
+            _commandInternalNames.Add(item.InternalName, item);
             _commandShortcuts.Add(item.Shortcut, item);
         }
 
@@ -40,7 +40,7 @@ namespace PixiEditor.Models.Commands
 
         public void ClearShortcuts() => _commandShortcuts.Clear();
 
-        public bool Contains(Command item) => _commandInternalNames.ContainsKey(item.Name);
+        public bool Contains(Command item) => _commandInternalNames.ContainsKey(item.InternalName);
 
         public void CopyTo(Command[] array, int arrayIndex) => _commandInternalNames.Values.CopyTo(array, arrayIndex);
 
@@ -50,7 +50,7 @@ namespace PixiEditor.Models.Commands
         {
             bool anyRemoved = false;
 
-            anyRemoved |= _commandInternalNames.Remove(item.Name);
+            anyRemoved |= _commandInternalNames.Remove(item.InternalName);
             anyRemoved |= _commandShortcuts.Remove(item);
 
             return anyRemoved;

+ 5 - 5
PixiEditor/Models/Commands/CommandController.cs

@@ -127,9 +127,9 @@ namespace PixiEditor.Models.Commands
                     {
                         AddCommand(methodInfo, maybeServiceInstance, attribute, (isDebug, name, x, xCan, xIcon) => new Command.BasicCommand(x, xCan)
                         {
-                            Name = name,
+                            InternalName = name,
                             IsDebug = isDebug,
-                            Display = attribute.DisplayName,
+                            DisplayName = attribute.DisplayName,
                             Description = attribute.Description,
                             IconPath = attribute.IconPath,
                             IconEvaluator = xIcon,
@@ -156,8 +156,8 @@ namespace PixiEditor.Models.Commands
 
                 var command = new Command.ToolCommand()
                 {
-                    Name = internalName,
-                    Display = $"Select {toolInstance.DisplayName} Tool",
+                    InternalName = internalName,
+                    DisplayName = $"Select {toolInstance.DisplayName} Tool",
                     Description = $"Select {toolInstance.DisplayName} Tool",
                     IconPath = $"@{toolInstance.ImagePath}",
                     IconEvaluator = IconEvaluator.Default,
@@ -188,7 +188,7 @@ namespace PixiEditor.Models.Commands
 
             void AddCommandToCommandsCollection(Command command)
             {
-                (string internalName, string displayName) group = commandGroupsData.FirstOrDefault(x => command.Name.StartsWith(x.internalName));
+                (string internalName, string displayName) group = commandGroupsData.FirstOrDefault(x => command.InternalName.StartsWith(x.internalName));
                 if (group == default)
                     commands.Add("", command);
                 else

+ 1 - 1
PixiEditor/Models/Commands/CommandGroup.cs

@@ -21,7 +21,7 @@ namespace PixiEditor.Models.Commands
         {
             DisplayName = displayName;
             this.commands = commands.ToArray();
-            visibleCommands = commands.Where(x => !string.IsNullOrEmpty(x.Display)).ToArray();
+            visibleCommands = commands.Where(x => !string.IsNullOrEmpty(x.DisplayName)).ToArray();
 
             foreach (var command in commands)
             {

+ 3 - 3
PixiEditor/Models/Commands/Commands/Command.cs

@@ -6,20 +6,20 @@ using System.Windows.Media;
 
 namespace PixiEditor.Models.Commands
 {
-    [DebuggerDisplay("{Name,nq} ('{Display,nq}')")]
+    [DebuggerDisplay("{InternalName,nq} ('{DisplayName,nq}')")]
     public abstract partial class Command : NotifyableObject
     {
         private KeyCombination _shortcut;
 
         public bool IsDebug { get; init; }
 
-        public string Name { get; init; }
+        public string InternalName { get; init; }
 
         public string IconPath { get; init; }
 
         public IconEvaluator IconEvaluator { get; init; }
 
-        public string Display { get; init; }
+        public string DisplayName { get; init; }
 
         public string Description { get; init; }
 

+ 1 - 1
PixiEditor/Models/Commands/Evaluators/IconEvaluator.cs

@@ -37,7 +37,7 @@ namespace PixiEditor.Models.Commands.Evaluators
                 }
                 else
                 {
-                    path = $"Images/Commands/{command.Name.Replace('.', '/')}.png";
+                    path = $"Images/Commands/{command.InternalName.Replace('.', '/')}.png";
                 }
 
                 path = path.ToLower();

+ 1 - 1
PixiEditor/Models/Commands/ShortcutFile.cs

@@ -30,7 +30,7 @@ namespace PixiEditor.Models.Commands
             {
                 foreach (var command in shortcut.Value.Where(x => x.Shortcut != x.DefaultShortcut))
                 {
-                    shortcuts.Add(shortcut.Key, command.Name);
+                    shortcuts.Add(shortcut.Key, command.InternalName);
                 }
             }
 

+ 2 - 2
PixiEditor/Models/Commands/XAML/Command.cs

@@ -35,8 +35,8 @@ namespace PixiEditor.Models.Commands.XAML
                 return GetICommand(
                     new Commands.Command.BasicCommand(null, null)
                     {
-                        Name = Name,
-                        Display = attribute.DisplayName,
+                        InternalName = Name,
+                        DisplayName = attribute.DisplayName,
                         Description = attribute.Description,
                         DefaultShortcut = attribute.GetShortcut(),
                         Shortcut = attribute.GetShortcut()

+ 3 - 3
PixiEditor/ViewModels/SettingsWindowViewModel.cs

@@ -84,7 +84,7 @@ namespace PixiEditor.ViewModels
                 int visibleCommands = 0;
                 foreach (var command in group.Commands)
                 {
-                    if (command.Command.Display.Contains(SearchTerm, StringComparison.OrdinalIgnoreCase))
+                    if (command.Command.DisplayName.Contains(SearchTerm, StringComparison.OrdinalIgnoreCase))
                     {
                         visibleCommands++;
                         command.Visibility = Visibility.Visible;
@@ -103,7 +103,7 @@ namespace PixiEditor.ViewModels
         {
             private Visibility visibility;
 
-            public string Display { get; set; }
+            public string DisplayName { get; set; }
 
             public List<CommandSearchResult> Commands { get; set; }
 
@@ -115,7 +115,7 @@ namespace PixiEditor.ViewModels
 
             public GroupSearchResult(CommandGroup group)
             {
-                Display = group.DisplayName;
+                DisplayName = group.DisplayName;
                 Commands = new(group.VisibleCommands.Select(x => new CommandSearchResult(x)));
             }
         }

+ 2 - 2
PixiEditor/Views/Dialogs/SettingsWindow.xaml

@@ -212,12 +212,12 @@
                             <ItemsControl.ItemTemplate>
                                 <DataTemplate>
                                     <StackPanel Margin="0,0,0,20" Visibility="{Binding Visibility}">
-                                        <TextBlock Text="{Binding Display}" FontSize="22" FontWeight="SemiBold"/>
+                                        <TextBlock Text="{Binding DisplayName}" FontSize="22" FontWeight="SemiBold"/>
                                         <ItemsControl ItemsSource="{Binding Commands}">
                                             <ItemsControl.ItemTemplate>
                                                 <DataTemplate>
                                                     <Grid Margin="0,5,5,0" Visibility="{Binding Visibility}">
-                                                        <TextBlock Text="{Binding Command.Display}" ToolTip="{Binding Command.Description}"/>
+                                                        <TextBlock Text="{Binding Command.DisplayName}" ToolTip="{Binding Command.Description}"/>
                                                         <usercontrols:ShortcutBox Width="120" Command="{Binding Command}" HorizontalAlignment="Right"/>
                                                     </Grid>
                                                 </DataTemplate>

+ 5 - 4
PixiEditor/Views/Dialogs/ShortcutPopup.xaml

@@ -10,8 +10,8 @@
         xmlns:usercontrols="clr-namespace:PixiEditor.Views.UserControls"
         mc:Ignorable="d"
         WindowStartupLocation="CenterScreen"
-        Title="ShortcutPopup" Height="740" Width="1220" WindowStyle="None"
-        MinHeight="770" MinWidth="620" Topmost="{Binding IsTopmost}">
+        Title="ShortcutPopup" Height="780" Width="1220" WindowStyle="None"
+        MinHeight="780" MinWidth="620" Topmost="{Binding IsTopmost}">
     <Window.Resources>
         <BoolToVisibilityConverter x:Key="BoolToVisibility"/>
 
@@ -81,7 +81,7 @@
                     <ItemsControl.ItemTemplate>
                         <DataTemplate DataType="{x:Type commands:CommandGroup}">
                             <StackPanel Visibility="{Binding HasAssignedShortcuts, Converter={StaticResource BoolToVisibility}}">
-                                <TextBlock Text="{Binding Display}" Foreground="White" FontSize="15" FontWeight="Medium" Margin="10,8,0,5"/>
+                                <TextBlock Text="{Binding DisplayName}" Foreground="White" FontSize="15" FontWeight="Medium" Margin="10,8,0,5"/>
                                 <ItemsControl ItemsSource="{Binding VisibleCommands}">
                                     <ItemsControl.ItemTemplate>
                                         <DataTemplate DataType="{x:Type commands:Command}">
@@ -105,7 +105,7 @@
                                                     <TextBlock Text="{Binding Shortcut.Key, Converter={converters:KeyToStringConverter}}" Style="{StaticResource KeyBorderText}"/>
                                                 </Border>
 
-                                                <TextBlock Text="{Binding Display}" Foreground="#FFEEEEEE" VerticalAlignment="Center" FontSize="14" Margin="8,0,0,0"/>
+                                                <TextBlock Text="{Binding DisplayName}" Foreground="#FFEEEEEE" VerticalAlignment="Center" FontSize="14" Margin="8,0,0,0"/>
                                             </StackPanel>
                                         </DataTemplate>
                                     </ItemsControl.ItemTemplate>
@@ -119,6 +119,7 @@
                         </ItemsPanelTemplate>
                     </ItemsControl.ItemsPanel>
                 </ItemsControl>
+                <TextBlock FontSize="14" Margin="5" Foreground="LightGray" HorizontalAlignment="Left">You can rebind the shortcuts in settings</TextBlock>
             </WrapPanel>
         </ScrollViewer>
     </Grid>

+ 2 - 2
PixiEditor/Views/UserControls/ShortcutBox.cs

@@ -53,8 +53,8 @@ namespace PixiEditor.Views.UserControls
                     bool enableSwap = oldShortcut is not { Key: Key.None, Modifiers: ModifierKeys.None };
                     
                     string text = enableSwap ?
-                        $"This shortcut is already assigned to '{controller.Commands[e].First().Display}'\nDo you want to replace the existing shortcut or swap the two?" :
-                        $"This shortcut is already assigned to '{controller.Commands[e].First().Display}'\nDo you want to replace the existing shortcut?";
+                        $"This shortcut is already assigned to '{controller.Commands[e].First().DisplayName}'\nDo you want to replace the existing shortcut or swap the two?" :
+                        $"This shortcut is already assigned to '{controller.Commands[e].First().DisplayName}'\nDo you want to replace the existing shortcut?";
                     OptionsDialog<string> dialog = new("Already assigned", text);
                     
                     dialog.Add("Replace", x => controller.ReplaceShortcut(Command, e));