Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(GH-3227) Fix for ThemeManager: dynamic accents only work once #3231

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/Directory.build.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<ItemGroup>
<None Remove="**\*.png;**\*.jpg;**\*.ico"/>
<Resource Include="**\*.png;**\*.jpg;**\*.ico"/>
<Compile DependentUpon="%(Filename)" SubType="Code" Update="**\*.g$(_SdkLanguageExtension)"/>
</ItemGroup>
<!-- workaround for https://github.com/NuGet/Home/issues/5894 -->
<Import Condition=" '$(MSBuildProjectExtension)' == '.tmp_proj'" Project="obj\*.targets"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,27 @@
</PropertyGroup>
<PropertyGroup>
<OutputType>WinExe</OutputType>
<StartupObject/>
<StartupObject />
<NoWarn>SA1652</NoWarn>
<ApplicationIcon>mahapps.metro.logo2.ico</ApplicationIcon>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\MahApps.Metro\MahApps.Metro.csproj"/>
<ProjectReference Include="..\..\MahApps.Metro\MahApps.Metro.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.ComponentModel.Composition"/>
<Reference Include="System.ComponentModel.Composition" />
</ItemGroup>
<ItemGroup>
<None Include="app.manifest"/>
<None Include="paket.references"/>
<None Remove="App.config"/>
<None Include="app.manifest" />
<None Include="paket.references" />
<None Remove="App.config" />
<AppConfigWithTargetPath Include="App.$(TargetFramework).config">
<TargetPath>$(AssemblyName).config</TargetPath>
</AppConfigWithTargetPath>
</ItemGroup>
<Import Project="..\..\.paket\Paket.Restore.targets"/>
<ItemGroup>
<Compile DependentUpon="%(Filename)" SubType="Code" Update="$(MSBuildProjectDirectory)\obj\**\*.g$(_SdkLanguageExtension)" />
</ItemGroup>
<Import Project="..\..\.paket\Paket.Restore.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,32 @@
</PropertyGroup>
<PropertyGroup>
<OutputType>WinExe</OutputType>
<StartupObject/>
<StartupObject />
<NoWarn>SA1652</NoWarn>
<ApplicationIcon>mahapps.metro.logo2.ico</ApplicationIcon>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\MahApps.Metro\MahApps.Metro.csproj"/>
<ProjectReference Include="..\..\MahApps.Metro\MahApps.Metro.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.ComponentModel.DataAnnotations"/>
<Reference Include="System.Configuration"/>
<Reference Include="System.Data.DataSetExtensions"/>
<Reference Include="System.Data"/>
<Reference Include="System.Windows.Forms"/>
<Reference Include="WindowsFormsIntegration"/>
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Windows.Forms" />
<Reference Include="WindowsFormsIntegration" />
</ItemGroup>
<ItemGroup>
<None Include="app.manifest"/>
<None Include="paket.references"/>
<None Remove="App.config"/>
<None Include="app.manifest" />
<None Include="paket.references" />
<None Remove="App.config" />
<AppConfigWithTargetPath Include="App.$(TargetFramework).config">
<TargetPath>$(AssemblyName).config</TargetPath>
</AppConfigWithTargetPath>
</ItemGroup>
<Import Project="..\..\.paket\Paket.Restore.targets"/>
<ItemGroup>
<Compile DependentUpon="%(Filename)" SubType="Code" Update="$(MSBuildProjectDirectory)\obj\**\*.g$(_SdkLanguageExtension)" />
</ItemGroup>
<Import Project="..\..\.paket\Paket.Restore.targets" />
</Project>
6 changes: 6 additions & 0 deletions src/MahApps.Metro.sln
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MahApps.Metro.Caliburn.Demo
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MahApps.Metro.Tests", "Mahapps.Metro.Tests\MahApps.Metro.Tests.csproj", "{40048BCF-D1C7-46CC-B781-05718BE25BFC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EC5373FC-2098-4D7B-8990-B15E9C631AE8}"
ProjectSection(SolutionItems) = preProject
Directory.build.props = Directory.build.props
Directory.build.targets = Directory.build.targets
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
11 changes: 7 additions & 4 deletions src/MahApps.Metro/MahApps.Metro.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System.ComponentModel.DataAnnotations"/>
<Reference Include="System.Configuration"/>
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration" />
</ItemGroup>
<!-- Items include -->
<ItemGroup>
<None Include="paket.references"/>
<None Include="paket.references" />
</ItemGroup>
<Import Project="..\.paket\Paket.Restore.targets"/>
<ItemGroup>
<Compile DependentUpon="%(Filename)" SubType="Code" Update="$(MSBuildProjectDirectory)\obj\**\*.g$(_SdkLanguageExtension)" />
</ItemGroup>
<Import Project="..\.paket\Paket.Restore.targets" />
</Project>
23 changes: 20 additions & 3 deletions src/MahApps.Metro/ThemeManager/Accent.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// ReSharper disable once CheckNamespace

namespace MahApps.Metro
{
using System;
using System.Diagnostics;
using System.Windows;
using JetBrains.Annotations;

/// <summary>
/// An object that represents the foreground color for a <see cref="AppTheme"/>.
Expand All @@ -25,20 +27,35 @@ public class Accent
/// Initializes a new instance of the Accent class.
/// </summary>
public Accent()
{ }
{
}

/// <summary>
/// Initializes a new instance of the Accent class.
/// </summary>
/// <param name="name">The name of the new Accent.</param>
/// <param name="resourceAddress">The URI of the accent ResourceDictionary.</param>
public Accent(string name, Uri resourceAddress)
public Accent([NotNull] string name, [NotNull] Uri resourceAddress)
{
if (name == null) throw new ArgumentNullException(nameof(name));
if (resourceAddress == null) throw new ArgumentNullException(nameof(resourceAddress));

this.Name = name;
this.Resources = new ResourceDictionary {Source = resourceAddress};
this.Resources = new ResourceDictionary { Source = resourceAddress };
}

/// <summary>
/// Initializes a new instance of the Accent class.
/// </summary>
/// <param name="name">The name of the new Accent.</param>
/// <param name="resourceDictionary">The ResourceDictionary of the accent.</param>
public Accent([NotNull] string name, [NotNull] ResourceDictionary resourceDictionary)
{
if (name == null) throw new ArgumentNullException(nameof(name));
if (resourceDictionary == null) throw new ArgumentNullException(nameof(resourceDictionary));

this.Name = name;
this.Resources = resourceDictionary;
}
}
}
24 changes: 20 additions & 4 deletions src/MahApps.Metro/ThemeManager/AppTheme.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// ReSharper disable once CheckNamespace

namespace MahApps.Metro
{
using System;
using System.Diagnostics;
using System.Windows;
using JetBrains.Annotations;

internal class AppName
{
Expand All @@ -19,7 +21,7 @@ public class AppTheme
/// <summary>
/// The ResourceDictionary that represents this application theme.
/// </summary>
public ResourceDictionary Resources {get; }
public ResourceDictionary Resources { get; }

/// <summary>
/// Gets the name of the application theme.
Expand All @@ -30,14 +32,28 @@ public class AppTheme
/// Initializes a new instance of the AppTheme class.
/// </summary>
/// <param name="name">The name of the new AppTheme.</param>
/// <param name="resourceAddress">The URI of the accent ResourceDictionary.</param>
public AppTheme(string name, Uri resourceAddress)
/// <param name="resourceAddress">The URI of the AppTheme ResourceDictionary.</param>
public AppTheme([NotNull] string name, [NotNull] Uri resourceAddress)
{
if (name == null) throw new ArgumentNullException(nameof(name));
if (resourceAddress == null) throw new ArgumentNullException(nameof(resourceAddress));

this.Name = name;
this.Resources = new ResourceDictionary {Source = resourceAddress};
this.Resources = new ResourceDictionary { Source = resourceAddress };
}

/// <summary>
/// Initializes a new instance of the AppTheme class.
/// </summary>
/// <param name="name">The name of the new AppTheme.</param>
/// <param name="resourceDictionary">The ResourceDictionary of the accent.</param>
public AppTheme([NotNull] string name, [NotNull] ResourceDictionary resourceDictionary)
{
if (name == null) throw new ArgumentNullException(nameof(name));
if (resourceDictionary == null) throw new ArgumentNullException(nameof(resourceDictionary));

this.Name = name;
this.Resources = resourceDictionary;
}
}
}
Loading