private void LoadDeviceInputs() { var devicelist = DeviceBinding.Profile.GetDeviceList(DeviceBinding); Devices = new ObservableCollection <ComboBoxItemViewModel>(); foreach (var device in devicelist) { Devices.Add(new ComboBoxItemViewModel(device.Title, device.Guid)); } ComboBoxItemViewModel selectedDevice = null; foreach (var comboBoxItem in Devices) { if (comboBoxItem.Value == DeviceBinding.DeviceGuid) { selectedDevice = comboBoxItem; break; } } if (Devices.Count == 0) { Devices.Add(new ComboBoxItemViewModel("No device group", Guid.Empty)); } if (selectedDevice == null) { selectedDevice = Devices[0]; DeviceBinding.SetDeviceGuid(selectedDevice.Value); } DeviceNumberBox.ItemsSource = Devices; DeviceNumberBox.SelectedItem = selectedDevice; }
private void PopulateComboBox(List <ComboBoxItemViewModel> groups, DeviceIoType deviceIoType, Guid currentGroup, ComboBox comboBox) { groups = new List <ComboBoxItemViewModel>(); ComboBoxItemViewModel selectedItem = null; groups.Add(new ComboBoxItemViewModel(profile.GetInheritedDeviceGroupName(deviceIoType), new DeviceGroupComboBoxItem() { DeviceIoType = deviceIoType })); foreach (var deviceGroup in context.DeviceGroupsManager.GetDeviceGroupList(deviceIoType)) { var model = new ComboBoxItemViewModel(deviceGroup.Title, new DeviceGroupComboBoxItem() { DeviceGroup = deviceGroup, DeviceIoType = deviceIoType }); groups.Add(model); if (deviceGroup.Guid == currentGroup) { selectedItem = model; } } comboBox.ItemsSource = groups; if (selectedItem != null) { comboBox.SelectedItem = selectedItem; } else { comboBox.SelectedItem = groups[0]; } }
public object Convert(object value, Type targetType, object parameter, CultureInfo info) { ComboBoxItemViewModel item = (ComboBoxItemViewModel)value; if (value == null || item.ID == "") { return(new SolidColorBrush(Colors.Red)); } else { return(new SolidColorBrush(Colors.Gray)); } }
private void PopulateStates() { States = new ObservableCollection <ComboBoxItemViewModel>(); ComboBoxItemViewModel selectedState = null; foreach (var profileState in PluginProperty.Plugin.Profile.AllStates) { var comboBoxItem = new ComboBoxItemViewModel(profileState.Title, profileState); States.Add(comboBoxItem); if (profileState.Guid.Equals((Guid)PluginProperty.Property)) { selectedState = comboBoxItem; } } StateComboBox.ItemsSource = States; if (selectedState != null) { StateComboBox.SelectedItem = selectedState; } else { StateComboBox.SelectedIndex = 0; } }
private void PopulateEnums() { Enums = new ObservableCollection <ComboBoxItemViewModel>(); ComboBoxItemViewModel selectedEnum = null; foreach (var enumValue in Enum.GetValues(PluginProperty.Property.GetType())) { var comboBoxItem = new ComboBoxItemViewModel(enumValue.ToString(), enumValue); Enums.Add(comboBoxItem); if (enumValue.Equals(PluginProperty.Property)) { selectedEnum = comboBoxItem; } } EnumComboBox.ItemsSource = Enums; if (selectedEnum != null) { EnumComboBox.SelectedItem = selectedEnum; } else { EnumComboBox.SelectedIndex = 0; } }