Beispiel #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;

            try
            {
                g = new SampleCodeGraphics();
                _graphicsSDKVersion = g.GetSDKVersion();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "GetSDKVersions threw exception");
            }
            finally
            {
                g = null;
            }
        }
Beispiel #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   = "";

            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;
                }

                #endregion


                #region Printing

                // Initialize the Print Side Class

                prn = new SampleCodeGraphics();

                // Determines the printing type

                SampleCodeDrawConfiguration config = new SampleCodeDrawConfiguration();
                config.StringLabelText = txtTextInput.Text;
                config.LabelLocation   = new Point(50, 465);

                if (openFileDialogBackground.FileName.EndsWith(".bmp") || openFileDialogBackground.FileName.EndsWith(".png"))
                {
                    config.BackgroundImageData =
                        new ZBRGraphics().AsciiEncoder.GetBytes(openFileDialogBackground.FileName);

                    config.BackgroundImageRect = new Rectangle(0, 0, 1024, 648);
                }

                if (openFileDialog1.FileName.EndsWith(".bmp") || openFileDialog1.FileName.EndsWith(".png"))
                {
                    config.ImageData =
                        new ZBRGraphics().AsciiEncoder.GetBytes(openFileDialog1.FileName);

                    config.ImageLocationRect = new Rectangle(50, 50, 400, 400);
                }
                if (SigMoves > 0)
                {
                    Bitmap   signbitmap = new Bitmap(240, 80, PixelFormat.Format32bppArgb); //Format32bppArgb for composite
                    Graphics g          = Graphics.FromImage(signbitmap);
                    g.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
                    for (int i = 1; i < SigMoves; i++)
                    {
                        g.DrawLine(blackPen, this.SigArrayX[i - 1], this.SigArrayY[i - 1], this.SigArrayX[i], this.SigArrayY[i]);
                    }
                    signbitmap.Save(Application.StartupPath + "signature.png", ImageFormat.Png);

                    config.SignatureImageData =
                        new ZBRGraphics().AsciiEncoder.GetBytes(Application.StartupPath + "signature.png");
                    config.SignatureImageRect = new Rectangle(10, 500, 240, 80);
                }

                prn.PrintFrontSideOnly(this.cboPrn.Text,
                                       config,
                                       out msg);
                if (msg == "")
                {
                    this.lblStatus.Text = "No Errors";
                }
            }
            catch (Exception ex)
            {
                msg += ex.Message;
                MessageBox.Show(ex.ToString(), "btnSubmit_Click threw exception");
            }
            finally
            {
                if (msg != "")
                {
                    this.lblStatus.Text = msg;
                }

                prn = null;
            }

            #endregion
        }