Exemple #1
0
        private byte[] BuildText(string text, float x, float y, string font, float fontSize, int fontColour, ZMotifGraphics.FontTypeEnum fontType,
                                 ZMotifGraphics.ImageOrientationEnum ImageOrientation, ZMotifGraphics.RibbonTypeEnum RibbonType, out string errMsg)
        {
            errMsg = string.Empty;

            byte[] TheImage = null;

            ZMotifGraphics graphics = null;

            try
            {
                int dataLen = 0;

                graphics = new ZMotifGraphics();

                graphics.InitGraphics(0, 0, ImageOrientation, RibbonType);

                if (RibbonType != ZMotifGraphics.RibbonTypeEnum.Color)
                {
                    graphics.ColorProfile = string.Empty;
                }

                graphics.DrawTextString(x, y, text, font, fontSize, fontType, fontColour);

                TheImage = graphics.CreateBitmap(out dataLen);

                return(TheImage);
            }
            catch (Exception ex)
            {
                TheImage = null;
                errMsg   = ex.StackTrace;
            }
            finally
            {
                graphics.ClearGraphics();
                graphics.CloseGraphics();
                graphics = null;
            }
            return(null);
        }
Exemple #2
0
        private byte[] BuildTest(ZMotifGraphics.ImageOrientationEnum ImageOrientation, ZMotifGraphics.RibbonTypeEnum RibbonType, out string errMsg)
        {
            errMsg = string.Empty;

            byte[] TheImage = null;

            ZMotifGraphics graphics = null;

            try
            {
                int dataLen = 0;

                graphics = new ZMotifGraphics();

                graphics.InitGraphics(0, 0, ImageOrientation, RibbonType);

                if (RibbonType != ZMotifGraphics.RibbonTypeEnum.Color)
                {
                    graphics.ColorProfile = string.Empty;
                }

                graphics.DrawRectangle(20, 20, DEFAULT_WIDTH - 40, DEFAULT_HEIGHT - 40, 10, System.Drawing.Color.Black.ToArgb());
                graphics.DrawTextString(25, 25, "PRINT TEST", "Arial", 12, ZMotifGraphics.FontTypeEnum.Bold, System.Drawing.Color.Black.ToArgb());

                TheImage = graphics.CreateBitmap(out dataLen);

                return(TheImage);
            }
            catch (Exception ex)
            {
                TheImage = null;
                errMsg   = ex.StackTrace;
            }
            finally
            {
                graphics.ClearGraphics();
                graphics.CloseGraphics();
                graphics = null;
            }
            return(null);
        }
        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);
        }
Exemple #4
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);
        }
        // Builds the front and back side bitmaps
        // --------------------------------------------------------------------------------------------------

        private bool BuildBitmaps()
        {
            ZMotifGraphics g = new ZMotifGraphics();

            bool builtOk = true;

            try
            {
                // Gets images from files

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

                byte[] imgFront = g.ImageFileToByteArray(_nameFrontImage);
                byte[] imgBack  = g.ImageFileToByteArray(_nameBackImage);

                // Initializes the graphic buffer for the front side

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

                // Draws text and image into the graphic buffer for front side

                g.DrawImage(ref imgFront, ZMotifGraphics.ImagePositionEnum.Centered, 1000, 620, 0);
                g.DrawTextString(50, 580, "Front Side: Color Image", "Arial", 10,
                                 ZMotifGraphics.FontTypeEnum.Regular, g.IntegerFromColorName("Navy"));

                // Creates the front side bitmap

                int dataLen;
                _bmpFront = g.CreateBitmap(out dataLen);

                // Clears the graphics buffer

                g.ClearGraphics();

                // Initializes the graphic buffer for the back side

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

                // Draws text an image into the graphic buffer for the back side

                g.DrawImage(ref imgBack, ZMotifGraphics.ImagePositionEnum.Centered, 1000, 620, 0);
                g.DrawTextString(50, 580, "Back Side Monochrome Image", "Arial", 10,
                                 ZMotifGraphics.FontTypeEnum.Regular, g.IntegerFromColorName("Black"));

                // Creates the back side bitmap

                _bmpBack = g.CreateBitmap(out dataLen);

                g.ClearGraphics();
            }
            catch
            {
                builtOk = false;
            }
            return(builtOk);
        }