private List <Setting> getSettings() { _propertyDict = new Dictionary <Setting, System.Reflection.PropertyInfo>(); string[] ignored = { "Type", "AllowedInteractionModes" }; var detailsSettings = new List <Setting>(); Type t = _command.Control.GetType(); var props = t.GetProperties().Where(p => !ignored.Contains(p.Name)); int i = 0; Setting s = null; string name; foreach (var p in props) { Type targetType = p.PropertyType; name = p.Name; switch (name) { case "Invert": case "Blend": s = new BoolSetting(i++, name + ":"); break; case "SoftTakeOver": s = new BoolSetting(i++, "Soft Takeover:"); break; case "AutoRepeat": s = new BoolSetting(i++, "Auto Repeat:"); break; case "RotaryAcceleration": s = new IntSetting(i++, "Rotary Acceleration:", 0, 100); break; case "RotarySensitivity": s = new IntSetting(i++, "Rotary Sensitivity:", 0, 300); break; case "Mode": case "EncoderMode": AGenericMidiDefinition midiBinding = (this._mappings.First().MidiBinding as AGenericMidiDefinition); if (midiBinding != null) { MidiEncoderMode actual_encoder_mode = midiBinding.MidiEncoderMode; _command.set_EncoderMode(actual_encoder_mode); } s = new EnumSetting <MidiEncoderMode>(i++, name + ":"); break; case "MidiRangeMin": // pestrela 2020/04/11: there is no source code to "IntSetting", comes from "SettingControlLibrary.dll" that is pre-compiled. //s = new IntSetting(i++, "MIDI Range Min:", 0, 127); // pestrela: replaced this with a realy large enum. s = new EnumSetting <MidiOutRange>(i++, "MIDI Range Min:"); break; case "MidiRangeMax": // s = new IntSetting(i++, "MIDI Range Max:", 0, 127); s = new EnumSetting <MidiOutRange>(i++, "MIDI Range Max:"); break; case "Resolution": s = new EnumSetting <MappingResolution>(i++, name + ":"); break; default: s = null; break; } if (s != null) { object rawValue = p.GetValue(_command.Control, null); s.TryParse(rawValue.ToString()); s.AcceptChanges(); detailsSettings.Add(s); _propertyDict.Add(s, p); s.PropertyChanged += s_PropertyChanged; } else { // Datatype not supported } } return(detailsSettings); }
private List <Setting> getSettings() { _propertyDict = new Dictionary <Setting, System.Reflection.PropertyInfo>(); string[] ignored = { "Type", "AllowedInteractionModes" }; var detailsSettings = new List <Setting>(); Type t = _command.Control.GetType(); var props = t.GetProperties().Where(p => !ignored.Contains(p.Name)); int i = 0; Setting s = null; string name; foreach (var p in props) { Type targetType = p.PropertyType; name = p.Name; switch (name) { case "Invert": case "Blend": s = new BoolSetting(i++, name + ":"); break; case "SoftTakeOver": s = new BoolSetting(i++, "Soft Takeover:"); break; case "AutoRepeat": s = new BoolSetting(i++, "Auto Repeat:"); break; case "RotaryAcceleration": s = new IntSetting(i++, "Rotary Acceleration:", 0, 100); break; case "RotarySensitivity": s = new IntSetting(i++, "Rotary Sensitivity:", 0, 300); break; case "Mode": s = new EnumSetting <MidiEncoderMode>(i++, name + ":"); break; case "MidiRangeMin": s = new IntSetting(i++, "MIDI Range Min:", 0, 127); break; case "MidiRangeMax": s = new IntSetting(i++, "MIDI Range Max:", 0, 127); break; case "Resolution": s = new EnumSetting <MappingResolution>(i++, name + ":"); break; default: s = null; break; } if (s != null) { object rawValue = p.GetValue(_command.Control, null); s.TryParse(rawValue.ToString()); s.AcceptChanges(); detailsSettings.Add(s); _propertyDict.Add(s, p); s.PropertyChanged += s_PropertyChanged; } else { // Datatype not supported } } return(detailsSettings); }