Skip to content

Commit

Permalink
Remove actions from UWP app that require editing registry keys
Browse files Browse the repository at this point in the history
  • Loading branch information
t1m0thyj committed Jun 2, 2019
1 parent ffc318e commit 2dc4e49
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/DesktopHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,13 @@ public override void OpenUpdateLink()
{
System.Diagnostics.Process.Start(updateLink);
}

public override void SetWallpaper(string imageFilename)
{
string imagePath = Path.Combine(Directory.GetCurrentDirectory(), "themes",
ThemeManager.currentTheme.themeId, imageFilename);

WallpaperApi.SetWallpaper(imagePath);
}
}
}
2 changes: 1 addition & 1 deletion src/SystemThemeChanger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static List<ToolStripItem> GetMenuItems()
{
RegistryKey themeKey = Registry.CurrentUser.OpenSubKey(registryThemeLocation);

if (themeKey != null)
if (!UwpDesktop.IsRunningAsUwp() && (themeKey != null))
{
themeKey.Close();

Expand Down
2 changes: 2 additions & 0 deletions src/UwpDesktop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ abstract class PlatformHelper
public abstract void ToggleStartOnBoot();

public abstract void OpenUpdateLink();

public abstract void SetWallpaper(string imageFilename);
}

class UwpDesktop
Expand Down
11 changes: 11 additions & 0 deletions src/UwpHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@ await Windows.System.Launcher.LaunchUriAsync(
new Uri("ms-windows-store://downloadsandupdates"));
}

public override async void SetWallpaper(string imageFilename)
{
var uri = new Uri("ms-appdata:///local/themes/" + ThemeManager.currentTheme.themeId +
"/" + imageFilename);
var file = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(uri);

var profileSettings =
Windows.System.UserProfile.UserProfilePersonalizationSettings.Current;
await profileSettings.TrySetWallpaperImageAsync(file);
}

public static async void SetLockScreenImage(string imageFilename)
{
var uri = new Uri("ms-appdata:///local/themes/" + ThemeManager.currentTheme.themeId +
Expand Down
2 changes: 1 addition & 1 deletion src/WallpaperChangeScheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private void SetWallpaper(int imageId)
return;
}

WallpaperApi.SetWallpaper(imagePath);
UwpDesktop.GetHelper().SetWallpaper(imageFilename);

if (UwpDesktop.IsRunningAsUwp() && JsonConfig.settings.changeLockScreen)
{
Expand Down

0 comments on commit 2dc4e49

Please sign in to comment.