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, 600); SetPosition(WindowPosition.Center); DeleteEvent += delegate { Program.Quit(); }; VBox vBox = new VBox(); Add(vBox); HBox hBox = new HBox(); vBox.PackStart(hBox, false, false, 5); Button button = new Button("Вибрати каталог"); button.Clicked += OnOpenDialog; hBox.PackStart(button, false, false, 5); ShowAll(); } void OnOpenDialog(object? sender, EventArgs args) { FileChooserDialog fc = new FileChooserDialog("Виберіть каталог", this, FileChooserAction.SelectFolder, "Закрити", ResponseType.Cancel, "Вибрати", ResponseType.Accept); if (fc.Run() == (int)ResponseType.Accept) Console.WriteLine(fc.CurrentFolder); fc.Dispose(); fc.Destroy(); } }
© accounting.org.ua - 2024