Skip to content

Commit f4bb19f

Browse files
batzenpunker76
authored andcommitted
Fixing a few issues in ThemeManager (#2992)
* Just a few code style and documentation changes * We always apply the new theme and accent even if old ones are not found * If style detection fails on window try on application * Look at merged dictionaries the way wpf does (in reverse order) * Using null conditional operator and adding missing documentation * Using string interpolation * Using nameof instead of hard coded strings * Using OrdinalIgnoreCase instead of InvariantCultureIgnoreCase * Removing empty parameter documentation * Adding missing documentation * Fixing documentation text * Removing "metro" to make porting/sharing of class easier * Making ReSharper happy
1 parent 543e1b2 commit f4bb19f

File tree

3 files changed

+112
-82
lines changed

3 files changed

+112
-82
lines changed
Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,44 @@
1-
using System;
2-
using System.Diagnostics;
3-
using System.Windows;
4-
1+
// ReSharper disable once CheckNamespace
52
namespace MahApps.Metro
63
{
4+
using System;
5+
using System.Diagnostics;
6+
using System.Windows;
7+
78
/// <summary>
8-
/// An object that represents the foreground color for a Metro <see cref="AppTheme"/>.
9+
/// An object that represents the foreground color for a <see cref="AppTheme"/>.
910
/// </summary>
1011
[DebuggerDisplay("accent={Name}, res={Resources.Source}")]
1112
public class Accent
1213
{
1314
/// <summary>
1415
/// The ResourceDictionary that represents this Accent.
1516
/// </summary>
16-
public ResourceDictionary Resources;
17+
public ResourceDictionary Resources { get; set; }
18+
1719
/// <summary>
1820
/// Gets/sets the name of the Accent.
1921
/// </summary>
2022
public string Name { get; set; }
2123

2224
/// <summary>
23-
/// Initializes a new instance of the MahApps.Metro.Accent class.
25+
/// Initializes a new instance of the Accent class.
2426
/// </summary>
2527
public Accent()
2628
{ }
2729

2830
/// <summary>
29-
/// Initializes a new instance of the MahApps.Metro.Accent class.
31+
/// Initializes a new instance of the Accent class.
3032
/// </summary>
3133
/// <param name="name">The name of the new Accent.</param>
3234
/// <param name="resourceAddress">The URI of the accent ResourceDictionary.</param>
3335
public Accent(string name, Uri resourceAddress)
3436
{
35-
if (name == null) throw new ArgumentException("name");
36-
if (resourceAddress == null) throw new ArgumentNullException("resourceAddress");
37+
if (name == null) throw new ArgumentNullException(nameof(name));
38+
if (resourceAddress == null) throw new ArgumentNullException(nameof(resourceAddress));
3739

38-
Name = name;
39-
Resources = new ResourceDictionary {Source = resourceAddress};
40+
this.Name = name;
41+
this.Resources = new ResourceDictionary {Source = resourceAddress};
4042
}
4143
}
4244
}

src/MahApps.Metro/MahApps.Metro.Shared/ThemeManager/AppTheme.cs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
using System;
2-
using System.Diagnostics;
3-
using System.Windows;
4-
1+
// ReSharper disable once CheckNamespace
52
namespace MahApps.Metro
63
{
4+
using System;
5+
using System.Diagnostics;
6+
using System.Windows;
7+
78
internal class AppName
89
{
910
public const string MahApps = "MahApps.Metro";
@@ -18,17 +19,22 @@ public class AppTheme
1819
/// <summary>
1920
/// The ResourceDictionary that represents this application theme.
2021
/// </summary>
21-
public ResourceDictionary Resources {get; private set;}
22+
public ResourceDictionary Resources {get; }
2223

2324
/// <summary>
2425
/// Gets the name of the application theme.
2526
/// </summary>
26-
public string Name { get; private set; }
27+
public string Name { get; }
2728

29+
/// <summary>
30+
/// Initializes a new instance of the AppTheme class.
31+
/// </summary>
32+
/// <param name="name">The name of the new AppTheme.</param>
33+
/// <param name="resourceAddress">The URI of the accent ResourceDictionary.</param>
2834
public AppTheme(string name, Uri resourceAddress)
2935
{
30-
if (name == null) throw new ArgumentException("name");
31-
if (resourceAddress == null) throw new ArgumentNullException("resourceAddress");
36+
if (name == null) throw new ArgumentNullException(nameof(name));
37+
if (resourceAddress == null) throw new ArgumentNullException(nameof(resourceAddress));
3238

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

0 commit comments

Comments
 (0)