dotnet new console
dotnet add package GtkSharp
dotnet run
using Gtk; class Program { public static void Main() { Application.Init(); new FirstWindow(); Application.Run(); } public static void Quit() { Application.Quit(); } }
using Gtk; class FirstWindow : Window { public FirstWindow() : base("Test") { SetDefaultSize(600, 350); SetPosition(WindowPosition.Center); DeleteEvent += delegate { Program.Quit(); }; VBox vBox = new VBox(); Add(vBox); HBox hBox = new HBox(); vBox.PackStart(hBox, false, false, 10); Label switchState = new Label() { UseMarkup = true }; Switch switch_me = new Switch(); switch_me.ButtonReleaseEvent += (object? o, ButtonReleaseEventArgs e) => { switchState.Markup = !switch_me.Active ? "<span color='red'>Включено</span>" : "Виключено"; }; hBox.PackStart(new Label("Переключатель"), false, false, 10); hBox.PackStart(switch_me, false, false, 10); hBox.PackEnd(switchState, false, false, 10); ShowAll(); } }
© accounting.org.ua - 2024