fix #49 - DO sort sensors by name

but retrieve value from combobox in a better way
pull/56/head
Sleevezipper 4 years ago
parent 7fb1a79cf9
commit 502aa05885

@ -25,7 +25,7 @@ namespace UserInterface.Views
this.InitializeComponent(); this.InitializeComponent();
DataContext = new AddCommandViewModel(); DataContext = new AddCommandViewModel();
this.comboBox = this.FindControl<ComboBox>("ComboBox"); this.comboBox = this.FindControl<ComboBox>("ComboBox");
this.comboBox.Items = Enum.GetValues(typeof(AvailableCommands)).Cast<AvailableCommands>(); this.comboBox.Items = Enum.GetValues(typeof(AvailableCommands)).Cast<AvailableCommands>().OrderBy(v => v.ToString());
this.comboBox.SelectedIndex = 0; this.comboBox.SelectedIndex = 0;
// register IPC clients // register IPC clients
@ -53,7 +53,7 @@ namespace UserInterface.Views
public void ComboBoxClosed(object sender, SelectionChangedEventArgs args) public void ComboBoxClosed(object sender, SelectionChangedEventArgs args)
{ {
var item = ((AddCommandViewModel)this.DataContext); var item = ((AddCommandViewModel)this.DataContext);
switch (item.SelectedType) switch (this.comboBox.SelectedItem)
{ {
case AvailableCommands.CustomCommand: case AvailableCommands.CustomCommand:
item.Description = "This command lets you execute any command you want. It will run in a Windows Command Prompt silently. "; item.Description = "This command lets you execute any command you want. It will run in a Windows Command Prompt silently. ";

@ -25,7 +25,7 @@ namespace UserInterface.Views
this.InitializeComponent(); this.InitializeComponent();
DataContext = new AddSensorViewModel(); DataContext = new AddSensorViewModel();
this.comboBox = this.FindControl<ComboBox>("ComboBox"); this.comboBox = this.FindControl<ComboBox>("ComboBox");
this.comboBox.Items = Enum.GetValues(typeof(AvailableSensors)).Cast<AvailableSensors>(); this.comboBox.Items = Enum.GetValues(typeof(AvailableSensors)).Cast<AvailableSensors>().OrderBy(v => v.ToString());
this.comboBox.SelectedIndex = 0; this.comboBox.SelectedIndex = 0;
// register IPC clients // register IPC clients
@ -53,7 +53,7 @@ namespace UserInterface.Views
public void ComboBoxClosed(object sender, SelectionChangedEventArgs args) public void ComboBoxClosed(object sender, SelectionChangedEventArgs args)
{ {
var item = ((AddSensorViewModel)this.DataContext); var item = ((AddSensorViewModel)this.DataContext);
switch (item.SelectedType) switch (this.comboBox.SelectedItem)
{ {
case AvailableSensors.UserNotificationStateSensor: 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 "; 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 ";

Loading…
Cancel
Save