From 502aa0588567807bcc52e3005ad61cdefc2ba713 Mon Sep 17 00:00:00 2001 From: Sleevezipper Date: Mon, 15 Mar 2021 21:40:09 +0100 Subject: [PATCH] fix #49 - DO sort sensors by name but retrieve value from combobox in a better way --- UserInterface/Views/AddCommandDialog.axaml.cs | 4 ++-- UserInterface/Views/AddSensorDialog.axaml.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/UserInterface/Views/AddCommandDialog.axaml.cs b/UserInterface/Views/AddCommandDialog.axaml.cs index e6a615a..a1ed877 100644 --- a/UserInterface/Views/AddCommandDialog.axaml.cs +++ b/UserInterface/Views/AddCommandDialog.axaml.cs @@ -25,7 +25,7 @@ namespace UserInterface.Views this.InitializeComponent(); DataContext = new AddCommandViewModel(); this.comboBox = this.FindControl("ComboBox"); - this.comboBox.Items = Enum.GetValues(typeof(AvailableCommands)).Cast(); + this.comboBox.Items = Enum.GetValues(typeof(AvailableCommands)).Cast().OrderBy(v => v.ToString()); this.comboBox.SelectedIndex = 0; // register IPC clients @@ -53,7 +53,7 @@ namespace UserInterface.Views public void ComboBoxClosed(object sender, SelectionChangedEventArgs args) { var item = ((AddCommandViewModel)this.DataContext); - switch (item.SelectedType) + switch (this.comboBox.SelectedItem) { case AvailableCommands.CustomCommand: item.Description = "This command lets you execute any command you want. It will run in a Windows Command Prompt silently. "; diff --git a/UserInterface/Views/AddSensorDialog.axaml.cs b/UserInterface/Views/AddSensorDialog.axaml.cs index 245d62b..8c12a81 100644 --- a/UserInterface/Views/AddSensorDialog.axaml.cs +++ b/UserInterface/Views/AddSensorDialog.axaml.cs @@ -25,7 +25,7 @@ namespace UserInterface.Views this.InitializeComponent(); DataContext = new AddSensorViewModel(); this.comboBox = this.FindControl("ComboBox"); - this.comboBox.Items = Enum.GetValues(typeof(AvailableSensors)).Cast(); + this.comboBox.Items = Enum.GetValues(typeof(AvailableSensors)).Cast().OrderBy(v => v.ToString()); this.comboBox.SelectedIndex = 0; // register IPC clients @@ -53,7 +53,7 @@ namespace UserInterface.Views public void ComboBoxClosed(object sender, SelectionChangedEventArgs args) { var item = ((AddSensorViewModel)this.DataContext); - switch (item.SelectedType) + switch (this.comboBox.SelectedItem) { case AvailableSensors.UserNotificationStateSensor: item.Description = "This sensor watches the UserNotificationState. This is normally used in applications to determine if it is appropriate to send a notification but we can use it to expose this state. \n ";