Smrf.NodeXL.ExcelTemplate.AnalyzeEmailNetworkDialog.ValidateFilterTextBox C# (CSharp) Method

ValidateFilterTextBox() protected method

protected ValidateFilterTextBox ( System.Boolean bCheckBoxIsChecked, System oTextBox, String sFilterDescription, String &sTrimmedText ) : System.Boolean
bCheckBoxIsChecked System.Boolean
oTextBox System
sFilterDescription String
sTrimmedText String
return System.Boolean
    ValidateFilterTextBox
    (
        Boolean bCheckBoxIsChecked,
        System.Windows.Forms.TextBox oTextBox,
        String sFilterDescription,
        out String sTrimmedText
    )
    {
        Debug.Assert(oTextBox != null);
        Debug.Assert( !String.IsNullOrEmpty(sFilterDescription) );
        AssertValid();

        sTrimmedText = null;

        if (!bCheckBoxIsChecked)
        {
            return (true);
        }

        // Remove leading and trailing spaces.

        sTrimmedText = oTextBox.Text.Trim();
        oTextBox.Text = sTrimmedText;

        if (sTrimmedText.Length == 0)
        {
            sTrimmedText = null;

            return (true);
        }

        if ( !ValidateFilter(sTrimmedText) )
        {
            String sErrorMessage = String.Format(

                "There must be at least one letter or number in {0}."
                ,
                sFilterDescription
                );

            return ( OnInvalidTextBox(oTextBox, sErrorMessage) );
        }

        return (true);
    }