-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
70 changed files
with
8,850 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<configSections> | ||
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> | ||
<section name="DevModManager.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> | ||
</sectionGroup> | ||
</configSections> | ||
<applicationSettings> | ||
<DevModManager.Properties.Settings> | ||
<setting name="ProbingPaths" serializeAs="String"> | ||
<value>lib;locale</value> | ||
</setting> | ||
<setting name="version" serializeAs="String"> | ||
<value>0.0.8</value> | ||
</setting> | ||
</DevModManager.Properties.Settings> | ||
</applicationSettings> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<Application x:Class="DevModManager.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
<Application.Resources> | ||
<!-- Application resource dictionary --> | ||
</Application.Resources> | ||
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Reflection; | ||
using System.Runtime.Loader; | ||
using System.Windows; | ||
|
||
namespace DevModManager | ||
{ | ||
/// <summary> | ||
/// Interaction logic for App.xaml | ||
/// </summary> | ||
public partial class App : Application | ||
{ | ||
public App() | ||
{ | ||
AssemblyLoadContext.Default.Resolving += OnAssemblyResolve; | ||
} | ||
|
||
protected override void OnStartup(StartupEventArgs e) | ||
{ | ||
base.OnStartup(e); | ||
Debug.WriteLine("Application_Startup called"); | ||
|
||
try | ||
{ | ||
// Set the probing paths before any other DLLs are loaded | ||
string probingPaths = DevModManager.Properties.Settings.Default.ProbingPaths; | ||
AppDomain.CurrentDomain.SetData("PROBING_DIRECTORIES", probingPaths); | ||
|
||
// Initialize the database | ||
Debug.WriteLine("Initializing database..."); | ||
DbManager.Instance.Initialize(); | ||
Debug.WriteLine("Database initialized."); | ||
|
||
// Initialize the configuration | ||
Debug.WriteLine("Initializing configuration..."); | ||
Config.Initialize(); | ||
Debug.WriteLine("Configuration initialized."); | ||
|
||
// Check if the database is correctly initialized | ||
if (DbManager.Instance.IsDatabaseInitialized()) | ||
{ | ||
// Open MainWindow if the database is initialized | ||
Debug.WriteLine("Database initialized. Opening MainWindow."); | ||
var mainWindow = new MainWindow(); | ||
mainWindow.Show(); | ||
} | ||
else | ||
{ | ||
// The DbManager should handle showing the SettingsWindow if needed | ||
Debug.WriteLine("Database not initialized. DbManager will handle SettingsWindow."); | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
Debug.WriteLine($"Exception during startup: {ex.Message}"); | ||
_ = MessageBox.Show($"An error occurred during startup: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error); | ||
Shutdown(); | ||
} | ||
} | ||
|
||
private void RestartApplication() | ||
{ | ||
var exePath = Process.GetCurrentProcess().MainModule?.FileName; | ||
if (exePath != null) | ||
{ | ||
_ = Process.Start(exePath); | ||
Shutdown(); | ||
} | ||
} | ||
|
||
private static Assembly? OnAssemblyResolve(AssemblyLoadContext context, AssemblyName assemblyName) | ||
{ | ||
string probingPaths = DevModManager.Properties.Settings.Default.ProbingPaths; | ||
string[] paths = probingPaths.Split(';'); | ||
|
||
foreach (string path in paths) | ||
{ | ||
string assemblyPath = Path.Combine(AppContext.BaseDirectory, path, $"{assemblyName.Name}.dll"); | ||
|
||
if (File.Exists(assemblyPath)) | ||
{ | ||
return context.LoadFromAssemblyPath(assemblyPath); | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.Windows; | ||
|
||
[assembly: ThemeInfo( | ||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located | ||
//(used if a resource is not found in the page, | ||
// or application resource dictionaries) | ||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located | ||
//(used if a resource is not found in the page, | ||
// app, or any theme specific resource dictionaries) | ||
)] |
Oops, something went wrong.