public bool Perform_Set_Error_Recovery_Mode_Print(string cardType)
        {
            bool bRet = true;

            byte[] img     = null;
            byte[] bmp     = null;
            byte[] monoBmp = null;

            Job            job = null;
            ZMotifGraphics g   = null;

            try
            {
                job = new Job();
                g   = new ZMotifGraphics();

                // Opens a connection with a ZXP Printer
                //     if it is in an alarm condition, exit function
                // -------------------------------------------------

                if (!Connect(ref job))
                {
                    _msg = "Unable to open device [" + _deviceName + "]";
                    return(false);
                }

                if (_alarm != 0)
                {
                    _msg = "Printer is in alarm condition" + "Error: " + job.Device.GetStatusMessageString(_alarm);
                    return(false);
                }

                if (_isZXP7)
                {
                    FrontImage = "ZXP7Front.bmp";
                }
                else
                {
                    FrontImage = "ZXP8Front.bmp";
                }

                img = g.ImageFileToByteArray(FrontImage);

                // Builds the image to print
                // -------------------------

                g.InitGraphics(0, 0, ZMotifGraphics.ImageOrientationEnum.Landscape,
                               ZMotifGraphics.RibbonTypeEnum.Color);

                g.DrawImage(ref img, 50, 50, 924, 548, 0);
                g.DrawTextString(50.0f, 580.0f, "Color + Set Error Recovery Mode", "Arial", 10.0f,
                                 ZMotifGraphics.FontTypeEnum.Regular,
                                 g.IntegerFromColor(System.Drawing.Color.Black));

                int dataLen = 0;
                bmp = g.CreateBitmap(out dataLen);

                g.ClearGraphics();

                //re-init graphics for MonoK panel
                g.InitGraphics(0, 0, ZMotifGraphics.ImageOrientationEnum.Landscape,
                               ZMotifGraphics.RibbonTypeEnum.MonoK);

                //load image to be printed as MonoK panel:
                img = g.ImageFileToByteArray("Back.bmp");
                g.DrawImage(ref img, 50, 50, 924, 548, 0);

                dataLen = 0;
                monoBmp = g.CreateBitmap(out dataLen);

                // Print image on both sides
                // -------------------------

                if (!_isZXP7)
                {
                    job.JobControl.CardType = cardType;
                }

                job.JobControl.FeederSource = FeederSourceEnum.CardFeeder;

                if (job.Device.HasLaminator)
                {
                    job.JobControl.Destination = DestinationTypeEnum.LaminatorAny;
                }
                else
                {
                    job.JobControl.Destination = DestinationTypeEnum.Eject;
                }

                //SET ERROR RECOVERY MODE FOR PRINTER:
                job.Device.ErrorControlLevel = ErrorControlLevelEnum.EC_None;

                job.BuildGraphicsLayers(SideEnum.Front, PrintTypeEnum.Color, 0, 0, 0, -1, GraphicTypeEnum.BMP, bmp);

                job.BuildGraphicsLayers(SideEnum.Back, PrintTypeEnum.MonoK, 0, 0, 0, -1, GraphicTypeEnum.BMP, monoBmp);

                int actionID = 0;
                job.PrintGraphicsLayers(1, out actionID);

                job.ClearGraphicsLayers();

                string status = string.Empty;
                JobWait(ref job, actionID, 180, out status);
            }
            catch (Exception e)
            {
                bRet = false;
                _msg = e.Message;
            }
            finally
            {
                g.CloseGraphics();
                g = null;

                img = null;
                bmp = null;

                Disconnect(ref job);
            }
            return(bRet);
        }
Ejemplo n.º 2
0
        public bool Perform_MonochromePrint(string cardType)
        {
            bool bRet = true;

            byte[] img      = null;
            byte[] bmp      = null;
            byte[] colorBmp = null;
            byte[] monoBmp  = null;

            Job            job = null;
            ZMotifGraphics g   = null;

            try
            {
                job = new Job();
                g   = new ZMotifGraphics();

                // Opens a connection with a ZXP Printer
                //     if it is in an alarm condition, exit function
                // -------------------------------------------------

                if (!Connect(ref job))
                {
                    _msg = "Unable to open device [" + _deviceName + "]";
                    return(false);
                }

                if (_alarm != 0)
                {
                    _msg = "Printer is in alarm condition" + "Error: " + job.Device.GetStatusMessageString(_alarm);
                    return(false);
                }

                if (_isZXP7)
                {
                    FrontImage = "ZXP7Front.bmp";
                }
                else
                {
                    FrontImage = "ZXP8Front.bmp";
                }


                img = g.ImageFileToByteArray(FrontImage);

                // Builds the image to print
                // -------------------------

                g.InitGraphics(0, 0, ZMotifGraphics.ImageOrientationEnum.Landscape,
                               ZMotifGraphics.RibbonTypeEnum.Color);

                g.DrawImage(ref img, 50, 50, 924, 548, 0);
                g.DrawTextString(50.0f, 580.0f, "Monochrome Print", "Arial", 10.0f,
                                 ZMotifGraphics.FontTypeEnum.Regular,
                                 g.IntegerFromColor(System.Drawing.Color.Black));

                int dataLen;
                bmp = g.CreateBitmap(out dataLen);
                g.ExtractBlackData(ref bmp, ref colorBmp, ref monoBmp);

                g.ClearGraphics();

                if (!_isZXP7)
                {
                    job.JobControl.CardType = cardType;
                }

                job.JobControl.FeederSource = FeederSourceEnum.CardFeeder;

                if (job.Device.HasLaminator)
                {
                    job.JobControl.Destination = DestinationTypeEnum.LaminatorAny;
                }
                else
                {
                    job.JobControl.Destination = DestinationTypeEnum.Eject;
                }

                //job.BuildGraphicsLayers(SideEnum.Front, PrintTypeEnum.Color, 0, 0, 0,
                //                        -1, GraphicTypeEnum.BMP, colorBmp);

                job.BuildGraphicsLayers(SideEnum.Front, PrintTypeEnum.MonoK, 0, 0, 0,
                                        -1, GraphicTypeEnum.BMP, monoBmp);

                int actionID = 0;
                job.PrintGraphicsLayers(1, out actionID);

                job.ClearGraphicsLayers();

                string status = string.Empty;
                JobWait(ref job, actionID, 180, out status);
            }
            catch (Exception e)
            {
                bRet = false;
                _msg = e.Message;
            }
            finally
            {
                g.CloseGraphics();
                g = null;

                img = null;
                bmp = null;

                Disconnect(ref job);
            }
            return(bRet);
        }