GtkSharp/Source/Templates/GtkSharp.Template.CSharp/content/GtkSharp.Application.CSharp/MainWindow.cs

36 lines
910 B
C#
Raw Normal View History

using System;
using Gtk;
using UI = Gtk.Builder.ObjectAttribute;
2017-10-26 17:49:21 +00:00
namespace GtkNamespace
{
class MainWindow : Window
{
[UI] private Label _label1 = null;
[UI] private Button _button1 = null;
private int _counter;
2017-10-26 17:49:21 +00:00
public MainWindow() : this(new Builder("MainWindow.glade")) { }
private MainWindow(Builder builder) : base(builder.GetObject("MainWindow").Handle)
{
builder.Autoconnect(this);
2017-11-02 21:13:53 +00:00
DeleteEvent += Window_DeleteEvent;
_button1.Clicked += Button1_Clicked;
}
2017-11-02 21:13:53 +00:00
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).";
}
}
}