private void ComboBoxDevices_SelectionChanged(object sender, SelectionChangedEventArgs e) { string current = (string)((ComboBox)sender).SelectedItem; if (current == null) { return; } ObservableCollection <SettingInfo> settingInfo; if (!Globals.SettingDict.TryGetValue(current, out settingInfo)) { settingInfo = new ObservableCollection <SettingInfo>(); Globals.SettingDict[current] = settingInfo; } settingList = settingInfo; this.ListBoxSetting.ItemsSource = settingList; this.TBoxNoSelection.DataContext = settingList; this.ButtonAdd.DataContext = settingList; this.ButtonDelete.DataContext = settingList; this.currentDevice = Globals.Devices[((ComboBox)sender).SelectedIndex]; }
/// <summary> /// 从设备读取设置 /// </summary> /// <param name="device"></param> public void ReadFromDevice(SimPad device) { this.KeySetting = new KeySetting[device.KeyCount]; for (uint i = 0; i < device.KeyCount; ++i) { KeySetting[i] = device.GetKeySetting(i + 1); } this.LightSpeed = device.LightSpeed; this.LightsType = device.LightsType; this.DelayInput = device.DelayInput; this.ColorG1 = device.GetLEDColor(1); this.ColorG2 = device.GetLEDColor(2); }
/// <summary> /// 应用到设备 /// </summary> public void Apply(SimPad device) { for (uint i = 0; i < device.KeyCount; ++i) { device.SetKeySetting(i + 1, KeySetting[i]); } device.LightSpeed = this.LightSpeed; device.LightsType = this.LightsType; device.DelayInput = this.DelayInput; device.SetLEDColor(1, this.ColorG1); device.SetLEDColor(2, this.ColorG2); device.ApplyAllSettings(); // 驱动那边做了diff了,所以这边不用管了 }