/// <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; } } }
///// <summary> ///// 所在段落的第一个内容元素对象 ///// </summary> //[System.ComponentModel.Browsable( false )] //[System.Xml.Serialization.XmlIgnore()] //internal XTextElement FirstContentElement1 //{ // get // { // return _FirstContentElement; // } // set // { // _FirstContentElement = value; // } //} /// <summary> /// 复制对象 /// </summary> /// <param name="Deeply">是否深入复制子元素</param> /// <returns>复制品</returns> public override DomElement Clone(bool Deeply) { DomParagraphFlagElement pe = (DomParagraphFlagElement)base.Clone(Deeply); //this.CopyAttributesTo(pe); return(pe); }
/// <summary> /// 刷新元素大小 /// </summary> /// <param name="g">参数</param> protected virtual void RefreshSize(DomParagraphFlagElement eof, System.Drawing.Graphics g) { int h = (int)Math.Ceiling((double)this.Document.DefaultStyle.DefaultLineHeight); DocumentContentStyle rs = eof.RuntimeStyle; SizeF size = g.MeasureString("#", rs.Font.Value); eof.Height = rs.Font.GetHeight(g);// size.Height; eof.Width = this.Document.PixelToDocumentUnit(10); eof.SizeInvalid = false; }
public override void FixElements() { if (this.Elements.Count == 0 || (this.Elements.LastElement is DomParagraphFlagElement) == false) { DomParagraphFlagElement flag = new DomParagraphFlagElement(); flag.AutoCreate = true; DocumentContentStyle style = new DocumentContentStyle(); style.Align = DocumentContentAlignment.Center; //style.BorderWidth = 1; //style.BorderColor = Color.Black; //style.BorderStyle = System.Drawing.Drawing2D.DashStyle.Solid; //style.BorderLeft = false; //style.BorderTop = false; //style.BorderRight = false; //style.BorderBottom = true; //style.BorderSpacing = 8; flag.StyleIndex = this.OwnerDocument.ContentStyles.GetStyleIndex(style); this.AppendChildElement(flag); } }
//private ParagraphListStyle _L //private float _LeftCount = 0 ; internal bool AddElement(DomElement element) { if (this.Count == 0) { //intLeftCount = 0 ; this.List.Add(element); { DomParagraphFlagElement p = element.OwnerParagraphEOF; if (p != null) { DocumentContentStyle rs = p.RuntimeStyle; if (element == p.ParagraphFirstContentElement) { if (rs.NumberedList || rs.BulletedList) { this.PaddingLeft = rs.LeftIndent; if (rs.NumberedList) { this.ParagraphListStyle = ParagraphListStyle.NumberedList; } else if (rs.BulletedList) { this.ParagraphListStyle = ParagraphListStyle.BulletedList; } this.ParagraphStyleIndex = p.ListIndex; } this.PaddingLeft = rs.LeftIndent + rs.FirstLineIndent; } else { this.PaddingLeft = rs.LeftIndent; } } else { this.PaddingLeft = 0; } } element.Left = this.PaddingLeft; if (this.ParagraphListStyle == Dom.ParagraphListStyle.BulletedList || this.ParagraphListStyle == Dom.ParagraphListStyle.NumberedList) { DomParagraphListItemElement item = new DomParagraphListItemElement(); DocumentContentStyle rs = element.RuntimeStyle; float size = rs.Font.GetHeight(element.OwnerDocument.DocumentGraphicsUnit); item.Width = size; item.Height = size; if (this.ParagraphListStyle == Dom.ParagraphListStyle.NumberedList) { item.Width = item.Width * 2; } item.OwnerDocument = element.OwnerDocument; item.StyleIndex = element.StyleIndex; this.Insert(0, item); // float size = rs.Font.GetHeight( } //intLeftCount = intLeftCount + element.Width + this.intSpacing ; //element.OwnerLine = this ; return(true); } float WidthCount = this.ContentWidth; if ((element is DomParagraphFlagElement) == false) { // 在排版中段落元素不计宽度,可以无条件的添加到文档行中。 if (WidthCount + element.Width + this._Spacing > this.Width - this.PaddingLeft) { return(false); } } DomElement PreElement = ( DomElement )this.List[this.Count - 1]; element.Left = PreElement.Left + PreElement.Width + this._Spacing; this.List.Add(element); //intLeftCount = intLeftCount + element.Width + this.intSpacing ; //element.OwnerLine = this ; return(true); }