mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-25 12:38:24 +01:00
samples: add Hello/Demo samples for most BRUTAL packages (#19)
Add samples/, a collection of single-file .NET 10 apps run with `dotnet run <file>.cs`. Hello/ has one minimal sample per package that has a public API, many of them headless; Demo/ has fuller programs that combine packages into a more interesting application. samples/README.md indexes every sample and covers the layout, error handling and per-OS requirements.
This commit is contained in:
parent
4ac91e105e
commit
7a3b72d843
1 changed files with 4599 additions and 1 deletions
34
samples/Hello/HelloNativeFileDialog.cs
Normal file
34
samples/Hello/HelloNativeFileDialog.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* HelloNativeFileDialog
|
||||
*
|
||||
* Opens the operating system's native file picker and prints the file you chose.
|
||||
*/
|
||||
|
||||
#:package Ahwoo.Brutal.NativeFileDialog@2026.10.2
|
||||
|
||||
// RIAN: We only use this package for tooling, we prefer in-game file pickers for games.
|
||||
|
||||
using Brutal.NativeFileDialogApi;
|
||||
|
||||
NativeFileDialog.Initialize();
|
||||
try
|
||||
{
|
||||
Run();
|
||||
}
|
||||
finally
|
||||
{
|
||||
NativeFileDialog.Shutdown();
|
||||
}
|
||||
|
||||
static void Run()
|
||||
{
|
||||
var path = NativeFileDialog.OpenDialog(
|
||||
new FileDialogInfo { FilterList = [new FilterItem { Name = "Text files", Spec = "txt,md" }] },
|
||||
out var result
|
||||
);
|
||||
|
||||
if (result == NativeFileDialog.Result.Okay)
|
||||
Console.WriteLine($"You picked: {path}");
|
||||
else
|
||||
Console.WriteLine($"No file picked ({result})");
|
||||
}
|
||||
Loading…
Reference in a new issue