Hi,
maybe this will be helpful for others. I wanted a little About dialog cross platform for the Grasshopper implementation we did. SO how about a background image, that matches the grasshopper about box.
using Eto.Drawing;
using Eto.Forms;
using AntFarmGH.Properties;
namespace AntFarmGH.UI
{
internal class AboutDialog : Dialog
{
int dialogWidth = 500;
int dialogHeight = 200;
internal AboutDialog()
{
this.Height = dialogHeight;
this.Width = dialogWidth;
this.WindowStyle = WindowStyle.None;
Drawable drawable = new Drawable();
drawable.Paint += (sender, e) =>
{
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(dialogWidth, dialogHeight);
System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap);
graphics.DrawImage(Resources.gh_antfarm, 0, 0, dialogWidth, dialogHeight);
graphics.Dispose();
System.Drawing.ImageConverter converter = new System.Drawing.ImageConverter();
byte[] bb = (byte[])converter.ConvertTo(bitmap, typeof(byte[]));
Image image = new Bitmap(bb);
e.Graphics.DrawImage(image, 0, 0);
};
drawable.Content = new StackLayout
{
HorizontalContentAlignment = HorizontalAlignment.Stretch,
VerticalContentAlignment = VerticalAlignment.Stretch,
BackgroundColor = Colors.Transparent,
Orientation = Orientation.Horizontal,
Padding = new Padding(0),
Spacing = 0,
Items =
{
new StackLayoutItem(new Label {Text = "Test" }),
}
};
this.Content = drawable;
}
}
}
I had some trouble to get the png to show up as a background and also wanted to scale the Bitmap
. You might want to put some more controls and content to the StackLayout
.
Kindest
Christian