Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.
C# audio-converteravaloniabatch-conversionconvertercsharpdocument-converterdocx-to-pdfdotnetdrag-and-dropfile-conversionfile-converterheic-converterhwphwpximage-converterlinuxmacospdf-convertervideo-converterwindows
Merge remote-tracking branch 'origin/feature/lower-memory' into HEAD
KnifeLemoncac7aa2aa78c
diff --cc src/Filee.App/App.axaml.csindex ea70f0a1,7ec9e56f..ba48ba9c--- a/src/Filee.App/App.axaml.cs+++ b/src/Filee.App/App.axaml.cs@@@ -133,7 -111,7 +133,8 @@@ public partial class App : Applicatiodesktop.Exit += (_, _) =>{+ watchdog.Dispose();+ AppHost.Get<MemoryTrimmer>().Dispose();AppHost.Get<TriggerService>().Dispose();AppHost.Get<TrayService>().Dispose();AppHost.Get<WatchFolderService>().DisposeAsync().AsTask().Wait(TimeSpan.FromSeconds(5));diff --cc src/Filee.App/Services/SingleInstance.csindex 4f1c1247,7871bef6..93a25dfa--- a/src/Filee.App/Services/SingleInstance.cs+++ b/src/Filee.App/Services/SingleInstance.cs@@@ -10,8 -11,7 +11,7 @@@ namespace Filee.App.Servicespublic sealed class SingleInstance : IDisposable{// string.GetHashCode() is randomized per process, so a stable hash is required for both processes to agree.- internal static readonly string DefaultName = "Filee-" + Convert.ToHexString(- System.Security.Cryptography.SHA256.HashData(System.Text.Encoding.UTF8.GetBytes(Environment.UserName)))[..12];- private static readonly string DefaultName = NameFor(Environment.UserName, UserDataStore.OverrideDirectory);++ internal static readonly string DefaultName = NameFor(Environment.UserName, UserDataStore.OverrideDirectory);private readonly Mutex _mutex;private readonly string _name;private readonly CancellationTokenSource _cts = new();diff --cc src/Filee.App/Views/MainWindow.axaml.csindex 4e3db3e1,e21e9f49..f5d743a5--- a/src/Filee.App/Views/MainWindow.axaml.cs+++ b/src/Filee.App/Views/MainWindow.axaml.cs@@@ -12,7 -9,8 +12,9 @@@ namespace Filee.App.Viewspublic partial class MainWindow : Window{+ private bool _asking;+ private bool _releasePosted;+ private bool _releasing;public MainWindow(){@@@ -35,61 -31,31 +37,82 @@@protected override void OnClosing(WindowClosingEventArgs e){base.OnClosing(e);- if (e.CloseReason is not WindowCloseReason.WindowClosing)- if (e.CloseReason is WindowCloseReason.WindowClosing && !_releasing)- {- e.Cancel = true;++ if (e.CloseReason is not WindowCloseReason.WindowClosing || _releasing)+ return;+ e.Cancel = true;- // Close() from code only hides, as before; the setting is for the title bar's close button and Alt+F4.++ // Close() from code goes to the tray, as before; the setting is for the title bar's close button and Alt+F4.+ if (e.IsProgrammatic)- Hide();+ HideToTray();+ else+ CloseAsTheUserChose();+ }++ /// <summary>What the user's close does: hide, quit or ask (<see cref="AppSettings.CloseAction"/>).</summary>+ internal void CloseAsTheUserChose()+ {+ var store = AppHost.Get<UserDataStore>();+ switch (store.Settings.CloseAction)+ {+ case CloseAction.Tray:- Hide();++ HideToTray();+ break;+ case CloseAction.Quit:+ Quit();+ break;+ default:+ _ = AskAsync(store);+ break;}}+ private async Task AskAsync(UserDataStore store)+ {+ if (_asking)+ return;+ _asking = true;+ try+ {+ var dialog = new CloseAskWindow();+ if (await dialog.ShowDialog<CloseAction?>(this) is not { } action)+ return;+ if (dialog.DontAskAgain)+ {+ store.Settings.CloseAction = action;+ store.SaveSettings();+ }+ if (action == CloseAction.Quit)+ Quit();+ else- Hide();++ HideToTray();+ }+ finally+ {+ _asking = false;+ }+ }++ // Posted: shutting down closes this window again, which must not happen inside its own Closing handler.+ private static void Quit() => Dispatcher.UIThread.Post(() =>+ (Application.Current?.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?.Shutdown());+++ /// <summary>+ /// Leaves Filee in the tray: hides the window at once, then closes it for real, so its pages, visuals and images+ /// don't stay in memory until the next time (issue #119). <see cref="WindowService.ShowMain"/> opens a new one.+ /// </summary>+ internal void HideToTray()+ {+ Hide();+ if (_releasePosted)+ return;+ _releasePosted = true;+ // Posted: a window can't close inside its own Closing handler.+ Dispatcher.UIThread.Post(() =>+ {+ _releasePosted = false;+ if (IsVisible)+ return; // shown again meanwhile+ _releasing = true;+ Close();+ });+ }}diff --cc src/Filee.Platform.Windows/NativeMethods.csindex e936aaf1,d78133ca..6db6b0e0--- a/src/Filee.Platform.Windows/NativeMethods.cs+++ b/src/Filee.Platform.Windows/NativeMethods.cs@@@ -78,47 -85,6 +85,44 @@@ internal static partial class NativeMet[LibraryImport("kernel32.dll")]public static unsafe partial int PackageFamilyNameFromId(PACKAGE_ID* packageId, ref uint packageFamilyNameLength, char* packageFamilyName);+ // Tokens and integrity levels (Elevation).+ public const uint TOKEN_QUERY = 0x0008;+ public const uint PROCESS_QUERY_LIMITED_INFORMATION = 0x1000;+ public const int TokenElevation = 20;+ public const int TokenIntegrityLevel = 25;+- [LibraryImport("kernel32.dll")]- public static partial nint GetCurrentProcess();-+ [LibraryImport("kernel32.dll", SetLastError = true)]+ public static partial nint OpenProcess(uint access, [MarshalAs(UnmanagedType.Bool)] bool inheritHandle, uint processId);++ [LibraryImport("kernel32.dll")]+ [return: MarshalAs(UnmanagedType.Bool)]+ public static partial bool CloseHandle(nint handle);++ [LibraryImport("advapi32.dll", SetLastError = true)]+ [return: MarshalAs(UnmanagedType.Bool)]+ public static partial bool OpenProcessToken(nint process, uint access, out nint token);++ [LibraryImport("advapi32.dll", SetLastError = true)]+ [return: MarshalAs(UnmanagedType.Bool)]+ public static unsafe partial bool GetTokenInformation(nint token, int informationClass, void* information, uint length, out uint returnLength);++ /// <summary>Pointer to the sub-authority count (a byte) inside a SID.</summary>+ [LibraryImport("advapi32.dll")]+ public static partial nint GetSidSubAuthorityCount(nint sid);++ /// <summary>Pointer to sub-authority <paramref name="index"/> (a DWORD) inside a SID.</summary>+ [LibraryImport("advapi32.dll")]+ public static partial nint GetSidSubAuthority(nint sid, uint index);++ /// <summary>The desktop window of the shell (Explorer's Progman), or 0 when no shell runs.</summary>+ [LibraryImport("user32.dll")]+ public static partial nint GetShellWindow();++ public const uint MB_OK = 0x0, MB_ICONWARNING = 0x30, MB_SETFOREGROUND = 0x10000, MB_TOPMOST = 0x40000;++ [LibraryImport("user32.dll", EntryPoint = "MessageBoxW", StringMarshalling = StringMarshalling.Utf16)]+ public static partial int MessageBox(nint owner, string text, string caption, uint type);+/// <summary>Returns the Win32 class name of a window ("CabinetWClass" for Explorer, ...).</summary>public static string ClassNameOf(nint hwnd){