From cd5c3d37dcae723165b64adfaf4df93af3f7fb08 Mon Sep 17 00:00:00 2001 From: Speykious Date: Sun, 27 Mar 2022 19:40:16 +0200 Subject: [PATCH] Add `NativeFileDialogs.Net` examples They look much easier to deal with, don't they? --- ...eFileDialogs.Net.Example.OpenDialog.csproj | 18 +++++++++++ .../Program.cs | 23 ++++++++++++++ ...logs.Net.Example.OpenDialogMultiple.csproj | 18 +++++++++++ .../Program.cs | 24 ++++++++++++++ ...eFileDialogs.Net.Example.PickFolder.csproj | 18 +++++++++++ .../Program.cs | 18 +++++++++++ ...eFileDialogs.Net.Example.SaveDialog.csproj | 18 +++++++++++ .../Program.cs | 23 ++++++++++++++ NativeFileDialogs.NET.sln | 31 +++++++++++++++++++ 9 files changed, 191 insertions(+) create mode 100644 Examples/Net/NativeFileDialogs.Net.Example.OpenDialog/NativeFileDialogs.Net.Example.OpenDialog.csproj create mode 100644 Examples/Net/NativeFileDialogs.Net.Example.OpenDialog/Program.cs create mode 100644 Examples/Net/NativeFileDialogs.Net.Example.OpenDialogMultiple/NativeFileDialogs.Net.Example.OpenDialogMultiple.csproj create mode 100644 Examples/Net/NativeFileDialogs.Net.Example.OpenDialogMultiple/Program.cs create mode 100644 Examples/Net/NativeFileDialogs.Net.Example.PickFolder/NativeFileDialogs.Net.Example.PickFolder.csproj create mode 100644 Examples/Net/NativeFileDialogs.Net.Example.PickFolder/Program.cs create mode 100644 Examples/Net/NativeFileDialogs.Net.Example.SaveDialog/NativeFileDialogs.Net.Example.SaveDialog.csproj create mode 100644 Examples/Net/NativeFileDialogs.Net.Example.SaveDialog/Program.cs diff --git a/Examples/Net/NativeFileDialogs.Net.Example.OpenDialog/NativeFileDialogs.Net.Example.OpenDialog.csproj b/Examples/Net/NativeFileDialogs.Net.Example.OpenDialog/NativeFileDialogs.Net.Example.OpenDialog.csproj new file mode 100644 index 0000000..e5e251d --- /dev/null +++ b/Examples/Net/NativeFileDialogs.Net.Example.OpenDialog/NativeFileDialogs.Net.Example.OpenDialog.csproj @@ -0,0 +1,18 @@ + + + + Exe + net6.0 + disable + enable + + + + + + + + + + + diff --git a/Examples/Net/NativeFileDialogs.Net.Example.OpenDialog/Program.cs b/Examples/Net/NativeFileDialogs.Net.Example.OpenDialog/Program.cs new file mode 100644 index 0000000..e999c89 --- /dev/null +++ b/Examples/Net/NativeFileDialogs.Net.Example.OpenDialog/Program.cs @@ -0,0 +1,23 @@ +// Copyright (c) Speykious +// This file is part of NativeFileDialogs.NET. +// NativeFileDialogs.NET is licensed under the Zlib License. See LICENSE for details. + +using System; +using System.Collections.Generic; +using NativeFileDialogs.Net; + +NfdStatus result = Nfd.OpenDialog(out string? outPath, new Dictionary() +{ + { "Source code", "c,cpp,cc" }, + { "Headers", "h,hpp" }, +}); + +if (result == NfdStatus.Ok && outPath is string path) +{ + Console.WriteLine("Success!"); + Console.WriteLine(path); +} +else +{ + Console.WriteLine("User pressed Cancel."); +} diff --git a/Examples/Net/NativeFileDialogs.Net.Example.OpenDialogMultiple/NativeFileDialogs.Net.Example.OpenDialogMultiple.csproj b/Examples/Net/NativeFileDialogs.Net.Example.OpenDialogMultiple/NativeFileDialogs.Net.Example.OpenDialogMultiple.csproj new file mode 100644 index 0000000..e5e251d --- /dev/null +++ b/Examples/Net/NativeFileDialogs.Net.Example.OpenDialogMultiple/NativeFileDialogs.Net.Example.OpenDialogMultiple.csproj @@ -0,0 +1,18 @@ + + + + Exe + net6.0 + disable + enable + + + + + + + + + + + diff --git a/Examples/Net/NativeFileDialogs.Net.Example.OpenDialogMultiple/Program.cs b/Examples/Net/NativeFileDialogs.Net.Example.OpenDialogMultiple/Program.cs new file mode 100644 index 0000000..67fee1e --- /dev/null +++ b/Examples/Net/NativeFileDialogs.Net.Example.OpenDialogMultiple/Program.cs @@ -0,0 +1,24 @@ +// Copyright (c) Speykious +// This file is part of NativeFileDialogs.NET. +// NativeFileDialogs.NET is licensed under the Zlib License. See LICENSE for details. + +using System; +using System.Collections.Generic; +using NativeFileDialogs.Net; + +NfdStatus result = Nfd.OpenDialogMultiple(out string[]? outPaths, new Dictionary() +{ + { "Source code", "c,cpp,cc" }, + { "Headers", "h,hpp" }, +}); + +if (result == NfdStatus.Ok && outPaths is string[] paths) +{ + Console.WriteLine("Success!"); + foreach (string path in paths) + Console.WriteLine($"- {path}"); +} +else +{ + Console.WriteLine("User pressed Cancel."); +} diff --git a/Examples/Net/NativeFileDialogs.Net.Example.PickFolder/NativeFileDialogs.Net.Example.PickFolder.csproj b/Examples/Net/NativeFileDialogs.Net.Example.PickFolder/NativeFileDialogs.Net.Example.PickFolder.csproj new file mode 100644 index 0000000..e5e251d --- /dev/null +++ b/Examples/Net/NativeFileDialogs.Net.Example.PickFolder/NativeFileDialogs.Net.Example.PickFolder.csproj @@ -0,0 +1,18 @@ + + + + Exe + net6.0 + disable + enable + + + + + + + + + + + diff --git a/Examples/Net/NativeFileDialogs.Net.Example.PickFolder/Program.cs b/Examples/Net/NativeFileDialogs.Net.Example.PickFolder/Program.cs new file mode 100644 index 0000000..49844c5 --- /dev/null +++ b/Examples/Net/NativeFileDialogs.Net.Example.PickFolder/Program.cs @@ -0,0 +1,18 @@ +// Copyright (c) Speykious +// This file is part of NativeFileDialogs.NET. +// NativeFileDialogs.NET is licensed under the Zlib License. See LICENSE for details. + +using System; +using NativeFileDialogs.Net; + +NfdStatus result = Nfd.PickFolder(out string? outPath); + +if (result == NfdStatus.Ok) +{ + Console.WriteLine("Success!"); + Console.WriteLine(outPath); +} +else +{ + Console.WriteLine("User pressed Cancel."); +} diff --git a/Examples/Net/NativeFileDialogs.Net.Example.SaveDialog/NativeFileDialogs.Net.Example.SaveDialog.csproj b/Examples/Net/NativeFileDialogs.Net.Example.SaveDialog/NativeFileDialogs.Net.Example.SaveDialog.csproj new file mode 100644 index 0000000..e5e251d --- /dev/null +++ b/Examples/Net/NativeFileDialogs.Net.Example.SaveDialog/NativeFileDialogs.Net.Example.SaveDialog.csproj @@ -0,0 +1,18 @@ + + + + Exe + net6.0 + disable + enable + + + + + + + + + + + diff --git a/Examples/Net/NativeFileDialogs.Net.Example.SaveDialog/Program.cs b/Examples/Net/NativeFileDialogs.Net.Example.SaveDialog/Program.cs new file mode 100644 index 0000000..1f5659b --- /dev/null +++ b/Examples/Net/NativeFileDialogs.Net.Example.SaveDialog/Program.cs @@ -0,0 +1,23 @@ +// Copyright (c) Speykious +// This file is part of NativeFileDialogs.NET. +// NativeFileDialogs.NET is licensed under the Zlib License. See LICENSE for details. + +using System; +using System.Collections.Generic; +using NativeFileDialogs.Net; + +NfdStatus result = Nfd.SaveDialog(out string? savePath, new Dictionary() +{ + { "Source code", "c,cpp,cc" }, + { "Headers", "h,hpp" }, +}, defaultName: "Untitled.c"); + +if (result == NfdStatus.Ok) +{ + Console.WriteLine("Success!"); + Console.WriteLine(savePath); +} +else +{ + Console.WriteLine("User pressed Cancel."); +} diff --git a/NativeFileDialogs.NET.sln b/NativeFileDialogs.NET.sln index 93940c3..31de38c 100644 --- a/NativeFileDialogs.NET.sln +++ b/NativeFileDialogs.NET.sln @@ -23,6 +23,16 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NativeFileDialogs.AutoGen.E EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NativeFileDialogs.AutoGen.Example.SaveDialog", "Examples\AutoGen\NativeFileDialogs.AutoGen.Example.SaveDialog\NativeFileDialogs.AutoGen.Example.SaveDialog.csproj", "{180E9F64-55C8-40FD-99E0-5E10C7917038}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Net", "Net", "{4324441D-90E0-43C2-9948-27CC33FBB71D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NativeFileDialogs.Net.Example.OpenDialog", "Examples\Net\NativeFileDialogs.Net.Example.OpenDialog\NativeFileDialogs.Net.Example.OpenDialog.csproj", "{E4DB3E4F-9B67-4D87-BAE4-2670475512C4}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NativeFileDialogs.Net.Example.OpenDialogMultiple", "Examples\Net\NativeFileDialogs.Net.Example.OpenDialogMultiple\NativeFileDialogs.Net.Example.OpenDialogMultiple.csproj", "{20C818D1-E5B1-4729-9874-DB322FB33662}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NativeFileDialogs.Net.Example.PickFolder", "Examples\Net\NativeFileDialogs.Net.Example.PickFolder\NativeFileDialogs.Net.Example.PickFolder.csproj", "{943A1673-49DD-4DC8-BAE1-D74C6D232463}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NativeFileDialogs.Net.Example.SaveDialog", "Examples\Net\NativeFileDialogs.Net.Example.SaveDialog\NativeFileDialogs.Net.Example.SaveDialog.csproj", "{AC9AEA38-59D3-452C-A738-15B88924A221}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -64,6 +74,22 @@ Global {180E9F64-55C8-40FD-99E0-5E10C7917038}.Debug|Any CPU.Build.0 = Debug|Any CPU {180E9F64-55C8-40FD-99E0-5E10C7917038}.Release|Any CPU.ActiveCfg = Release|Any CPU {180E9F64-55C8-40FD-99E0-5E10C7917038}.Release|Any CPU.Build.0 = Release|Any CPU + {E4DB3E4F-9B67-4D87-BAE4-2670475512C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E4DB3E4F-9B67-4D87-BAE4-2670475512C4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E4DB3E4F-9B67-4D87-BAE4-2670475512C4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E4DB3E4F-9B67-4D87-BAE4-2670475512C4}.Release|Any CPU.Build.0 = Release|Any CPU + {20C818D1-E5B1-4729-9874-DB322FB33662}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {20C818D1-E5B1-4729-9874-DB322FB33662}.Debug|Any CPU.Build.0 = Debug|Any CPU + {20C818D1-E5B1-4729-9874-DB322FB33662}.Release|Any CPU.ActiveCfg = Release|Any CPU + {20C818D1-E5B1-4729-9874-DB322FB33662}.Release|Any CPU.Build.0 = Release|Any CPU + {943A1673-49DD-4DC8-BAE1-D74C6D232463}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {943A1673-49DD-4DC8-BAE1-D74C6D232463}.Debug|Any CPU.Build.0 = Debug|Any CPU + {943A1673-49DD-4DC8-BAE1-D74C6D232463}.Release|Any CPU.ActiveCfg = Release|Any CPU + {943A1673-49DD-4DC8-BAE1-D74C6D232463}.Release|Any CPU.Build.0 = Release|Any CPU + {AC9AEA38-59D3-452C-A738-15B88924A221}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AC9AEA38-59D3-452C-A738-15B88924A221}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AC9AEA38-59D3-452C-A738-15B88924A221}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AC9AEA38-59D3-452C-A738-15B88924A221}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {901C3F34-519E-4AA5-BF80-9E1788848D7C} = {B7B10789-6A38-46A8-9CCC-378B1D405D3D} @@ -71,5 +97,10 @@ Global {0DFF9BF7-0715-4559-B86D-8F5A02A11175} = {901C3F34-519E-4AA5-BF80-9E1788848D7C} {7ED52D4C-EDFC-4C9E-B1D7-4F7E88951FCE} = {901C3F34-519E-4AA5-BF80-9E1788848D7C} {180E9F64-55C8-40FD-99E0-5E10C7917038} = {901C3F34-519E-4AA5-BF80-9E1788848D7C} + {4324441D-90E0-43C2-9948-27CC33FBB71D} = {B7B10789-6A38-46A8-9CCC-378B1D405D3D} + {E4DB3E4F-9B67-4D87-BAE4-2670475512C4} = {4324441D-90E0-43C2-9948-27CC33FBB71D} + {20C818D1-E5B1-4729-9874-DB322FB33662} = {4324441D-90E0-43C2-9948-27CC33FBB71D} + {943A1673-49DD-4DC8-BAE1-D74C6D232463} = {4324441D-90E0-43C2-9948-27CC33FBB71D} + {AC9AEA38-59D3-452C-A738-15B88924A221} = {4324441D-90E0-43C2-9948-27CC33FBB71D} EndGlobalSection EndGlobal