D2D.Factory D2DFactory;
#endif
DW.TextFormat format;
- D2D.Bitmap bitmap;
- D2D.RenderTarget render;
+ protected D2D.Bitmap cachedBitMap;
CustomTextRenderer textRender;
int tabLength = 8;
- bool hasCache, _ShowLineBreak;
- Size renderSize = new Size();
+ bool _ShowLineBreak;
Color4 _Comment, _Literal, _Keyword1, _Keyword2;
+ protected bool hasCache;
+
+ protected Size renderSize
+ {
+ get;
+ private set;
+ }
+
+ protected D2D.RenderTarget render
+ {
+ get;
+ private set;
+ }
public D2DRenderCommon()
{
this.Strokes.Factory = this.D2DFactory;
this.ChangedRenderResource += (s, e) => { };
this.ChangedRightToLeft += (s, e) => { };
+ this.renderSize = new Size();
}
public event ChangedRenderResourceEventHandler ChangedRenderResource;
public virtual void DrawCachedBitmap(Rectangle rect)
{
- if (this.render == null || this.render.IsDisposed)
- return;
- render.DrawBitmap(this.bitmap, rect, 1.0f, D2D.BitmapInterpolationMode.Linear, rect);
}
public virtual void CacheContent()
{
- if (this.render == null || this.bitmap == null || this.bitmap.IsDisposed || this.render.IsDisposed)
- return;
- render.Flush();
- this.bitmap.CopyFromRenderTarget(this.render, new SharpDX.Point(), new SharpDX.Rectangle(0, 0, (int)this.renderSize.Width, (int)this.renderSize.Height));
- this.hasCache = true;
}
public virtual bool IsVaildCache()
bmpProp.DpiX = dpiX;
bmpProp.DpiY = dpiY;
bmpProp.PixelFormat = new D2D.PixelFormat(DXGI.Format.B8G8R8A8_UNorm, D2D.AlphaMode.Ignore);
- this.bitmap = new D2D.Bitmap(this.render, new SharpDX.Size2((int)width, (int)height), bmpProp);
+ this.cachedBitMap = new D2D.Bitmap(this.render, new SharpDX.Size2((int)width, (int)height), bmpProp);
this.hasCache = false;
this.ConstrctedResource();
this.textRender = new CustomTextRenderer(this.render, this.Brushes,this.Strokes, this.Foreground);
- this.renderSize.Width = width;
- this.renderSize.Height = height;
+ this.renderSize = new Size(width,height);
this.TextAntialiasMode = this._TextAntialiasMode;
}
public void DestructDeviceResource()
{
this.hasCache = false;
- if (this.bitmap != null)
- this.bitmap.Dispose();
+ if (this.cachedBitMap != null)
+ this.cachedBitMap.Dispose();
this.Brushes.Clear();
this.Strokes.Clear();
this.Effects.Clear();
return (DW.FontWeight)Enum.Parse(typeof(DW.FontWeight), weigth.ToString());
}
+ public override void DrawCachedBitmap(Rectangle rect)
+ {
+ if (this.render == null || this.render.IsDisposed)
+ return;
+ render.DrawBitmap(this.cachedBitMap, rect, 1.0f, D2D.BitmapInterpolationMode.Linear, rect);
+ }
+
+ public override void CacheContent()
+ {
+ if (this.render == null || this.cachedBitMap == null || this.cachedBitMap.IsDisposed || this.render.IsDisposed)
+ return;
+ 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;
+ }
+
void CreateDevice()
{
D3D10.FeatureLevel[] levels = new D3D10.FeatureLevel[]{D3D10.FeatureLevel.Level_10_1,
null);
}
+ public override void DrawCachedBitmap(Rectangle rect)
+ {
+ if (this.render == null || this.render.IsDisposed)
+ return;
+ render.DrawBitmap(this.cachedBitMap, rect, 1.0f, D2D.BitmapInterpolationMode.Linear, rect);
+ }
+
+ public override void CacheContent()
+ {
+ if (this.render == null || this.cachedBitMap == null || this.cachedBitMap.IsDisposed || this.render.IsDisposed)
+ return;
+ 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;
+ }
+
D2D.WindowRenderTarget WindowRender;
protected override D2D.RenderTarget ConstructRender(D2D.Factory factory, D2D.RenderTargetProperties prop, double width, double height)