private void validateOptionsAndAdjustControlStates()
{
textServerAddress.Enabled = !checkSelectInSidebar.Checked && status != ValidationStatus.Validating;
buttonConnect.Enabled = !string.IsNullOrWhiteSpace(textServerAddress.Text) && status != ValidationStatus.Validating;
bool isValid = checkSelectInSidebar.Checked || (!string.IsNullOrWhiteSpace(textServerAddress.Text) && lastCheckedServerAddress == textServerAddress.Text && status == ValidationStatus.Success);
buttonOk.Enabled = isValid;
if (isValid)
{
textStatus.Text = Properties.Resources.SDK_OPTION_LABEL_STATUS_SUCCESS;
pictureStatus.Image = Resources.iconConnected;
this.AcceptButton = buttonOk;
}
else
{
if (status == ValidationStatus.NotStarted)
{
textStatus.Text = Properties.Resources.SDK_OPTION_LABEL_STATUS_NOT_CONNECTED;
pictureStatus.Image = null;
this.AcceptButton = buttonConnect;
}
if (status == ValidationStatus.Validating)
{
textStatus.Text = Properties.Resources.SDK_OPTION_LABEL_STATUS_CONNECTING;
pictureStatus.Image = Resources.iconConnecting;
this.AcceptButton = buttonCancel;
}
else if (status == ValidationStatus.Failure)
{
textStatus.Text = Properties.Resources.SDK_OPTION_LABEL_STATUS_FAILURE;
pictureStatus.Image = Resources.iconDisconnected;
this.AcceptButton = buttonConnect;
}
}
}