Skip to content

Commit 23edcbd

Browse files
committed
Show error nicely when setting wallpaper fails
1 parent 5b8eeae commit 23edcbd

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

scripts/installer.iss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Name: "finnish"; MessagesFile: "compiler:Languages\Finnish.isl"
5050
Name: "french"; MessagesFile: "compiler:Languages\French.isl"
5151
Name: "german"; MessagesFile: "compiler:Languages\German.isl"
5252
Name: "hebrew"; MessagesFile: "compiler:Languages\Hebrew.isl"
53+
Name: "hungarian"; MessagesFile: "compiler:Languages\Hungarian.isl"
5354
Name: "icelandic"; MessagesFile: "compiler:Languages\Icelandic.isl"
5455
Name: "italian"; MessagesFile: "compiler:Languages\Italian.isl"
5556
Name: "japanese"; MessagesFile: "compiler:Languages\Japanese.isl"

src/EventScheduler.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,16 +174,26 @@ private void HandleDisplayEvent(DisplayEvent e)
174174
}
175175
}
176176

177-
LoggingHandler.LogMessage("Setting wallpaper to {0}", imagePath);
178-
if (e.displayIndex != DisplayEvent.LockScreenIndex)
177+
LoggingHandler.LogMessage("Setting wallpaper to {0}@{1}", imagePath, e.displayIndex);
178+
try
179179
{
180-
UwpDesktop.GetHelper().SetWallpaper(imagePath, e.displayIndex);
180+
if (e.displayIndex != DisplayEvent.LockScreenIndex)
181+
{
182+
UwpDesktop.GetHelper().SetWallpaper(imagePath, e.displayIndex);
183+
}
184+
else
185+
{
186+
UwpDesktop.GetHelper().SetLockScreen(imagePath);
187+
}
188+
e.lastImagePath = imagePath;
181189
}
182-
else
190+
catch (Exception exc)
183191
{
184-
UwpDesktop.GetHelper().SetLockScreen(imagePath);
192+
LoggingHandler.LogMessage("Error setting wallpaper: {0}", exc.ToString());
193+
MessageDialog.ShowWarning(string.Format(Localization.GetTranslation(
194+
"Error occurred when setting wallpaper '{0}':\n\n{1}"),
195+
Path.GetRelativePath(Environment.CurrentDirectory, imagePath), exc.ToString()));
185196
}
186-
e.lastImagePath = imagePath;
187197
}
188198

189199
private void StartTimer(DateTime futureTime)

src/ThemeDialog.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,8 @@ private void ThemeDialog_Load(object sender, EventArgs e)
394394
themeId => themeId != null) ?? -1;
395395
displayComboBox.SelectedIndex = activeThemeIndex != -1 ? activeThemeIndex : 0;
396396

397-
string activeTheme = JsonConfig.settings.activeThemes?[displayComboBox.SelectedIndex];
397+
string activeTheme = JsonConfig.IsNullOrEmpty(JsonConfig.settings.activeThemes) ? null :
398+
JsonConfig.settings.activeThemes[displayComboBox.SelectedIndex];
398399
string focusTheme = activeTheme ?? "";
399400
if (activeTheme == null && JsonConfig.firstRun)
400401
{

0 commit comments

Comments
 (0)