protected override void OnPaint(PaintEventArgs e) { if (DesignMode) { e.Graphics.Clear(System.Drawing.Color.Black); e.Graphics.DrawString("Direct2D cannot be used at design time.", this.Font, System.Drawing.Brushes.White, 10, 10); } else { d2dGraphics.BeginDraw(); OnRender(d2dGraphics); try { d2dGraphics.EndDraw(); } catch (SharpDX.SharpDXException ex) { Debug.WriteLine(ex.Message); Debug.WriteLine(ex.StackTrace); if (ex.HResult == -2003238900) // D2DERR_RECREATE_TARGET { TerminateRenderGraphics(); InitRenderGraphics(); Invalidate(); } } } }
protected override void OnPaint(PaintEventArgs e) { if (DesignMode) { e.Graphics.Clear(System.Drawing.Color.Black); e.Graphics.DrawString("Direct2D cannot be used at design time.", this.Font, System.Drawing.Brushes.White, 10, 10); } else { d2dGraphics.BeginDraw(); OnRender(d2dGraphics); d2dGraphics.EndDraw(); } }