Merge branch 'fix/shell-notify': taskbar progress, OS notifications, shortcuts, job notices, badges, General settings
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
117 files changed
+1807
-190
No files matched your search
@@ -0,0 +1,61 @@
|
||||
namespace Titano.Core.IO;
|
||||
|
||||
/// <summary>
|
||||
/// The sign-in entries of Titano's programs: <c>HKCU\Software\Microsoft\Windows\CurrentVersion\Run</c> values whose
|
||||
/// command starts one executable with one option (<c>"C:\…\Titano.exe" --minimized</c>). Shared by the programs that
|
||||
/// write them and the uninstaller that removes them; the paths are Windows paths, compared ignoring case.
|
||||
/// </summary>
|
||||
public static class StartupCommand
|
||||
{
|
||||
public const string RunKey = @"Software\Microsoft\Windows\CurrentVersion\Run";
|
||||
|
||||
/// <summary>The client's value (Settings › General › Startup).</summary>
|
||||
public const string ClientValue = "Titano";
|
||||
|
||||
/// <summary>The Uploader's value (its "Start with Windows").</summary>
|
||||
public const string UploaderValue = "Titano Uploader";
|
||||
|
||||
/// <summary>The command that starts <paramref name="executable"/> with <paramref name="option"/>.</summary>
|
||||
public static string Format(string executable, string option) => $"\"{executable}\" {option}";
|
||||
|
||||
/// <summary>
|
||||
/// The program <paramref name="command"/> starts: its quoted first part, or the text up to the first space when it
|
||||
/// is not quoted; null for an empty or malformed command.
|
||||
/// </summary>
|
||||
public static string? Executable(string? command)
|
||||
{
|
||||
var text = command?.Trim();
|
||||
if (string.IsNullOrEmpty(text)) return null;
|
||||
if (text[0] == '"')
|
||||
{
|
||||
var end = text.IndexOf('"', 1);
|
||||
return end > 1 ? text[1..end] : null;
|
||||
}
|
||||
var space = text.IndexOf(' ', StringComparison.Ordinal);
|
||||
return space < 0 ? text : text[..space];
|
||||
}
|
||||
|
||||
/// <summary><paramref name="command"/> starts <paramref name="executable"/>, not another copy of the program.</summary>
|
||||
public static bool Starts(string? command, string? executable) =>
|
||||
executable is { Length: > 0 } && string.Equals(Executable(command), executable, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
/// <summary>The program <paramref name="command"/> starts lies in <paramref name="directory"/> or one of its folders.</summary>
|
||||
public static bool StartsFrom(string? command, string directory)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(directory);
|
||||
var folder = directory.TrimEnd('\\', '/');
|
||||
return Executable(command) is { } exe && folder.Length > 0 && exe.Length > folder.Length + 1
|
||||
&& exe.StartsWith(folder, StringComparison.OrdinalIgnoreCase) && exe[folder.Length] is '\\' or '/';
|
||||
}
|
||||
|
||||
/// <summary>The folder of the program <paramref name="command"/> starts; null when it names none.</summary>
|
||||
public static string? Folder(string? command) => Executable(command) is { } exe ? FolderOf(exe) : null;
|
||||
|
||||
/// <summary>The folder part of a Windows path (on any platform); null when it has none.</summary>
|
||||
public static string? FolderOf(string path)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(path);
|
||||
var slash = path.LastIndexOfAny(['\\', '/']);
|
||||
return slash > 0 ? path[..slash] : null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user