update data folders

This commit is contained in:
seraphima
2024-06-12 17:52:04 +02:00
parent 7e93d1f767
commit 6fba21d9ad
5 changed files with 45 additions and 27 deletions

View File

@@ -136,20 +136,19 @@ namespace ProjectsEditor.ViewModels
private void CreateShortcut(Project project)
{
object shDesktop = (object)"Desktop";
IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShell();
string shortcutAddress = (string)shell.SpecialFolders.Item(ref shDesktop) + $"\\{project.Name}.lnk";
IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(shortcutAddress);
shortcut.Description = $"Project Launcher {project.Id}";
string basePath = AppDomain.CurrentDomain.BaseDirectory;
shortcut.TargetPath = Path.Combine(basePath, "PowerToys.ProjectsLauncher.exe");
shortcut.Arguments = '"' + project.Id + '"';
shortcut.WorkingDirectory = basePath;
string shortcutAddress = FolderUtils.Desktop() + $"\\{project.Name}.lnk";
string shortcutIconFilename = FolderUtils.Temp() + $"\\{project.Name}.ico";
string shortcutIconFilename = (string)shell.SpecialFolders.Item(ref shDesktop) + $"\\{project.Name}.ico";
Bitmap icon = ProjectIcon.DrawIcon(ProjectIcon.IconTextFromProjectName(project.Name));
ProjectIcon.SaveIcon(icon, shortcutIconFilename);
IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShell();
IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(shortcutAddress);
shortcut.Description = $"Project Launcher {project.Id}";
shortcut.TargetPath = Path.Combine(basePath, "PowerToys.ProjectsLauncher.exe");
shortcut.Arguments = '"' + project.Id + '"';
shortcut.WorkingDirectory = basePath;
shortcut.IconLocation = shortcutIconFilename;
shortcut.Save();
}