simplify object initialisers

This commit is contained in:
Jack Baron 2020-11-16 14:03:46 +00:00
parent d4753910f4
commit 1c0f6dcaba
No known key found for this signature in database
GPG key ID: CD10BCEEC646C064
2 changed files with 32 additions and 15 deletions

View file

@ -44,8 +44,11 @@ namespace ModAssistant.API
return null; return null;
} }
BeatSaverMap map = new BeatSaverMap(); BeatSaverMap map = new BeatSaverMap
map.Success = false; {
Success = false
};
if (showNotification) Utils.SetMessage($"{string.Format((string)Application.Current.FindResource("OneClick:Installing"), id)}"); if (showNotification) Utils.SetMessage($"{string.Format((string)Application.Current.FindResource("OneClick:Installing"), id)}");
try try
{ {

View file

@ -49,20 +49,27 @@ namespace ModAssistant
string location = $"Themes/{localTheme}.xaml"; string location = $"Themes/{localTheme}.xaml";
Uri local = new Uri(location, UriKind.Relative); Uri local = new Uri(location, UriKind.Relative);
ResourceDictionary localDictionary = new ResourceDictionary(); ResourceDictionary localDictionary = new ResourceDictionary
localDictionary.Source = local; {
Source = local
};
/* /*
* Load any Waifus that come with these built-in themes, too. * Load any Waifus that come with these built-in themes, too.
* The format must be: Background.png and Sidebar.png as a subfolder with the same name as the theme name. * The format must be: Background.png and Sidebar.png as a subfolder with the same name as the theme name.
* For example: "Themes/Dark/Background.png", or "Themes/Ugly Kulu-Ya-Ku/Sidebar.png" * For example: "Themes/Dark/Background.png", or "Themes/Ugly Kulu-Ya-Ku/Sidebar.png"
*/ */
Waifus waifus = new Waifus(); Waifus waifus = new Waifus
waifus.Background = GetImageFromEmbeddedResources(localTheme, "Background"); {
waifus.Sidebar = GetImageFromEmbeddedResources(localTheme, "Sidebar"); Background = GetImageFromEmbeddedResources(localTheme, "Background"),
Sidebar = GetImageFromEmbeddedResources(localTheme, "Sidebar")
};
Theme theme = new Theme(localTheme, localDictionary)
{
Waifus = waifus
};
Theme theme = new Theme(localTheme, localDictionary);
theme.Waifus = waifus;
loadedThemes.Add(localTheme, theme); loadedThemes.Add(localTheme, theme);
} }
@ -250,8 +257,10 @@ namespace ModAssistant
/// <returns></returns> /// <returns></returns>
private static Theme LoadTheme(string directory, string name) private static Theme LoadTheme(string directory, string name)
{ {
Theme theme = new Theme(name, null); Theme theme = new Theme(name, null)
theme.Waifus = new Waifus(); {
Waifus = new Waifus()
};
foreach (string file in Directory.EnumerateFiles(directory).OrderBy(x => x)) foreach (string file in Directory.EnumerateFiles(directory).OrderBy(x => x))
{ {
@ -275,8 +284,11 @@ namespace ModAssistant
try try
{ {
Uri resourceSource = new Uri(info.FullName); Uri resourceSource = new Uri(info.FullName);
ResourceDictionary dictionary = new ResourceDictionary(); ResourceDictionary dictionary = new ResourceDictionary
dictionary.Source = resourceSource; {
Source = resourceSource
};
theme.ThemeDictionary = dictionary; theme.ThemeDictionary = dictionary;
} }
catch (Exception ex) catch (Exception ex)
@ -405,8 +417,10 @@ namespace ModAssistant
} }
} }
Theme theme = new Theme(name, dictionary); Theme theme = new Theme(name, dictionary)
theme.Waifus = waifus; {
Waifus = waifus
};
return theme; return theme;
} }