Example #1
0
        // Gets the versions of the SDK's DLLs
        //     if the version == "" then the supporting dll is not present ----------------------------------
        private void GetSDKVersions()
        {
            SampleCodeGraphics g;
            SampleCodeMag      p;

            try
            {
                g = new SampleCodeGraphics();
                _graphicsSDKVersion = g.GetSDKVersion();

                p = new SampleCodeMag();
                _prnSDKVersion = p.GetSDKVersion();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "GetSDKVersions threw exception");
            }
            finally
            {
                g = null;
                p = null;
            }
        }
Example #2
0
        // Submit Button
        //     Starts the example code based on Form selections ---------------------------------------------

        private void btnSubmit_Click(object sender, EventArgs e)
        {
            #region Variables

            bool   eject = false;
            string msg   = "";

            SampleCodeMag      mag = null;
            SampleCodeGraphics prn = null;

            #endregion

            #region Check Selections

            // Verifies that a printer has been selected
            try
            {
                if (cboPrn.SelectedIndex < 0)
                {
                    msg = "Error: A Printer has not been selected";
                    return;
                }

                // Verifies that at least one selection is made
                if (!this.cbBack.Checked && !this.cbFront.Checked && !this.cbMag.Checked && !this.cbContactless.Checked)
                {
                    msg = "Error: No Selections";
                    return;
                }

                #endregion



                #region Smart Cards
                {
                    // the eject variable is set to true if magnetic encoding is not selected
                    //  and neither Front or Back is selected

                    eject = (!this.cbMag.Checked && !this.cbBack.Checked && !this.cbFront.Checked);

                    // Determines which smart card sample code to run

                    if (this.cbContactless.Checked)
                    {
                        Contactless = new SampleCodeContactless();
                        string _ContactlessReader = "";
                        string _ContactReader     = "";
                        string errorMsg           = "";

                        WinSCard.GetPCSCReaders(out _ContactlessReader, out _ContactReader, out errorMsg);
                        if (_ContactlessReader != null && _ContactlessReader.Length > 0)
                        {
                            Contactless.ContactlessEncode(this.cboPrn.Text, _ContactlessReader, Convert.ToInt16(eject), out msg);
                            if (msg == "")
                            {
                                this.lblStatus.Text = "Contactless : No Errors";
                            }
                            else
                            {
                                this.lblStatus.Text = msg;
                            }
                        }
                        else
                        {
                            this.lblStatus.Text = "Error: No Contactless Reader found";
                        }
                    }
                }

                #endregion

                #region Magnetic Encoding

                if (cbMag.Checked)
                {
                    // the eject variable is set to true if neither Front or Back is selected

                    eject = (!this.cbBack.Checked && !this.cbFront.Checked);

                    // Encodes and Verifies all three Tracks

                    mag = new SampleCodeMag();
                    mag.PerformMagneticEncodeJob(this.cboPrn.Text, out msg);
                    if (msg != "")
                    {
                        return;
                    }
                    this.lblStatus.Text = "Magnetic Encoding : No Errors";
                }

                #endregion

                #region Printing

                // Initialize the Print Side Class

                prn = new SampleCodeGraphics();

                // Determines the printing type

                if (this.cbFront.Checked && !this.cbBack.Checked)
                {
                    prn.PrintFrontSideOnly(this.cboPrn.Text, "Front Side Text", Application.StartupPath, out msg);
                    if (msg == "")
                    {
                        this.lblStatus.Text = "No Errors : Front Side Only Printing";
                    }
                }
                else if (this.cbFront.Checked && this.cbBack.Checked)
                {
                    prn.PrintBothSides(this.cboPrn.Text, "Front Side Text", "Back Side Text", Application.StartupPath, out msg);
                    if (msg == "")
                    {
                        this.lblStatus.Text = "No Errors : Both Side Printing";
                    }
                }
            }
            catch (Exception ex)
            {
                msg += ex.Message;
                MessageBox.Show(ex.ToString(), "btnSubmit_Click threw exception");
            }
            finally
            {
                if (msg != "")
                {
                    this.lblStatus.Text = msg;
                }

                mag = null;
                prn = null;
            }

            #endregion
        }