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) { //Вибрані файли string[] selectFileNames = []; FileChooserDialog fc = new FileChooserDialog("Виберіть файли", this, FileChooserAction.Open, "Закрити", ResponseType.Cancel, "Вибрати", ResponseType.Accept) { Filter = new FileFilter(), SelectMultiple = true }; fc.Filter.AddPattern("*.*"); fc.SetCurrentFolder("/home"); if (fc.Run() == (int)ResponseType.Accept) selectFileNames = fc.Filenames; fc.Dispose(); fc.Destroy(); foreach (string fileName in selectFileNames) Console.WriteLine(fileName); } }
© accounting.org.ua - 2024