IEnumerable<FactorSettingRecord> LoadFactorSettingRecords() { List<FactorSettingRecord> factorRecords = new List<FactorSettingRecord>(); foreach (FactorSettings factorSettings in CurrentBase.Factors) { IFactor factorInstance = factorSettings.CreateInstance(); FactorSettingRecord factorRecord = new FactorSettingRecord(); factorRecord.ReferenceToSettings = factorSettings; factorRecord.Name = factorInstance.GetName(); factorRecord.Description = factorInstance.GetDescription(); factorRecord.Fine = factorSettings.Fine; factorRecord.DataType = factorSettings.DataTypeGuid; factorRecord.Data = factorSettings.Data; if (factorRecord.DataType.HasValue) { factorRecord.UseProgramData = factorInstance is IFactorProgramData; factorRecord.UseUsersData = factorInstance is IFactorFormData && FactorsEditors.GetFactorEditors().ContainsKey(factorRecord.DataType.Value); } factorRecords.Add(factorRecord); } return factorRecords; }
void OpenFactorEditor(FactorSettingRecord factorRecord) { try { Type editorType = FactorsEditors.GetFactorEditors()[factorRecord.DataType.Value]; Window editorForm = (Window)Activator.CreateInstance(editorType); FactorsEditors.InitFactorEditor(factorRecord.ReferenceToSettings, (IFactorEditor)editorForm); editorForm.ShowDialog(); } catch (Exception ex) { throw; } }