Merge branch 'dev/feature/projects' of https://github.com/microsoft/PowerToys into dev/feature/projects

This commit is contained in:
donlaci
2024-06-19 11:03:55 +02:00
14 changed files with 98 additions and 16 deletions

View File

@@ -192,6 +192,7 @@
"PowerToys.ProjectsSnapshotTool.exe",
"PowerToys.ProjectsLauncher.exe",
"PowerToys.ProjectsEditor.exe",
"PowerToys.ProjectsEditor.dll",
"PowerToys.ProjectsModuleInterface.dll",
"WinUI3Apps\\PowerToys.RegistryPreviewExt.dll",

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

@@ -1,4 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\Version.props" />
<PropertyGroup>
<AssemblyTitle>PowerToys.ProjectsEditor</AssemblyTitle>
<AssemblyDescription>PowerToys Projects Editor</AssemblyDescription>
@@ -60,6 +61,15 @@
<Isolated>false</Isolated>
<EmbedInteropTypes>true</EmbedInteropTypes>
</COMReference>
<COMReference Include="Shell32">
<WrapperTool>tlbimp</WrapperTool>
<VersionMinor>0</VersionMinor>
<VersionMajor>1</VersionMajor>
<Guid>50a7e9b0-70ef-11d1-b75a-00a0c90564fe</Guid>
<Lcid>0</Lcid>
<Isolated>false</Isolated>
<EmbedInteropTypes>true</EmbedInteropTypes>
</COMReference>
</ItemGroup>
<ItemGroup>
<Content Include="images\DefaultIcon.ico">

View File

@@ -84,7 +84,12 @@ namespace ProjectsEditor.Utils
public static void SaveIcon(Bitmap icon, string path)
{
FileStream fileStream = new FileStream(path, FileMode.OpenOrCreate);
if (Path.Exists(path))
{
File.Delete(path);
}
FileStream fileStream = new FileStream(path, FileMode.CreateNew);
using (var memoryStream = new MemoryStream())
{
icon.Save(memoryStream, ImageFormat.Png);

View File

@@ -159,20 +159,36 @@ namespace ProjectsEditor.ViewModels
private void CreateShortcut(Project project)
{
string basePath = AppDomain.CurrentDomain.BaseDirectory;
string shortcutAddress = FolderUtils.Desktop() + $"\\{project.Name}.lnk";
string shortcutIconFilename = FolderUtils.Temp() + $"\\{project.Name}.ico";
string shortcutAddress = Path.Combine(FolderUtils.Desktop(), project.Name + ".lnk");
string shortcutIconFilename = Path.Combine(FolderUtils.Temp(), project.Id + ".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();
try
{
// Workaround to be able to create a shortcut with unicode filename
File.WriteAllBytes(shortcutAddress, Array.Empty<byte>());
// Create a ShellLinkObject that references the .lnk file
Shell32.Shell shl = new Shell32.Shell();
Shell32.Folder dir = shl.NameSpace(FolderUtils.Desktop());
Shell32.FolderItem itm = dir.Items().Item($"{project.Name}.lnk");
Shell32.ShellLinkObject lnk = (Shell32.ShellLinkObject)itm.GetLink;
// Set the .lnk file properties
lnk.Description = $"Project Launcher {project.Id}";
lnk.Path = Path.Combine(basePath, "PowerToys.ProjectsLauncher.exe");
lnk.Arguments = project.Id.ToString();
lnk.WorkingDirectory = basePath;
lnk.SetIconLocation(shortcutIconFilename, 0);
lnk.Save(shortcutAddress);
}
catch (Exception ex)
{
Logger.LogError($"Shortcut creation error: {ex.Message}");
}
}
public void SaveProjectName(Project project)

View File

@@ -132,6 +132,7 @@
<ItemGroup>
<ClInclude Include="AppLauncher.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="resource.h" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
@@ -147,6 +148,9 @@
<Project>{6955446d-23f7-4023-9bb3-8657f904af99}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="ProjectLauncherResource.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<Import Project="..\..\..\..\deps\spdlog.props" />
<ImportGroup Label="ExtensionTargets">

View File

@@ -21,6 +21,9 @@
<ClInclude Include="AppLauncher.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
@@ -34,6 +37,11 @@
</ClCompile>
</ItemGroup>
<ItemGroup>
<Natvis Include="$(MSBuildThisFileDirectory)..\..\natvis\wil.natvis" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="ProjectLauncherResource.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,13 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by ProjectLauncherResource.rc
//////////////////////////////
// Non-localizable
#define FILE_DESCRIPTION "PowerToys Projects Launcher"
#define INTERNAL_NAME "PowerToys.ProjectsLauncher"
#define ORIGINAL_FILENAME "PowerToys.ProjectsLauncher.exe"
// Non-localizable
//////////////////////////////

View File

@@ -134,6 +134,7 @@
<ClInclude Include="MonitorUtils.h" />
<ClInclude Include="OnThreadExecutor.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="resource.h" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
@@ -149,6 +150,9 @@
<Project>{6955446d-23f7-4023-9bb3-8657f904af99}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="ProjectsSnapshotTool.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<Import Project="..\..\..\..\deps\spdlog.props" />
<ImportGroup Label="ExtensionTargets">

View File

@@ -24,6 +24,9 @@
<ClInclude Include="OnThreadExecutor.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
@@ -40,6 +43,11 @@
</ClCompile>
</ItemGroup>
<ItemGroup>
<Natvis Include="$(MSBuildThisFileDirectory)..\..\natvis\wil.natvis" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="ProjectsSnapshotTool.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,13 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by ProjectsSnapshotTool.rc
//////////////////////////////
// Non-localizable
#define FILE_DESCRIPTION "PowerToys Projects Snapshot Tool"
#define INTERNAL_NAME "PowerToys.ProjectsSnapshotTool"
#define ORIGINAL_FILENAME "PowerToys.ProjectsSnapshotTool.exe"
// Non-localizable
//////////////////////////////

View File

@@ -22,9 +22,9 @@ namespace WindowUtils
const char SplashClassName[] = "MsoSplash";
const wchar_t CoreWindow[] = L"WINDOWS.UI.CORE.COREWINDOW";
const wchar_t SearchUI[] = L"SEARCHUI.EXE";
const wchar_t ProjectsSnapshotTool[] = L"PROJECTSSNAPSHOTTOOL";
const wchar_t ProjectsEditor[] = L"PROJECTSEDITOR";
const wchar_t ProjectsLauncher[] = L"PROJECTSLAUNCHER";
const wchar_t ProjectsSnapshotTool[] = L"POWERTOYS.PROJECTSSNAPSHOTTOOL";
const wchar_t ProjectsEditor[] = L"POWERTOYS.PROJECTSEDITOR";
const wchar_t ProjectsLauncher[] = L"POWERTOYS.PROJECTSLAUNCHER";
}
inline bool IsRoot(HWND window) noexcept