コード例 #1
0
ファイル: DomImageElement.cs プロジェクト: ywscr/CSharpWriter
        /// <summary>
        /// 复制对象
        /// </summary>
        /// <param name="Deeply">是否深度复制</param>
        /// <returns>复制品</returns>
        public override DomElement Clone(bool Deeply)
        {
            DomImageElement img = ( DomImageElement )base.Clone(Deeply);

            if (this._PreviewImage != null)
            {
                img._PreviewImage = ( Image )this._PreviewImage.Clone();
            }
            if (this.myImage != null)
            {
                img.myImage = this.myImage.Clone();
            }
            return(img);
        }
コード例 #2
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 );
 }