/// Rectで指定された範囲にドキュメントを描く
/// </summary>
/// <param name="updateRect">描写する範囲</param>
- /// <remarks>キャレットを点滅させる場合、定期的のこのメソッドを呼び出してください</remarks>
- public override void Draw(Rectangle updateRect)
+ /// <returns>キャッシュしてはならない場合は真を返し、そうでない場合は偽を返します</returns>
+ /// <remarks>描写する範囲がPageBoundより小さい場合、キャッシュされた内容を使用することがあります。なお、レタリング後にrender.CacheContent()を呼び出さなかった場合は更新範囲にかかわらずキャッシュを使用しません</remarks>
+ public override bool Draw(Rectangle updateRect)
{
if (this.LayoutLines.Count == 0)
- return;
+ return false;
IEditorRender render = (IEditorRender)base.render;
this.DrawInsertPoint();
- render.CacheContent();
+ this.Document.SelectGrippers.BottomLeft.Draw(this.render);
+ this.Document.SelectGrippers.BottomRight.Draw(this.render);
}
-
- this.DrawCaret();
-
- this.Document.SelectGrippers.BottomLeft.Draw(this.render);
- this.Document.SelectGrippers.BottomRight.Draw(this.render);
+ return this.DrawCaret(); //キャレットを描いた場合はキャッシュしてはならない
}
void DrawUpdateArea(int row,double ypos)
}
}
- void DrawCaret()
+ bool DrawCaret()
{
if (this.HideCaret || !this.IsFocused)
- return;
+ return false;
long diff = DateTime.Now.Ticks - this.tickCount;
long blinkTime = this.To100nsTime(this.CaretBlinkTime);
if (this.CaretBlink && diff % blinkTime >= blinkTime / 2)
- return;
+ return false;
Rectangle CaretRect = new Rectangle();
CaretRect.Location = new Point(this.CaretLocation.X, this.CaretLocation.Y + lineHeight - height);
render.FillRectangle(CaretRect, FillRectType.OverwriteCaret);
}
+ return true;
}
long To100nsTime(int ms)
set;
}
- public override void Draw(Rectangle updateRect)
+ public override bool Draw(Rectangle updateRect)
{
if (this.LayoutLines.Count == 0)
- return;
+ return false;
if (this.Hilighter != null)
this.Hilighter.Reset();
this.render.DrawString(this.Footer, pos.X, pos.Y, StringAlignment.Center,
new Size(render.TextArea.Width - this.GetRealtiveX(AreaType.TextArea), render.FooterHeight));
}
+
+ return false;
}
public bool TryPageDown()
set { this.Document.Src = value; }
}
- public virtual void Draw(Rectangle updateRect)
+ public virtual bool Draw(Rectangle updateRect)
{
+ return false;
}
public virtual bool TryScroll(double x, int row)
{
if (this.render == null || this.cachedBitMap == null || this.cachedBitMap.IsDisposed || this.render.IsDisposed)
return;
- render.Flush();
+ //render.Flush();
this.cachedBitMap.CopyFromRenderTarget(this.render, new SharpDX.Point(), new SharpDX.Rectangle(0, 0, (int)this.renderSize.Width, (int)this.renderSize.Height));
this.hasCache = true;
}
return;
this.Render.BegineDraw();
+ bool useCache = false;
if (this.IsEnabled)
- this.View.Draw(updateRect);
+ useCache = this.View.Draw(updateRect);
else
this.Render.FillBackground(updateRect);
this.Render.EndDraw();
+ //キャッシュされた内容が使用されていない=キャレットが描かれてない
+ if(!useCache)
+ this.Render.CacheContent();
}
#region Commands
{
if (this.render == null || this.cachedBitMap == null || this.cachedBitMap.IsDisposed || this.render.IsDisposed)
return;
- render.Flush();
+ //render.Flush();
this.cachedBitMap.CopyFromRenderTarget(this.render, new SharpDX.Point(), new SharpDX.Rectangle(0, 0, (int)this.renderSize.Width, (int)this.renderSize.Height));
this.hasCache = true;
}
{
base.OnGotFocus(e);
this.View.IsFocused = true;
+ this.Timer.Start();
this.Refresh();
}
{
base.OnLostFocus(e);
this.View.IsFocused = false;
+ this.Timer.Stop();
this.Refresh();
}
brush.Dispose();
}else if (this.Document.FireUpdateEvent){
this.render.BegineDraw();
- this.View.Draw(e.ClipRectangle);
+ bool useCache = this.View.Draw(e.ClipRectangle);
this.render.EndDraw();
+ if (!useCache)
+ this.render.CacheContent();
}
base.OnPaint(e);
}
if (CaretBlinkTime == -1)
{
this.View.CaretBlink = false;
- if (this.IsHandleCreated)
- this.BeginInvoke(new Action(() =>
- {
- this.Timer.Stop();
- }));
}
else
{
this.View.CaretBlink = true;
this.View.CaretBlinkTime = CaretBlinkTime * 2;
- if(this.IsHandleCreated)
- this.BeginInvoke(new Action(() =>
- {
- this.Timer.Start();
- }));
}
this.View.CaretWidthOnInsertMode = SystemInformation.CaretWidth;
}