protected Rectangle _Rect;
protected double _LongestWidth;
Padding _Padding;
- bool _DrawLineNumber,_UrlMark;
- LineBreakMethod _LineBreak;
- int _LineBreakCharCount = 80;
public ViewBase(Document doc, ITextRender r,Padding padding)
{
this.SrcChanged += new EventHandler((s, e) => { });
this.PerformLayouted += new EventHandler((s, e) => { });
this.PageBoundChanged += new EventHandler((s, e) => { });
- this.MarkerPatternSet = new MarkerPatternSet(this._LayoutLines, doc.Markers);
- this.MarkerPatternSet.Updated += WacthDogPattern_Updated;
+ this.Document.LineBreakChanged += (s, e) =>
+ {
+ if (this.Document.LineBreak != LineBreakMethod.None)
+ this._LayoutLines.SpilitString = new SpilitStringEventHandler(LayoutLines_SpilitStringByPixelbase);
+ else
+ this._LayoutLines.SpilitString = new SpilitStringEventHandler(LayoutLines_SpilitStringByChar);
+ };
+ this.Document.TabStopsChanged += (s, e) =>
+ {
+ this.render.TabWidthChar = this.Document.TabStops;
+ };
+ this.Document.DrawLineNumberChanged += (s, e) =>
+ {
+ CalculateClipRect();
+ };
}
protected LineToIndexTable _LayoutLines
/// </summary>
public MarkerPatternSet MarkerPatternSet
{
- get;
- private set;
+ get { return this.Document.MarkerPatternSet; }
}
/// <summary>
/// </summary>
public bool UrlMark
{
- get { return this._UrlMark; }
+ get { return this.Document.UrlMark; }
set
{
- this._UrlMark = value;
- if (value)
- {
- Regex regex = new Regex("(http|https|ftp)(:\\/\\/[-_.!~*\\'()a-zA-Z0-9;\\/?:\\@&=+\\$,%#]+)");
- this.MarkerPatternSet.Add(MarkerIDs.URL, new RegexMarkerPattern(regex, HilightType.Url,new Color()));
- }
- else
- {
- this.MarkerPatternSet.Remove(MarkerIDs.URL);
- }
+ this.Document.UrlMark = value;
}
}
{
get
{
- return this._LineBreak;
+ return this.Document.LineBreak;
}
set
{
- this._LineBreak = value;
- if (value != LineBreakMethod.None)
- this._LayoutLines.SpilitString = new SpilitStringEventHandler(LayoutLines_SpilitStringByPixelbase);
- else
- this._LayoutLines.SpilitString = new SpilitStringEventHandler(LayoutLines_SpilitStringByChar);
+ this.Document.LineBreak = value;
}
}
{
get
{
- return this._LineBreakCharCount;
+ return this.Document.LineBreakCharCount;
}
set
{
- this._LineBreakCharCount = value;
+ this.Document.LineBreakCharCount = value;
}
}
/// <remarks>変更した場合、呼び出し側で再描写する必要があります</remarks>
public int TabStops
{
- get { return this.render.TabWidthChar; }
- set { this.render.TabWidthChar = value; }
+ get { return this.Document.TabStops; }
+ set { this.Document.TabStops = value; }
}
/// <summary>
/// </summary>
public bool DrawLineNumber
{
- get { return this._DrawLineNumber; }
+ get { return this.Document.DrawLineNumber; }
set
{
- this._DrawLineNumber = value;
- this._LayoutLines.ClearLayoutCache();
- CalculateClipRect();
+ this.Document.DrawLineNumber = value;
}
}
this.PageBoundChanged(this, e);
}
- void WacthDogPattern_Updated(object sender, EventArgs e)
- {
- this._LayoutLines.ClearLayoutCache();
- }
-
void render_ChangedRightToLeft(object sender, EventArgs e)
{
this._Src.X = 0;
IList<LineToIndexTableData> LayoutLines_SpilitStringByPixelbase(object sender, SpilitStringEventArgs e)
{
double WrapWidth;
- if (_LineBreak == LineBreakMethod.PageBound)
+ if (this.LineBreak == LineBreakMethod.PageBound)
WrapWidth = this.render.TextArea.Width - LineBreakingMarginWidth; //余白を残さないと欠ける
else
- WrapWidth = this.render.emSize.Width * this._LineBreakCharCount;
+ WrapWidth = this.render.emSize.Width * this.LineBreakCharCount;
- if (WrapWidth < 0 && this._LineBreak != LineBreakMethod.None)
+ if (WrapWidth < 0 && this.LineBreak != LineBreakMethod.None)
throw new InvalidOperationException();
int startIndex = e.index;
IList<LineToIndexTableData> LayoutLines_SpilitStringByChar(object sender, SpilitStringEventArgs e)
{
- return this.Document.CreateLineList(e.index, e.length,1000);
+ return this.Document.CreateLineList(e.index, e.length, Document.MaximumLineLength);
}
}
}