Last active
August 29, 2015 14:24
-
-
Save wieslawsoltes/8fedd8bdc0e5493ae35f to your computer and use it in GitHub Desktop.
Eto.Wpf.Drawing.FontHandler.Dispose throws System.NullReferenceException
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Eto.Forms; | |
using Eto.Drawing; | |
using System.Diagnostics; | |
using System.Threading; | |
using System.Globalization; | |
namespace ConsoleApplication22 | |
{ | |
class MyForm : Form | |
{ | |
public MyForm() | |
{ | |
this.ClientSize = new Eto.Drawing.Size(500, 500); | |
this.Title = "Hello, Eto.Forms " + Platform.ID; | |
var drawable = new Drawable { Size = new Size(700, 600) }; | |
drawable.Paint += (sender, e) => | |
{ | |
try | |
{ | |
var g = e.Graphics; | |
g.Clear(Brushes.White); | |
var brush = new SolidBrush(Colors.Black); | |
var font = new Font("Arial", 14f); | |
g.DrawText(font, brush, new PointF(100f, 100f), "Test"); | |
brush.Dispose(); | |
font.Dispose(); | |
} | |
catch (Exception ex) | |
{ | |
Debug.Print(ex.Message); | |
Debug.Print(ex.StackTrace); | |
} | |
}; | |
var layout = new PixelLayout(); | |
layout.Add(drawable, 0, 0); | |
Content = layout; | |
} | |
} | |
class Program | |
{ | |
[STAThread] | |
static void Main(string[] args) | |
{ | |
new Application(Eto.Platforms.Wpf).Run(new MyForm()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment