internal MoreOptionsDialogResult ShowDialog(Socket socket) { string title = _translation.GetSocketWithIDAndName(socket); _form = createForm(title); _btnOn = createOnButton(); _btnOff = createOffButton(); _btnUndefined = createUndefinedButton(); _cbTimeSpan = createComboBox(); _btnOK = createOKButton(); _form.Controls.Add(_btnOn); _form.Controls.Add(_btnOff); _form.Controls.Add(_btnUndefined); _form.Controls.Add(_cbTimeSpan); _form.Controls.Add(_btnOK); _btnOn.Click += _btnStatus_Click; _btnOff.Click += _btnStatus_Click; _btnUndefined.Click += _btnStatus_Click; _cbTimeSpan.SelectedValueChanged += _cbTimeSpan_SelectedValueChanged; _btnOK.Click += _btnOK_Click; _canceled = true; _status = SensorPowerStatus.On; _timeSpan = new TimeSpan(); _form.ShowDialog(); _btnOn.Click -= _btnStatus_Click; _btnOff.Click -= _btnStatus_Click; _btnUndefined.Click -= _btnStatus_Click; _cbTimeSpan.SelectedValueChanged -= _cbTimeSpan_SelectedValueChanged; _btnOK.Click -= _btnOK_Click; _form = null; _btnOn = null; _btnOff = null; _btnUndefined = null; _cbTimeSpan = null; _btnOK = null; return(new MoreOptionsDialogResult(socket, _status, _timeSpan, _canceled)); }