Skip to content

Instantly share code, notes, and snippets.

@cwensley
Created September 26, 2019 18:14
Show Gist options
  • Save cwensley/ad3f6c810e5ca25cdad2f77dc907b7c7 to your computer and use it in GitHub Desktop.
Save cwensley/ad3f6c810e5ca25cdad2f77dc907b7c7 to your computer and use it in GitHub Desktop.
Loading Screen for Eto
using System;
using Eto.Forms;
using Eto.Drawing;
using System.Threading.Tasks;
using System.Threading;
namespace EtoLoadingScreen.Desktop
{
public partial class MainForm : Form
{
public MainForm()
{
Title = "My Eto Form";
ClientSize = new Size(400, 350);
Content = new StackLayout
{
Padding = 10,
Items =
{
"Hello World!",
// add more controls here
}
};
}
}
class LoadingForm : Form
{
public LoadingForm()
{
WindowStyle = WindowStyle.None;
Resizable = false;
Minimizable = false;
Maximizable = false;
Topmost = true;
ClientSize = new Size(300, 150);
Location = (Point)Screen.PrimaryScreen.Bounds.Center - ClientSize / 2;
Content = new TableLayout
{
Rows =
{
null,
new TableRow(null, new Spinner { Enabled = true, Size = new Size(24, 24) }, "Loading...", null),
null
}
};
}
}
class Program
{
[STAThread]
static void Main(string[] args)
{
var app = new Application(Eto.Platform.Detect);
app.Initialized += async (sender, e) =>
{
var loadingForm = new LoadingForm();
loadingForm.Show();
await Task.Run(() =>
{
Thread.Sleep(5000);
});
var form = new MainForm();
form.Closed += (sender_, e_) => app.Quit();
form.Show();
loadingForm.Close();
};
app.Run();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment