protected void DrawObjectUnselected(RenderTarget rt, LiveRect r) { var brush = Color.Pink.SolidBrush(rt); var frameBrush = Color.White.SolidBrush(rt); rt.FillRectangle(r.Rectangle.ToRectF(), brush); rt.DrawRectangle(r.Rectangle.ToRectF(), frameBrush, 1); brush.Dispose(); frameBrush.Dispose(); var textBrush = Color.White.SolidBrush(rt); DWriteFactory dw = DWriteFactory.CreateFactory(); TextFormat normalTextFormat = dw.CreateTextFormat("微软雅黑", 20); if (r.Rectangle.Bottom > Mapper.GetScreenY(0)) { rt.DrawText(r.Value.ToString(), normalTextFormat, new RectangleF(r.Rectangle.X - 5, r.Rectangle.Top - 40, 100, 100).ToRectF(), textBrush); } else { rt.DrawText(r.Value.ToString(), normalTextFormat, new RectangleF(r.Rectangle.X - 5, r.Rectangle.Bottom + 20, 100, 100).ToRectF(), textBrush); } dw.Dispose(); textBrush.Dispose(); normalTextFormat.Dispose(); }
public virtual void Dispose() { _d2dFactory?.Dispose(); DWriteFactory?.Dispose(); WicFactory?.Dispose(); DeviceContext?.Dispose(); _d2dDevice?.Dispose(); }
protected override void InitializeComponents(RenderTarget rt) { base.InitializeComponents(rt); textBrush = DisplayModel.FontColor.SolidBrush(rt); DWriteFactory dw = DWriteFactory.CreateFactory(); textFormat = dw.CreateTextFormat(DisplayModel.FontName, DisplayModel.FontSize); dw.Dispose(); }
public virtual void Dispose() { _d2dFactory?.Dispose(); DWriteFactory?.Dispose(); WicFactory.Dispose(); WicFormatConverter.Dispose(); WhiteBrush.Dispose(); RedBrush.Dispose(); DeviceContext?.Dispose(); _d2dDevice?.Dispose(); }
public SideViewDisplayerBackground(RenderTarget canvas, D2DFactory factory, CoordinateSystem csp) : base(canvas, factory, csp) { axisBrush = canvas.CreateSolidColorBrush(new ColorF(0, 255, 0)); //绿色 dashLineBrush = canvas.CreateSolidColorBrush(new ColorF(128, 138, 135)); //冷灰 DWriteFactory dw = DWriteFactory.CreateFactory(); xTextFromation = dw.CreateTextFormat("Berlin Sans FB Demi", 15); yTextFromation = dw.CreateTextFormat("Berlin Sans FB Demi", 15); yTextFromation.TextAlignment = TextAlignment.Trailing; textBrush = canvas.CreateSolidColorBrush(new ColorF(new ColorI(128, 138, 135))); angleLines = new float[] { 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330 }; angleNumbers = new float[] { 0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360 }; distanceNumbers = new[] { 0, Distance / 6, Distance / 3, Distance / 2, Distance * 2 / 3, Distance * 5 / 6, Distance }; dw.Dispose(); }
protected override void Dispose(bool disposing) { if (disposing) { //dispose of all layouts while (layouts.Keys.Count > 0) { foreach (string key in layouts.Keys) { layouts[key].Dispose(); layouts.Remove(key); break; } } if (brush != null) { brush.Dispose(); } brush = null; if (dcRenderTarget != null) { dcRenderTarget.Dispose(); } dcRenderTarget = null; if (dwriteFactory != null) { dwriteFactory.Dispose(); } dwriteFactory = null; if (d2DFactory != null) { d2DFactory.Dispose(); } d2DFactory = null; } base.Dispose(disposing); }
protected override void DisposeManagedResources() { writeFactory.Dispose(); base.DisposeManagedResources(); }
/// <summary> /// Dispose of resources (IDisposable implementation) /// </summary> /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param> protected override void Dispose(bool disposing) { if (disposing && !disposed) { lock (renderSyncObject) { render = null; lock (sharedSyncObject) { if (sharedD2DFactory != null && d2DFactory == sharedD2DFactory) { sharedRefCount--; } if (d2DFactory != null && d2DFactory != sharedD2DFactory) { d2DFactory.Dispose(); } d2DFactory = null; if (dwriteFactory != null && dwriteFactory != sharedDwriteFactory) { dwriteFactory.Dispose(); } dwriteFactory = null; if (wicFactory != null && wicFactory != sharedWicFactory) { wicFactory.Dispose(); } wicFactory = null; if (sharedRefCount == 0) { if (sharedD2DFactory != null) { sharedD2DFactory.Dispose(); } sharedD2DFactory = null; if (sharedDwriteFactory != null) { sharedDwriteFactory.Dispose(); } sharedDwriteFactory = null; if (sharedWicFactory != null) { sharedWicFactory.Dispose(); } sharedWicFactory = null; } } foreach (DrawingShape shape in drawingShapes) { shape.Dispose(); } if (bitmap != null) { bitmap.Dispose(); } bitmap = null; if (dcRenderTarget != null) { dcRenderTarget.Dispose(); } dcRenderTarget = null; if (bitmapRenderTarget != null) { bitmapRenderTarget.Dispose(); } bitmapRenderTarget = null; if (hwndRenderTarget != null) { hwndRenderTarget.Dispose(); } hwndRenderTarget = null; disposed = true; } } base.Dispose(disposing); }