public override bool RefreshView() { if (myOwnerDocument.Info.Printing) { return(true); } RefreshSize(); int y = this.RealTop + (this.Height / 2); int x = 0; if (WeiWenProcess.weiwen) { //修正因为字号过大引起的回车在行首光标位置错位的问题 add by Ukey zhang 2017-11-11 if (this.RealLeft + this.Width > this.OwnerLine.ContentWidth) { this.Left = this.OwnerLine.ContentWidth - this.Width; } x = this.RealLeft + this.Width; } else { x = this.RealLeft; } if (myOwnerDocument.Info.ShowParagraphFlag) { myOwnerDocument.View.DrawParagraphFlag( x, y, GraphicsUnitConvert.GetRate(myOwnerDocument.DocumentGraphicsUnit, System.Drawing.GraphicsUnit.Pixel)); } return(true); }
/// <summary> /// 创建指定页的BMP图片对象 /// </summary> /// <param name="page">页面对象</param> /// <param name="DrawMargin">是否绘制页边距线</param> /// <returns>创建的BMP图片对象</returns> public Metafile GetPageBmp2(PrintPage page, bool DrawMargin) { double rate = GraphicsUnitConvert.GetRate( myDocument.DocumentGraphicsUnit, System.Drawing.GraphicsUnit.Pixel); int width = ( int )Math.Ceiling(myPages.PaperWidth / rate); int height = ( int )Math.Ceiling(myPages.PaperHeight / rate); System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(width, height); Graphics g1 = Graphics.FromImage(bmp); Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height); string folder = CreateFolder(); string m_FilePath1 = folder + Guid.NewGuid().ToString() + ".wmf"; Metafile mf1 = new Metafile(m_FilePath1, g1.GetHdc(), rect, MetafileFrameUnit.Pixel); using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(mf1)) { //Add by wwj 2013-01-24 g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; if (intBackColor.A != 0) { g.Clear(this.intBackColor); } g.PageUnit = myDocument.DocumentGraphicsUnit; //Metafile mf = new Metafile(bmp,g.GetHdc(),); PageFrameDrawer drawer = new PageFrameDrawer(); //Graphics gg = Graphics.FromImage(mf); drawer.DrawMargin = DrawMargin; drawer.BackColor = System.Drawing.Color.Transparent; drawer.BorderColor = this.intBorderColor; drawer.BorderWidth = 1; drawer.LeftMargin = myPages.LeftMargin; drawer.TopMargin = myPages.TopMargin; drawer.RightMargin = myPages.RightMargin; drawer.BottomMargin = myPages.BottomMargin; drawer.Bounds = new System.Drawing.Rectangle( 0, 0, myPages.PaperWidth, myPages.PaperHeight); drawer.DrawPageFrame(g, System.Drawing.Rectangle.Empty); DrawPage(page, g, page.Bounds, true); } return(mf1); }
//private System.Drawing.Printing.Margins myClientMargins = new System.Drawing.Printing.Margins(); //private System.Drawing.Size myClientPageSize = System.Drawing.Size.Empty ; /// <summary> /// 刷新坐标转换信息 /// </summary> protected override void RefreshScaleTransform() { MultiPageTransform trans = ( MultiPageTransform )this.myTransform; intGraphicsUnit = _Pages.GraphicsUnit; trans.Rate = GraphicsUnitConvert.GetRate( intGraphicsUnit, System.Drawing.GraphicsUnit.Pixel); //float rate = ( float )( 1.0 / this.ClientToViewXRate ); //trans.Pages = myPages ; //trans.Refresh( rate , this.intPageSpacing ); System.Drawing.Point sp = this.AutoScrollPosition; trans.ClearSourceOffset(); trans.OffsetSource(sp.X, sp.Y, true); }
public override bool RefreshView() { if (myOwnerDocument.Info.Printing) { return(true); } if (myOwnerDocument.Info.ShowParagraphFlag) { myOwnerDocument.View.DrawLineFlag( this.RealLeft, this.RealTop + this.Height, GraphicsUnitConvert.GetRate(myOwnerDocument.DocumentGraphicsUnit, System.Drawing.GraphicsUnit.Pixel)); } return(true); }
/// <summary> /// 创建指定页的BMP图片对象 /// </summary> /// <param name="page">页面对象</param> /// <param name="DrawMargin">是否绘制页边距线</param> /// <returns>创建的BMP图片对象</returns> public System.Drawing.Bitmap GetPageBmp(PrintPage page, bool DrawMargin) { XPageSettings pageSettings = page.PageSettings; double rate = GraphicsUnitConvert.GetRate( myDocument.DocumentGraphicsUnit, System.Drawing.GraphicsUnit.Pixel); int width = (int)Math.Ceiling(pageSettings.ViewPaperWidth / rate); int height = (int)Math.Ceiling(pageSettings.ViewPaperHeight / rate); System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(width, height); using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp)) { if (intBackColor.A != 0) { g.Clear(this.intBackColor); } g.PageUnit = myDocument.DocumentGraphicsUnit; PageFrameDrawer drawer = new PageFrameDrawer(); drawer.DrawMargin = DrawMargin; drawer.BackColor = System.Drawing.Color.Transparent; drawer.BorderColor = this.intBorderColor; drawer.BorderWidth = 1; drawer.LeftMargin = (int)page.ViewLeftMargin; drawer.TopMargin = (int)page.ViewTopMargin; drawer.RightMargin = (int)page.ViewRightMargin; drawer.BottomMargin = (int)page.ViewBottomMargin; drawer.Bounds = new System.Drawing.Rectangle( 0, 0, (int)page.ViewPaperWidth, (int)page.ViewPaperHeight); drawer.BackgroundImage = this.PageBackgroundImage; drawer.DrawPageFrame(g, System.Drawing.Rectangle.Empty); DrawPage(page, g, page.Bounds, true); } return(bmp); }
public static double GetRate(System.Drawing.GraphicsUnit unit) { return(GraphicsUnitConvert.GetRate(unit, System.Drawing.GraphicsUnit.Document) / 3.0); }