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(); }; Fixed @fixed = new Fixed(); Add(@fixed); Image mapImage = new Image("/home/map4.png"); @fixed.Put(mapImage, 0, 0); Button button = new Button("Move"); button.Clicked += (object? sender, EventArgs eventArgs) => { int i = 0; bool a = true; while (true) { @fixed.Move(mapImage, i, 0); if (a) i++; else i--; if (i > 100) a = false; if (i < 0) a = true; Application.RunIteration(true); } }; @fixed.Put(button, 250, 200); ShowAll(); } }
© accounting.org.ua - 2024