public override void Draw(DocumentPaintEventArgs args)
        {
            DomContentLine line = this.OwnerLine;
            RectangleF     rect = this.AbsBounds;

            if (line.ParagraphListStyle == ParagraphListStyle.BulletedList)
            {
                float      size       = Math.Min(rect.Width * 0.6f, rect.Height * 0.6f);
                RectangleF circleRect = new RectangleF(rect.Left + size / 2, rect.Top + size / 2, size, size);
                args.Graphics.FillEllipse(Brushes.Black, circleRect);
            }
            else if (line.ParagraphListStyle == ParagraphListStyle.NumberedList)
            {
                using (System.Drawing.StringFormat f
                           = new System.Drawing.StringFormat())
                {
                    XFontValue font = this.RuntimeStyle.Font;
                    f.Alignment     = System.Drawing.StringAlignment.Near;
                    f.LineAlignment = System.Drawing.StringAlignment.Center;
                    f.FormatFlags   = System.Drawing.StringFormatFlags.NoWrap;
                    args.Graphics.DrawString(
                        line.ParagraphStyleIndex + ".",
                        font.Value,
                        System.Drawing.Brushes.Black,
                        rect,
                        f);
                }
            }
        }
        /// <summary>
        /// 复制对象的一个复本
        /// </summary>
        /// <returns>复制的对象</returns>
        object System.ICloneable.Clone()
        {
            DocumentPaintEventArgs a = new DocumentPaintEventArgs(this.myGraphics, this.myViewBounds);

            a._Render                 = this._Render;
            a._ActiveMode             = this._ActiveMode;
            a._Bounds                 = this._Bounds;
            a._Cancel                 = this._Cancel;
            a._DocumentContentElement = this._DocumentContentElement;
            a._Render                 = this._Render;
            a._Style               = this._Style;
            a.bolForCreateImage    = this.bolForCreateImage;
            a.fScaleRate           = this.fScaleRate;
            a.intPageLinePositions = this.intPageLinePositions;
            a.intRenderStyle       = this.intRenderStyle;
            a.intType              = this.intType;
            a.myClipRectangle      = this.myClipRectangle;
            a.myDocument           = this.myDocument;
            a.myDrawRectangles     = this.myDrawRectangles;
            a.myElement            = this.myElement;
            a.myGraphics           = this.myGraphics;
            a.myPageClipRectangle  = this.myPageClipRectangle;
            a.myViewBounds         = this.myViewBounds;

            if (this.myDrawRectangles != null)
            {
                a.myDrawRectangles = (System.Drawing.Rectangle[])myDrawRectangles.Clone();
            }
            //a.bolCancel = this.bolCancel;
            return(a);
        }
Exemplo n.º 3
0
 /// <summary>
 /// 绘制元素
 /// </summary>
 /// <param name="g">图形绘制对象</param>
 /// <param name="ClipRectangle">剪切矩形</param>
 protected virtual void DrawContent(DomParagraphFlagElement eof, DocumentPaintEventArgs args)
 {
     if (_ParagraphEOFIcon == null)
     {
         _ParagraphEOFIcon = (System.Drawing.Bitmap)WriterResources.paragrapheof.Clone();
         _ParagraphEOFIcon.MakeTransparent(Color.White);
     }
     if (this.Document.Options.ViewOptions.ShowParagraphFlag &&
         args.RenderStyle == DocumentRenderStyle.Paint)
     {
         System.Drawing.RectangleF rect = eof.AbsBounds;
         if (args.RenderStyle == DocumentRenderStyle.Paint)
         {
             System.Drawing.Size size = _ParagraphEOFIcon.Size;
             size = this.Document.PixelToDocumentUnit(size);
             System.Drawing.Drawing2D.InterpolationMode back
                 = args.Graphics.InterpolationMode;
             args.Graphics.InterpolationMode
                 = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
             args.Graphics.DrawImage(
                 _ParagraphEOFIcon,
                 rect.Left,
                 rect.Bottom - size.Height);
             args.Graphics.InterpolationMode = back;
         }
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// 重新绘制对象
 /// </summary>
 /// <param name="g">图形绘制对象</param>
 /// <param name="ClipRectangle">剪切矩形</param>
 public virtual void RefreshView(DomElement element, DocumentPaintEventArgs args)
 {
     if (element == null || element.OwnerLine == null)
     {
         return;
     }
     this.DrawBackground(element, args);
     this.DrawContent(element, args);
     if (args.RenderStyle == DocumentRenderStyle.Paint && args.ActiveMode)
     {
         if (element is DomObjectElement)
         {
             DomObjectElement oe = (DomObjectElement)element;
             if (oe.ShowDragRect)
             {
                 DragRectangle dr = oe.CreateDragRectangle();
                 dr.Bounds = new Rectangle(
                     (int)element.AbsLeft,
                     (int)element.AbsTop,
                     dr.Bounds.Width,
                     dr.Bounds.Height);
                 dr.RefreshView(args.Graphics);
             }
         }
     }
 }
Exemplo n.º 5
0
 public override void RefreshSize(DocumentPaintEventArgs args)
 {
     if (this.Elements != null)
     {
         foreach (DomElement e in this.Elements)
         {
             e.RefreshSize(args);
         }
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// 绘制对象背景
        /// </summary>
        /// <param name="g">图形绘制对象</param>
        /// <param name="ClipRectangle">剪切矩形</param>
        public virtual void DrawBackground(DomElement element, DocumentPaintEventArgs args)
        {
            if (element == null || element.OwnerLine == null)
            {
                System.Console.WriteLine("");
                return;
            }

            System.Drawing.RectangleF bounds = new System.Drawing.RectangleF(
                element.AbsLeft,
                element.OwnerLine.AbsTop,
                element.Width + element.WidthFix,
                element.OwnerLine.Height);
            DrawBackground(element, args, bounds);
        }
Exemplo n.º 7
0
        public virtual void RenderBorder(
            DomElement element,
            DocumentPaintEventArgs args,
            RectangleF bounds)
        {
            DocumentContentStyle style = element.RuntimeStyle;

            if (style.HasVisibleBorder)
            {
                using (Pen p = style.CreateBorderPen())
                {
                    style.DrawBorder(args.Graphics, p, bounds);
                }
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// 绘制元素
 /// </summary>
 /// <param name="g">图形绘制对象</param>
 /// <param name="ClipRectangle">剪切矩形</param>
 protected virtual void DrawContent(DomLineBreakElement element, DocumentPaintEventArgs args)
 {
     if (_LineBreakIcon == null)
     {
         _LineBreakIcon = ( Bitmap )WriterResources.linebreak.Clone();
         _LineBreakIcon.MakeTransparent(System.Drawing.Color.White);
     }
     System.Drawing.RectangleF rect = element.AbsBounds;
     if (args.RenderStyle == DocumentRenderStyle.Paint)
     {
         System.Drawing.Size size = _LineBreakIcon.Size;
         size = this.Document.PixelToDocumentUnit(size);
         args.Graphics.DrawImage(_LineBreakIcon, rect.Left, rect.Bottom - size.Height);
         //WriterUtils.DrawParagraphFlag( g , rect );
     }
 }
Exemplo n.º 9
0
 /// <summary>
 /// 绘制对象内容
 /// </summary>
 /// <param name="g">图形绘制对象</param>
 /// <param name="ClipRectangle">剪切矩形</param>
 public virtual void DrawContent(DomElement element, DocumentPaintEventArgs args)
 {
     if (element is DomCharElement)
     {
         DrawContent((DomCharElement)element, args);
     }
     else if (element is DomParagraphFlagElement)
     {
         DrawContent((DomParagraphFlagElement)element, args);
     }
     else if (element is DomImageElement)
     {
         DrawContent((DomImageElement)element, args);
     }
     else if (element is DomLineBreakElement)
     {
         DrawContent((DomLineBreakElement)element, args);
     }
 }
Exemplo n.º 10
0
        //public override void RefreshView(DocumentPaintEventArgs  args)
        //{
        //    base.DrawBackground( args);
        //    this.DrawContent( args  );
        //    if( ShowDragRect )
        //    {
        //        DragRectangle dr = this.CreateDragRectangle();
        //        dr.RefreshView( args.Graphics );
        //    }
        //}

        /// <summary>
        /// 绘制对象
        /// </summary>
        /// <param name="args"></param>
        public override void Draw(DocumentPaintEventArgs args)
        {
            args.Render.DrawBackground(this, args);
            this.DrawContent(args);
            if (args.RenderStyle == DocumentRenderStyle.Paint && args.ActiveMode)
            {
                if (this.ShowDragRect && this.Enabled)
                {
                    DragRectangle dr = this.CreateDragRectangle();
                    dr.Bounds = new Rectangle(
                        (int)this.AbsLeft,
                        (int)this.AbsTop,
                        dr.Bounds.Width,
                        dr.Bounds.Height);
                    dr.RefreshView(args.Graphics);
                }
            }
            System.Drawing.RectangleF bounds = this.AbsBounds;
            bounds.Width  = bounds.Width - 1;
            bounds.Height = bounds.Height - 1;
            args.Render.RenderBorder(this, args, bounds);
        }
Exemplo n.º 11
0
 /// <summary>
 /// 绘制元素内容
 /// </summary>
 /// <param name="g">图形绘制对象</param>
 /// <param name="ClipRectangle">剪切矩形</param>
 protected virtual void DrawContent(DomImageElement imgElement, DocumentPaintEventArgs args)
 {
     System.Drawing.Image img = null;
     if (args.RenderStyle == DocumentRenderStyle.Paint)
     {
         img = imgElement.PreviewImage;
     }
     else
     {
         img = imgElement.Image.Value;
     }
     System.Drawing.RectangleF bounds = imgElement.AbsBounds;
     if (img != null)
     {
         args.Graphics.DrawImage(
             img,
             bounds.X,
             bounds.Y,
             imgElement.Width,
             imgElement.Height);
     }
     else
     {
         using (System.Drawing.StringFormat f
                    = new System.Drawing.StringFormat())
         {
             f.Alignment     = System.Drawing.StringAlignment.Center;
             f.LineAlignment = System.Drawing.StringAlignment.Center;
             args.Graphics.DrawString(
                 WriterStrings.NoImage,
                 System.Windows.Forms.Control.DefaultFont,
                 System.Drawing.Brushes.Red,
                 bounds,
                 f);
         }
     }
     //base.DrawContent( g , ClipRectangle );
 }
Exemplo n.º 12
0
        /// <summary>
        /// 创建包含元素内容的图片对象
        /// </summary>
        /// <returns>图片对象</returns>
        public virtual System.Drawing.Image CreateContentImage()
        {
            if (this.Width <= 0 || this.Height <= 0)
            {
                return(null);
            }
            System.Drawing.SizeF size = new System.Drawing.SizeF(this.Width, this.Height);
            size = GraphicsUnitConvert.Convert(
                size,
                this.OwnerDocument.DocumentGraphicsUnit,
                System.Drawing.GraphicsUnit.Pixel);
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(
                (int)Math.Ceiling(size.Width),
                (int)Math.Ceiling(size.Height));
            using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp))
            {
                g.Clear(Color.White);
                g.PageUnit = this.OwnerDocument.DocumentGraphicsUnit;
                RectangleF bounds = this.AbsBounds;
                g.TranslateTransform(-bounds.Left, -bounds.Top);
                DocumentPaintEventArgs args = new DocumentPaintEventArgs(g, Rectangle.Empty);
                args.Document          = this.OwnerDocument;
                args.PageClipRectangle = Rectangle.Ceiling(bounds);
                args.Render            = this.OwnerDocument.Render;
                args.RenderStyle       = DocumentRenderStyle.Bitmap;
                args.Style             = this.RuntimeStyle;
                args.Type           = this.DocumentContentElement.ContentPartyStyle;
                args.ViewBounds     = Rectangle.Ceiling(bounds);
                args.ActiveMode     = true;
                args.Bounds         = bounds;
                args.Element        = this;
                args.ForCreateImage = true;

                this.Draw(args);
            }//using
            return(bmp);
        }
Exemplo n.º 13
0
        /// <summary>
        /// 绘制图片文档内容
        /// </summary>
        /// <param name="args"></param>
        public override void DrawContent(DocumentPaintEventArgs args)
        {
            //try
            //{
            System.Drawing.RectangleF bounds = this.AbsBounds;
            float rate = 1;

            if (this.OwnerLine.AdditionHeight < 0)
            {
                float newHeight = bounds.Height + this.OwnerLine.AdditionHeight;
                rate          = newHeight / bounds.Height;
                bounds.Height = newHeight;
            }
            if (args.RenderStyle == DocumentRenderStyle.Paint &&
                this.PreviewImage != null)
            {
                Image img = this.PreviewImage;
                args.Graphics.DrawImage(
                    img,
                    bounds,
                    new RectangleF(
                        0,
                        0,
                        img.Width,
                        img.Height * rate),
                    GraphicsUnit.Pixel);
                //bounds.X,
                //bounds.Y,
                //bounds.Width ,
                //bounds.Height );
            }
            else
            {
                if (this.Image.HasContent)
                {
                    Image img = this.Image.Value;
                    args.Graphics.DrawImage(
                        img,
                        bounds,
                        new RectangleF(
                            0,
                            0,
                            img.Width,
                            img.Height * rate),
                        GraphicsUnit.Pixel);
                }
                else
                {
                    bool draw = true;
                    if (args.RenderStyle == DocumentRenderStyle.Print &&
                        this.OwnerDocument.Options.ViewOptions.PrintImageAltText == false)
                    {
                        draw = false;
                    }
                    if (draw)
                    {
                        using (System.Drawing.StringFormat f
                                   = new System.Drawing.StringFormat())
                        {
                            f.Alignment     = System.Drawing.StringAlignment.Center;
                            f.LineAlignment = System.Drawing.StringAlignment.Center;
                            string text = WriterStrings.NoImage;
                            if (string.IsNullOrEmpty(this.Alt) == false)
                            {
                                text = this.Alt;
                            }
                            args.Graphics.DrawString(
                                text,
                                System.Windows.Forms.Control.DefaultFont,
                                System.Drawing.Brushes.Red,
                                bounds,
                                f);
                        } //using
                    }     //if
                }
            }
            //}
            //catch (Exception ext)
            //{
            //    System.Console.WriteLine(ext.ToString());
            //}
        }
Exemplo n.º 14
0
        /// <summary>
        /// 绘制文档元素背景
        /// </summary>
        /// <param name="element">文档元素对象</param>
        /// <param name="args">参数</param>
        /// <param name="bounds">要绘制背景的区域</param>
        public virtual void DrawBackground(
            DomElement element,
            DocumentPaintEventArgs args,
            RectangleF bounds)
        {
            if (bounds.IsEmpty)
            {
                // 不绘制图形
                return;
            }

            DocumentContentStyle rs = null;

            if (element.Parent != null)
            {
                rs = element.Parent.GetContentBackgroundStyle(element);
            }
            if (rs == null)
            {
                rs = element.RuntimeStyle;
            }
            System.Drawing.Color c = rs.BackgroundColor;
            if (c.A != 0)
            {
                System.Drawing.SolidBrush b = GraphicsObjectBuffer.GetSolidBrush(c);
                bounds = System.Drawing.RectangleF.Intersect(bounds, args.ClipRectangleF);
                if (!bounds.IsEmpty)
                {
                    args.Graphics.FillRectangle(b, bounds);
                    return;
                }
            }

            HighlightInfo highlight = null;

            if (args.ActiveMode && args.RenderStyle == DocumentRenderStyle.Paint)
            {
                highlight = this.Document.HighlightManager[element];
            }
            if (highlight != null)
            {
                if (args.RenderStyle == DocumentRenderStyle.Print &&
                    highlight.ActiveStyle != HighlightActiveStyle.AllTime)
                {
                    // 当进行打印时不显示不能打印的高亮度色
                    return;
                }
                // 如果需要高亮度显示
                // 则绘制高亮度背景
                bounds = RectangleF.Intersect(bounds, args.ClipRectangleF);
                if (highlight.BackColor.A != 0)
                {
                    if (!bounds.IsEmpty)
                    {
                        args.Graphics.FillRectangle(
                            GraphicsObjectBuffer.GetSolidBrush(highlight.BackColor),
                            bounds);
                    }
                }
            }
        }
Exemplo n.º 15
0
 /// <summary>
 /// 计算元素大小
 /// </summary>
 /// <param name="args">参数</param>
 public virtual void RefreshSize(DocumentPaintEventArgs args)
 {
     args.Render.RefreshSize(this, args.Graphics);
 }
Exemplo n.º 16
0
 public virtual void DrawContent(DocumentPaintEventArgs args)
 {
     args.Render.DrawContent(this, args);
 }
Exemplo n.º 17
0
        ///// <summary>
        ///// 输出文档
        ///// </summary>
        ///// <param name="writer">文档书写器</param>
        //public virtual void WriteDocument( DocumentContentWriter writer )
        //{

        //}

        public virtual void Draw(DocumentPaintEventArgs args)
        {
            args.Render.RefreshView(this, args);
        }
Exemplo n.º 18
0
        /// <summary>
        /// 绘制对象
        /// </summary>
        /// <param name="g">图形绘制对象</param>
        /// <param name="ClipRectangle">剪切矩形</param>
        protected virtual void DrawContent(DomCharElement chr, DocumentPaintEventArgs args)
        {
            DocumentContentStyle rs = chr.RuntimeStyle;

            System.Drawing.RectangleF rect = chr.AbsBounds;
            rect.Height = rect.Height * 1.5f;
            rect.Width  = rect.Width * 1.5f;
            //if (chr.OwnerLine.AdditionHeight < 0)
            {
                rect.Height = Math.Max(
                    rect.Height,
                    chr.OwnerLine.Height + chr.OwnerLine.AdditionHeight);
            }
            //rect.Height = Math.Min(rect.Height, chr.OwnerLine.Height);
            Color cc = rs.Color;

            if (args.RenderStyle == DocumentRenderStyle.Paint)
            {
                HighlightInfo info = this.Document.HighlightManager[chr];
                if (info != null && info.Color.A != 0)
                {
                    // 设置高亮度文本值
                    cc = info.Color;
                }
            }
            SolidBrush b    = GraphicsObjectBuffer.GetSolidBrush(cc);
            XFontValue font = rs.Font.Clone();

            if (rs.Subscript || rs.Superscript)
            {
                font.Size = font.Size * 0.6f;
                if (rs.Superscript)
                {
                    args.Graphics.DrawString(chr.CharValue.ToString(),
                                             font.Value,
                                             b,
                                             rect.Left,
                                             rect.Top,
                                             myMeasureFormat);
                }
                else
                {
                    args.Graphics.DrawString(chr.CharValue.ToString(),
                                             font.Value,
                                             b,
                                             rect.Left,
                                             (int)Math.Floor(rect.Top + (rect.Height * 0.4)),
                                             myMeasureFormat);
                }
            }
            else
            {
                if ((rs.Underline || rs.Strikeout) && chr.CharValue == ' ')
                {
                    // .NET框架存在一个BUG,不能为空格绘制下划线和删除线,因此在此进行替换绘制成不带下划线的下划线字母。
                    XFontValue font2 = rs.Font.Clone();
                    if (font2.Underline)
                    {
                        font2.Underline = false;
                        args.Graphics.DrawString(
                            "_",
                            font2.Value,
                            b,
                            rect.Left,
                            rect.Top,
                            myMeasureFormat);
                    }
                    else
                    {
                        font2.Strikeout = false;
                        args.Graphics.DrawString(
                            "-",
                            font2.Value,
                            b,
                            rect.Left,
                            rect.Top,
                            myMeasureFormat);
                    }
                }
                else
                {
                    //InnerFormat.FormatFlags = InnerFormat.FormatFlags | StringFormatFlags.MeasureTrailingSpaces;
                    //InnerFormat.FormatFlags = StringFormatFlags.FitBlackBox | StringFormatFlags.MeasureTrailingSpaces ;
                    args.Graphics.DrawString(
                        chr.CharValue.ToString(),
                        rs.Font.Value,
                        b,
                        rect,
                        myMeasureFormat);
                }
            }
            //if ( font.Underline )
            //{
            //    float fh = font.GetHeight(args.Graphics);
            //    Pen p = SolidBrushBuffer.GetPen(cc);
            //    args.Graphics.DrawLine(
            //        p,
            //        rect.Left ,
            //        rect.Top + fh ,
            //        rect.Right + chr.WidthFix,
            //        rect.Top + fh );
            //}
        }
Exemplo n.º 19
0
        /// <summary>
        /// 绘制授权状态标记
        /// </summary>
        /// <param name="element">文档元素对象</param>
        /// <param name="args">参数</param>
        public virtual void DrawPermissionMark(DomElement element, DocumentPaintEventArgs args)
        {
            DocumentContentStyle style = element.Style;

            if (style.DeleterIndex >= 0)
            {
                DomContentLine line   = element.OwnerLine;
                RectangleF     bounds = new RectangleF(
                    element.AbsLeft,
                    line.AbsTop,
                    element.Width + element.WidthFix,
                    line.Height);
                int level = element.DeleterPermissionLevel;
                if (level >= 0)
                {
                    if (level == 0)
                    {
                        args.Graphics.DrawLine(
                            Pens.Blue,
                            bounds.Left,
                            bounds.Top + bounds.Height / 2,
                            bounds.Right,
                            bounds.Top + bounds.Height / 2);
                    }
                    else
                    {
                        float step = bounds.Height / (level + 1);
                        for (int iCount = 1; iCount <= level; iCount++)
                        {
                            args.Graphics.DrawLine(
                                Pens.Red,
                                bounds.Left,
                                bounds.Top + step * iCount,
                                bounds.Right,
                                bounds.Top + step * iCount);
                        }//for
                    }
                }
            }
            else if (style.CreatorIndex >= 0)
            {
                DomContentLine line   = element.OwnerLine;
                RectangleF     bounds = new RectangleF(
                    element.AbsLeft,
                    line.AbsTop,
                    element.Width + element.WidthFix,
                    line.Height);
                int level = element.CreatorPermessionLevel;
                if (level > 0)
                {
                    if (level == 1)
                    {
                        args.Graphics.DrawLine(Pens.Blue, bounds.Left, bounds.Bottom, bounds.Right, bounds.Bottom);
                    }
                    else
                    {
                        args.Graphics.DrawLine(Pens.Blue, bounds.Left, bounds.Bottom, bounds.Right, bounds.Bottom);
                        args.Graphics.DrawLine(Pens.Blue, bounds.Left, bounds.Bottom - 6, bounds.Right, bounds.Bottom - 6);
                    }
                }
            }
        }