using Avalonia.Media; using Avalonia.Media.Immutable; using Avalonia.Platform.Storage; using System.Reflection; using System.Text.RegularExpressions; namespace EllieHub.Common; /// /// Defines the application's environment data. /// public static partial class AppStatics { /// /// Defines the default location where the updater configuration and bot instances are stored. /// #if DEBUG public static string AppDefaultConfigDirectoryUri { get; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "EllieHubDebug"); #else public static string AppDefaultConfigDirectoryUri { get; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "EllieHub"); #endif /// /// Defines the default location where the bot instances are stored. /// public static string AppDefaultBotDirectoryUri { get; } = Path.Combine(AppDefaultConfigDirectoryUri, "Bots"); /// /// Defines the default location where the backups of bot instances are stored. /// public static string AppDefaultBotBackupDirectoryUri { get; } = Path.Combine(AppDefaultConfigDirectoryUri, "Backups"); /// /// Defines the default location where the logs of bot instances are stored. /// public static string AppDefaultLogDirectoryUri { get; } = Path.Combine(AppDefaultConfigDirectoryUri, "Logs"); /// /// Defines the location of the application's configuration file. /// public static string AppConfigUri { get; } = Path.Combine(AppDefaultConfigDirectoryUri, "config.json"); /// /// Defines the location of the application's dependencies. /// public static string AppDepsUri { get; } = Path.Combine(AppDefaultConfigDirectoryUri, "Dependencies"); /// /// Defines a transparent color brush. /// public static ImmutableSolidColorBrush TransparentColorBrush { get; } = new(Colors.Transparent); /// /// Represents the image formats supported by the views of this application. /// public static FilePickerOpenOptions ImageFilePickerOptions { get; } = new() { AllowMultiple = false, FileTypeFilter = new FilePickerFileType[] { new("Image") { Patterns = new[] { "*.png", "*.jpg", "*.jpeg", "*.gif", "*.webp" } }, new("All") { Patterns = new[] { "*.*" } } } }; /// /// The version of this application. /// public static string AppVersion { get; } = Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? throw new InvalidOperationException("Version is missing from application assembly."); /// /// Matches the version of Ffmpeg from its CLI output. /// /// Pattern: ^(?:\S+\s+\D*?){2}(git\S+|[\d\.]+) public static Regex FfmpegVersionRegex { get; } = FfmpegVersionRegexGenerator(); [GeneratedRegex(@"^(?:\S+\s+\D*?){2}(git\S+|[\d\.]+)", RegexOptions.Compiled)] private static partial Regex FfmpegVersionRegexGenerator(); }