} // ShowConfigurationForm public static T ShowConfigurationForm <T>(IWin32Window owner, string settingsGuid, T overrideSettings) where T : class, IConfigurationItem { var registration = AppUiConfiguration.Current.ItemsRegistry[new Guid(settingsGuid)]; var data = new ConfigurationItem() { Registration = registration, ExistingData = overrideSettings ?? AppUiConfiguration.Current[registration.DirectIndex] }; var items = new List <ConfigurationItem>(1); items.Add(data); using (var form = new ConfigurationForm()) { BasicGoogleTelemetry.SendScreenHit(form, data.Registration.ItemType.Name); form.ConfigurationItems = items; var dialogResult = form.ShowDialog(owner); if (dialogResult != DialogResult.OK) { return(null); } else { return((T)items[0].NewData); } // if-else } // using } // ShowConfigurationForm
} // ConfigurationItem public static DialogResult ShowConfigurationForm(IWin32Window owner, bool autoSave = true, IDictionary <Guid, Action> applyChanges = null) { DialogResult result; bool changed; var q = from item in AppUiConfiguration.Current.ItemsRegistry let registration = item.Value where registration.HasEditor orderby registration.EditorPriority select new ConfigurationItem() { Registration = registration, ExistingData = AppUiConfiguration.Current[registration.DirectIndex] }; var items = q.ToList(); using (var form = new ConfigurationForm()) { BasicGoogleTelemetry.SendScreenHit(form, "(default)"); form.ConfigurationItems = items; result = form.ShowDialog(owner); if (result != DialogResult.OK) { return(result); } // if } // using // save new settings changed = false; foreach (var item in items) { var newData = item.NewData; if (newData == null) { continue; } changed = true; AppUiConfiguration.Current[item.Registration.DirectIndex] = newData; } // foreach // autosave if settings changed if ((changed) && (autoSave)) { AppUiConfiguration.Current.Save(); } // if // apply changes if ((changed) && (applyChanges != null) && (applyChanges.Count > 0)) { Action applyChangesMethod; foreach (var item in items) { if (item.NewData == null) { continue; } if (applyChanges.TryGetValue(item.Registration.Id, out applyChangesMethod)) { applyChangesMethod(); } // if } // foreach } // if return(result); } // ShowConfigurationForm