/// <summary> /// Load data into the controls /// </summary> private void InitializeRegistryMappings() { // Populate the combo box with each of the applications for which we have already got // a registry mapping _applicationsFile = new ApplicationDefinitionsFile(); List <string> listRegistryMappings = new List <string>(); _applicationsFile.SetSection(ApplicationDefinitionsFile.APPLICATION_MAPPINGS_SECTION); _applicationsFile.EnumerateKeys(ApplicationDefinitionsFile.APPLICATION_MAPPINGS_SECTION, listRegistryMappings); // Iterate through the keys and create an application mapping object cbApplications.BeginUpdate(); cbApplications.Items.Clear(); // foreach (string thisKey in listRegistryMappings) { // The key is the application name, the value the registry mapping ApplicationRegistryMapping applicationMapping = new ApplicationRegistryMapping(thisKey); String mappings = _applicationsFile.GetString(thisKey, ""); if (thisKey == "Travel") { int a = 0; } applicationMapping.AddMapping(mappings); // Add this entry to the combo box noting that we store the object with it to make // it easier to display the registry keys when selected ValueListItem newItem = cbApplications.Items.Add(applicationMapping.ApplicationName); newItem.Tag = applicationMapping; } cbApplications.EndUpdate(); // Select the first entry cbApplications.SelectedIndex = 0; }
private void UpdateSerialNumberMappings() { List <SerialNumberMapping> lSerialNumberMappingsList = new List <SerialNumberMapping>(); ApplicationDefinitionsFile _applicationDefinitionsFile = new ApplicationDefinitionsFile(); List <string> listRegistryMappings = new List <string>(); _applicationDefinitionsFile.SetSection(ApplicationDefinitionsFile.APPLICATION_MAPPINGS_SECTION); _applicationDefinitionsFile.EnumerateKeys(ApplicationDefinitionsFile.APPLICATION_MAPPINGS_SECTION, listRegistryMappings); // Iterate through the keys and create an application mapping object foreach (string thisKey in listRegistryMappings) { // The key is the application name, the value the registry mapping ApplicationRegistryMapping applicationMapping = new ApplicationRegistryMapping(thisKey); string mappings = _applicationDefinitionsFile.GetString(thisKey, ""); applicationMapping.AddMapping(mappings); SerialNumberMapping lSerialNumberMapping = new SerialNumberMapping(); lSerialNumberMapping.ApplicationName = applicationMapping.ApplicationName; foreach (RegistryMapping lMapping in applicationMapping) { SerialNumberMappingsRegistryKey lSerialNumberMappingRegKey = new SerialNumberMappingsRegistryKey(); lSerialNumberMappingRegKey.RegistryKeyName = lMapping.RegistryKey; lSerialNumberMappingRegKey.RegistryKeyValue = lMapping.ValueName; lSerialNumberMapping.RegistryKeysList.Add(lSerialNumberMappingRegKey); } lSerialNumberMappingsList.Add(lSerialNumberMapping); } auditAgentScannerDefinition.SerialNumberMappingsList = lSerialNumberMappingsList; }
/// <summary> /// Add a new application to the list of registry mappings /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void bnNewApplication_Click(object sender, EventArgs e) { FormSelectApplication form = new FormSelectApplication(); if (form.ShowDialog() == DialogResult.OK) { String newApplication = form.SelectedApplication; ApplicationRegistryMapping applicationMapping = new ApplicationRegistryMapping(newApplication); // Add this entry to the combo box noting that we store the object with it to make // it easier to display the registry keys when selected ValueListItem newItem = cbApplications.Items.Add(applicationMapping.ApplicationName); newItem.Tag = applicationMapping; } }
/// <summary> /// Called as we change the selection in the combo box of applications /// we need to populate the list of registry mappings for the newly selected /// application /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cbApplications_SelectionChanged(object sender, EventArgs e) { // First clear the list view of any existing items lvRegistryKeys.Items.Clear(); // Get the selected application object ApplicationRegistryMapping applicationMapping = cbApplications.SelectedItem.Tag as ApplicationRegistryMapping; // ...and add to the list view foreach (RegistryMapping mapping in applicationMapping) { UltraListViewSubItem[] subItemArray = new UltraListViewSubItem[1]; subItemArray[0] = new UltraListViewSubItem(); subItemArray[0].Value = mapping.ValueName; UltraListViewItem item = new UltraListViewItem(mapping.RegistryKey, subItemArray); item.Tag = mapping; lvRegistryKeys.Items.Add(item); } }