private void sealSignBSSWacomSTUPanel1_ErrorCaptureEvent(object sender, EventArgs e)
        {
            m_progressWindow.Close();
            m_otherProgressWindow.Close();

            if (((Exception)((System.UnhandledExceptionEventArgs)e).ExceptionObject).Message == "La firma no puede estar vacía")
            {
                MessageBox.Show(this, ((Exception)((System.UnhandledExceptionEventArgs)e).ExceptionObject).Message, Tools.GetLocalizedString("Title"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                Tools.ShowUnexpectedError(this, ((Exception)((System.UnhandledExceptionEventArgs)e).ExceptionObject));
                this.DialogResult = DialogResult.Cancel;
                this.CloseWindow();
            }

            /*this.DialogResult = DialogResult.Cancel;
             * this.Close();*/
        }
        public DTUSignatureForm(int signatureIndex, SignatureClientBehaviour signatureClientBehaviour, JobReferenceEx jobReferenceEx)
        {
            try
            {
                m_SignatureClientBehaviour = signatureClientBehaviour;
                m_jobReferenceEx           = jobReferenceEx;
                m_signatureIndex           = signatureIndex;

                m_ErrorCaptureEvent += new SealSignBSSClientLibrary.SealSignBSSPanel.ErrorCapture(sealSignBSSPanel1_ErrorCaptureEvent);

                m_progressWindow = new ProgressWindow(Convert.ToInt32(Tools.GetAppSettings("wacom_dtu_screen_number")) - 1);

                InitializeComponent();
            }
            catch (Exception ex)
            {
                if (m_progressWindow != null)
                {
                    m_progressWindow.Close();
                }

                Tools.ShowUnexpectedError(this, ex);
            }
        }
        private void frmSignature_Load(object sender, EventArgs e)
        {
            bSigning   = false;
            CancelHwnd = btnCancel.Handle;
            SignHwnd   = btnSign.Handle;

            string Logo = Tools.GetAppSettings("Logo").ToString();

            if (Logo != "")
            {
                try
                {
                    pictureBox1.Load(Logo);
                }
                catch { }
            }

            string WindowColor = Tools.GetAppSettings("WindowColor").ToString();

            if (WindowColor != "")
            {
                backgroundPanel.BackColor = System.Drawing.ColorTranslator.FromHtml(WindowColor);
                lblTitle.BackColor        = backgroundPanel.BackColor;
                pictureBox1.BackColor     = backgroundPanel.BackColor;
            }

            string TitleColor = Tools.GetAppSettings("TitleColor").ToString();

            if (TitleColor != "")
            {
                lblTitle.ForeColor = System.Drawing.ColorTranslator.FromHtml(TitleColor);
            }

            string FrameColor = Tools.GetAppSettings("FrameColor").ToString();

            if (FrameColor != "")
            {
                framePanel.BackColor   = System.Drawing.ColorTranslator.FromHtml(FrameColor);
                buttonsPanel.BackColor = framePanel.BackColor;
            }

            string CancelButtonColor = Tools.GetAppSettings("CancelButtonColor").ToString();

            if (CancelButtonColor != "")
            {
                btnCancel.BackColor = System.Drawing.ColorTranslator.FromHtml(CancelButtonColor);
            }

            string OKButtonColor = Tools.GetAppSettings("OKButtonColor").ToString();

            if (OKButtonColor != "")
            {
                btnSign.BackColor = System.Drawing.ColorTranslator.FromHtml(OKButtonColor);
            }

            m_progressWindow.Show(null, Tools.GetLocalizedString("InitializingDevice"));
            m_bDeviceConnected = true;

            sealSignBSSWacomSTUPanel1.ErrorCaptureEvent            += m_ErrorCaptureEvent;
            sealSignBSSWacomSTUPanel1.ErrorDeviceNotConnectedEvent += m_ErrorDeviceNotConnectedEvent;
            sealSignBSSWacomSTUPanel1.Start();

            if (m_SignatureClientBehaviour.stuConfiguration != null)
            {
                if (m_SignatureClientBehaviour.stuConfiguration.OKButton != null)
                {
                    sealSignBSSWacomSTUPanel1.OkButtonClickEvent += m_OkButtonClickEvent;
                    sealSignBSSWacomSTUPanel1.SetOkButtonArea(m_SignatureClientBehaviour.stuConfiguration.OKButton.x1,
                                                              m_SignatureClientBehaviour.stuConfiguration.OKButton.y1,
                                                              m_SignatureClientBehaviour.stuConfiguration.OKButton.x2,
                                                              m_SignatureClientBehaviour.stuConfiguration.OKButton.y2);
                }
                if (m_SignatureClientBehaviour.stuConfiguration.CancelButton != null)
                {
                    sealSignBSSWacomSTUPanel1.CancelButtonClickEvent += m_CancelButtonClickEvent;
                    sealSignBSSWacomSTUPanel1.SetCancelButtonArea(m_SignatureClientBehaviour.stuConfiguration.CancelButton.x1,
                                                                  m_SignatureClientBehaviour.stuConfiguration.CancelButton.y1,
                                                                  m_SignatureClientBehaviour.stuConfiguration.CancelButton.x2,
                                                                  m_SignatureClientBehaviour.stuConfiguration.CancelButton.y2);
                }
                if (m_SignatureClientBehaviour.stuConfiguration.Image != null)
                {
                    MemoryStream imageStream = new MemoryStream(m_SignatureClientBehaviour.stuConfiguration.Image);
                    imageStream.Seek(0, SeekOrigin.Begin);
                    sealSignBSSWacomSTUPanel1.SetImage(imageStream);
                }
            }

            btnSign.Enabled = m_bDeviceConnected;
            m_progressWindow.Close();

            if (!String.IsNullOrEmpty(m_SignatureClientBehaviour.signatureWindowTitle))
            {
                this.Text     = m_SignatureClientBehaviour.signatureWindowTitle;
                lblTitle.Text = m_SignatureClientBehaviour.signatureWindowTitle;
            }

            //Load the Form At Position of Main Form
            int WidthOfMain   = this.Owner.Width;
            int HeightofMain  = this.Owner.Height;
            int LocationMainX = this.Owner.Location.X;
            int locationMainy = this.Owner.Location.Y;

            this.Location = new Point(LocationMainX + WidthOfMain - this.Width - 50, locationMainy + HeightofMain - this.Height - 55);

            this.Activate();
        }
        private void btnSign_Click(object sender, EventArgs e)
        {
            SignatureQueueServiceClient service = null;

            try
            {
                if (bSigning)
                {
                    return;
                }
                bSigning = true;

                sealSignBSSWacomSTUPanel1.Stop();

                m_otherProgressWindow = new ProgressWindow();
                m_otherProgressWindow.Show(null, Tools.GetLocalizedString("Signing"));

                service = WSTools.GetSignatureQueueServiceClient();

                BiometricSignatureContext context = service.BeginBiometricSignatureProvider(
                    m_jobReferenceEx.id,
                    m_signatureIndex,
                    m_jobReferenceEx.queueName,
                    m_SignatureClientBehaviour.signatureId,
                    m_SignatureClientBehaviour.signatureAccount,
                    m_SignatureClientBehaviour.uri,
                    m_SignatureClientBehaviour.providerParameter,
                    null);
                if (context != null && context.instance != null)
                {
                    byte[] biometricFinalState = sealSignBSSWacomSTUPanel1.GetSignature(context.instance, context.biometricState);
                    if (biometricFinalState != null)
                    {
                        m_signedDocument = service.EndBiometricSignatureProvider(
                            context.instance,
                            biometricFinalState,
                            m_jobReferenceEx.id,
                            m_signatureIndex,
                            m_jobReferenceEx.queueName,
                            m_SignatureClientBehaviour.uri,
                            m_SignatureClientBehaviour.providerParameter);
                    }
                    else
                    {
                        // Te error has already reported on the error handler
                        return;
                    }
                }

                m_otherProgressWindow.SetMessage(Tools.GetLocalizedString("SignatureSuccess"), 1500);

                m_otherProgressWindow.Close();

                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                sealSignBSSWacomSTUPanel1.Stop();
                m_otherProgressWindow.Close();

                Tools.ShowUnexpectedError(this, ex);
            }
            finally
            {
                if (service != null)
                {
                    try
                    {
                        service.Close();
                    }
                    catch { }
                }

                this.CloseWindow();
                bSigning = false;
            }
        }