Skip to content

Commit b887084

Browse files
committedMar 2, 2019
Prepare for Version 0.0.1.0 Prerelease
1 parent b5379de commit b887084

File tree

7 files changed

+82
-16
lines changed

7 files changed

+82
-16
lines changed
 

‎WinDirStat.Net.Wpf.Single/App.config

-6
This file was deleted.

‎WinDirStat.Net.Wpf.Single/App.xaml.cs

+76-1
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,94 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Configuration;
4+
using System.Globalization;
5+
using System.IO;
46
using System.Linq;
7+
using System.Reflection;
58
using System.Threading.Tasks;
69
using System.Windows;
10+
using System.Windows.Media.Imaging;
711
using WinDirStat.Net.Wpf.Windows;
812

913
namespace WinDirStat.Net.Wpf {
1014
/// <summary>
11-
/// Interaction logic for App.xaml
15+
/// Interaction logic for App.xaml
1216
/// </summary>
1317
public partial class App : Application {
18+
#region Constants
1419

20+
private static readonly string[] assemblyExtensions = { ".dll", ".exe" };
21+
22+
#endregion
23+
24+
#region Constructors
25+
26+
/// <summary>
27+
/// Constructs the app and sets up embedded assembly resolving.
28+
/// </summary>
1529
public App() {
30+
AppDomain.CurrentDomain.AssemblyResolve += OnResolveAssemblies;
31+
// Call this to avoid referencing assemblies before the assembly resolver can be added.
32+
Initialize();
33+
}
34+
35+
/// <summary>
36+
/// Called to avoid referencing assemblies before the assembly resolver can be added.
37+
/// </summary>
38+
private void Initialize() {
39+
ErrorMessageBox.ProgramName = "WinDirStat.Net";
40+
ErrorMessageBox.HyperlinkName = "GitHub Page";
41+
ErrorMessageBox.HyperlinkUri = new Uri(@"https://github.com/trigger-death/WinDirStat.Net");
42+
ErrorMessageBox.ErrorIcon = new BitmapImage(new Uri("pack://application:,,,/Resources/App.ico"));
1643
ErrorMessageBox.GlobalHook(this);
1744
}
45+
46+
#endregion
47+
48+
#region Event Handlers
49+
50+
/// <summary>
51+
/// Resolves assemblies that may be embedded in the executable.
52+
/// </summary>
53+
private Assembly OnResolveAssemblies(object sender, ResolveEventArgs args) {
54+
AssemblyName assemblyName = new AssemblyName(args.Name);
55+
string assemblyPath;
56+
57+
if (TryResolveAssembly(assemblyName, out Assembly assembly))
58+
return assembly;
59+
assemblyPath = CultureInfo.CurrentCulture.TwoLetterISOLanguageName;
60+
if (TryResolveAssembly(assemblyPath, assemblyName, out assembly))
61+
return assembly;
62+
assemblyPath = CultureInfo.CurrentCulture.ToString();
63+
if (TryResolveAssembly(assemblyPath, assemblyName, out assembly))
64+
return assembly;
65+
66+
return null;
67+
}
68+
69+
#endregion
70+
71+
#region TryResolveAssembly
72+
73+
private bool TryResolveAssembly(AssemblyName assemblyName, out Assembly assembly) {
74+
return TryResolveAssembly(null, assemblyName, out assembly);
75+
}
76+
private bool TryResolveAssembly(string path, AssemblyName assemblyName, out Assembly assembly) {
77+
foreach (string ext in assemblyExtensions) {
78+
string startPath = Path.Combine(AppContext.BaseDirectory, "bin");
79+
if (path != null && !Path.IsPathRooted(path))
80+
startPath = Path.Combine(startPath, path);
81+
82+
path = Path.Combine(startPath, assemblyName.Name + ext);
83+
if (File.Exists(path)) {
84+
assembly = Assembly.LoadFile(path);
85+
return true;
86+
}
87+
}
88+
assembly = null;
89+
return false;
90+
}
91+
92+
#endregion
1893
}
1994
}

‎WinDirStat.Net.Wpf.Single/MainWindow.xaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
DataContext="{Binding Main, Source={StaticResource Locator}}"
1818
Title="{Binding Title}" Height="450" Width="800" SnapsToDevicePixels="True" UseLayoutRounding="True" Background="#FFF0F0F0"
1919
Loaded="OnLoaded"
20-
Icon="App.ico"
20+
Icon="Resources/App.ico"
2121
cmd:RelayInfo.Collection="{StaticResource MainCommands}">
2222
<Window.Resources>
2323
<ResourceDictionary>

‎WinDirStat.Net.Wpf.Single/Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
// You can specify all the values or you can default the Build and Revision Numbers
5252
// by using the '*' as shown below:
5353
// [assembly: AssemblyVersion("1.0.*")]
54-
[assembly: AssemblyVersion("1.0.0.0")]
55-
[assembly: AssemblyFileVersion("1.0.0.0")]
54+
[assembly: AssemblyVersion("0.0.1.0")]
55+
[assembly: AssemblyFileVersion("0.0.1.0")]
5656
[assembly: NeutralResourcesLanguage("en-US")]
5757

File renamed without changes.

‎WinDirStat.Net.Wpf.Single/WinDirStat.Net.Wpf.Single.csproj

+2-5
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<LangVersion>latest</LangVersion>
4040
</PropertyGroup>
4141
<PropertyGroup>
42-
<ApplicationIcon>App.ico</ApplicationIcon>
42+
<ApplicationIcon>Resources\App.ico</ApplicationIcon>
4343
</PropertyGroup>
4444
<PropertyGroup>
4545
<ApplicationManifest>Properties\App.manifest</ApplicationManifest>
@@ -181,9 +181,6 @@
181181
</Compile>
182182
<None Include="Properties\App.manifest" />
183183
</ItemGroup>
184-
<ItemGroup>
185-
<None Include="App.config" />
186-
</ItemGroup>
187184
<ItemGroup>
188185
<ProjectReference Include="..\FunctionalFun.UI.Behaviours\FunctionalFun.UI.Behaviors.csproj">
189186
<Project>{7da5a107-b474-4ac0-b861-63a489db0c02}</Project>
@@ -288,7 +285,7 @@
288285
<Resource Include="Resources\Icons\ShowTotalSpace.png" />
289286
</ItemGroup>
290287
<ItemGroup>
291-
<Resource Include="App.ico" />
288+
<Resource Include="Resources\App.ico" />
292289
</ItemGroup>
293290
<ItemGroup>
294291
<Resource Include="Resources\FileIcons\Missing.png" />

‎WinDirStat.Net.Wpf.Single/Windows/DriveSelectDialog.xaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
1212
mc:Ignorable="d"
1313
DataContext="{Binding DriveSelect, Source={StaticResource Locator}}"
14-
Title="{Binding Title}" Height="313" Width="435" SourceInitialized="OnSourceInitialized" Loaded="OnLoaded" Icon="/WinDirStat.Net;component/App.ico" WindowStartupLocation="CenterOwner"
14+
Title="{Binding Title}" Height="313" Width="435" SourceInitialized="OnSourceInitialized" Loaded="OnLoaded" Icon="/WinDirStat.Net;component/Resources/App.ico" WindowStartupLocation="CenterOwner"
1515
Background="#FFF0F0F0" SnapsToDevicePixels="True" UseLayoutRounding="True" ShowInTaskbar="False">
1616
<Window.Resources>
1717
<ResourceDictionary>

0 commit comments

Comments
 (0)
Please sign in to comment.