From 1f02f6970e685d57190c09843ac3d104f446b2ed Mon Sep 17 00:00:00 2001 From: TheXamlGuy Date: Wed, 17 Jan 2024 19:28:21 +0000 Subject: [PATCH] Initial orderby on primary items --- Hyperbar.Windows.Primary/PrimaryCommandConfiguration.cs | 9 +++++---- Hyperbar.Windows.Primary/PrimaryWidgetConfiguration.cs | 2 +- .../WidgetComponentViewModelEnumerator.cs | 2 +- Hyperbar/Views/Created.cs | 4 +++- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Hyperbar.Windows.Primary/PrimaryCommandConfiguration.cs b/Hyperbar.Windows.Primary/PrimaryCommandConfiguration.cs index ce9816b..567ef92 100644 --- a/Hyperbar.Windows.Primary/PrimaryCommandConfiguration.cs +++ b/Hyperbar.Windows.Primary/PrimaryCommandConfiguration.cs @@ -6,11 +6,12 @@ namespace Hyperbar.Windows.Primary; [JsonDerivedType(typeof(ProcessCommandConfiguration), typeDiscriminator: "ProcessCommand")] public class PrimaryCommandConfiguration { - public required Guid Id { get; set; } - + public List Commands { get; set; } = []; public required string Icon { get; set; } - public required string Text { get; set; } + public required Guid Id { get; set; } - public List Commands { get; set; } = []; + public required int Order { get; set; } + + public required string Text { get; set; } } \ No newline at end of file diff --git a/Hyperbar.Windows.Primary/PrimaryWidgetConfiguration.cs b/Hyperbar.Windows.Primary/PrimaryWidgetConfiguration.cs index 73f977b..891f486 100644 --- a/Hyperbar.Windows.Primary/PrimaryWidgetConfiguration.cs +++ b/Hyperbar.Windows.Primary/PrimaryWidgetConfiguration.cs @@ -5,6 +5,6 @@ public class PrimaryWidgetConfiguration : { public static PrimaryWidgetConfiguration Defaults => new() { - new KeyAcceleratorCommandConfiguration { Id = Guid.NewGuid(), Icon = "\uE720", Text = "Test", Key = 91, Modifiers = [] } + new KeyAcceleratorCommandConfiguration { Id = Guid.NewGuid(), Order = 1, Icon = "\uE720", Text = "Test", Key = 91, Modifiers = [] } }; } \ No newline at end of file diff --git a/Hyperbar.Windows.Primary/WidgetComponentViewModelEnumerator.cs b/Hyperbar.Windows.Primary/WidgetComponentViewModelEnumerator.cs index 6721ba9..392a279 100644 --- a/Hyperbar.Windows.Primary/WidgetComponentViewModelEnumerator.cs +++ b/Hyperbar.Windows.Primary/WidgetComponentViewModelEnumerator.cs @@ -6,7 +6,7 @@ public class WidgetComponentViewModelEnumerator(PrimaryWidgetConfiguration confi { public IEnumerable Next() { - foreach (PrimaryCommandConfiguration item in configuration) + foreach (PrimaryCommandConfiguration item in configuration.OrderBy(x => x.Order)) { yield return factory.Create(item); } diff --git a/Hyperbar/Views/Created.cs b/Hyperbar/Views/Created.cs index 32b0510..2e8c597 100644 --- a/Hyperbar/Views/Created.cs +++ b/Hyperbar/Views/Created.cs @@ -1,3 +1,5 @@ namespace Hyperbar; -public record Created(TValue Value) : INotification; \ No newline at end of file +public record Created(TValue Value) : INotification; + +public record Inserted(int Index, TValue Value) : INotification; \ No newline at end of file