コード例 #1
0
        private void btnGetSignature_Click(object sender, EventArgs e)
        {
            try
            {
                SigPlusNET1.SetTabletComTest(1);
                SigPlusNET1.SetTabletState(1);
                //open port, turn tablet on

                while ((!SigPlusNET1.TabletConnectQuery() || SigPlusNET1.GetTabletState() != 1))
                {
                    if (MessageBox.Show("Cannot locate signature pad. Please make sure it is connected.", "Cannot locate signature pad", System.Windows.Forms.MessageBoxButtons.RetryCancel, System.Windows.Forms.MessageBoxIcon.Exclamation) == DialogResult.Cancel)
                    {
                        //Continue, turn off test
                        SigPlusNET1.SetTabletComTest(0);
                        return;
                    }
                    else
                    {
                        //Max 08/31/2016 - We must reset the TabletCom and TabletState to zero which is the original state before retryning setting it to 1
                        SigPlusNET1.SetTabletComTest(0);
                        SigPlusNET1.SetTabletState(0);

                        SigPlusNET1.SetTabletComTest(1);
                        SigPlusNET1.SetTabletState(1);
                        //open port, turn tablet on
                        SigPlusNET1.ClearTablet();
                        //Clears the SigPlus object of ink
                    }
                }

                //Continue, turn off test
                SigPlusNET1.SetTabletComTest(0);
                SigPlusNET1.ClearTablet();
                //Clears the SigPlus object of ink

                btnGetSignature.Enabled = false;

                if (pictureBox1.Image != null)
                {
                    pictureBox1.Image.Dispose();
                    pictureBox1.Image = null;
                }

                btnAccept.Enabled = false;
                SigPlusNET1.BringToFront();
                this.Refresh();

                if (this.miSigPadWidth == 640)
                {
                    //******************************************************************'
                    // The following parameters are set in case the user's INI file is not correctly set up for an LCD 4X3 tablet
                    // Otherwise, if the INI is correctly set up, these parameters do not need to be set

                    SigPlusNET1.SetTabletXStart(300);
                    SigPlusNET1.SetTabletXStop(2370);
                    SigPlusNET1.SetTabletYStart(350);
                    SigPlusNET1.SetTabletYStop(1950);
                    SigPlusNET1.SetTabletLogicalXSize(2070);
                    SigPlusNET1.SetTabletLogicalYSize(1600);

                    SigPlusNET1.LCDSetWindow(0, 0, 1, 1);
                    //Prohibit inking on entire LCD
                    SigPlusNET1.SetSigWindow(1, 0, 0, 1, 1);
                    //Prohibit inking in SigPlus
                    SigPlusNET1.LCDRefresh(0, 0, 0, 640, 480);
                    //Refresh entire tablet


                    SigPlusNET1.SetLCDCaptureMode(2);


                    //Dim bmSignHere As New Bitmap(mbmsignhere)
                    //Dim myGR As Graphics = Graphics.FromImage(bmSignHere)
                    //Dim drawFont As Font = New System.Drawing.Font("Arial", 16.0F, System.Drawing.FontStyle.Bold)
                    //Dim drawBrush As New SolidBrush(Color.Black)
                    //Dim drawPoint As New PointF(0.0F, 0.0F)
                    //myGR.DrawString(msInfoLabel, drawFont, drawBrush, drawPoint)

                    SigPlusNET1.LCDSetPixelDepth(8);

                    SigPlusNET1.LCDSendGraphic(0, 2, 0, 0, mbmsignhere);
                    //this BMP is loaded into background

                    //SigPlusNET1.LCDRefresh(2, 0, 0, 240, 128) 'sets the BMP in the background
                    //to the foreground--note the initial argument 2

                    //Harish Ramakrishnan 05/15/2010
                    SigPlusNET1.LCDSetPixelDepth(0);
                    SigPlusNET1.LCDWriteString(0, 2, 0, 430, _sigFont, msInfoLabel);

                    SigPlusNET1.LCDSetPixelDepth(8);
                    Bitmap   objBitmap  = new Bitmap(640, 2);
                    Graphics objGraphic = Graphics.FromImage(objBitmap);
                    Pen      blackPen   = new Pen(Color.Black, 1);
                    objGraphic.DrawLine(blackPen, new Point(5, 1), new Point(630, 195));
                    SigPlusNET1.LCDSendGraphic(1, 2, 0, 428, objBitmap);
                    SigPlusNET1.LCDRefresh(2, 0, 428, 640, 2);
                    SigPlusNET1.LCDSetPixelDepth(0);

                    SigPlusNET1.LCDWriteString(0, 2, 20, 290, _sigFont, "CLEAR");
                    SigPlusNET1.LCDWriteString(0, 2, 400, 290, _sigFont, "OK");

                    SigPlusNET1.KeyPadAddHotSpot(0, 1, 0, 280, 150, 30);
                    SigPlusNET1.KeyPadAddHotSpot(1, 1, 350, 280, 100, 30);

                    //Dim label As Font
                    //label = New System.Drawing.Font("Arial", 16.0F, System.Drawing.FontStyle.Regular)
                    //SigPlusNET1.SetTabletState(1)
                    //SigPlusNET1.LCDWriteString(0, 2, 4, 0, label, msInfoLabel)
                    SigPlusNET1.LCDRefresh(2, 0, 313, 640, 115);
                    SigPlusNET1.LCDSetWindow(0, 313, 640, 115);
                    SigPlusNET1.SetSigWindow(1, 0, 313, 640, 115);
                    //SigPlusNET1.LCDSetWindow(0, 74, 240, 54) 'Permits only the section on LCD
                    //to display ink
                    //SigPlusNET1.SetSigWindow(1, 0, 68, 240, 60)
                    //specifies area in sigplus object to accept ink
                }
                else
                {
                    throw new Exception("Signature pad resolution is not supported");
                }

                //Timer1.Enabled = true;
            }
            catch (Exception ex)
            {
                Logger.LogError("Error reading the signature image from SigPlusNET", ex);
            }
        }