mirror of
				https://github.com/chylex/Discord-History-Tracker.git
				synced 2025-11-04 03:40:12 +01:00 
			
		
		
		
	Compare commits
	
		
			1 Commits
		
	
	
		
			v39.1
			...
			93fe018343
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						
						
							
						
						93fe018343
	
				 | 
					
					
						
@@ -1,4 +1,3 @@
 | 
				
			|||||||
using System;
 | 
					 | 
				
			||||||
using Avalonia;
 | 
					using Avalonia;
 | 
				
			||||||
using Avalonia.Controls.ApplicationLifetimes;
 | 
					using Avalonia.Controls.ApplicationLifetimes;
 | 
				
			||||||
using Avalonia.Markup.Xaml;
 | 
					using Avalonia.Markup.Xaml;
 | 
				
			||||||
@@ -13,7 +12,7 @@ sealed class App : Application {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	public override void OnFrameworkInitializationCompleted() {
 | 
						public override void OnFrameworkInitializationCompleted() {
 | 
				
			||||||
		if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) {
 | 
							if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) {
 | 
				
			||||||
			desktop.MainWindow = new MainWindow(new Arguments(desktop.Args ?? Array.Empty<string>()));
 | 
								desktop.MainWindow = new MainWindow(Program.Arguments);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		base.OnFrameworkInitializationCompleted();
 | 
							base.OnFrameworkInitializationCompleted();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,25 +6,32 @@ namespace DHT.Desktop;
 | 
				
			|||||||
sealed class Arguments {
 | 
					sealed class Arguments {
 | 
				
			||||||
	private static readonly Log Log = Log.ForType<Arguments>();
 | 
						private static readonly Log Log = Log.ForType<Arguments>();
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
						private const int FirstArgument = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public static Arguments Empty => new(Array.Empty<string>());
 | 
						public static Arguments Empty => new(Array.Empty<string>());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public bool Console { get; }
 | 
				
			||||||
	public string? DatabaseFile { get; }
 | 
						public string? DatabaseFile { get; }
 | 
				
			||||||
	public ushort? ServerPort { get; }
 | 
						public ushort? ServerPort { get; }
 | 
				
			||||||
	public string? ServerToken { get; }
 | 
						public string? ServerToken { get; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public Arguments(string[] args) {
 | 
						public Arguments(string[] args) {
 | 
				
			||||||
		for (int i = 0; i < args.Length; i++) {
 | 
							for (int i = FirstArgument; i < args.Length; i++) {
 | 
				
			||||||
			string key = args[i];
 | 
								string key = args[i];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			switch (key) {
 | 
								switch (key) {
 | 
				
			||||||
				case "-debug":
 | 
									case "-debug":
 | 
				
			||||||
					Log.IsDebugEnabled = true;
 | 
										Log.IsDebugEnabled = true;
 | 
				
			||||||
					continue;
 | 
										continue;
 | 
				
			||||||
 | 
									
 | 
				
			||||||
 | 
									case "-console":
 | 
				
			||||||
 | 
										Console = true;
 | 
				
			||||||
 | 
										continue;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			string value;
 | 
								string value;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (i == 0 && !key.StartsWith('-')) {
 | 
								if (i == FirstArgument && !key.StartsWith('-')) {
 | 
				
			||||||
				value = key;
 | 
									value = key;
 | 
				
			||||||
				key = "-db";
 | 
									key = "-db";
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,8 @@
 | 
				
			|||||||
using System.Globalization;
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Globalization;
 | 
				
			||||||
using System.Reflection;
 | 
					using System.Reflection;
 | 
				
			||||||
using Avalonia;
 | 
					using Avalonia;
 | 
				
			||||||
 | 
					using DHT.Utils.Logging;
 | 
				
			||||||
using DHT.Utils.Resources;
 | 
					using DHT.Utils.Resources;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace DHT.Desktop;
 | 
					namespace DHT.Desktop;
 | 
				
			||||||
@@ -9,6 +11,7 @@ static class Program {
 | 
				
			|||||||
	public static string Version { get; }
 | 
						public static string Version { get; }
 | 
				
			||||||
	public static CultureInfo Culture { get; }
 | 
						public static CultureInfo Culture { get; }
 | 
				
			||||||
	public static ResourceLoader Resources { get; }
 | 
						public static ResourceLoader Resources { get; }
 | 
				
			||||||
 | 
						public static Arguments Arguments { get; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	static Program() {
 | 
						static Program() {
 | 
				
			||||||
		var assembly = Assembly.GetExecutingAssembly();
 | 
							var assembly = Assembly.GetExecutingAssembly();
 | 
				
			||||||
@@ -25,10 +28,21 @@ static class Program {
 | 
				
			|||||||
		CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture;
 | 
							CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Resources = new ResourceLoader(assembly);
 | 
							Resources = new ResourceLoader(assembly);
 | 
				
			||||||
 | 
							Arguments = new Arguments(Environment.GetCommandLineArgs());
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public static void Main(string[] args) {
 | 
						public static void Main(string[] args) {
 | 
				
			||||||
 | 
							if (Arguments.Console && OperatingSystem.IsWindows()) {
 | 
				
			||||||
 | 
								WindowsConsole.AllocConsole();
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							try {
 | 
				
			||||||
			BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
 | 
								BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
 | 
				
			||||||
 | 
							} finally {
 | 
				
			||||||
 | 
								if (Arguments.Console && OperatingSystem.IsWindows()) {
 | 
				
			||||||
 | 
									WindowsConsole.FreeConsole();
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private static AppBuilder BuildAvaloniaApp() {
 | 
						private static AppBuilder BuildAvaloniaApp() {
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										13
									
								
								app/Utils/Logging/WindowsConsole.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								app/Utils/Logging/WindowsConsole.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,13 @@
 | 
				
			|||||||
 | 
					using System.Runtime.InteropServices;
 | 
				
			||||||
 | 
					using System.Runtime.Versioning;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DHT.Utils.Logging; 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[SupportedOSPlatform("windows")]
 | 
				
			||||||
 | 
					public static partial class WindowsConsole {
 | 
				
			||||||
 | 
						[LibraryImport("kernel32.dll", SetLastError = true)]
 | 
				
			||||||
 | 
						public static partial void AllocConsole();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						[LibraryImport("kernel32.dll", SetLastError = true)]
 | 
				
			||||||
 | 
						public static partial void FreeConsole();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -6,6 +6,10 @@
 | 
				
			|||||||
    <PackageId>DiscordHistoryTrackerUtils</PackageId>
 | 
					    <PackageId>DiscordHistoryTrackerUtils</PackageId>
 | 
				
			||||||
  </PropertyGroup>
 | 
					  </PropertyGroup>
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
 | 
					  <PropertyGroup>
 | 
				
			||||||
 | 
					    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
 | 
				
			||||||
 | 
					  </PropertyGroup>
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
  <ItemGroup>
 | 
					  <ItemGroup>
 | 
				
			||||||
    <FrameworkReference Include="Microsoft.AspNetCore.App" />
 | 
					    <FrameworkReference Include="Microsoft.AspNetCore.App" />
 | 
				
			||||||
  </ItemGroup>
 | 
					  </ItemGroup>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user