/// <summary> /// Restores settings prior to firing the cancelled event. /// </summary> protected override void OnCancel() { SettingsConverter.CopyConfiguration(_settingsObject, ref _editableObject); _CfgView.Refresh(); }
/// <summary> /// Called when settings are refreshed. /// </summary> protected override void OnRefreshSettings() { if (_settingsObject == null) { return; } SettingsConverter.CopyConfiguration(_settingsObject, ref _editableObject); DisableReadonly(_editableObject); int selectedListViewIndex = -1; if (_cfgListView.SelectedIndices.Count > 0) { selectedListViewIndex = _cfgListView.SelectedIndices[0]; } Clear(); if (_settingsObject == null) { return; } PropertyInfo[] propertyInfos = _editableObject.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance); List <KeyValuePair <string, object> > selectableList = new List <KeyValuePair <string, object> >(); foreach (PropertyInfo t in propertyInfos) { if (t == null) { continue; } if (t.PropertyType.IsPrimitive || t.PropertyType.IsValueType || t.PropertyType == typeof(string)) { continue; } object value = t.GetValue(_editableObject, null); if (value == null) { continue; } selectableList.Add(new KeyValuePair <string, object>(t.Name, value)); } UIUtility.Invoke(this, () => { btnSave.Enabled = true; foreach (KeyValuePair <string, object> kv in selectableList) { _cfgListView.Items.Add(CreateListViewItem(kv.Key, kv.Value)); } if (selectedListViewIndex > -1) { _cfgListView.Items[selectedListViewIndex].Selected = true; } }); }