private void btnVerify_Click(object sender, EventArgs e)
        {
            if (!File.Exists(txtFileToVerify.Text))
            {
                MessageBox.Show("Please select the file containing the XML Signature");
                return;
            }

            try
            {
                SAPIWrapper.SignatureDetails details = SAPIWrapper.ValidateXMLSignature(txtFileToVerify.Text);
                if (details == null)
                {
                    MessageBox.Show("Signature could not be validated");
                    return;
                }
                lblSignerName.Text  = details.SignerName;
                lblSigningTime.Text = details.SignatureTimeTicks == 0 ?
                                      "Not Available" : string.Format("{0}, {1}",
                                                                      new DateTime(details.SignatureTimeTicks).ToShortDateString(),
                                                                      new DateTime(details.SignatureTimeTicks).ToShortTimeString());
                chkIsValid.Checked = details.isValid;
                lblShowCert.Tag    = details.SignerCertificate;
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
        }
        private void btnSign_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtUsername.Text))
            {
                MessageBox.Show("Please provide Username");
                return;
            }

            if (string.IsNullOrEmpty(txtPassword.Text))
            {
                MessageBox.Show("Please provide Password");
                return;
            }

            if (!File.Exists(txtFile.Text))
            {
                MessageBox.Show(string.Format("The file '{0}' doesn't exist!",
                                              txtFile.Text));
                return;
            }

            try
            {
                //Sign XML Stream
                SAPIWrapper.SignXML(
                    txtUsername.Text,
                    txtDomain.Text,
                    txtPassword.Text,
                    txtFile.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }


            MessageBox.Show("The data was signed successfully");
        }