07.06.2024 11:26 Gtk3
Fixed поміщає віджет у задані координати. В даному прикладі на формі розміщена картинка і кнопка. Клік по кнопці запускає переміщення картинки вправо та вліво.

dotnet new consoledotnet add package GtkSharpdotnet runusing 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 - 2025