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> /// <param name="line">要添加的文本行对象</param> /// <returns>新文本行在列表中的序号</returns> public int Add(DomContentLine line) { if (line != null) { //line.OwnerList = this ; return(this.List.Add(line)); } return(-1); }
/// <summary> /// 初始化对象 /// </summary> /// <param name="content">要统计的文档内容</param> public WordCountResult(DomDocument document, System.Collections.IEnumerable content) { if (document == null) { throw new ArgumentNullException("document"); } if (content == null) { throw new ArgumentNullException("content"); } this._Pages = document.Pages.Count; bool wordFlag = false; DomContentLine line = null; //XTextParagraphElement p = null; foreach (DomElement element in content) { if (line != element.OwnerLine) { line = element.OwnerLine; _Lines++; } if (element is DomParagraphFlagElement) { _Paragraphs++; } if (element is DomCharElement) { char c = ((DomCharElement)element).CharValue; _Chars++; if (char.IsWhiteSpace(c) == false) { _CharsNoWhitespace++; } if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) { if (wordFlag == false) { _Words++; } wordFlag = true; } else { if (char.IsWhiteSpace(c) == false) { _Words++; } wordFlag = false; } continue; }//foreach wordFlag = false; if (element is DomImageElement) { _Images++; } }//foreach }
/// <summary> /// 将旧行对象替换成新的行对象 /// </summary> /// <param name="index">序号</param> /// <param name="NewLine">新的行对象</param> public void Replace(int index, DomContentLine NewLine) { //NewLine.OwnerList = this ; this.List[index] = NewLine; }
/// <summary> /// 判断列表是否存在指定的文本行对象 /// </summary> /// <param name="line">文本行对象</param> /// <returns>列表中是否存在指定的文本行对象</returns> public bool Contains(DomContentLine line) { return(this.List.Contains(line)); }
/// <summary> /// 获得指定的文本行对象在列表中的序号 /// </summary> /// <param name="line">文本行对象</param> /// <returns>文本行对象在列表中的序号,若未找到则返回-1</returns> public int IndexOf(DomContentLine line) { return(this.List.IndexOf(line)); }
/// <summary> /// 删除文本行对象 /// </summary> /// <param name="line">要删除的文本行对象</param> public void Remove(DomContentLine line) { this.List.Remove(line); }
// public void Replace( XTextLine OldLine , XTextLine NewLine ) // { // // } /// <summary> /// 插入文本行对象 /// </summary> /// <param name="index">插入的位置序号</param> /// <param name="line">要插入的文本行对象</param> public void Insert(int index, DomContentLine line) { //line.OwnerList = this ; this.List.Insert(index, line); }
/// <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); } } } }