Improve guards for theme loading
This commit is contained in:
parent
367c3b67eb
commit
819d7ef453
2 changed files with 13 additions and 3 deletions
|
|
@ -159,7 +159,7 @@ namespace MatterHackers.MatterControl
|
|||
if (themeset == null)
|
||||
{
|
||||
var themeProvider = ThemeProviders.Values.First();
|
||||
themeset = themeProvider.GetTheme("Dark", themeProvider.DefaultColor);
|
||||
themeset = themeProvider.GetTheme(themeProvider.ThemeNames.First(), themeProvider.DefaultColor);
|
||||
}
|
||||
|
||||
DefaultThumbView.ThumbColor = new Color(themeset.Theme.Colors.PrimaryTextColor, 30);
|
||||
|
|
|
|||
|
|
@ -79,8 +79,18 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
public ThemeSet GetTheme(string themeName, Color accentColor)
|
||||
{
|
||||
var themeset = JsonConvert.DeserializeObject<ThemeSet>(
|
||||
AggContext.StaticData.ReadAllText(Path.Combine(path, themeName + ".json")));
|
||||
ThemeSet themeset = null;
|
||||
|
||||
try
|
||||
{
|
||||
themeset = JsonConvert.DeserializeObject<ThemeSet>(
|
||||
AggContext.StaticData.ReadAllText(Path.Combine(path, themeName + ".json")));
|
||||
}
|
||||
catch
|
||||
{
|
||||
themeset = JsonConvert.DeserializeObject<ThemeSet>(
|
||||
AggContext.StaticData.ReadAllText(Path.Combine(path, this.ThemeNames.First() + ".json")));
|
||||
}
|
||||
|
||||
themeset.ThemeID = themeName;
|
||||
themeset.SetAccentColor(accentColor);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue