Skip to content

Instantly share code, notes, and snippets.

@wieslawsoltes
Last active August 29, 2015 14:24
Show Gist options
  • Save wieslawsoltes/8fedd8bdc0e5493ae35f to your computer and use it in GitHub Desktop.
Save wieslawsoltes/8fedd8bdc0e5493ae35f to your computer and use it in GitHub Desktop.
Eto.Wpf.Drawing.FontHandler.Dispose throws System.NullReferenceException
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