diff --git a/.gitignore b/.gitignore index a437a65..e498ca0 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ project.lock.json .DS_Store *.pyc +*.exe nupkg/ # Visual Studio Code diff --git a/Photomator.nsi b/Photomator.nsi new file mode 100644 index 0000000..e3f6dce --- /dev/null +++ b/Photomator.nsi @@ -0,0 +1,74 @@ +Unicode true + +!include "MUI2.nsh" +!include "x64.nsh" +!include "nsDialogs.nsh" +!include "FileFunc.nsh" + +Function .onInit + ${If} ${RunningX64} + # 64 bit code + SetRegView 64 + ${Else} + # 32 bit code + MessageBox MB_OK "Photomator unterstützt nur 64-Bit-Systeme." + Abort + ${EndIf} +FunctionEnd + +!define ARP "Software\Microsoft\Windows\CurrentVersion\Uninstall\Photomator" + +Name "Photomator" +OutFile "photomator-setup.exe" + +BrandingText "Copyright (c) 2024 Denys Konovalov" + +InstallDir "$PROGRAMFILES\GCG\Photomator" + +RequestExecutionLevel admin + +!insertmacro MUI_LANGUAGE "German" + +!define MUI_ABORTWARNING + +!insertmacro MUI_PAGE_DIRECTORY +!insertmacro MUI_PAGE_INSTFILES + +!insertmacro MUI_UNPAGE_CONFIRM +!insertmacro MUI_UNPAGE_INSTFILES + +Section "Install" + SetOutPath $INSTDIR + + File /nonfatal /a /r "Photomator\bin\Release\net8.0\win-x64\publish\" + + CreateShortcut "$SMPROGRAMS\Photomator.lnk" "$INSTDIR\bin\Photomator.exe" + + WriteUninstaller "$INSTDIR\Uninstall.exe" + + ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2 + IntFmt $0 "0x%08X" $0 + WriteRegDWORD HKLM "${ARP}" "EstimatedSize" "$0" + + WriteRegStr HKLM "${ARP}" "DisplayName" "Photomator" + WriteRegStr HKLM "${ARP}" "InstallLocation" "$\"$INSTDIR$\"" + WriteRegStr HKLM "${ARP}" "Publisher" "Georg-Cantor-Gymnasium Halle (Saale)" + WriteRegStr HKLM "${ARP}" "VersionMajor" "0" + WriteRegStr HKLM "${ARP}" "VersionMinor" "01" + WriteRegStr HKLM "${ARP}" "UninstallString" "$\"$INSTDIR\Uninstall.exe$\"" +SectionEnd + +Section "uninstall" + SetRegView 64 + + Delete "$SMPROGRAMS\Photomator.lnk" + + Delete "$INSTDIR\Uninstall.exe" + RMDir /R "$INSTDIR\bin\" + RMDir /R "$INSTDIR\lib\" + RMDir /R "$INSTDIR\share\" + + DeleteRegKey HKLM "${ARP}" + + RMDir /R $INSTDIR +SectionEnd \ No newline at end of file diff --git a/Photomator/Lib.cs b/Photomator/Lib.cs index a7d1336..c023214 100644 --- a/Photomator/Lib.cs +++ b/Photomator/Lib.cs @@ -1,10 +1,25 @@ using SixLabors.ImageSharp; using SixLabors.ImageSharp.Formats.Webp; using SixLabors.ImageSharp.Processing; +using System.Runtime.InteropServices; namespace Photomator; public static class Lib { + const int SW_HIDE = 0; + const int SW_SHOW = 5; + readonly static IntPtr handle = GetConsoleWindow(); + [DllImport("kernel32.dll")] static extern IntPtr GetConsoleWindow(); + [DllImport("user32.dll")] static extern bool ShowWindow(IntPtr hWnd,int nCmdShow); + + public static void HideConsole() { + ShowWindow(handle,SW_HIDE); + } + + public static void ShowConsole() { + ShowWindow(handle,SW_SHOW); + } + public static async Task Convert(string src, string dest, ConvertOptions options) { Image img = await Image.LoadAsync(src); img.Mutate(i => { diff --git a/Photomator/Photomator.csproj b/Photomator/Photomator.csproj index 73e7b64..3fa513e 100644 --- a/Photomator/Photomator.csproj +++ b/Photomator/Photomator.csproj @@ -5,6 +5,8 @@ net8.0 enable enable + true + Resources\de.cantorgymnasium.Photomator.ico @@ -17,8 +19,26 @@ - + + + + + + + + + + + + + + + + + + + diff --git a/Photomator/Program.cs b/Photomator/Program.cs index 732b83e..44315c5 100644 --- a/Photomator/Program.cs +++ b/Photomator/Program.cs @@ -11,10 +11,12 @@ public partial class Program { public static int Main() => new Program().Run(); public Program() { + Lib.HideConsole(); _application = Adw.Application.New("de.cantorgymnasium.Photomator", Gio.ApplicationFlags.FlagsNone); Gtk.Window.SetDefaultIconName("de.cantorgymnasium.Photomator"); - if (File.Exists(Path.GetFullPath(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!) + "/de.cantorgymnasium.Photomator.gresource")) - Gio.Functions.ResourcesRegister(Gio.Functions.ResourceLoad(Path.GetFullPath(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!) + "/de.cantorgymnasium.Photomator.gresource")); + string localPath = Path.GetFullPath(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!) + "/de.cantorgymnasium.Photomator.gresource"; + if (File.Exists(localPath)) + Gio.Functions.ResourcesRegister(Gio.Functions.ResourceLoad(localPath)); else { var prefixes = new List { Directory.GetParent(Directory.GetParent(Path.GetFullPath(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!))!.FullName)!.FullName, diff --git a/Photomator/Resources/de.cantorgymnasium.Photomator.ico b/Photomator/Resources/de.cantorgymnasium.Photomator.ico new file mode 100644 index 0000000..0e75b69 Binary files /dev/null and b/Photomator/Resources/de.cantorgymnasium.Photomator.ico differ diff --git a/Photomator/Resources/loaders.cache b/Photomator/Resources/loaders.cache new file mode 100644 index 0000000..01e3ebb --- /dev/null +++ b/Photomator/Resources/loaders.cache @@ -0,0 +1,7 @@ +"lib\\gdk-pixbuf-2.0\\2.10.0\\loaders\\libpixbufloader-svg.dll" +"svg" 6 "gdk-pixbuf" "Scalable Vector Graphics" "LGPL" +"image/svg+xml" "image/svg" "image/svg-xml" "image/vnd.adobe.svg+xml" "text/xml-svg" "image/svg+xml-compressed" "" +"svg" "svgz" "svg.gz" "" +" { - FileLauncher fileLauncher = FileLauncher.New(Gio.FileHelper.NewForPath(dest)); - await fileLauncher.LaunchAsync(_mainWindow); + if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { + FileLauncher fileLauncher = FileLauncher.New(Gio.FileHelper.NewForPath(dest)); + await fileLauncher.LaunchAsync(_mainWindow); + } else { + Process.Start("explorer.exe", @$"{dest}"); + } + Close(); }; btnOpen.SetCssClasses(["pill", "suggested-action"]); @@ -102,8 +109,13 @@ public partial class StatusDialog : Adw.Window { if (convertErrors.Length < number) { Button btnOpen = Button.NewWithLabel("Ordner öffnen"); btnOpen.OnClicked += async (_, _) => { - FileLauncher fileLauncher = FileLauncher.New(Gio.FileHelper.NewForPath(dest)); - await fileLauncher.LaunchAsync(_mainWindow); + if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { + FileLauncher fileLauncher = FileLauncher.New(Gio.FileHelper.NewForPath(dest)); + await fileLauncher.LaunchAsync(_mainWindow); + } else { + Process.Start("explorer.exe", @$"{dest}"); + } + Close(); }; btnOpen.SetCssClasses(["pill", "suggested-action"]);