|
|
@@ -1,21 +1,28 @@
|
|
|
-using PicView.ChangeImage;
|
|
|
+using Microsoft.Win32;
|
|
|
+using PicView.ChangeImage;
|
|
|
using PicView.ChangeTitlebar;
|
|
|
using PicView.FileHandling;
|
|
|
using PicView.ImageHandling;
|
|
|
using PicView.UILogic;
|
|
|
using System.Diagnostics;
|
|
|
using System.IO;
|
|
|
+using System.Runtime.InteropServices;
|
|
|
using System.Windows;
|
|
|
using System.Windows.Input;
|
|
|
using System.Windows.Media.Imaging;
|
|
|
-using Windows.Storage;
|
|
|
-using Windows.System.UserProfile;
|
|
|
+using PicView.ProcessHandling;
|
|
|
+
|
|
|
+//using Windows.Storage;
|
|
|
+//using Windows.System.UserProfile;
|
|
|
using Rotation = PicView.UILogic.TransformImage.Rotation;
|
|
|
|
|
|
namespace PicView.SystemIntegration;
|
|
|
|
|
|
public static class LockScreenHelper
|
|
|
{
|
|
|
+ [DllImport("kernel32.dll", SetLastError = true)]
|
|
|
+ public static extern bool Wow64DisableWow64FsRedirection(ref IntPtr ptr); //If on 64 bit, C# will replace "System32" with "SysWOW64". This disables that.
|
|
|
+
|
|
|
public static async Task<bool> SetLockScreenImageAsync(string? path = null)
|
|
|
{
|
|
|
var url = string.Empty;
|
|
|
@@ -26,7 +33,7 @@ public static class LockScreenHelper
|
|
|
Application.Current.MainWindow!.Cursor = Cursors.Wait;
|
|
|
});
|
|
|
|
|
|
- string? folderPath, fileName;
|
|
|
+ string destinationPath;
|
|
|
var hasEffect = ConfigureWindows.GetMainWindow.MainImage.Effect != null;
|
|
|
var rotationAngle = Rotation.RotationAngle;
|
|
|
var isFlipped = Rotation.IsFlipped;
|
|
|
@@ -59,8 +66,7 @@ public static class LockScreenHelper
|
|
|
{
|
|
|
// Create a temporary directory
|
|
|
var tempDirectory = Path.GetTempPath();
|
|
|
- var tempFileName = Path.GetRandomFileName();
|
|
|
- var destinationPath = Path.Combine(tempDirectory, tempFileName);
|
|
|
+ destinationPath = Path.Combine(tempDirectory, Path.GetFileNameWithoutExtension(path) + ".jpg");
|
|
|
|
|
|
BitmapSource? bitmapSource = null;
|
|
|
string? imagePath = null;
|
|
|
@@ -75,24 +81,18 @@ public static class LockScreenHelper
|
|
|
}
|
|
|
|
|
|
await SaveImages.SaveImageAsync(rotationAngle, isFlipped, bitmapSource, imagePath, destinationPath, null, hasEffect).ConfigureAwait(false);
|
|
|
-
|
|
|
- folderPath = Path.GetDirectoryName(destinationPath);
|
|
|
- fileName = Path.GetFileName(destinationPath);
|
|
|
+ path = destinationPath;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- folderPath = Path.GetDirectoryName(Navigation.Pics[Navigation.FolderIndex]);
|
|
|
- fileName = Path.GetFileName(Navigation.Pics[Navigation.FolderIndex]);
|
|
|
+ path = Navigation.Pics[Navigation.FolderIndex];
|
|
|
}
|
|
|
|
|
|
try
|
|
|
{
|
|
|
Tooltip.ShowTooltipMessage(Application.Current.Resources["Applying"]);
|
|
|
- var storageFolder = await StorageFolder.GetFolderFromPathAsync(folderPath);
|
|
|
- var imageFile = await storageFolder.GetFileAsync(fileName);
|
|
|
|
|
|
- using var stream = await imageFile.OpenAsync(FileAccessMode.Read);
|
|
|
- await LockScreen.SetImageStreamAsync(stream);
|
|
|
+ ProcessLogic.RunElevated("PicView.Tools.exe", "lockscreen," + path);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|