Exemplo n.º 1
0
        /// <summary>
        /// Check that the data supplied via the controls on the form satisfies validation rules.
        /// </summary>
        /// <returns>True if the data passes validation.</returns>
        private bool ValidateData()
        {
            bool          IsValid       = true;
            StringBuilder ErrorMessages = new StringBuilder();

            if (String.IsNullOrEmpty(this.NetworkNameTextBox.Text))
            {
                IsValid = false;
                ErrorMessages.AppendLine("A Network Name must be provded.");
            }

            if (String.IsNullOrEmpty(this.NetworkAddressTextBox.Text))
            {
                IsValid = false;
                ErrorMessages.AppendLine("An Address must be provided.");
            }

            WolHostNetwork.NetworkLocality SelectedLocality = (WolHostNetwork.NetworkLocality)Enum.Parse(typeof(WolHostNetwork.NetworkLocality),
                                                                                                         this.NetworkLocalityComboBox.SelectedValue.ToString());
            if (SelectedLocality == WolHostNetwork.NetworkLocality.Remote && String.IsNullOrEmpty(this.HostSubnetMaskTextBox.Text))
            {
                IsValid = false;
                ErrorMessages.AppendLine("A subnet mask is required for remote networks.");
            }

            if (IsValid == false)
            {
                MessageBox.Show(ErrorMessages.ToString(), "Network Properties Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(IsValid);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Enables or disables controls on the form according to view rules.
 /// </summary>
 private void LockUnlockControls()
 {
     // Subnet Mask is not required unless the network is a Remote Network.
     WolHostNetwork.NetworkLocality SelectedLocation = (WolHostNetwork.NetworkLocality)Enum.Parse(typeof(WolHostNetwork.NetworkLocality),
                                                                                                  this.NetworkLocalityComboBox.SelectedValue.ToString());
     this.HostSubnetMaskTextBox.Enabled = (SelectedLocation == WolHostNetwork.NetworkLocality.Remote);
 }