コード例 #1
0
 private void DisconnectFromPrinter(ref ZXPSampleCode z, ref Job job)
 {
     try
     {
         z.Disconnect(ref job);
     }
     catch (Exception ex)
     {
         MessageBox.Show("DisconnectFromPrinter threw exception: " + ex.Message);
     }
 }
コード例 #2
0
        private void btnConnectToPrinter_Click(object sender, EventArgs e)
        {
            ZXPSampleCode z   = null;
            Job           job = null;

            try
            {
                Cursor = Cursors.WaitCursor;

                btnRun.Enabled = false;

                lbStatus.Visible = true;
                lbStatus.Text    = "Connecting to printer";
                Refresh();
                Application.DoEvents();

                job = new Job();

                z = new ZXPSampleCode(this.cboPrn.Text);

                if (z.Connect(ref job))
                {
                    // Displays versions
                    this.lblVersions.Text = z.GetVersions();

                    if (!z.IsZXP7)
                    {
                        // Loads card types based on type of sample type
                        _cardTypeList = new ArrayList();

                        CardTypesInit(ref z, this.cboPrn.Text);

                        cboCardTypeInit();
                    }
                    else
                    {
                        cboCardType.Enabled = false;
                    }

                    btnRun.Enabled = true;
                }
                else
                {
                    MessageBox.Show("Could not open connection to printer " + cboPrn.Text, "Warning");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("btnConnectToPrinter_Click exception: " + ex.Message);
            }
            finally
            {
                if (z != null)
                {
                    z.Disconnect(ref job);
                }
                z = null;
                lbStatus.Visible = false;
                Cursor           = Cursors.Default;
            }
        }