Ejemplo n.º 1
0
        public static void LogSetPrinterSetting(SPrinterSetting ss, bool bprinting, string source)
        {
            int passnum = 0;
            int step    = 0;

            if (bprinting)
            {
                SPrtFileInfo jobInfo = new SPrtFileInfo();
                if (CoreInterface.Printer_GetJobInfo(ref jobInfo) > 0)
                {
                    passnum = jobInfo.sFreSetting.nPass;
                    if (ss.nKillBiDirBanding != 0)
                    {
                        step = ss.sCalibrationSetting.nPassStepArray[(passnum + 1) / 2 - 1];
                    }
                    else
                    {
                        step = ss.sCalibrationSetting.nPassStepArray[passnum - 1];
                    }
                }
            }
            else
            {
                passnum = ss.sFrequencySetting.nPass;
                if (ss.nKillBiDirBanding != 0)
                {
                    step = ss.sCalibrationSetting.nPassStepArray[(ss.sFrequencySetting.nPass + 1) / 2 - 1];
                }
                else
                {
                    step = ss.sCalibrationSetting.nPassStepArray[ss.sFrequencySetting.nPass - 1];
                }
            }
            LogWriter.WriteLog(new string[] { string.Format("SetPrinterSetting[source={0}];setted value[passnum={1},stepPerhead={2},fixstep={3}]", source, passnum, ss.sCalibrationSetting.nStepPerHead, step) }, true);
        }
Ejemplo n.º 2
0
        private void buttondebug_Click(object sender, EventArgs e)
        {
            SPrtFileInfo jobInfo = new SPrtFileInfo();

            if (CoreInterface.Printer_GetJobInfo(ref jobInfo) > 0)
            {
                Debug.WriteLine(string.Format(" Printing Pass ={0}", jobInfo.sFreSetting.nPass));
            }
        }
Ejemplo n.º 3
0
        public Image GetThumbNail(string fileName, int imgWidth, int imgHeight, Color penColor)
        {
            bool   hasError        = false;
            string previewFileName = m_LastPreviewForlder + Path.GetFileNameWithoutExtension(fileName) + ".bmp";
            Bitmap bmp             = null;

            try
            {
                if (File.Exists(previewFileName))
                {
                    bmp = new Bitmap(previewFileName);
                }
                else
                {
                    if (File.Exists(fileName))
                    {
                        SPrtFileInfo jobInfo     = new SPrtFileInfo();
                        IntPtr       imgadataPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(SPrtImagePreview)));
                        jobInfo.sImageInfo.nImageData = imgadataPtr;
                        int bret = CoreInterface.Printer_GetFileInfo(fileName, ref jobInfo, 1);
                        if (bret == 1)
                        {
                            bmp = SerialFunction.CreateImageWithImageInfo(jobInfo.sImageInfo);
                            if (!Directory.Exists(m_LastPreviewForlder))
                            {
                                Directory.CreateDirectory(m_LastPreviewForlder);
                            }
                            bmp.Save(previewFileName);
                        }
                        else
                        {
                            hasError = true;
                        }
                        Marshal.FreeHGlobal(imgadataPtr);
                    }
                }
            }
            catch (Exception ex)
            {
                hasError = true;
                System.Diagnostics.Debug.Assert(true, ex.Message + ex.StackTrace);
            }
            if (bmp == null || hasError)
            {
                bmp = this.CreatDefaultBmp("¼ÓÔØʧ°Ü!!", Color.Wheat, Color.Red);
            }

            Bitmap retBmp = this.CreatDefaultBmp(bmp, penColor, Color.Black);

            return(retBmp);
        }
Ejemplo n.º 4
0
        public Image GetThumbNail(string fileName, int imgWidth, int imgHeight, Color penColor)
        {
            bool   hasError        = false;
            string previewFileName = m_LastPreviewForlder + Path.GetFileNameWithoutExtension(fileName) + ".bmp";
            Bitmap bmp             = null;

            try
            {
                if (File.Exists(previewFileName))
                {
                    bmp = new Bitmap(previewFileName);
                }
                else
                {
                    if (File.Exists(fileName))
                    {
                        SPrtFileInfo jobInfo = new SPrtFileInfo();
                        Int32        bret    = 0;
                        bret = CoreInterface.Printer_GetFileInfo(fileName, ref jobInfo, 1);
                        if (bret == 1)
                        {
                            bmp = SerialFunction.CreateImageWithImageInfo(jobInfo.sImageInfo);
                        }
                        else
                        {
                            hasError = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                hasError = true;
                System.Diagnostics.Debug.Assert(true, ex.Message + ex.StackTrace);
            }
            if (bmp == null || hasError)
            {
                bmp = this.CreatDefaultBmp("¼ÓÔØʧ°Ü!!", Color.Wheat, Color.Red);
            }
            else if (!File.Exists(previewFileName))
            {
                bmp.Save(previewFileName);
            }

            Bitmap retBmp = this.CreatDefaultBmp(bmp, penColor, Color.Black);

            return(retBmp);
        }
Ejemplo n.º 5
0
 private void buttonAdd_Click(object sender, System.EventArgs e)
 {
     if (FileName1 != null && FileName1 != string.Empty &&
         FileName2 != null && FileName2 != string.Empty &&
         FileName1 != FileName2)
     {
         SPrtFileInfo jobInfo  = new SPrtFileInfo();
         SPrtFileInfo jobInfo1 = new SPrtFileInfo();
         Int32        bret     = 0;
         bret = CoreInterface.Printer_GetFileInfo(FileName1, ref jobInfo, 0);
         if (bret == 1)
         {
             bret = CoreInterface.Printer_GetFileInfo(FileName2, ref jobInfo1, 0);
             if (bret == 1)
             {
                 if (
                     jobInfo.sImageInfo.nImageResolutionX != jobInfo1.sImageInfo.nImageResolutionX ||
                     jobInfo.sImageInfo.nImageResolutionY != jobInfo1.sImageInfo.nImageResolutionY ||
                     jobInfo.sImageInfo.nImageWidth != jobInfo1.sImageInfo.nImageWidth ||
                     jobInfo.sImageInfo.nImageHeight != jobInfo1.sImageInfo.nImageHeight
                     //|| jobInfo.sImageInfo.nImageColorNum !=jobInfo1.sImageInfo.nImageColorNum
                     || jobInfo.sImageInfo.nImageColorDeep != jobInfo1.sImageInfo.nImageColorDeep
                     )
                 {
                     string info = "俩个文件属性不匹配.[分辨率,尺寸,色深]";                            //SErrorCode.GetEnumDisplayName(typeof(Software),Software.Parser);
                     MessageBox.Show(info, ResString.GetProductName(), MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
                 else
                 {
                     this.DialogResult = DialogResult.OK;
                 }
             }
         }
         if (bret != 1)
         {
             string info = SErrorCode.GetEnumDisplayName(typeof(Software), Software.Parser);
             info += ":" + FileName1;
             MessageBox.Show(info, ResString.GetProductName(), MessageBoxButtons.OK, MessageBoxIcon.Information);
             return;
         }
     }
     else
     {
         string info = "必须选择俩个文件,而且是不同的.";                //SErrorCode.GetEnumDisplayName(typeof(Software),Software.Parser);
         MessageBox.Show(info, ResString.GetProductName(), MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Ejemplo n.º 6
0
        public void OnPrintStart(UIPreference m_Preference)
        {
            m_StartTime = DateTime.Now;
            SPrtFileInfo jobInfo = new SPrtFileInfo();

            if (CoreInterface.Printer_GetJobInfo(ref jobInfo) > 0)
            {
                string passDispName = ResString.GetDisplayPass();
                int    IndexOfPass  = m_Preference.IndexOf(JobListColumnHeader.PrintedPasses);
                if (IndexOfPass > 0)
                {
                    this.SubItems[IndexOfPass].Text = jobInfo.sFreSetting.nPass.ToString() + " " + passDispName;
                }
            }
            //更新ToolTip
            ToolTipText = GetTooltipString(this.Tag as UIJob, m_Preference);
        }
Ejemplo n.º 7
0
        public void OnUpdatePrintingInfo(Image preview)
        {
            UpdatePreviewImage(preview);

            SPrtFileInfo jobInfo = new SPrtFileInfo();

            if (CoreInterface.Printer_GetJobInfo(ref jobInfo) > 0)
            {
                UpdatePrintingJobInfo(m_curUnit, jobInfo);
                SizeF previewsize = GetJobSize(jobInfo.sImageInfo.nImageWidth, jobInfo.sImageInfo.nImageHeight, jobInfo.sFreSetting.nResolutionX, jobInfo.sFreSetting.nResolutionY);
                UpdateJobSizeInfo(previewsize);
            }
            else
            {
                //??????????????????????????????????????????  should do it
                UpdatePrintingJobInfo(m_curUnit, jobInfo);
                UpdateJobSizeInfo(SizeF.Empty);
            }
        }
Ejemplo n.º 8
0
        private UIJob CreatJob(string fileName)
        {
            UIJob job = new UIJob();

            job.Name        = Path.GetFileName(fileName);
            job.PreViewFile = m_LastPreviewForlder + Path.GetFileNameWithoutExtension(fileName) + ".bmp";
            job.Status      = JobStatus.Idle;

            SPrtFileInfo jobInfo = new SPrtFileInfo();
            Int32        bret    = 0;

            bret = CoreInterface.Printer_GetFileInfo(fileName, ref jobInfo, 0);
            //if (bret == 1)
            {
                job.PrtFileInfo  = jobInfo;
                job.FileLocation = fileName;
            }
            return(job);
        }
Ejemplo n.º 9
0
        private void UpdatePrintingJobInfo(UILengthUnit unit, SPrtFileInfo jobInfo)
        {
            float width = 0;

            if (jobInfo.sFreSetting.nResolutionX != 0)
            {
                width = (float)jobInfo.sImageInfo.nImageWidth / (float)(jobInfo.sFreSetting.nResolutionX);
//				width = this.CalcRealJobWidth(unit,width);
                //width = UIPreference.ToDisplayLength(unit,width);
            }
            float height = 0;

            if (jobInfo.sFreSetting.nResolutionY != 0)
            {
                height = (float)jobInfo.sImageInfo.nImageHeight / (float)(jobInfo.sFreSetting.nResolutionY);
                //height = UIPreference.ToDisplayLength(unit,height);
            }
            UpdateJobInfoText(unit, width, height, jobInfo.sFreSetting.nResolutionX * jobInfo.sImageInfo.nImageResolutionX, jobInfo.sFreSetting.nResolutionY * jobInfo.sImageInfo.nImageResolutionY,
                              jobInfo.sImageInfo.nImageColorDeep, jobInfo.sFreSetting.nPass, jobInfo.sFreSetting.nBidirection, null, 0);
        }
Ejemplo n.º 10
0
        public void OnSwitchToPrintingPreview()
        {
            bool         bPrinting = m_bPrintingPreview;
            SPrtFileInfo jobInfo   = new SPrtFileInfo();

            if (CoreInterface.Printer_GetJobInfo(ref jobInfo) > 0)
            {
                UpdatePrintingJobInfo(m_curUnit, jobInfo);
                CreatePrintingPreviewAsPercentage(0);
                SizeF previewsize = GetJobSize(jobInfo.sImageInfo.nImageWidth, jobInfo.sImageInfo.nImageHeight, jobInfo.sFreSetting.nResolutionX, jobInfo.sFreSetting.nResolutionY);
                UpdateJobSizeInfo(previewsize);
            }
            else
            {
                //??????????????????????????????????????????  should do it
                UpdatePrintingJobInfo(m_curUnit, jobInfo);
                UpdatePreviewImage(null);
                UpdateJobSizeInfo(SizeF.Empty);
            }
        }
Ejemplo n.º 11
0
        private void Init(bool isparent)
        {
            IsParent = isparent;
//			NoteFontName = "Arial";
            Note        = TopSrc = src = string.Empty;
            PrtFileInfo = new SPrtFileInfo();
            ClipRect    = new Rectangle(1, 1, 1, 1);
            W           = H = Left = Top = Rotation = 0;
//			NoteFontSize = 16;
            NotePosition      = 3;
            Childs            = null;
            NoteMargin        = Margin_L = Margin_R = Margin_T = Margin_B = 0;
            XCnt              = YCnt = 1;
            XDis              = YDis = 0;
            AutoSizeToContent = true;
            isSimpleMode      = true;
            SrcMiniature      = null;
            noClip            = true;
            NoteFont          = new Font("Arial", 16, GraphicsUnit.Point);
            AddtionInfoMask   = 0;
        }
Ejemplo n.º 12
0
        private UIJob CreatJob(string fileName)
        {
            UIJob job = new UIJob();

            job.Name   = Path.GetFileName(fileName);
            job.Status = JobStatus.Idle;

            SPrtFileInfo jobInfo = new SPrtFileInfo();
            Int32        bret    = 0;

            bret = CoreInterface.Printer_GetFileInfo(fileName, ref jobInfo, 0);
            //if (bret == 1)
            {
                job.PrtFileInfo  = jobInfo;
                job.FileLocation = fileName;
            }
            job.TilePreViewFile = job.GeneratePreviewName(true);
            job.PreViewFile     = job.GeneratePreviewName(false);

            return(job);
        }
Ejemplo n.º 13
0
        unsafe private void CreatePrintingPreviewAsPercentage(int percentage)
        {
            SPrtFileInfo jobInfo = new SPrtFileInfo();

            if (CoreInterface.Printer_GetJobInfo(ref jobInfo) <= 0)
            {
                return;
            }
            IntPtr handle = (IntPtr)jobInfo.sImageInfo.nImageData;

            if (handle == IntPtr.Zero)
            {
                return;
            }
            SPrtImagePreview previewData = (SPrtImagePreview)Marshal.PtrToStructure(handle, typeof(SPrtImagePreview));
            Bitmap           image       = SerialFunction.CreateImageWithPreview(previewData);

            if (image != null)
            {
                int clipy      = (image.Height * percentage / 100);
                int clipheight = image.Height - clipy;

                if (clipheight > 0)
                {
                    BitmapData data = image.LockBits(new Rectangle(0, clipy, image.Width, clipheight), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);

                    byte *buf  = (byte *)data.Scan0;
                    int   size = data.Stride * clipheight;

                    for (int i = 0; i < size; i++)
                    {
                        buf[i] = 0xff;
                    }

                    image.UnlockBits(data);
                }

                UpdatePreviewImage(image);
            }
        }
Ejemplo n.º 14
0
        public Bitmap CreateClipsMiniature()
        {
            string text = GetRealNoteText(this);

            float CoefficientX, CoefficientY;
            int   marginl, marginr, margint, marginb;
            int   xdis, xdis2, ydis;
            int   left, top, notemargin;

            string fpath = this.src;

            if (string.IsNullOrEmpty(fpath))
            {
                fpath = this.TopSrc;
            }

            Image srcMiniature = null;

            if (File.Exists(SrcMiniature))
            {
                srcMiniature = new Bitmap(SrcMiniature);
            }
            if (srcMiniature == null)
            {
                SPrtFileInfo jobInfo     = new SPrtFileInfo();
                IntPtr       imgadataPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(SPrtImagePreview)));
                jobInfo.sImageInfo.nImageData = imgadataPtr;
                int bret = CoreInterface.Printer_GetFileInfo(fpath, ref this.PrtFileInfo, 1);
                srcMiniature = SerialFunction.CreateImageWithImageInfo(this.PrtFileInfo.sImageInfo);
                Marshal.FreeHGlobal(imgadataPtr);
            }

            CoefficientX = (float)PrtFileInfo.sImageInfo.nImageWidth / srcMiniature.Width;
            CoefficientY = (float)PrtFileInfo.sImageInfo.nImageHeight / srcMiniature.Height;
            Rectangle scaledclip = new Rectangle();

            if (noClip)
            {
                scaledclip = new Rectangle(0, 0, srcMiniature.Width, srcMiniature.Height);
            }
            else
            {
                scaledclip = new Rectangle(Convert.ToInt32(this.ClipRect.Left / CoefficientX), Convert.ToInt32(this.ClipRect.Top / CoefficientY),
                                           Convert.ToInt32(this.ClipRect.Width / CoefficientX), Convert.ToInt32(this.ClipRect.Height / CoefficientY));
            }
            marginl = Convert.ToInt32(Margin_L / CoefficientX);
            marginr = Convert.ToInt32(Margin_R / CoefficientX);
            margint = Convert.ToInt32(Margin_T / CoefficientY);
            marginb = Convert.ToInt32(Margin_B / CoefficientY);
            xdis    = Convert.ToInt32(XDis / CoefficientX);
            xdis2   = Convert.ToInt32(XDis2 / CoefficientX);
            ydis    = Convert.ToInt32(YDis / CoefficientY);
            left    = Convert.ToInt32(Left / CoefficientX);
            top     = Convert.ToInt32(Top / CoefficientY);
            if (this.NotePosition == 0 || this.NotePosition == 2)
            {
                notemargin = Convert.ToInt32(NoteMargin / CoefficientX);
            }
            else
            {
                notemargin = Convert.ToInt32(NoteMargin / CoefficientY);
            }
            Rectangle size = GetBound(this);

            int   maxSize        = 600 * 800 * 3;// 单个预览图最大尺寸
            float dstCoefficient = 1;

            if (size.Width / CoefficientX * size.Height / CoefficientY > maxSize)
            {
                dstCoefficient = (float)Math.Sqrt((size.Width / CoefficientX * size.Height / CoefficientY) / maxSize);
                dstCoefficient = Math.Min(20, dstCoefficient); // dstCoefficient最大不超过20
            }
            size.Width  = (int)Math.Max(1, (float)size.Width / dstCoefficient);
            size.Height = (int)Math.Max(1, (float)size.Height / dstCoefficient);
            Bitmap   ret = null;
            Graphics g;

            try
            {
                ret = new Bitmap(Math.Max(1, Convert.ToInt32(size.Width / CoefficientX)), Math.Max(1, Convert.ToInt32(size.Height / CoefficientY)));
                g   = Graphics.FromImage(ret);

                if (isSimpleMode)
                {
                    int w          = (int)(scaledclip.Width / dstCoefficient);
                    int h          = (int)(scaledclip.Height / dstCoefficient);
                    int marginlInt = (int)(marginl / dstCoefficient);
                    int margintInt = (int)(margint / dstCoefficient);
                    int xdisInt    = (int)(xdis / dstCoefficient);
                    int xdis2Int   = (int)(xdis2 / dstCoefficient);
                    int ydisInt    = (int)(ydis / dstCoefficient);
                    for (int i = 0; i < this.XCnt; i++)
                    {
                        int left1 = marginlInt + i * (w + xdisInt);
                        if (IsNktTreeTileMode && i == 2)
                        {
                            left1 = marginlInt + (w + xdisInt) + (w + xdis2Int);
                        }
                        int top1 = 0;
                        for (int j = 0; j < this.YCnt; j++)
                        {
                            top1 = margintInt + j * (h + ydisInt);
                            Rectangle dstrect = new Rectangle(left1, top1, w, h);
                            g.DrawImage(srcMiniature, dstrect, scaledclip, GraphicsUnit.Pixel);
                            Debug.WriteLine("====CreateClipsMiniature===" + dstrect.ToString());
                        }
                        if (YAddtion > 0)
                        {
                            top1 += this.YCnt > 0 ?(h + ydisInt):0;
                            Rectangle scaledclip1 = new Rectangle();
                            if (noClip)
                            {
                                scaledclip1 = new Rectangle(0, 0, srcMiniature.Width, srcMiniature.Height);
                            }
                            else
                            {
                                scaledclip1 = new Rectangle(Convert.ToInt32(this.ClipRect.Left / CoefficientX), Convert.ToInt32(this.ClipRect.Top / CoefficientY),
                                                            Convert.ToInt32(this.ClipRect.Width / CoefficientX), Convert.ToInt32(this.YAddtion / CoefficientY));
                            }
                            Rectangle dstrect = new Rectangle(left1, top1, w, h);
                            g.DrawImage(srcMiniature, dstrect, scaledclip1, GraphicsUnit.Pixel);
                        }
                    }
                    if (text != null && text != string.Empty)
                    {
                        int notetop = margint + YCnt * (scaledclip.Height + ydis) + this.YAddtion - ydis + notemargin;
                        notetop = (int)(notetop / dstCoefficient);
                        Rectangle nrect = new Rectangle(marginl, 0, ret.Width - marginl - marginr, ret.Height - marginb - notetop);
                        if (nrect.Size.Width != 0 && nrect.Size.Height != 0)
                        {
                            Font      prevewFont = this.GetNoteFont();
                            Bitmap    bmp        = GetPreviewNoteImage(nrect, size.Width, text, prevewFont, this.NotePosition == 0 || this.NotePosition == 2);
                            Rectangle dstrect    = new Rectangle(marginlInt, (int)(ret.Height - marginb - bmp.Height), (int)(bmp.Width / dstCoefficient), (int)(bmp.Height / dstCoefficient));
                            g.DrawImage(bmp, dstrect, new Rectangle(0, 0, bmp.Width, bmp.Height), GraphicsUnit.Pixel);
                        }
                        else
                        {
                            this.CreatNoteImage(size.Width, text, this.GetNoteFont(), this.NotePosition == 0 || this.NotePosition == 2);
                        }
                    }
                }
                else
                {
                    if (IsParent)
                    {
                        for (int i = 0; i < this.Childs.Length; i++)
                        {
                            Bitmap     bmp     = this.Childs[i].CreateClipsMiniature();
                            RectangleF dstrect = new RectangleF(left / dstCoefficient, top / dstCoefficient, bmp.Width / dstCoefficient, bmp.Height / dstCoefficient);
                            g.DrawImage(bmp, dstrect, new Rectangle(0, 0, bmp.Width, bmp.Height), GraphicsUnit.Pixel);
                        }
                    }
                    else
                    {
                        RectangleF dstrect = new RectangleF(marginl / dstCoefficient, margint / dstCoefficient, scaledclip.Width / dstCoefficient, scaledclip.Height / dstCoefficient);
                        g.DrawImage(srcMiniature, dstrect, scaledclip, GraphicsUnit.Pixel);
                        if (text != null && text != string.Empty)
                        {
                            int       notetop = margint + YCnt * (scaledclip.Height + ydis) - ydis + notemargin;
                            Rectangle nrect   = new Rectangle(marginl, notetop, ret.Width - marginl - marginr, ret.Height - marginb - notetop);
                            Bitmap    bmp     = GetPreviewNoteImage(nrect, size.Width, text, this.GetNoteFont(), this.NotePosition == 0 || this.NotePosition == 2);
                            dstrect = new RectangleF(marginl / dstCoefficient, (margint + scaledclip.Height + notemargin) / dstCoefficient, bmp.Width / dstCoefficient, bmp.Height / dstCoefficient);
                            g.DrawImage(bmp, dstrect, new Rectangle(0, 0, bmp.Width, bmp.Height), GraphicsUnit.Pixel);
                        }
                    }
                }
                g.Dispose();
                srcMiniature.Dispose();
                //GC.Collect();
            }
            catch (Exception ex)
            {
                ret = null;
                Debug.Assert(false, ex.Message + ex.StackTrace);
            }
            return(ret);
        }