/// <summary> /// Called when we want to add a new registry mapping /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void bnAddKey_Click(object sender, EventArgs e) { FormShadedAskInput2 form = new FormShadedAskInput2("Please enter the registry key name and value name to map to the application. Do not specify the registry hive as HKEY_LOCAL_MACHINE is assumed." , "Enter Registry Key (beneath HKEY_LOCAL_MACHINE)" , "Registry Key Name:", "Value Name", "", "", Properties.Resources.application_serial_number_corner , true); if (form.ShowDialog() == DialogResult.OK) { // OK add the new mapping to our list RegistryMapping mapping = new RegistryMapping(form.Value1Entered(), form.Value2Entered()); 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); // Build the mappings string String mappingString = BuildMappingString(); // ..and update the configuration file _applicationsFile.SetString(cbApplications.SelectedItem.ToString(), mappingString, true); } }
public async Task <RegistryResponse> GetRegistryByID(int id) { CsvParserOptions csvParserOptions = new CsvParserOptions(false, ','); CsvReaderOptions csvReaderOptions = new CsvReaderOptions(new[] { Environment.NewLine }); RegistryMapping csvMapper = new RegistryMapping(); CsvParser <RegistryServices> csvParser = new CsvParser <RegistryServices>(csvParserOptions, csvMapper); RegistryResponse resultList = null; var list = new List <RegistryResponse>(); try { string fileName = $"Doc//RegistryServices.csv"; var result = csvParser .ReadFromFile(fileName, Encoding.UTF8).Skip(1) .ToList(); result.ForEach(x => { list.Add(new RegistryResponse { Id = Convert.ToInt32(x.Result.IdAgreement.ToString()), NombreEmpresa = x.Result.NameEnterprise.ToString(), EndpointUrl = new Uri($"http://{x.Result.EndpointUrl}"), Formato = x.Result.FormatTransformation.ToString() }); }); } catch (Exception ex) { var error = ex.ToString(); } return(list.Where(x => x.Id.Equals(id)).FirstOrDefault()); }
/// <summary> /// Edit an existing registry key mapping /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void bnEditKey_Click(object sender, EventArgs e) { // Get the mapping that is to be edited UltraListViewItem editItem = lvRegistryKeys.SelectedItems[0]; RegistryMapping editMapping = editItem.Tag as RegistryMapping; // ...and invoke a form to edit it //FormAskInput2 form = new FormAskInput2("Please enter the registry key name and value name to map to the application. Do not specify the registry hive as HKEY_LOCAL_MACHINE is assumed" // , "Enter Registry Key (beneath HKEY_LOCAL_MACHINE)" // , "Registry Key Name:" // , "Value Name" // , editMapping.RegistryKey // , editMapping.ValueName); FormShadedAskInput2 form = new FormShadedAskInput2("Please enter the registry key name and value name to map to the application. Do not specify the registry hive as HKEY_LOCAL_MACHINE is assumed" , "Enter Registry Key (beneath HKEY_LOCAL_MACHINE)" , "Registry Key Name:" , "Value Name" , editMapping.RegistryKey , editMapping.ValueName , Properties.Resources.application_serial_number_corner , true); if (form.ShowDialog() == DialogResult.OK) { // Remove the existing item from the list int index = editItem.Index; lvRegistryKeys.Items.Remove(editItem); // ...and add in the new item RegistryMapping mapping = new RegistryMapping(form.Value1Entered(), form.Value2Entered()); 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.Insert(index, item); // Build the mappings string String mappingString = BuildMappingString(); // ..and update the configuration file _applicationsFile.SetString(cbApplications.SelectedItem.ToString(), mappingString, true); } }