Skip to content

Instantly share code, notes, and snippets.

@wieslawsoltes
Created June 3, 2015 08:44
Show Gist options
  • Save wieslawsoltes/1ac32267f6b998366a06 to your computer and use it in GitHub Desktop.
Save wieslawsoltes/1ac32267f6b998366a06 to your computer and use it in GitHub Desktop.
Eto.Forms transform test
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Eto.Forms;
using Eto.Drawing;
namespace MyApp1
{
class MyForm : Eto.Forms.Form
{
public MyForm()
{
this.ClientSize = new Eto.Drawing.Size(800, 700);
this.Title = "Hello, Eto.Forms " + Platform.ID;
var drawable = new Drawable { Size = new Size(700, 600) };
drawable.Paint += (sender, e) =>
{
var g = e.Graphics;
g.Clear(Brushes.White);
var gp = new GraphicsPath();
gp.FillMode = FillMode.Winding;
gp.AddBezier(new PointF(10f, 6f), new PointF(10f, 4f), new PointF(8f, 2f), new PointF(6f, 2f));
gp.CloseFigure();
var m = Matrix.Create();
m.Scale(60f, 60f);
g.SaveTransform();
g.MultiplyTransform(m);
var brush = new SolidBrush(Colors.Black);
var pen = new Pen(Colors.Red, 0.1f);
g.FillPath(
brush,
gp);
g.DrawPath(
pen,
gp);
brush.Dispose();
pen.Dispose();
var brushY = new SolidBrush(Color.FromArgb(0xFF, 0xFF, 0x00, 0x9F));
var penB = new Pen(Color.FromArgb(0x00, 0x00, 0xFF, 0x9F), 0.1f);
g.DrawEllipse(penB, 10f, 6f, 0.5f, 0.5f);
g.FillEllipse(brushY, 10f, 6f, 0.5f, 0.5f);
g.DrawEllipse(penB, 6f, 2f, 0.5f, 0.5f);
g.FillEllipse(brushY, 6f, 2f, 0.5f, 0.5f);
g.RestoreTransform();
};
var layout = new PixelLayout();
layout.Add(drawable, 50, 50);
Content = layout;
}
}
class Program
{
[STAThread]
static void Main(string[] args)
{
//new Application(Eto.Platforms.WinForms).Run(new MyForm());
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