private void DoPopupFormPaint() { if (FOnPaint != null) { PAINTSTRUCT vPaintStruct = new PAINTSTRUCT(); IntPtr vDC = (IntPtr)User.BeginPaint(FPopupWindow, ref vPaintStruct); try { HCCanvas vCanvas = new HCCanvas(vDC); try { RECT vRect = new RECT(); User.GetClientRect(FPopupWindow, ref vRect); FOnPaint(vCanvas, vRect); } finally { vCanvas.Dispose(); } } finally { User.EndPaint(FPopupWindow, ref vPaintStruct); } } }
public virtual bool SaveToBitmap(ref Bitmap aBitmap) { if ((FWidth == 0) || (FHeight == 0)) { return(false); } aBitmap = new Bitmap(FWidth, FHeight); PaintInfo vPaintInfo = new PaintInfo(); vPaintInfo.Print = true; vPaintInfo.WindowWidth = aBitmap.Width; vPaintInfo.WindowHeight = aBitmap.Height; vPaintInfo.ScaleX = 1; vPaintInfo.ScaleY = 1; vPaintInfo.Zoom = 1; using (HCCanvas vCanvas = new HCCanvas()) { vCanvas.Graphics = Graphics.FromImage(aBitmap); vCanvas.Brush.Color = Color.White; vCanvas.FillRect(new RECT(0, 0, aBitmap.Width, aBitmap.Height)); this.DoPaint(OwnerData.Style, new RECT(0, 0, aBitmap.Width, aBitmap.Height), 0, aBitmap.Height, 0, aBitmap.Height, vCanvas, vPaintInfo); vCanvas.Dispose(); } return(true); }
public virtual void SaveToBitmap(ref Bitmap aBitmap) { aBitmap = new Bitmap(FWidth, FHeight); PaintInfo vPaintInfo = new PaintInfo(); vPaintInfo.Print = true; vPaintInfo.WindowWidth = aBitmap.Width; vPaintInfo.WindowHeight = aBitmap.Height; vPaintInfo.ScaleX = 1; vPaintInfo.ScaleY = 1; vPaintInfo.Zoom = 1; Graphics vGraphic = Graphics.FromImage(aBitmap); IntPtr vDC = vGraphic.GetHdc(); try { HCCanvas vCanvas = new HCCanvas(vDC); try { this.DoPaint(OwnerData.Style, new RECT(0, 0, aBitmap.Width, aBitmap.Height), 0, aBitmap.Height, 0, aBitmap.Height, vCanvas, vPaintInfo); } finally { vCanvas.Dispose(); } } finally { vGraphic.ReleaseHdc(); } }
public static void DestroyStyleCanvas(HCCanvas aCanvas) { aCanvas.Dispose(); }
public void SaveToImage(string path, string prefix, string imageType, bool onePaper = true) { HCCanvas vBmpCanvas = new HCCanvas(); SectionPaintInfo vPaintInfo = new SectionPaintInfo(); try { vPaintInfo.ScaleX = 1; vPaintInfo.ScaleY = 1; vPaintInfo.Zoom = 1; vPaintInfo.Print = true; vPaintInfo.DPI = HCUnitConversion.PixelsPerInchX; vPaintInfo.ViewModel = HCViewModel.hvmFilm; int vWidth = 0, vHeight = 0; if (onePaper) { for (int i = 0; i < FSections.Count; i++) { vHeight = vHeight + FSections[i].PaperHeightPix * FSections[i].PageCount; if (vWidth < FSections[i].PaperWidthPix) { vWidth = FSections[i].PaperWidthPix; } } vPaintInfo.WindowWidth = vWidth; vPaintInfo.WindowHeight = vHeight; using (Bitmap vBmp = new Bitmap(vWidth, vHeight)) { vBmpCanvas.Graphics = Graphics.FromImage(vBmp); int vSectionIndex = 0, vSectionPageIndex = 0, vTop = 0; for (int i = 0; i < this.PageCount; i++) { vSectionIndex = GetSectionPageIndexByPageIndex(i, ref vSectionPageIndex); //vWidth = FSections[vSectionIndex].PaperWidthPix; vHeight = FSections[vSectionIndex].PaperHeightPix; vBmpCanvas.Brush.Color = Color.White; vBmpCanvas.FillRect(new RECT(0, vTop, vWidth, vTop + vHeight)); ScaleInfo vScaleInfo = vPaintInfo.ScaleCanvas(vBmpCanvas); try { FSections[vSectionIndex].PaintPaper(vSectionPageIndex, 0, vTop, vBmpCanvas, vPaintInfo); vTop = vTop + vHeight; } finally { vPaintInfo.RestoreCanvasScale(vBmpCanvas, vScaleInfo); } } vBmpCanvas.Dispose(); if (imageType == "BMP") { vBmp.Save(path + prefix + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp); } else if (imageType == "JPG") { vBmp.Save(path + prefix + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg); } else { vBmp.Save(path + prefix + ".png", System.Drawing.Imaging.ImageFormat.Png); } } } else { int vSectionIndex = 0, vSectionPageIndex = 0; for (int i = 0; i < this.PageCount; i++) { vSectionIndex = GetSectionPageIndexByPageIndex(i, ref vSectionPageIndex); using (Bitmap vBmp = new Bitmap(FSections[vSectionIndex].PaperWidthPix, FSections[vSectionIndex].PaperHeightPix)) { vBmpCanvas.Graphics = Graphics.FromImage(vBmp); vBmpCanvas.Brush.Color = Color.White; vBmpCanvas.FillRect(new RECT(0, 0, vBmp.Width, vBmp.Height)); vPaintInfo.WindowWidth = vBmp.Width; vPaintInfo.WindowHeight = vBmp.Height; ScaleInfo vScaleInfo = vPaintInfo.ScaleCanvas(vBmpCanvas); try { vBmpCanvas.Brush.Color = Color.White; vBmpCanvas.FillRect(new RECT(0, 0, vBmp.Width, vBmp.Height)); FSections[vSectionIndex].PaintPaper(vSectionPageIndex, 0, 0, vBmpCanvas, vPaintInfo); } finally { vPaintInfo.RestoreCanvasScale(vBmpCanvas, vScaleInfo); } vBmpCanvas.Dispose(); if (imageType == "BMP") { vBmp.Save(path + prefix + (i + 1).ToString() + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp); } else if (imageType == "JPG") { vBmp.Save(path + prefix + (i + 1).ToString() + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg); } else { vBmp.Save(path + prefix + (i + 1).ToString() + ".png", System.Drawing.Imaging.ImageFormat.Png); } } } } } finally { vPaintInfo.Dispose(); } }