/// <summary> /// Changes the application mode to the specified mode. /// </summary> /// <param name="mode">The specified mode.</param> private void ChangeMode(ProfilesMode mode) { switch (mode) { case ProfilesMode.NONE: this.ChangeToNoneMode(); break; case ProfilesMode.NEW: this.ChangeToNewMode(); break; case ProfilesMode.EDIT: this.ChangeToEditMode(); break; } }
/// <summary> /// Changes the application mode to the none mode. /// </summary> private void ChangeToNoneMode() { profilesComboBox.SelectedIndex = -1; hostTextBox.Enabled = false; hostTextBox.Text = string.Empty; domainTextBox.Enabled = false; domainTextBox.Text = string.Empty; dynamicDnsPasswordTextBox.Enabled = false; dynamicDnsPasswordTextBox.Text = string.Empty; updateIntervalComboBox.Enabled = false; updateIntervalComboBox.SelectedIndex = -1; autoDetectCheckBox.Enabled = false; autoDetectCheckBox.Checked = false; ipAddressTextBox.Enabled = false; ipAddressTextBox.Text = string.Empty; deleteButton.Enabled = false; saveButton.Enabled = false; cancelButton.Enabled = false; this.mode = ProfilesMode.NONE; }
/// <summary> /// Changes the application mode to the edit mode. /// </summary> private void ChangeToEditMode() { var id = ((ComboBoxItem)profilesComboBox .Items[profilesComboBox.SelectedIndex]).Id; var profile = this.dynamicDns.GetProfile(id); if (profile == null) { return; } hostTextBox.Enabled = true; hostTextBox.Text = profile.Host; domainTextBox.Enabled = true; domainTextBox.Text = profile.Domain; dynamicDnsPasswordTextBox.Enabled = true; dynamicDnsPasswordTextBox.Text = profile.DynamicDnsPassword; updateIntervalComboBox.Enabled = true; updateIntervalComboBox.SelectedIndex = (int)profile.Interval; autoDetectCheckBox.Enabled = true; autoDetectCheckBox.Checked = profile.AutoDetectIPAddress; ipAddressTextBox.Enabled = !profile.AutoDetectIPAddress; ipAddressTextBox.Text = profile.UpdateIPAddress?.ToString() ?? string.Empty; if (autoDetectCheckBox.Checked) { ipAddressTextBox.Text = string.Empty; } deleteButton.Enabled = true; saveButton.Enabled = true; cancelButton.Enabled = true; this.mode = ProfilesMode.EDIT; }