diff --git a/Source/Samples/MainWindow.cs b/Source/Samples/MainWindow.cs new file mode 100644 index 000000000..a435042de --- /dev/null +++ b/Source/Samples/MainWindow.cs @@ -0,0 +1,37 @@ +using System; +using Gtk; +using UI = Gtk.Builder.ObjectAttribute; + +namespace Samples +{ + class MainWindow : Window + { +#pragma warning disable 0649 + [UI] private Label _label1; + [UI] private Button _button1; +#pragma warning restore 0649 + + private int _counter; + + public MainWindow() : this(new Builder("MainWindow.glade")) { } + + private MainWindow(Builder builder) : base(builder.GetObject("MainWindow").Handle) + { + builder.Autoconnect(this); + + DeleteEvent += Window_DeleteEvent; + _button1.Clicked += Button1_Clicked; + } + + private void Window_DeleteEvent(object sender, DeleteEventArgs a) + { + Application.Quit(); + } + + private void Button1_Clicked(object sender, EventArgs a) + { + _counter++; + _label1.Text = "Hello World! This button has been clicked " + _counter + " time(s)."; + } + } +} diff --git a/Source/Samples/MainWindow.glade b/Source/Samples/MainWindow.glade new file mode 100644 index 000000000..a13c41b20 --- /dev/null +++ b/Source/Samples/MainWindow.glade @@ -0,0 +1,46 @@ + + + + + False + Example Window + 480 + 240 + + + True + False + 4 + 4 + 4 + 4 + vertical + + + True + False + Hello World! + + + True + True + 0 + + + + + Click me! + True + False + True + + + False + True + 1 + + + + + + diff --git a/Source/Samples/Program.cs b/Source/Samples/Program.cs new file mode 100644 index 000000000..877424780 --- /dev/null +++ b/Source/Samples/Program.cs @@ -0,0 +1,23 @@ +using System; +using Gtk; + +namespace Samples +{ + class Program + { + [STAThread] + public static void Main(string[] args) + { + Application.Init(); + + var app = new Application("org.Samples.Samples", GLib.ApplicationFlags.None); + app.Register(GLib.Cancellable.Current); + + var win = new MainWindow(); + app.AddWindow(win); + + win.Show(); + Application.Run(); + } + } +} diff --git a/Source/Samples/Samples.csproj b/Source/Samples/Samples.csproj new file mode 100644 index 000000000..33aa99279 --- /dev/null +++ b/Source/Samples/Samples.csproj @@ -0,0 +1,17 @@ + + + WinExe + netcoreapp2.0 + false + ..\..\BuildOutput\Samples + + + + + %(Filename)%(Extension) + + + + + + diff --git a/build.cake b/build.cake index 84b3e7bb3..be39d7fd8 100755 --- a/build.cake +++ b/build.cake @@ -81,6 +81,20 @@ Task("Build") } }); +Task("RunSamples") + .IsDependentOn("Build") + .Does(() => +{ + var settings = new DotNetCoreBuildSettings + { + Configuration = "Release", + MSBuildSettings = msbuildsettings + }; + + DotNetCoreBuild("Source/Samples/Samples.csproj", settings); + DotNetCoreRun("Source/Samples/Samples.csproj"); +}); + Task("PackageNuGet") .IsDependentOn("Build") .Does(() =>