Ejemplo n.º 1
0
        private void btnLocatePrinters_Click(object sender, EventArgs e)
        {
            ZXPSampleCode z = null;

            try
            {
                Cursor = Cursors.WaitCursor;

                lbStatus.Visible = true;
                lbJobStatus.Text = "Searching for printers";
                lbSamples.Items.Clear();
                Refresh();
                Application.DoEvents();

                // Get a list of ZXP devices
                if (cboPrnInit(rbUSB.Checked))
                {
                    // Loads list box with samples
                    for (int i = 0; i < _lbSamples.Length; i++)
                    {
                        this.lbSamples.Items.Add(_lbSamples[i]);
                    }

                    this.lbSamples.Text = _lbSamples[0];

                    // Displays versions
                    z = new ZXPSampleCode(this.cboPrn.Text);
                    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(SAMPLE_TYPE.PRINTING);
                    }
                    else
                    {
                        cboCardType.Enabled = false;
                    }
                }
                else //do not close the program
                {
                    string temp = rbUSB.Checked ? " USB" : " Ethernet";
                    MessageBox.Show("Could not locate a ZXP Printer via " + temp, "Warning");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("btnLocatePrinters_Click exception: " + ex.Message);
            }
            finally
            {
                z = null;
                lbStatus.Visible = false;
                Cursor           = Cursors.Default;
            }
        }
Ejemplo n.º 2
0
        private void frmMain_Shown(object sender, EventArgs e)
        {
            ZXPSampleCode z = null;

            try
            {
                // Get a list of USB ZXP devices
                if (cboPrnInit(true))
                {
                    // Loads list box with samples
                    for (int i = 0; i < _lbSamples.Length; i++)
                    {
                        this.lbSamples.Items.Add(_lbSamples[i]);
                    }

                    this.lbSamples.Text = _lbSamples[0];

                    // Displays versions
                    z = new ZXPSampleCode(this.cboPrn.Text);
                    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(SAMPLE_TYPE.PRINTING);
                    }
                    else
                    {
                        cboCardType.Enabled = false;
                    }

                    Text = "ZXP Sample Code " + ProductVersion;
                }
                else //do not close the program
                {
                    MessageBox.Show("Could not locate a ZXP Printer on USB ports", "Warning");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("frmMain_Load threw exception: " + ex.Message);
            }
            finally
            {
                z = null;
            }
        }
Ejemplo n.º 3
0
        private void btnConnectToPrinter_Click(object sender, EventArgs e)
        {
            ZXPSampleCode z   = null;
            Job           job = null;

            try
            {
                Cursor = Cursors.WaitCursor;

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

                job = new Job();

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

                if (z.Connect(ref job))
                {
                    // Loads list box with samples
                    for (int i = 0; i < _lbSamples.Length; i++)
                    {
                        this.lbSamples.Items.Add(_lbSamples[i]);
                    }

                    this.lbSamples.Text = _lbSamples[0];

                    // 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(SAMPLE_TYPE.PRINTING);
                    }
                    else
                    {
                        cboCardType.Enabled = false;
                    }

                    Text = "ZXP Sample Code " + ProductVersion;
                }
                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;
            }
        }