コード例 #1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            RMPackLic.Source licSource = ToLicenseSource(comboType.SelectedIndex);
            if (ValidateLicenseValue(txtValue.Text, licSource))
            {
                DialogResult   = DialogResult.OK;
                PackageLicense = new RMPackLic(licSource, txtValue.Text);
                Close();
            }
            else
            {
                switch (licSource)
                {
                case RMPackLic.Source.File:
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmLicenseEdit.FileNotFound(txtValue.Text), MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;

                case RMPackLic.Source.Text:
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmLicenseEdit.TEXT_EMPTY, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;

                case RMPackLic.Source.URL:
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmLicenseEdit.INVALID_URL, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;
                }
            }
        }
コード例 #2
0
 bool ValidateLicenseValue(string value, RMPackLic.Source type)
 {
     if (type == RMPackLic.Source.File)
     {
         if (File.Exists(value) && RMPackLic.HasAValidLicFileExtension(Path.GetExtension(value)))
         {
             return(true);
         }
         return(false);
     }
     else if (type == RMPackLic.Source.Text)
     {
         if (string.IsNullOrWhiteSpace(value))
         {
             return(false);
         }
         return(true);
     }
     else
     {
         if (value.IsAValidURL())
         {
             return(true);
         }
         return(false);
     }
 }
コード例 #3
0
        int ToIndex(RMPackLic.Source source)
        {
            switch (source)
            {
            case RMPackLic.Source.URL:
                return(0);

            case RMPackLic.Source.File:
                return(1);

            case RMPackLic.Source.Text:
                return(2);

            default:
                return(0);
            }
        }