private void addVariableMenuItem_Click(object sender, System.EventArgs e) { if (upnpService == null) return; StateVariableEditForm stateVariableEditForm = new StateVariableEditForm(upnpService); DialogResult r = stateVariableEditForm.ShowDialog(this); if (r == DialogResult.OK) { UPnPStateVariable var = stateVariableEditForm.StateVariable; if (var != null) { upnpService.AddStateVariable(var); updateUserInterface(); } } }
private void stateVariableListView_DoubleClick(object sender, System.EventArgs e) { if (upnpService == null) return; if (stateVariableListView.SelectedItems.Count == 1) { UPnPStateVariable var = (UPnPStateVariable)stateVariableListView.SelectedItems[0].Tag; StateVariableEditForm stateVariableEditForm = new StateVariableEditForm(); stateVariableEditForm.StateVariable = var; DialogResult r = stateVariableEditForm.ShowDialog(this); if (r == DialogResult.OK) { if(var.Name==stateVariableEditForm.StateVariable.Name) { upnpService.AddStateVariable(stateVariableEditForm.StateVariable); } else { try { upnpService.RemoveStateVariable(var); upnpService.AddStateVariable(stateVariableEditForm.StateVariable); } catch(UPnPStateVariable.CannotRemoveException) { MessageBox.Show("You cannot remove this State variable because it is associated with an existing action"); return; } } updateUserInterface(); } } }