private void EditAddressValue() { var index = lvStoredAddresses.SelectedIndex(); try { if (lvStoredAddresses.Items[index].SubItems[GetColumnID(lvStoredAddresses, "cAddress")].Text == "") { return; } using (var editValue = new FrmEditDialog(MessageType.AddressValue, lvStoredAddresses.Items[index] .SubItems[GetColumnID(lvStoredAddresses, "cValueType")].Text)) { if (editValue.ShowDialog() != DialogResult.OK) { return; } //Edit Existing Address lvStoredAddresses.Items[index].SubItems[GetColumnID(lvStoredAddresses, "cValue")].Text = editValue.OutputValue; if (editValue.cbPoke.Checked) { MySwitch.SendCommand(Commands.PokeAddress, "", lvStoredAddresses.Items[index].SubItems[GetColumnID(lvStoredAddresses, "cAddress")].Text, SearchSize, editValue.OutputValue); } } } catch (ArgumentOutOfRangeException) { MessageBox.Show("No Valid Address!"); } }
private void AddAddress() { var index = lvAddress.SelectedIndex(); using (var editValue = new FrmEditDialog(MessageType.AddressValue, cbValueType.Text)) { if (editValue.ShowDialog() == DialogResult.OK) { //Check if address exist //Get Stored Address Count //If more than 0 var count = lvStoredAddresses.Items.Count; if (count > 0) { var found = false; //Loop thru the addresses for (var i = 0; i < count; i++) { var address = lvStoredAddresses.Items[i].SubItems[GetColumnID(lvStoredAddresses, "cAddress")].Text; address = address.Split(' ')[0]; //If address found if (lvAddress.Items[index].SubItems[GetColumnID(lvAddress, "colAddress")].Text == address) { found = true; //Edit Existing Address lvStoredAddresses.Items[i].SubItems[GetColumnID(lvStoredAddresses, "cValue")].Text = editValue.OutputValue; break; } } if (!found) { lvStoredAddresses.Items.Add(AddListViewItem( lvAddress.Items[index].SubItems[GetColumnID(lvAddress, "colAddress")].Text, "", SearchSize, editValue.OutputValue)); } } else { //Else Add a new Address lvStoredAddresses.Items.Add(AddListViewItem(lvAddress.Items[index].SubItems[GetColumnID(lvAddress, "colAddress")].Text, "", SearchSize, editValue.OutputValue)); } } if (editValue.cbPoke.Checked) { MySwitch.SendCommand(Commands.PokeAddress, "", lvAddress.Items[index].SubItems[GetColumnID(lvAddress, "colAddress")].Text, SearchSize, editValue.OutputValue); } } }
private void EditDescriptionValue() { var index = lvStoredAddresses.SelectedIndex(); try { if (lvStoredAddresses.Items[index].SubItems[GetColumnID(lvStoredAddresses, "cAddress")].Text == "") { return; } using (var editValue = new FrmEditDialog(MessageType.Description)) { if (editValue.ShowDialog() == DialogResult.OK) { lvStoredAddresses.Items[index].SubItems[GetColumnID(lvStoredAddresses, "cDescription")].Text = editValue.OutputValue; } } } catch (ArgumentOutOfRangeException) { MessageBox.Show("No Valid Address!"); } }