mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-01-01 01:46:50 +01:00
Compare commits
3 Commits
khmyznikov
...
leilzh/tim
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2e25722300 | ||
|
|
617c6e00f2 | ||
|
|
40a1729462 |
3
.github/actions/spell-check/allow/code.txt
vendored
3
.github/actions/spell-check/allow/code.txt
vendored
@@ -29,14 +29,11 @@ RUS
|
||||
AYUV
|
||||
bak
|
||||
Bcl
|
||||
bgcode
|
||||
Deflatealgorithm
|
||||
exa
|
||||
exabyte
|
||||
Gbits
|
||||
Gbps
|
||||
gcode
|
||||
Heatshrink
|
||||
Mbits
|
||||
MBs
|
||||
mkv
|
||||
|
||||
1
.github/actions/spell-check/excludes.txt
vendored
1
.github/actions/spell-check/excludes.txt
vendored
@@ -18,7 +18,6 @@
|
||||
/TestFiles/
|
||||
[^/]\.cur$
|
||||
[^/]\.gcode$
|
||||
[^/]\.bgcode$
|
||||
[^/]\.rgs$
|
||||
\.a$
|
||||
\.ai$
|
||||
|
||||
3
.github/actions/spell-check/expect.txt
vendored
3
.github/actions/spell-check/expect.txt
vendored
@@ -287,7 +287,6 @@ CVal
|
||||
cvd
|
||||
CVirtual
|
||||
CVS
|
||||
CWMO
|
||||
CXSCREEN
|
||||
CXSMICON
|
||||
CXVIRTUALSCREEN
|
||||
@@ -1383,7 +1382,6 @@ RIGHTSCROLLBAR
|
||||
riid
|
||||
RKey
|
||||
RNumber
|
||||
Rns
|
||||
rop
|
||||
ROUNDSMALL
|
||||
ROWSETEXT
|
||||
@@ -1933,7 +1931,6 @@ Wubi
|
||||
WUX
|
||||
Wwanpp
|
||||
XAxis
|
||||
XButton
|
||||
xclip
|
||||
xcopy
|
||||
XDeployment
|
||||
|
||||
@@ -66,12 +66,6 @@
|
||||
"PowerToys.GcodeThumbnailProvider.dll",
|
||||
"PowerToys.GcodeThumbnailProvider.exe",
|
||||
"PowerToys.GcodeThumbnailProviderCpp.dll",
|
||||
"PowerToys.BgcodePreviewHandler.dll",
|
||||
"PowerToys.BgcodePreviewHandler.exe",
|
||||
"PowerToys.BgcodePreviewHandlerCpp.dll",
|
||||
"PowerToys.BgcodeThumbnailProvider.dll",
|
||||
"PowerToys.BgcodeThumbnailProvider.exe",
|
||||
"PowerToys.BgcodeThumbnailProviderCpp.dll",
|
||||
"PowerToys.ManagedTelemetry.dll",
|
||||
"PowerToys.MarkdownPreviewHandler.dll",
|
||||
"PowerToys.MarkdownPreviewHandler.exe",
|
||||
|
||||
@@ -19,7 +19,7 @@ parameters:
|
||||
- name: enableMsBuildCaching
|
||||
type: boolean
|
||||
displayName: "Enable MSBuild Caching"
|
||||
default: true
|
||||
default: false
|
||||
- name: runTests
|
||||
type: boolean
|
||||
displayName: "Run Tests"
|
||||
@@ -36,8 +36,7 @@ extends:
|
||||
template: templates/pipeline-ci-build.yml
|
||||
parameters:
|
||||
buildPlatforms: ${{ parameters.buildPlatforms }}
|
||||
${{ if eq(variables['System.PullRequest.IsFork'], 'False') }}:
|
||||
enableMsBuildCaching: ${{ parameters.enableMsBuildCaching }}
|
||||
enableMsBuildCaching: ${{ parameters.enableMsBuildCaching }}
|
||||
runTests: ${{ parameters.runTests }}
|
||||
useVSPreview: ${{ parameters.useVSPreview }}
|
||||
useLatestWebView2: ${{ parameters.useLatestWebView2 }}
|
||||
|
||||
@@ -19,7 +19,7 @@ parameters:
|
||||
- name: enableMsBuildCaching
|
||||
type: boolean
|
||||
displayName: "Enable MSBuild Caching"
|
||||
default: true
|
||||
default: false
|
||||
- name: runTests
|
||||
type: boolean
|
||||
displayName: "Run Tests"
|
||||
@@ -42,8 +42,7 @@ extends:
|
||||
template: templates/pipeline-ci-build.yml
|
||||
parameters:
|
||||
buildPlatforms: ${{ parameters.buildPlatforms }}
|
||||
${{ if eq(variables['System.PullRequest.IsFork'], 'False') }}:
|
||||
enableMsBuildCaching: ${{ parameters.enableMsBuildCaching }}
|
||||
enableMsBuildCaching: ${{ parameters.enableMsBuildCaching }}
|
||||
runTests: ${{ parameters.runTests }}
|
||||
useVSPreview: ${{ parameters.useVSPreview }}
|
||||
useLatestWinAppSDK: ${{ parameters.useLatestWinAppSDK }}
|
||||
|
||||
@@ -32,7 +32,7 @@ parameters:
|
||||
- name: enableMsBuildCaching
|
||||
type: boolean
|
||||
displayName: "Enable MSBuild Caching"
|
||||
default: true
|
||||
default: false
|
||||
- name: runTests
|
||||
type: boolean
|
||||
displayName: "Run Tests"
|
||||
@@ -46,7 +46,6 @@ extends:
|
||||
template: templates/pipeline-ci-build.yml
|
||||
parameters:
|
||||
buildPlatforms: ${{ parameters.buildPlatforms }}
|
||||
${{ if eq(variables['System.PullRequest.IsFork'], 'False') }}:
|
||||
enableMsBuildCaching: ${{ parameters.enableMsBuildCaching }}
|
||||
enableMsBuildCaching: ${{ parameters.enableMsBuildCaching }}
|
||||
runTests: ${{ parameters.runTests }}
|
||||
useVSPreview: ${{ parameters.useVSPreview }}
|
||||
|
||||
@@ -38,11 +38,6 @@ parameters:
|
||||
displayName: "Build Using Visual Studio Preview"
|
||||
default: false
|
||||
|
||||
- name: enableAOT
|
||||
type: boolean
|
||||
displayName: "Enable AOT (Ahead-of-Time) Compilation for CmdPal"
|
||||
default: true
|
||||
|
||||
name: $(BuildDefinitionName)_$(date:yyMM).$(date:dd)$(rev:rrr)
|
||||
|
||||
variables:
|
||||
@@ -100,7 +95,7 @@ extends:
|
||||
useManagedIdentity: $(SigningUseManagedIdentity)
|
||||
clientId: $(SigningOriginalClientId)
|
||||
# Have msbuild use the release nuget config profile
|
||||
additionalBuildOptions: /p:RestoreConfigFile="$(Build.SourcesDirectory)\.pipelines\release-nuget.config" /p:EnableCmdPalAOT=${{ parameters.enableAOT }}
|
||||
additionalBuildOptions: /p:RestoreConfigFile="$(Build.SourcesDirectory)\.pipelines\release-nuget.config"
|
||||
beforeBuildSteps:
|
||||
# Sets versions for all PowerToy created DLLs
|
||||
- pwsh: |-
|
||||
|
||||
@@ -3,6 +3,9 @@ variables:
|
||||
value: false
|
||||
- name: EnablePipelineCache
|
||||
value: true
|
||||
- ${{ if eq(parameters.enableMsBuildCaching, true) }}:
|
||||
- name: EnablePipelineCache
|
||||
value: true
|
||||
|
||||
parameters:
|
||||
- name: buildPlatforms
|
||||
|
||||
@@ -3,6 +3,9 @@ variables:
|
||||
value: false
|
||||
- name: EnablePipelineCache
|
||||
value: true
|
||||
- ${{ if eq(parameters.enableMsBuildCaching, true) }}:
|
||||
- name: EnablePipelineCache
|
||||
value: true
|
||||
|
||||
parameters:
|
||||
- name: buildPlatforms
|
||||
|
||||
@@ -19,7 +19,7 @@ Get-ChildItem $targetDir -Recurse -Filter *.deps.json -Exclude *UITest*,MouseJum
|
||||
# Temporarily exclude All UI-Test, Fuzzer-Test projects because of Appium.WebDriver dependencies
|
||||
$depsJsonFullFileName = $_.FullName
|
||||
|
||||
if ($depsJsonFullFileName -like "*CmdPal*" -or $depsJsonFullFileName -like "*CommandPalette*") {
|
||||
if ($depsJsonFullFileName -like "*CmdPal*") {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -383,18 +383,6 @@ _If you want to find diagnostic data events in the source code, these two links
|
||||
<td>Microsoft.PowerToys.GcodeFilePreviewError</td>
|
||||
<td>Triggered when there is an error previewing a G-code file.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Microsoft.PowerToys.BgcodeFileHandlerLoaded</td>
|
||||
<td>Triggered when a Binary G-code file handler is loaded.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Microsoft.PowerToys.BgcodeFilePreviewed</td>
|
||||
<td>Occurs when a Binary G-code file is previewed in File Explorer.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Microsoft.PowerToys.BgcodeFilePreviewError</td>
|
||||
<td>Triggered when there is an error previewing a Binary G-code file.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Microsoft.PowerToys.MarkdownFileHandlerLoaded</td>
|
||||
<td>Occurs when a Markdown file handler is loaded.</td>
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
<PackageVersion Include="CommunityToolkit.WinUI.Extensions" Version="8.2.250402" />
|
||||
<PackageVersion Include="CommunityToolkit.WinUI.UI.Controls.DataGrid" Version="7.1.2" />
|
||||
<PackageVersion Include="CommunityToolkit.WinUI.UI.Controls.Markdown" Version="7.1.2" />
|
||||
<PackageVersion Include="CommunityToolkit.Labs.WinUI.Controls.MarkdownTextBlock" Version="0.1.250703-build.2173" />
|
||||
<PackageVersion Include="ControlzEx" Version="6.0.0" />
|
||||
<PackageVersion Include="HelixToolkit" Version="2.24.0" />
|
||||
<PackageVersion Include="HelixToolkit.Core.Wpf" Version="2.24.0" />
|
||||
|
||||
@@ -1497,7 +1497,6 @@ SOFTWARE.
|
||||
- Appium.WebDriver 4.4.5
|
||||
- Azure.AI.OpenAI 1.0.0-beta.17
|
||||
- CommunityToolkit.Common 8.4.0
|
||||
- CommunityToolkit.Labs.WinUI.Controls.MarkdownTextBlock 0.1.250703-build.2173
|
||||
- CommunityToolkit.Mvvm 8.4.0
|
||||
- CommunityToolkit.WinUI.Animations 8.2.250402
|
||||
- CommunityToolkit.WinUI.Collections 8.2.250402
|
||||
@@ -1580,3 +1579,4 @@ SOFTWARE.
|
||||
- WinUIEx 2.2.0
|
||||
- WPF-UI 3.0.5
|
||||
- WyHash 1.0.5
|
||||
|
||||
|
||||
@@ -714,18 +714,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CmdPalKeyboardService", "sr
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PowerRename.FuzzingTest", "src\modules\powerrename\PowerRename.FuzzingTest\PowerRename.FuzzingTest.vcxproj", "{2694E2FB-DCD5-4BFF-A418-B6C3C7CE3B8E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BgcodePreviewHandler", "src\modules\previewpane\BgcodePreviewHandler\BgcodePreviewHandler.csproj", "{9E0CBC06-F29A-4810-B93C-97D53863B95E}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BgcodePreviewHandlerCpp", "src\modules\previewpane\BgcodePreviewHandlerCpp\BgcodePreviewHandlerCpp.vcxproj", "{F6088A11-1C9E-4420-AA90-CF7E78DD7F1C}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BgcodeThumbnailProviderCpp", "src\modules\previewpane\BgcodeThumbnailProviderCpp\BgcodeThumbnailProviderCpp.vcxproj", "{47B0678C-806B-4FE1-9F50-46BA88989532}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BgcodeThumbnailProvider", "src\modules\previewpane\BgcodeThumbnailProvider\BgcodeThumbnailProvider.csproj", "{9BC1C986-1E97-4D07-A7B1-CE226C239EFA}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests-BgcodePreviewHandler", "src\modules\previewpane\UnitTests-BgcodePreviewHandler\UnitTests-BgcodePreviewHandler.csproj", "{99CA1509-FB73-456E-AFAF-AB89C017BD72}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests-BgcodeThumbnailProvider", "src\modules\previewpane\UnitTests-BgcodeThumbnailProvider\UnitTests-BgcodeThumbnailProvider.csproj", "{61CBF221-9452-4934-B685-146285E080D7}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MouseUtils.UITests", "src\modules\MouseUtils\MouseUtils.UITests\MouseUtils.UITests.csproj", "{4E0AE3A4-2EE0-44D7-A2D0-8769977254A1}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkspacesEditorUITest", "src\modules\Workspaces\WorkspacesEditorUITest\WorkspacesEditorUITest.csproj", "{43E779F3-D83C-48B1-BA8D-1912DBD76FC9}"
|
||||
@@ -2638,54 +2626,6 @@ Global
|
||||
{2694E2FB-DCD5-4BFF-A418-B6C3C7CE3B8E}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{2694E2FB-DCD5-4BFF-A418-B6C3C7CE3B8E}.Release|x64.ActiveCfg = Release|x64
|
||||
{2694E2FB-DCD5-4BFF-A418-B6C3C7CE3B8E}.Release|x64.Build.0 = Release|x64
|
||||
{9E0CBC06-F29A-4810-B93C-97D53863B95E}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{9E0CBC06-F29A-4810-B93C-97D53863B95E}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{9E0CBC06-F29A-4810-B93C-97D53863B95E}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{9E0CBC06-F29A-4810-B93C-97D53863B95E}.Debug|x64.Build.0 = Debug|x64
|
||||
{9E0CBC06-F29A-4810-B93C-97D53863B95E}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{9E0CBC06-F29A-4810-B93C-97D53863B95E}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{9E0CBC06-F29A-4810-B93C-97D53863B95E}.Release|x64.ActiveCfg = Release|x64
|
||||
{9E0CBC06-F29A-4810-B93C-97D53863B95E}.Release|x64.Build.0 = Release|x64
|
||||
{F6088A11-1C9E-4420-AA90-CF7E78DD7F1C}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{F6088A11-1C9E-4420-AA90-CF7E78DD7F1C}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{F6088A11-1C9E-4420-AA90-CF7E78DD7F1C}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{F6088A11-1C9E-4420-AA90-CF7E78DD7F1C}.Debug|x64.Build.0 = Debug|x64
|
||||
{F6088A11-1C9E-4420-AA90-CF7E78DD7F1C}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{F6088A11-1C9E-4420-AA90-CF7E78DD7F1C}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{F6088A11-1C9E-4420-AA90-CF7E78DD7F1C}.Release|x64.ActiveCfg = Release|x64
|
||||
{F6088A11-1C9E-4420-AA90-CF7E78DD7F1C}.Release|x64.Build.0 = Release|x64
|
||||
{47B0678C-806B-4FE1-9F50-46BA88989532}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{47B0678C-806B-4FE1-9F50-46BA88989532}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{47B0678C-806B-4FE1-9F50-46BA88989532}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{47B0678C-806B-4FE1-9F50-46BA88989532}.Debug|x64.Build.0 = Debug|x64
|
||||
{47B0678C-806B-4FE1-9F50-46BA88989532}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{47B0678C-806B-4FE1-9F50-46BA88989532}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{47B0678C-806B-4FE1-9F50-46BA88989532}.Release|x64.ActiveCfg = Release|x64
|
||||
{47B0678C-806B-4FE1-9F50-46BA88989532}.Release|x64.Build.0 = Release|x64
|
||||
{9BC1C986-1E97-4D07-A7B1-CE226C239EFA}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{9BC1C986-1E97-4D07-A7B1-CE226C239EFA}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{9BC1C986-1E97-4D07-A7B1-CE226C239EFA}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{9BC1C986-1E97-4D07-A7B1-CE226C239EFA}.Debug|x64.Build.0 = Debug|x64
|
||||
{9BC1C986-1E97-4D07-A7B1-CE226C239EFA}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{9BC1C986-1E97-4D07-A7B1-CE226C239EFA}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{9BC1C986-1E97-4D07-A7B1-CE226C239EFA}.Release|x64.ActiveCfg = Release|x64
|
||||
{9BC1C986-1E97-4D07-A7B1-CE226C239EFA}.Release|x64.Build.0 = Release|x64
|
||||
{99CA1509-FB73-456E-AFAF-AB89C017BD72}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{99CA1509-FB73-456E-AFAF-AB89C017BD72}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{99CA1509-FB73-456E-AFAF-AB89C017BD72}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{99CA1509-FB73-456E-AFAF-AB89C017BD72}.Debug|x64.Build.0 = Debug|x64
|
||||
{99CA1509-FB73-456E-AFAF-AB89C017BD72}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{99CA1509-FB73-456E-AFAF-AB89C017BD72}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{99CA1509-FB73-456E-AFAF-AB89C017BD72}.Release|x64.ActiveCfg = Release|x64
|
||||
{99CA1509-FB73-456E-AFAF-AB89C017BD72}.Release|x64.Build.0 = Release|x64
|
||||
{61CBF221-9452-4934-B685-146285E080D7}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{61CBF221-9452-4934-B685-146285E080D7}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{61CBF221-9452-4934-B685-146285E080D7}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{61CBF221-9452-4934-B685-146285E080D7}.Debug|x64.Build.0 = Debug|x64
|
||||
{61CBF221-9452-4934-B685-146285E080D7}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{61CBF221-9452-4934-B685-146285E080D7}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{61CBF221-9452-4934-B685-146285E080D7}.Release|x64.ActiveCfg = Release|x64
|
||||
{61CBF221-9452-4934-B685-146285E080D7}.Release|x64.Build.0 = Release|x64
|
||||
{4E0AE3A4-2EE0-44D7-A2D0-8769977254A1}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{4E0AE3A4-2EE0-44D7-A2D0-8769977254A1}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{4E0AE3A4-2EE0-44D7-A2D0-8769977254A1}.Debug|x64.ActiveCfg = Debug|x64
|
||||
@@ -3000,12 +2940,6 @@ Global
|
||||
{0217E86E-3476-9946-DE8E-9D200CEBD47A} = {D1D6BC88-09AE-4FB4-AD24-5DED46A791DD}
|
||||
{5F63C743-F6CE-4DBA-A200-2B3F8A14E8C2} = {3846508C-77EB-4034-A702-F8BB263C4F79}
|
||||
{2694E2FB-DCD5-4BFF-A418-B6C3C7CE3B8E} = {89E20BCE-EB9C-46C8-8B50-E01A82E6FDC3}
|
||||
{9E0CBC06-F29A-4810-B93C-97D53863B95E} = {2F305555-C296-497E-AC20-5FA1B237996A}
|
||||
{F6088A11-1C9E-4420-AA90-CF7E78DD7F1C} = {2F305555-C296-497E-AC20-5FA1B237996A}
|
||||
{47B0678C-806B-4FE1-9F50-46BA88989532} = {2F305555-C296-497E-AC20-5FA1B237996A}
|
||||
{9BC1C986-1E97-4D07-A7B1-CE226C239EFA} = {2F305555-C296-497E-AC20-5FA1B237996A}
|
||||
{99CA1509-FB73-456E-AFAF-AB89C017BD72} = {2F305555-C296-497E-AC20-5FA1B237996A}
|
||||
{61CBF221-9452-4934-B685-146285E080D7} = {2F305555-C296-497E-AC20-5FA1B237996A}
|
||||
{4E0AE3A4-2EE0-44D7-A2D0-8769977254A1} = {322566EF-20DC-43A6-B9F8-616AF942579A}
|
||||
{43E779F3-D83C-48B1-BA8D-1912DBD76FC9} = {A2221D7E-55E7-4BEA-90D1-4F162D670BBF}
|
||||
{2CF78CF7-8FEB-4BE1-9591-55FA25B48FC6} = {1AFB6476-670D-4E80-A464-657E01DFF482}
|
||||
|
||||
16
README.md
16
README.md
@@ -37,17 +37,17 @@ Go to the [Microsoft PowerToys GitHub releases page][github-release-link] and cl
|
||||
<!-- items that need to be updated release to release -->
|
||||
[github-next-release-work]: https://github.com/microsoft/PowerToys/issues?q=is%3Aissue+milestone%3A%22PowerToys+0.93%22
|
||||
[github-current-release-work]: https://github.com/microsoft/PowerToys/issues?q=is%3Aissue+milestone%3A%22PowerToys+0.92%22
|
||||
[ptUserX64]: https://github.com/microsoft/PowerToys/releases/download/v0.92.1/PowerToysUserSetup-0.92.1-x64.exe
|
||||
[ptUserArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.92.1/PowerToysUserSetup-0.92.1-arm64.exe
|
||||
[ptMachineX64]: https://github.com/microsoft/PowerToys/releases/download/v0.92.1/PowerToysSetup-0.92.1-x64.exe
|
||||
[ptMachineArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.92.1/PowerToysSetup-0.92.1-arm64.exe
|
||||
[ptUserX64]: https://github.com/microsoft/PowerToys/releases/download/v0.92.0/PowerToysUserSetup-0.92.0-x64.exe
|
||||
[ptUserArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.92.0/PowerToysUserSetup-0.92.0-arm64.exe
|
||||
[ptMachineX64]: https://github.com/microsoft/PowerToys/releases/download/v0.92.0/PowerToysSetup-0.92.0-x64.exe
|
||||
[ptMachineArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.92.0/PowerToysSetup-0.92.0-arm64.exe
|
||||
|
||||
| Description | Filename |
|
||||
|----------------|----------|
|
||||
| Per user - x64 | [PowerToysUserSetup-0.92.1-x64.exe][ptUserX64] |
|
||||
| Per user - ARM64 | [PowerToysUserSetup-0.92.1-arm64.exe][ptUserArm64] |
|
||||
| Machine wide - x64 | [PowerToysSetup-0.92.1-x64.exe][ptMachineX64] |
|
||||
| Machine wide - ARM64 | [PowerToysSetup-0.92.1-arm64.exe][ptMachineArm64] |
|
||||
| Per user - x64 | [PowerToysUserSetup-0.92.0-x64.exe][ptUserX64] |
|
||||
| Per user - ARM64 | [PowerToysUserSetup-0.92.0-arm64.exe][ptUserArm64] |
|
||||
| Machine wide - x64 | [PowerToysSetup-0.92.0-x64.exe][ptMachineX64] |
|
||||
| Machine wide - ARM64 | [PowerToysSetup-0.92.0-arm64.exe][ptMachineArm64] |
|
||||
|
||||
This is our preferred method.
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ Welcome to the PowerToys developer documentation. This documentation provides in
|
||||
|
||||
- [Coding Guidelines](development/guidelines.md) - Development guidelines and best practices
|
||||
- [Coding Style](development/style.md) - Code formatting and style conventions
|
||||
- [UI Testing](UITests.md) - How to write UI tests for PowerToys
|
||||
- [UI Testing](development/ui-tests.md) - How to write UI tests for PowerToys
|
||||
- [Debugging](development/debugging.md) - Techniques for debugging PowerToys
|
||||
|
||||
## Tools
|
||||
|
||||
@@ -18,7 +18,6 @@ This script checks the preview handler registration for the following file types
|
||||
* .svgz
|
||||
* .pdf
|
||||
* .gcode
|
||||
* .bgcode
|
||||
* .stl
|
||||
* .txt
|
||||
* .ini
|
||||
|
||||
@@ -47,8 +47,6 @@ Contact the developers of a plugin directly for assistance with a specific plugi
|
||||
| [Weather](https://github.com/ruslanlap/PowerToysRun-Weather) | [ruslanlap](https://github.com/ruslanlap) | Get real-time weather information directly from PowerToys Run. |
|
||||
| [Pomodoro](https://github.com/ruslanlap/PowerToysRun-Pomodoro) | [ruslanlap](https://github.com/ruslanlap) | Manage Pomodoro productivity sessions directly from PowerToys Run. |
|
||||
| [Definition](https://github.com/ruslanlap/PowerToysRun-Definition) | [ruslanlap](https://github.com/ruslanlap) | Lookup word definitions, phonetics, and synonyms directly in PowerToys Run. |
|
||||
| [Hotkeys](https://github.com/ruslanlap/PowerToysRun-Hotkeys) | [ruslanlap](https://github.com/ruslanlap) | Create, manage, and trigger custom keyboard shortcuts directly from PowerToys Run. |
|
||||
| [RandomGen](https://github.com/ruslanlap/PowerToysRun-RandomGen) | [ruslanlap](https://github.com/ruslanlap) | 🎲 Generate random data instantly with a single keystroke. Perfect for developers, testers, designers, and anyone who needs quick access to random data. Features include secure passwords, PINs, names, business data, dates, numbers, GUIDs, color codes, and more. Especially useful for designers who need random color codes and placeholder content. |
|
||||
|
||||
## Extending software plugins
|
||||
|
||||
|
||||
@@ -458,15 +458,6 @@
|
||||
</RegistryKey>
|
||||
<File Id="WorkspacesEditor_$(var.IdSafeLanguage)_File" Source="$(var.BinDir)\$(var.Language)\PowerToys.WorkspacesEditor.resources.dll" />
|
||||
</Component>
|
||||
<Component
|
||||
Id="BgcodePreviewHandler_$(var.IdSafeLanguage)_Component"
|
||||
Directory="Resource$(var.IdSafeLanguage)INSTALLFOLDER"
|
||||
Guid="$(var.CompGUIDPrefix)22">
|
||||
<RegistryKey Root="$(var.RegistryScope)" Key="Software\Classes\powertoys\components">
|
||||
<RegistryValue Type="string" Name="BgcodePreviewHandler_$(var.IdSafeLanguage)_Component" Value="" KeyPath="yes"/>
|
||||
</RegistryKey>
|
||||
<File Id="BgcodePreviewHandler_$(var.IdSafeLanguage)_File" Source="$(var.BinDir)\$(var.Language)\PowerToys.BgcodePreviewHandler.resources.dll" />
|
||||
</Component>
|
||||
<?undef IdSafeLanguage?>
|
||||
<?undef CompGUIDPrefix?>
|
||||
<?endforeach?>
|
||||
|
||||
@@ -1170,7 +1170,7 @@ UINT __stdcall TerminateProcessesCA(MSIHANDLE hInstall)
|
||||
}
|
||||
processes.resize(bytes / sizeof(processes[0]));
|
||||
|
||||
std::array<std::wstring_view, 41> processesToTerminate = {
|
||||
std::array<std::wstring_view, 39> processesToTerminate = {
|
||||
L"PowerToys.PowerLauncher.exe",
|
||||
L"PowerToys.Settings.exe",
|
||||
L"PowerToys.AdvancedPaste.exe",
|
||||
@@ -1186,14 +1186,12 @@ UINT __stdcall TerminateProcessesCA(MSIHANDLE hInstall)
|
||||
L"PowerToys.PowerRename.exe",
|
||||
L"PowerToys.ImageResizer.exe",
|
||||
L"PowerToys.GcodeThumbnailProvider.exe",
|
||||
L"PowerToys.BgcodeThumbnailProvider.exe",
|
||||
L"PowerToys.PdfThumbnailProvider.exe",
|
||||
L"PowerToys.MonacoPreviewHandler.exe",
|
||||
L"PowerToys.MarkdownPreviewHandler.exe",
|
||||
L"PowerToys.StlThumbnailProvider.exe",
|
||||
L"PowerToys.SvgThumbnailProvider.exe",
|
||||
L"PowerToys.GcodePreviewHandler.exe",
|
||||
L"PowerToys.BgcodePreviewHandler.exe",
|
||||
L"PowerToys.QoiPreviewHandler.exe",
|
||||
L"PowerToys.PdfPreviewHandler.exe",
|
||||
L"PowerToys.QoiThumbnailProvider.exe",
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<clear />
|
||||
<add key="PowerToysPublicDependencies" value="https://pkgs.dev.azure.com/shine-oss/PowerToys/_packaging/PowerToysPublicDependencies/nuget/v3/index.json" />
|
||||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
|
||||
</packageSources>
|
||||
<packageSourceMapping>
|
||||
<packageSource key="PowerToysPublicDependencies">
|
||||
<packageSource key="nuget.org">
|
||||
<package pattern="*" />
|
||||
</packageSource>
|
||||
</packageSourceMapping>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.MSBuildCache.AzurePipelines" version="0.1.318-preview" />
|
||||
<package id="Microsoft.MSBuildCache.Local" version="0.1.318-preview" />
|
||||
<package id="Microsoft.MSBuildCache.SharedCompilation" version="0.1.318-preview" />
|
||||
<package id="Microsoft.MSBuildCache.AzurePipelines" version="0.1.283-preview" />
|
||||
<package id="Microsoft.MSBuildCache.Local" version="0.1.283-preview" />
|
||||
<package id="Microsoft.MSBuildCache.SharedCompilation" version="0.1.283-preview" />
|
||||
</packages>
|
||||
@@ -7,7 +7,6 @@
|
||||
<CsWinRTAotWarningLevel>2</CsWinRTAotWarningLevel>
|
||||
|
||||
<!-- Suppress DynamicallyAccessedMemberTypes.PublicParameterlessConstructor in fallback code path of Windows SDK projection -->
|
||||
<!-- Suppress CA1416 for Windows-specific APIs that are used in PowerToys which only runs on Windows 10.0.19041.0+ -->
|
||||
<WarningsNotAsErrors>IL2081;CsWinRT1028;CA1416;$(WarningsNotAsErrors)</WarningsNotAsErrors>
|
||||
<WarningsNotAsErrors>IL2081;CsWinRT1028;$(WarningsNotAsErrors)</WarningsNotAsErrors>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
namespace Microsoft.PowerToys.FilePreviewCommon
|
||||
{
|
||||
public enum BgcodeBlockType
|
||||
{
|
||||
FileMetadataBlock = 0,
|
||||
GCodeBlock = 1,
|
||||
SlicerMetadataBlock = 2,
|
||||
PrinterMetadataBlock = 3,
|
||||
PrintMetadataBlock = 4,
|
||||
ThumbnailBlock = 5,
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
namespace Microsoft.PowerToys.FilePreviewCommon
|
||||
{
|
||||
public enum BgcodeChecksumType
|
||||
{
|
||||
None = 0,
|
||||
CRC32 = 1,
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
namespace Microsoft.PowerToys.FilePreviewCommon
|
||||
{
|
||||
public enum BgcodeCompressionType
|
||||
{
|
||||
NoCompression = 0,
|
||||
DeflateAlgorithm = 1,
|
||||
HeatshrinkAlgorithm11 = 2,
|
||||
HeatshrinkAlgorithm12 = 3,
|
||||
}
|
||||
}
|
||||
@@ -1,129 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
|
||||
namespace Microsoft.PowerToys.FilePreviewCommon
|
||||
{
|
||||
/// <summary>
|
||||
/// Bgcode file helper class.
|
||||
/// </summary>
|
||||
public static class BgcodeHelper
|
||||
{
|
||||
private const uint MagicNumber = 'G' | 'C' << 8 | 'D' << 16 | 'E' << 24;
|
||||
|
||||
/// <summary>
|
||||
/// Gets any thumbnails found in a bgcode file.
|
||||
/// </summary>
|
||||
/// <param name="reader">The <see cref="BinaryReader"/> instance to the bgcode file.</param>
|
||||
/// <returns>The thumbnails found in a bgcode file.</returns>
|
||||
public static IEnumerable<BgcodeThumbnail> GetThumbnails(BinaryReader reader)
|
||||
{
|
||||
var magicNumber = reader.ReadUInt32();
|
||||
|
||||
if (magicNumber != MagicNumber)
|
||||
{
|
||||
throw new InvalidDataException("Invalid magic number.");
|
||||
}
|
||||
|
||||
var version = reader.ReadUInt32();
|
||||
|
||||
if (version != 1)
|
||||
{
|
||||
// Version 1 is the only one that exists
|
||||
throw new InvalidDataException("Unsupported version.");
|
||||
}
|
||||
|
||||
var checksum = (BgcodeChecksumType)reader.ReadUInt16();
|
||||
|
||||
while (reader.BaseStream.Position < reader.BaseStream.Length)
|
||||
{
|
||||
var blockType = (BgcodeBlockType)reader.ReadUInt16();
|
||||
var compression = (BgcodeCompressionType)reader.ReadUInt16();
|
||||
var uncompressedSize = reader.ReadUInt32();
|
||||
|
||||
var size = compression == BgcodeCompressionType.NoCompression ? uncompressedSize : reader.ReadUInt32();
|
||||
|
||||
switch (blockType)
|
||||
{
|
||||
case BgcodeBlockType.FileMetadataBlock:
|
||||
case BgcodeBlockType.PrinterMetadataBlock:
|
||||
case BgcodeBlockType.PrintMetadataBlock:
|
||||
case BgcodeBlockType.SlicerMetadataBlock:
|
||||
case BgcodeBlockType.GCodeBlock:
|
||||
reader.BaseStream.Seek(2 + size, SeekOrigin.Current); // Skip
|
||||
|
||||
break;
|
||||
|
||||
case BgcodeBlockType.ThumbnailBlock:
|
||||
var format = (BgcodeThumbnailFormat)reader.ReadUInt16();
|
||||
|
||||
reader.BaseStream.Seek(4, SeekOrigin.Current); // Skip width and height
|
||||
|
||||
var data = ReadAndDecompressData(reader, compression, (int)size);
|
||||
|
||||
if (data != null)
|
||||
{
|
||||
yield return new BgcodeThumbnail(format, data);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (checksum == BgcodeChecksumType.CRC32)
|
||||
{
|
||||
reader.BaseStream.Seek(4, SeekOrigin.Current); // Skip checksum
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the best thumbnail available in a bgcode file.
|
||||
/// </summary>
|
||||
/// <param name="reader">The <see cref="BinaryReader"/> instance to the gcode file.</param>
|
||||
/// <returns>The best thumbnail available in the gcode file.</returns>
|
||||
public static BgcodeThumbnail? GetBestThumbnail(BinaryReader reader)
|
||||
{
|
||||
return GetThumbnails(reader)
|
||||
.OrderByDescending(x => x.Format switch
|
||||
{
|
||||
BgcodeThumbnailFormat.PNG => 2,
|
||||
BgcodeThumbnailFormat.QOI => 1,
|
||||
BgcodeThumbnailFormat.JPG => 0,
|
||||
_ => 0,
|
||||
})
|
||||
.ThenByDescending(x => x.Data.Length)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
private static byte[]? ReadAndDecompressData(BinaryReader reader, BgcodeCompressionType compression, int size)
|
||||
{
|
||||
// Though the spec doesn't actually mention it, the reference encoder code never applies compression to thumbnails data
|
||||
// which makes complete sense as this data is PNG, JPEG or QOI encoded so already compressed as much as possible!
|
||||
switch (compression)
|
||||
{
|
||||
case BgcodeCompressionType.NoCompression:
|
||||
return reader.ReadBytes(size);
|
||||
|
||||
case BgcodeCompressionType.DeflateAlgorithm:
|
||||
var buffer = new byte[size];
|
||||
|
||||
using (var deflateStream = new DeflateStream(reader.BaseStream, CompressionMode.Decompress, true))
|
||||
{
|
||||
deflateStream.ReadExactly(buffer, 0, size);
|
||||
}
|
||||
|
||||
return buffer;
|
||||
|
||||
default:
|
||||
reader.BaseStream.Seek(size, SeekOrigin.Current); // Skip unknown or unsupported compression types
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
|
||||
namespace Microsoft.PowerToys.FilePreviewCommon
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a bgcode thumbnail.
|
||||
/// </summary>
|
||||
public class BgcodeThumbnail
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the bgcode thumbnail image format.
|
||||
/// </summary>
|
||||
public BgcodeThumbnailFormat Format { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the bgcode thumbnail image data.
|
||||
/// </summary>
|
||||
public byte[] Data { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BgcodeThumbnail"/> class.
|
||||
/// </summary>
|
||||
/// <param name="format">The bgcode thumbnail image format.</param>
|
||||
/// <param name="data">The bgcode thumbnail image data.</param>
|
||||
public BgcodeThumbnail(BgcodeThumbnailFormat format, byte[] data)
|
||||
{
|
||||
Format = format;
|
||||
Data = data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Bitmap"/> representing this thumbnail.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="Bitmap"/> representing this thumbnail.</returns>
|
||||
public Bitmap? GetBitmap()
|
||||
{
|
||||
switch (Format)
|
||||
{
|
||||
case BgcodeThumbnailFormat.JPG:
|
||||
case BgcodeThumbnailFormat.PNG:
|
||||
return BitmapFromByteArray();
|
||||
|
||||
case BgcodeThumbnailFormat.QOI:
|
||||
return BitmapFromQoiByteArray();
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Bitmap BitmapFromByteArray()
|
||||
{
|
||||
return new Bitmap(new MemoryStream(Data));
|
||||
}
|
||||
|
||||
private Bitmap BitmapFromQoiByteArray()
|
||||
{
|
||||
return QoiImage.FromStream(new MemoryStream(Data));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
namespace Microsoft.PowerToys.FilePreviewCommon
|
||||
{
|
||||
public enum BgcodeThumbnailFormat
|
||||
{
|
||||
/// <summary>
|
||||
/// PNG image format.
|
||||
/// </summary>
|
||||
PNG = 0,
|
||||
|
||||
/// <summary>
|
||||
/// JPG image format.
|
||||
/// </summary>
|
||||
JPG = 1,
|
||||
|
||||
/// <summary>
|
||||
/// QOI image format.
|
||||
/// </summary>
|
||||
QOI = 2,
|
||||
}
|
||||
}
|
||||
@@ -56,10 +56,6 @@ namespace winrt::PowerToys::GPOWrapper::implementation
|
||||
{
|
||||
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredGcodePreviewEnabledValue());
|
||||
}
|
||||
GpoRuleConfigured GPOWrapper::GetConfiguredBgcodePreviewEnabledValue()
|
||||
{
|
||||
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredBgcodePreviewEnabledValue());
|
||||
}
|
||||
GpoRuleConfigured GPOWrapper::GetConfiguredSvgThumbnailsEnabledValue()
|
||||
{
|
||||
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredSvgThumbnailsEnabledValue());
|
||||
@@ -72,10 +68,6 @@ namespace winrt::PowerToys::GPOWrapper::implementation
|
||||
{
|
||||
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredGcodeThumbnailsEnabledValue());
|
||||
}
|
||||
GpoRuleConfigured GPOWrapper::GetConfiguredBgcodeThumbnailsEnabledValue()
|
||||
{
|
||||
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredBgcodeThumbnailsEnabledValue());
|
||||
}
|
||||
GpoRuleConfigured GPOWrapper::GetConfiguredStlThumbnailsEnabledValue()
|
||||
{
|
||||
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredStlThumbnailsEnabledValue());
|
||||
|
||||
@@ -21,11 +21,9 @@ namespace winrt::PowerToys::GPOWrapper::implementation
|
||||
static GpoRuleConfigured GetConfiguredMouseWithoutBordersEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredPdfPreviewEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredGcodePreviewEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredBgcodePreviewEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredSvgThumbnailsEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredPdfThumbnailsEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredGcodeThumbnailsEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredBgcodeThumbnailsEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredStlThumbnailsEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredHostsFileEditorEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredImageResizerEnabledValue();
|
||||
|
||||
@@ -24,11 +24,9 @@ namespace PowerToys
|
||||
static GpoRuleConfigured GetConfiguredMonacoPreviewEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredPdfPreviewEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredGcodePreviewEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredBgcodePreviewEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredSvgThumbnailsEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredPdfThumbnailsEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredGcodeThumbnailsEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredBgcodeThumbnailsEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredStlThumbnailsEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredHostsFileEditorEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredImageResizerEnabledValue();
|
||||
|
||||
@@ -127,10 +127,6 @@ namespace winrt::PowerToys::Interop::implementation
|
||||
{
|
||||
return CommonSharedConstants::GCODE_PREVIEW_RESIZE_EVENT;
|
||||
}
|
||||
hstring Constants::BgcodePreviewResizeEvent()
|
||||
{
|
||||
return CommonSharedConstants::BGCODE_PREVIEW_RESIZE_EVENT;
|
||||
}
|
||||
hstring Constants::QoiPreviewResizeEvent()
|
||||
{
|
||||
return CommonSharedConstants::QOI_PREVIEW_RESIZE_EVENT;
|
||||
|
||||
@@ -35,7 +35,6 @@ namespace winrt::PowerToys::Interop::implementation
|
||||
static hstring RegistryPreviewTriggerEvent();
|
||||
static hstring MeasureToolTriggerEvent();
|
||||
static hstring GcodePreviewResizeEvent();
|
||||
static hstring BgcodePreviewResizeEvent();
|
||||
static hstring QoiPreviewResizeEvent();
|
||||
static hstring DevFilesPreviewResizeEvent();
|
||||
static hstring MarkdownPreviewResizeEvent();
|
||||
|
||||
@@ -32,7 +32,6 @@ namespace PowerToys
|
||||
static String RegistryPreviewTriggerEvent();
|
||||
static String MeasureToolTriggerEvent();
|
||||
static String GcodePreviewResizeEvent();
|
||||
static String BgcodePreviewResizeEvent();
|
||||
static String QoiPreviewResizeEvent();
|
||||
static String DevFilesPreviewResizeEvent();
|
||||
static String MarkdownPreviewResizeEvent();
|
||||
|
||||
@@ -92,9 +92,6 @@ namespace CommonSharedConstants
|
||||
// Path to the event used by GcodePreviewHandler
|
||||
const wchar_t GCODE_PREVIEW_RESIZE_EVENT[] = L"Local\\PowerToysGcodePreviewResizeEvent-6ff1f9bd-ccbd-4b24-a79f-40a34fb0317d";
|
||||
|
||||
// Path to the event used by BgcodePreviewHandler
|
||||
const wchar_t BGCODE_PREVIEW_RESIZE_EVENT[] = L"Local\\PowerToysBgcodePreviewResizeEvent-1a76a553-919a-49e0-8179-776582d8e476";
|
||||
|
||||
// Path to the event used by QoiPreviewHandler
|
||||
const wchar_t QOI_PREVIEW_RESIZE_EVENT[] = L"Local\\PowerToysQoiPreviewResizeEvent-579518d1-8c8b-494f-8143-04f43d761ead";
|
||||
|
||||
|
||||
@@ -19,10 +19,6 @@ struct LogSettings
|
||||
inline const static std::wstring gcodePrevLogPath = L"logs\\FileExplorer_localLow\\GcodePreviewHandler\\gcode-prev-handler-log.log";
|
||||
inline const static std::string gcodeThumbLoggerName = "GcodeThumbnailProvider";
|
||||
inline const static std::wstring gcodeThumbLogPath = L"logs\\FileExplorer_localLow\\GcodeThumbnailProvider\\gcode-thumbnail-provider-log.log";
|
||||
inline const static std::string bgcodePrevLoggerName = "bgcodePrevHandler";
|
||||
inline const static std::wstring bgcodePrevLogPath = L"logs\\FileExplorer_localLow\\BgcodePreviewHandler\\bgcode-prev-handler-log.log";
|
||||
inline const static std::string bgcodeThumbLoggerName = "BgcodeThumbnailProvider";
|
||||
inline const static std::wstring bgcodeThumbLogPath = L"logs\\FileExplorer_localLow\\BgcodeThumbnailProvider\\bgcode-thumbnail-provider-log.log";
|
||||
inline const static std::string mdPrevLoggerName = "MDPrevHandler";
|
||||
inline const static std::wstring mdPrevLogPath = L"logs\\FileExplorer_localLow\\MDPrevHandler\\md-prev-handler-log.log";
|
||||
inline const static std::string monacoPrevLoggerName = "MonacoPrevHandler";
|
||||
|
||||
@@ -37,11 +37,9 @@ namespace powertoys_gpo
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_MONACO_PREVIEW = L"ConfigureEnabledUtilityFileExplorerMonacoPreview";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_PDF_PREVIEW = L"ConfigureEnabledUtilityFileExplorerPDFPreview";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_GCODE_PREVIEW = L"ConfigureEnabledUtilityFileExplorerGcodePreview";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_BGCODE_PREVIEW = L"ConfigureEnabledUtilityFileExplorerBgcodePreview";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_SVG_THUMBNAILS = L"ConfigureEnabledUtilityFileExplorerSVGThumbnails";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_PDF_THUMBNAILS = L"ConfigureEnabledUtilityFileExplorerPDFThumbnails";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_GCODE_THUMBNAILS = L"ConfigureEnabledUtilityFileExplorerGcodeThumbnails";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_BGCODE_THUMBNAILS = L"ConfigureEnabledUtilityFileExplorerBgcodeThumbnails";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_STL_THUMBNAILS = L"ConfigureEnabledUtilityFileExplorerSTLThumbnails";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_HOSTS_FILE_EDITOR = L"ConfigureEnabledUtilityHostsFileEditor";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_IMAGE_RESIZER = L"ConfigureEnabledUtilityImageResizer";
|
||||
@@ -330,11 +328,6 @@ namespace powertoys_gpo
|
||||
return getUtilityEnabledValue(POLICY_CONFIGURE_ENABLED_GCODE_PREVIEW);
|
||||
}
|
||||
|
||||
inline gpo_rule_configured_t getConfiguredBgcodePreviewEnabledValue()
|
||||
{
|
||||
return getUtilityEnabledValue(POLICY_CONFIGURE_ENABLED_BGCODE_PREVIEW);
|
||||
}
|
||||
|
||||
inline gpo_rule_configured_t getConfiguredSvgThumbnailsEnabledValue()
|
||||
{
|
||||
return getUtilityEnabledValue(POLICY_CONFIGURE_ENABLED_SVG_THUMBNAILS);
|
||||
@@ -350,11 +343,6 @@ namespace powertoys_gpo
|
||||
return getUtilityEnabledValue(POLICY_CONFIGURE_ENABLED_GCODE_THUMBNAILS);
|
||||
}
|
||||
|
||||
inline gpo_rule_configured_t getConfiguredBgcodeThumbnailsEnabledValue()
|
||||
{
|
||||
return getUtilityEnabledValue(POLICY_CONFIGURE_ENABLED_BGCODE_THUMBNAILS);
|
||||
}
|
||||
|
||||
inline gpo_rule_configured_t getConfiguredStlThumbnailsEnabledValue()
|
||||
{
|
||||
return getUtilityEnabledValue(POLICY_CONFIGURE_ENABLED_STL_THUMBNAILS);
|
||||
|
||||
@@ -17,7 +17,6 @@ namespace NonLocalizable
|
||||
const static std::vector<std::wstring> ExtMarkdown = { L".md", L".markdown", L".mdown", L".mkdn", L".mkd", L".mdwn", L".mdtxt", L".mdtext" };
|
||||
const static std::vector<std::wstring> ExtPDF = { L".pdf" };
|
||||
const static std::vector<std::wstring> ExtGCode = { L".gcode" };
|
||||
const static std::vector<std::wstring> ExtBGCode = { L".bgcode" };
|
||||
const static std::vector<std::wstring> ExtSTL = { L".stl" };
|
||||
const static std::vector<std::wstring> ExtQOI = { L".qoi" };
|
||||
const static std::vector<std::wstring> ExtNoNoNo = {
|
||||
@@ -147,19 +146,6 @@ inline registry::ChangeSet getGcodePreviewHandlerChangeSet(const std::wstring in
|
||||
NonLocalizable::ExtGCode);
|
||||
}
|
||||
|
||||
inline registry::ChangeSet getBgcodePreviewHandlerChangeSet(const std::wstring installationDir, const bool perUser)
|
||||
{
|
||||
using namespace registry::shellex;
|
||||
return generatePreviewHandler(PreviewHandlerType::preview,
|
||||
perUser,
|
||||
L"{0e6d5bdd-d5f8-4692-a089-8bb88cdd37f4}",
|
||||
get_std_product_version(),
|
||||
(fs::path{ installationDir } / LR"d(PowerToys.BgcodePreviewHandlerCpp.dll)d").wstring(),
|
||||
L"BgcodePreviewHandler",
|
||||
L"Binary G-code Preview Handler",
|
||||
NonLocalizable::ExtBGCode);
|
||||
}
|
||||
|
||||
inline registry::ChangeSet getQoiPreviewHandlerChangeSet(const std::wstring installationDir, const bool perUser)
|
||||
{
|
||||
using namespace registry::shellex;
|
||||
@@ -214,19 +200,6 @@ inline registry::ChangeSet getGcodeThumbnailHandlerChangeSet(const std::wstring
|
||||
NonLocalizable::ExtGCode);
|
||||
}
|
||||
|
||||
inline registry::ChangeSet getBgcodeThumbnailHandlerChangeSet(const std::wstring installationDir, const bool perUser)
|
||||
{
|
||||
using namespace registry::shellex;
|
||||
return generatePreviewHandler(PreviewHandlerType::thumbnail,
|
||||
perUser,
|
||||
L"{5c93a1e4-99d0-4fb3-991c-6c296a27be21}",
|
||||
get_std_product_version(),
|
||||
(fs::path{ installationDir } / LR"d(PowerToys.BgcodeThumbnailProviderCpp.dll)d").wstring(),
|
||||
L"BgcodeThumbnailProvider",
|
||||
L"Binary G-code Thumbnail Provider",
|
||||
NonLocalizable::ExtBGCode);
|
||||
}
|
||||
|
||||
inline registry::ChangeSet getStlThumbnailHandlerChangeSet(const std::wstring installationDir, const bool perUser)
|
||||
{
|
||||
using namespace registry::shellex;
|
||||
@@ -302,11 +275,9 @@ inline std::vector<registry::ChangeSet> getAllOnByDefaultModulesChangeSets(const
|
||||
getMdPreviewHandlerChangeSet(installationDir, PER_USER),
|
||||
getMonacoPreviewHandlerChangeSet(installationDir, PER_USER),
|
||||
getGcodePreviewHandlerChangeSet(installationDir, PER_USER),
|
||||
getBgcodePreviewHandlerChangeSet(installationDir, PER_USER),
|
||||
getQoiPreviewHandlerChangeSet(installationDir, PER_USER),
|
||||
getSvgThumbnailHandlerChangeSet(installationDir, PER_USER),
|
||||
getGcodeThumbnailHandlerChangeSet(installationDir, PER_USER),
|
||||
getBgcodeThumbnailHandlerChangeSet(installationDir, PER_USER),
|
||||
getStlThumbnailHandlerChangeSet(installationDir, PER_USER),
|
||||
getQoiThumbnailHandlerChangeSet(installationDir, PER_USER),
|
||||
getRegistryPreviewChangeSet(installationDir, PER_USER) };
|
||||
@@ -320,12 +291,10 @@ inline std::vector<registry::ChangeSet> getAllModulesChangeSets(const std::wstri
|
||||
getMonacoPreviewHandlerChangeSet(installationDir, PER_USER),
|
||||
getPdfPreviewHandlerChangeSet(installationDir, PER_USER),
|
||||
getGcodePreviewHandlerChangeSet(installationDir, PER_USER),
|
||||
getBgcodePreviewHandlerChangeSet(installationDir, PER_USER),
|
||||
getQoiPreviewHandlerChangeSet(installationDir, PER_USER),
|
||||
getSvgThumbnailHandlerChangeSet(installationDir, PER_USER),
|
||||
getPdfThumbnailHandlerChangeSet(installationDir, PER_USER),
|
||||
getGcodeThumbnailHandlerChangeSet(installationDir, PER_USER),
|
||||
getBgcodeThumbnailHandlerChangeSet(installationDir, PER_USER),
|
||||
getStlThumbnailHandlerChangeSet(installationDir, PER_USER),
|
||||
getQoiThumbnailHandlerChangeSet(installationDir, PER_USER),
|
||||
getRegistryPreviewChangeSet(installationDir, PER_USER),
|
||||
|
||||
@@ -54,8 +54,6 @@ properties:
|
||||
EnablePdfThumbnail: false
|
||||
EnableGcodePreview: false
|
||||
EnableGcodeThumbnail: false
|
||||
EnableBgcodePreview: false
|
||||
EnableBgcodeThumbnail: false
|
||||
EnableStlThumbnail: false
|
||||
EnableQoiPreview: false
|
||||
EnableQoiThumbnail: false
|
||||
|
||||
@@ -54,8 +54,6 @@ properties:
|
||||
EnablePdfThumbnail: true
|
||||
EnableGcodePreview: true
|
||||
EnableGcodeThumbnail: true
|
||||
EnableBgcodePreview: true
|
||||
EnableBgcodeThumbnail: true
|
||||
EnableStlThumbnail: true
|
||||
EnableQoiPreview: true
|
||||
EnableQoiThumbnail: true
|
||||
|
||||
@@ -217,16 +217,6 @@
|
||||
<decimal value="0" />
|
||||
</disabledValue>
|
||||
</policy>
|
||||
<policy name="ConfigureEnabledUtilityFileExplorerBgcodePreview" class="Both" displayName="$(string.ConfigureEnabledUtilityFileExplorerBgcodePreview)" explainText="$(string.ConfigureEnabledUtilityDescription)" key="Software\Policies\PowerToys" valueName="ConfigureEnabledUtilityFileExplorerBgcodePreview">
|
||||
<parentCategory ref="PowerToys" />
|
||||
<supportedOn ref="SUPPORTED_POWERTOYS_0_93_0" />
|
||||
<enabledValue>
|
||||
<decimal value="1" />
|
||||
</enabledValue>
|
||||
<disabledValue>
|
||||
<decimal value="0" />
|
||||
</disabledValue>
|
||||
</policy>
|
||||
<policy name="ConfigureEnabledUtilityFileExplorerSVGThumbnails" class="Both" displayName="$(string.ConfigureEnabledUtilityFileExplorerSVGThumbnails)" explainText="$(string.ConfigureEnabledUtilityDescription)" key="Software\Policies\PowerToys" valueName="ConfigureEnabledUtilityFileExplorerSVGThumbnails">
|
||||
<parentCategory ref="PowerToys" />
|
||||
<supportedOn ref="SUPPORTED_POWERTOYS_0_64_0" />
|
||||
@@ -257,16 +247,6 @@
|
||||
<decimal value="0" />
|
||||
</disabledValue>
|
||||
</policy>
|
||||
<policy name="ConfigureEnabledUtilityFileExplorerBgcodeThumbnails" class="Both" displayName="$(string.ConfigureEnabledUtilityFileExplorerBgcodeThumbnails)" explainText="$(string.ConfigureEnabledUtilityDescription)" key="Software\Policies\PowerToys" valueName="ConfigureEnabledUtilityFileExplorerBgcodeThumbnails">
|
||||
<parentCategory ref="PowerToys" />
|
||||
<supportedOn ref="SUPPORTED_POWERTOYS_0_93_0" />
|
||||
<enabledValue>
|
||||
<decimal value="1" />
|
||||
</enabledValue>
|
||||
<disabledValue>
|
||||
<decimal value="0" />
|
||||
</disabledValue>
|
||||
</policy>
|
||||
<policy name="ConfigureEnabledUtilityFileExplorerQOIPreview" class="Both" displayName="$(string.ConfigureEnabledUtilityFileExplorerQOIPreview)" explainText="$(string.ConfigureEnabledUtilityDescription)" key="Software\Policies\PowerToys" valueName="ConfigureEnabledUtilityFileExplorerQOIPreview">
|
||||
<parentCategory ref="PowerToys" />
|
||||
<supportedOn ref="SUPPORTED_POWERTOYS_0_76_0" />
|
||||
|
||||
@@ -253,11 +253,9 @@ If you don't configure this policy, the user will be able to control the setting
|
||||
<string id="ConfigureEnabledUtilityFileExplorerMonacoPreview">Source code file preview: Configure enabled state</string>
|
||||
<string id="ConfigureEnabledUtilityFileExplorerPDFPreview">PDF file preview: Configure enabled state</string>
|
||||
<string id="ConfigureEnabledUtilityFileExplorerGcodePreview">Gcode file preview: Configure enabled state</string>
|
||||
<string id="ConfigureEnabledUtilityFileExplorerBgcodePreview">BGcode file preview: Configure enabled state</string>
|
||||
<string id="ConfigureEnabledUtilityFileExplorerSVGThumbnails">SVG file thumbnail: Configure enabled state</string>
|
||||
<string id="ConfigureEnabledUtilityFileExplorerPDFThumbnails">PDF file thumbnail: Configure enabled state</string>
|
||||
<string id="ConfigureEnabledUtilityFileExplorerGcodeThumbnails">Gcode file thumbnail: Configure enabled state</string>
|
||||
<string id="ConfigureEnabledUtilityFileExplorerBgcodeThumbnails">BGcode file thumbnail: Configure enabled state</string>
|
||||
<string id="ConfigureEnabledUtilityFileExplorerSTLThumbnails">STL file thumbnail: Configure enabled state</string>
|
||||
<string id="ConfigureEnabledUtilityHostsFileEditor">Hosts file editor: Configure enabled state</string>
|
||||
<string id="ConfigureEnabledUtilityImageResizer">Image Resizer: Configure enabled state</string>
|
||||
|
||||
@@ -19,13 +19,13 @@ public interface IExtensionService
|
||||
|
||||
Task SignalStopExtensionsAsync();
|
||||
|
||||
event TypedEventHandler<IExtensionService, IEnumerable<IExtensionWrapper>>? OnExtensionAdded;
|
||||
public event TypedEventHandler<IExtensionService, IEnumerable<IExtensionWrapper>>? OnExtensionAdded;
|
||||
|
||||
event TypedEventHandler<IExtensionService, IEnumerable<IExtensionWrapper>>? OnExtensionRemoved;
|
||||
public event TypedEventHandler<IExtensionService, IEnumerable<IExtensionWrapper>>? OnExtensionRemoved;
|
||||
|
||||
void EnableExtension(string extensionUniqueId);
|
||||
public void EnableExtension(string extensionUniqueId);
|
||||
|
||||
void DisableExtension(string extensionUniqueId);
|
||||
public void DisableExtension(string extensionUniqueId);
|
||||
|
||||
///// <summary>
|
||||
///// Gets a boolean indicating whether the extension was disabled due to the corresponding Windows optional feature
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.CmdPal.Common.Services;
|
||||
|
||||
public interface IRootPageService
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the root page of the command palette. Return any IPage implementation that
|
||||
/// represents the root view of this instance of the command palette.
|
||||
/// </summary>
|
||||
Microsoft.CommandPalette.Extensions.IPage GetRootPage();
|
||||
|
||||
/// <summary>
|
||||
/// Pre-loads any necessary data or state before the root page is loaded.
|
||||
/// This will be awaited before the root page and the user can do anything,
|
||||
/// so ideally it should be quick and not block the UI thread for long.
|
||||
/// </summary>
|
||||
Task PreLoadAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Do any loading work that can be done after the root page is loaded and
|
||||
/// displayed to the user.
|
||||
/// This is run asynchronously, on a background thread.
|
||||
/// </summary>
|
||||
Task PostLoadRootPageAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Called when a top-level command is performed. The context is the
|
||||
/// sender context for the invoked command. This is typically the IListItem
|
||||
/// or ICommandContextItem that was used to invoke the command.
|
||||
/// </summary>
|
||||
void OnPerformTopLevelCommand(object? context);
|
||||
}
|
||||
@@ -40,8 +40,6 @@ public sealed class CommandProviderWrapper
|
||||
|
||||
public CommandSettingsViewModel? Settings { get; private set; }
|
||||
|
||||
public bool IsActive { get; private set; }
|
||||
|
||||
public string ProviderId
|
||||
{
|
||||
get
|
||||
@@ -126,14 +124,12 @@ public sealed class CommandProviderWrapper
|
||||
{
|
||||
if (!isValid)
|
||||
{
|
||||
IsActive = false;
|
||||
return;
|
||||
}
|
||||
|
||||
var settings = serviceProvider.GetService<SettingsModel>()!;
|
||||
|
||||
IsActive = GetProviderSettings(settings).IsEnabled;
|
||||
if (!IsActive)
|
||||
if (!GetProviderSettings(settings).IsEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -177,13 +173,13 @@ public sealed class CommandProviderWrapper
|
||||
private void InitializeCommands(ICommandItem[] commands, IFallbackCommandItem[] fallbacks, IServiceProvider serviceProvider, WeakReference<IPageContext> pageContext)
|
||||
{
|
||||
var settings = serviceProvider.GetService<SettingsModel>()!;
|
||||
var providerSettings = GetProviderSettings(settings);
|
||||
|
||||
Func<ICommandItem?, bool, TopLevelViewModel> makeAndAdd = (ICommandItem? i, bool fallback) =>
|
||||
{
|
||||
CommandItemViewModel commandItemViewModel = new(new(i), pageContext);
|
||||
TopLevelViewModel topLevelViewModel = new(commandItemViewModel, fallback, ExtensionHost, ProviderId, settings, providerSettings, serviceProvider);
|
||||
topLevelViewModel.InitializeProperties();
|
||||
TopLevelViewModel topLevelViewModel = new(commandItemViewModel, fallback, ExtensionHost, ProviderId, settings, serviceProvider);
|
||||
|
||||
topLevelViewModel.ItemViewModel.SlowInitializeProperties();
|
||||
|
||||
return topLevelViewModel;
|
||||
};
|
||||
|
||||
@@ -13,7 +13,7 @@ internal sealed partial class FallbackLogItem : FallbackCommandItem
|
||||
private readonly LogMessagesPage _logMessagesPage;
|
||||
|
||||
public FallbackLogItem()
|
||||
: base(new LogMessagesPage() { Id = "com.microsoft.cmdpal.log" }, Resources.builtin_log_subtitle)
|
||||
: base(new LogMessagesPage(), Resources.builtin_log_subtitle)
|
||||
{
|
||||
_logMessagesPage = (LogMessagesPage)Command!;
|
||||
Title = string.Empty;
|
||||
|
||||
@@ -12,9 +12,7 @@ internal sealed partial class FallbackReloadItem : FallbackCommandItem
|
||||
private readonly ReloadExtensionsCommand _reloadCommand;
|
||||
|
||||
public FallbackReloadItem()
|
||||
: base(
|
||||
new ReloadExtensionsCommand() { Id = "com.microsoft.cmdpal.reload" },
|
||||
Properties.Resources.builtin_reload_display_title)
|
||||
: base(new ReloadExtensionsCommand(), Properties.Resources.builtin_reload_display_title)
|
||||
{
|
||||
_reloadCommand = (ReloadExtensionsCommand)Command!;
|
||||
Title = string.Empty;
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
using System.Collections.Immutable;
|
||||
using System.Collections.Specialized;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using ManagedCommon;
|
||||
using Microsoft.CmdPal.Ext.Apps;
|
||||
using Microsoft.CmdPal.UI.ViewModels.Messages;
|
||||
using Microsoft.CommandPalette.Extensions;
|
||||
@@ -26,8 +25,6 @@ public partial class MainListPage : DynamicListPage,
|
||||
|
||||
private readonly TopLevelCommandManager _tlcManager;
|
||||
private IEnumerable<IListItem>? _filteredItems;
|
||||
private bool _includeApps;
|
||||
private bool _filteredItemsIncludesApps;
|
||||
|
||||
public MainListPage(IServiceProvider serviceProvider)
|
||||
{
|
||||
@@ -67,34 +64,7 @@ public partial class MainListPage : DynamicListPage,
|
||||
}
|
||||
}
|
||||
|
||||
private void Commands_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
_includeApps = _tlcManager.IsProviderActive(AllAppsCommandProvider.WellKnownId);
|
||||
if (_includeApps != _filteredItemsIncludesApps)
|
||||
{
|
||||
ReapplySearchInBackground();
|
||||
}
|
||||
else
|
||||
{
|
||||
RaiseItemsChanged(_tlcManager.TopLevelCommands.Count);
|
||||
}
|
||||
}
|
||||
|
||||
private void ReapplySearchInBackground()
|
||||
{
|
||||
_ = Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var currentSearchText = SearchText;
|
||||
UpdateSearchText(currentSearchText, currentSearchText);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError("Failed to reload search", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
private void Commands_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) => RaiseItemsChanged(_tlcManager.TopLevelCommands.Count);
|
||||
|
||||
public override IListItem[] GetItems()
|
||||
{
|
||||
@@ -149,23 +119,12 @@ public partial class MainListPage : DynamicListPage,
|
||||
_filteredItems = null;
|
||||
}
|
||||
|
||||
// If the internal state has changed, reset _filteredItems to reset the list.
|
||||
if (_filteredItemsIncludesApps != _includeApps)
|
||||
{
|
||||
_filteredItems = null;
|
||||
}
|
||||
|
||||
// If we don't have any previous filter results to work with, start
|
||||
// with a list of all our commands & apps.
|
||||
if (_filteredItems == null)
|
||||
{
|
||||
_filteredItems = commands;
|
||||
_filteredItemsIncludesApps = _includeApps;
|
||||
if (_includeApps)
|
||||
{
|
||||
IEnumerable<IListItem> apps = AllAppsCommandProvider.Page.GetItems();
|
||||
_filteredItems = _filteredItems.Concat(apps);
|
||||
}
|
||||
IEnumerable<IListItem> apps = AllAppsCommandProvider.Page.GetItems();
|
||||
_filteredItems = commands.Concat(apps);
|
||||
}
|
||||
|
||||
// Produce a list of everything that matches the current filter.
|
||||
|
||||
@@ -13,7 +13,6 @@ public partial class QuitCommand : InvokableCommand, IFallbackHandler
|
||||
{
|
||||
public QuitCommand()
|
||||
{
|
||||
Id = "com.microsoft.cmdpal.quit";
|
||||
Icon = new IconInfo("\uE711");
|
||||
}
|
||||
|
||||
|
||||
@@ -249,19 +249,7 @@ public partial class PageViewModel : ExtensionObjectViewModel, IPageContext
|
||||
|
||||
public interface IPageContext
|
||||
{
|
||||
void ShowException(Exception ex, string? extensionHint = null);
|
||||
public void ShowException(Exception ex, string? extensionHint = null);
|
||||
|
||||
TaskScheduler Scheduler { get; }
|
||||
}
|
||||
|
||||
public interface IPageViewModelFactoryService
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new instance of the page view model for the given page type.
|
||||
/// </summary>
|
||||
/// <param name="page">The page for which to create the view model.</param>
|
||||
/// <param name="nested">Indicates whether the page is not the top-level page.</param>
|
||||
/// <param name="host">The command palette host that will host the page (for status messages)</param>
|
||||
/// <returns>A new instance of the page view model.</returns>
|
||||
PageViewModel? TryCreatePageViewModel(IPage page, bool nested, CommandPaletteHost host);
|
||||
public TaskScheduler Scheduler { get; }
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.CommandPalette.Extensions;
|
||||
|
||||
namespace Microsoft.CmdPal.UI.ViewModels;
|
||||
|
||||
public class PageViewModelFactory : IPageViewModelFactoryService
|
||||
{
|
||||
private readonly TaskScheduler _scheduler;
|
||||
|
||||
public PageViewModelFactory(TaskScheduler scheduler)
|
||||
{
|
||||
_scheduler = scheduler;
|
||||
}
|
||||
|
||||
public PageViewModel? TryCreatePageViewModel(IPage page, bool nested, CommandPaletteHost host)
|
||||
{
|
||||
return page switch
|
||||
{
|
||||
IListPage listPage => new ListViewModel(listPage, _scheduler, host) { IsNested = nested },
|
||||
IContentPage contentPage => new ContentPageViewModel(contentPage, _scheduler, host),
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,6 @@ public class ProviderSettings
|
||||
{
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
|
||||
public Dictionary<string, bool> FallbackCommands { get; set; } = [];
|
||||
|
||||
[JsonIgnore]
|
||||
public string ProviderDisplayName { get; set; } = string.Empty;
|
||||
|
||||
@@ -44,14 +42,4 @@ public class ProviderSettings
|
||||
throw new InvalidDataException("Did you add a built-in command and forget to set the Id? Make sure you do that!");
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsFallbackEnabled(TopLevelViewModel command)
|
||||
{
|
||||
return FallbackCommands.TryGetValue(command.Id, out var enabled) ? enabled : true;
|
||||
}
|
||||
|
||||
public void SetFallbackEnabled(TopLevelViewModel command, bool enabled)
|
||||
{
|
||||
FallbackCommands[command.Id] = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,11 +25,7 @@ public partial class ProviderSettingsViewModel(
|
||||
|
||||
public string ExtensionName => _provider.Extension?.ExtensionDisplayName ?? "Built-in";
|
||||
|
||||
public string ExtensionSubtext => IsEnabled ?
|
||||
HasFallbackCommands ?
|
||||
$"{ExtensionName}, {TopLevelCommands.Count} commands, {FallbackCommands.Count} fallback commands" :
|
||||
$"{ExtensionName}, {TopLevelCommands.Count} commands" :
|
||||
Resources.builtin_disabled_extension;
|
||||
public string ExtensionSubtext => IsEnabled ? $"{ExtensionName}, {TopLevelCommands.Count} commands" : Resources.builtin_disabled_extension;
|
||||
|
||||
[MemberNotNullWhen(true, nameof(Extension))]
|
||||
public bool IsFromExtension => _provider.Extension != null;
|
||||
@@ -143,31 +139,6 @@ public partial class ProviderSettingsViewModel(
|
||||
return [.. providersCommands];
|
||||
}
|
||||
|
||||
[field: AllowNull]
|
||||
public List<TopLevelViewModel> FallbackCommands
|
||||
{
|
||||
get
|
||||
{
|
||||
if (field == null)
|
||||
{
|
||||
field = BuildFallbackViewModels();
|
||||
}
|
||||
|
||||
return field;
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasFallbackCommands => _provider.FallbackItems?.Length > 0;
|
||||
|
||||
private List<TopLevelViewModel> BuildFallbackViewModels()
|
||||
{
|
||||
var thisProvider = _provider;
|
||||
var providersCommands = thisProvider.FallbackItems;
|
||||
|
||||
// Remember! This comes in on the UI thread!
|
||||
return [.. providersCommands];
|
||||
}
|
||||
|
||||
private void Save() => SettingsModel.SaveSettings(_settings);
|
||||
|
||||
private void InitializeSettingsPage()
|
||||
|
||||
@@ -12,71 +12,63 @@ public partial class RecentCommandsManager : ObservableObject
|
||||
[JsonInclude]
|
||||
internal List<HistoryItem> History { get; set; } = [];
|
||||
|
||||
private readonly Lock _lock = new();
|
||||
|
||||
public RecentCommandsManager()
|
||||
{
|
||||
}
|
||||
|
||||
public int GetCommandHistoryWeight(string commandId)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
var entry = History
|
||||
var entry = History
|
||||
.Index()
|
||||
.Where(item => item.Item.CommandId == commandId)
|
||||
.FirstOrDefault();
|
||||
|
||||
// These numbers are vaguely scaled so that "VS" will make "Visual Studio" the
|
||||
// match after one use.
|
||||
// Usually it has a weight of 84, compared to 109 for the VS cmd prompt
|
||||
if (entry.Item != null)
|
||||
// These numbers are vaguely scaled so that "VS" will make "Visual Studio" the
|
||||
// match after one use.
|
||||
// Usually it has a weight of 84, compared to 109 for the VS cmd prompt
|
||||
if (entry.Item != null)
|
||||
{
|
||||
var index = entry.Index;
|
||||
|
||||
// First, add some weight based on how early in the list this appears
|
||||
var bucket = index switch
|
||||
{
|
||||
var index = entry.Index;
|
||||
var i when index <= 2 => 35,
|
||||
var i when index <= 10 => 25,
|
||||
var i when index <= 15 => 15,
|
||||
var i when index <= 35 => 10,
|
||||
_ => 5,
|
||||
};
|
||||
|
||||
// First, add some weight based on how early in the list this appears
|
||||
var bucket = index switch
|
||||
{
|
||||
var i when index <= 2 => 35,
|
||||
var i when index <= 10 => 25,
|
||||
var i when index <= 15 => 15,
|
||||
var i when index <= 35 => 10,
|
||||
_ => 5,
|
||||
};
|
||||
// Then, add weight for how often this is used, but cap the weight from usage.
|
||||
var uses = Math.Min(entry.Item.Uses * 5, 35);
|
||||
|
||||
// Then, add weight for how often this is used, but cap the weight from usage.
|
||||
var uses = Math.Min(entry.Item.Uses * 5, 35);
|
||||
|
||||
return bucket + uses;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return bucket + uses;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void AddHistoryItem(string commandId)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
var entry = History
|
||||
var entry = History
|
||||
.Where(item => item.CommandId == commandId)
|
||||
.FirstOrDefault();
|
||||
if (entry == null)
|
||||
{
|
||||
var newitem = new HistoryItem() { CommandId = commandId, Uses = 1 };
|
||||
History.Insert(0, newitem);
|
||||
}
|
||||
else
|
||||
{
|
||||
History.Remove(entry);
|
||||
entry.Uses++;
|
||||
History.Insert(0, entry);
|
||||
}
|
||||
if (entry == null)
|
||||
{
|
||||
var newitem = new HistoryItem() { CommandId = commandId, Uses = 1 };
|
||||
History.Insert(0, newitem);
|
||||
}
|
||||
else
|
||||
{
|
||||
History.Remove(entry);
|
||||
entry.Uses++;
|
||||
History.Insert(0, entry);
|
||||
}
|
||||
|
||||
if (History.Count > 50)
|
||||
{
|
||||
History.RemoveRange(50, History.Count - 50);
|
||||
}
|
||||
if (History.Count > 50)
|
||||
{
|
||||
History.RemoveRange(50, History.Count - 50);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,11 @@ using CommunityToolkit.Mvvm.Input;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using ManagedCommon;
|
||||
using Microsoft.CmdPal.Common.Services;
|
||||
using Microsoft.CmdPal.UI.ViewModels.MainPage;
|
||||
using Microsoft.CmdPal.UI.ViewModels.Messages;
|
||||
using Microsoft.CmdPal.UI.ViewModels.Models;
|
||||
using Microsoft.CommandPalette.Extensions;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using WinRT;
|
||||
|
||||
namespace Microsoft.CmdPal.UI.ViewModels;
|
||||
@@ -19,9 +21,8 @@ namespace Microsoft.CmdPal.UI.ViewModels;
|
||||
public partial class ShellViewModel : ObservableObject,
|
||||
IRecipient<PerformCommandMessage>
|
||||
{
|
||||
private readonly IRootPageService _rootPageService;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private readonly TaskScheduler _scheduler;
|
||||
private readonly IPageViewModelFactoryService _pageViewModelFactory;
|
||||
private readonly Lock _invokeLock = new();
|
||||
private Task? _handleInvokeTask;
|
||||
|
||||
@@ -59,18 +60,17 @@ public partial class ShellViewModel : ObservableObject,
|
||||
}
|
||||
}
|
||||
|
||||
private IPage? _rootPage;
|
||||
private MainListPage? _mainListPage;
|
||||
|
||||
private IExtensionWrapper? _activeExtension;
|
||||
private bool _isNested;
|
||||
|
||||
public bool IsNested { get => _isNested; }
|
||||
|
||||
public ShellViewModel(TaskScheduler scheduler, IRootPageService rootPageService, IPageViewModelFactoryService pageViewModelFactory)
|
||||
public ShellViewModel(IServiceProvider serviceProvider, TaskScheduler scheduler)
|
||||
{
|
||||
_pageViewModelFactory = pageViewModelFactory;
|
||||
_serviceProvider = serviceProvider;
|
||||
_scheduler = scheduler;
|
||||
_rootPageService = rootPageService;
|
||||
_currentPage = new LoadingPageViewModel(null, _scheduler);
|
||||
|
||||
// Register to receive messages
|
||||
@@ -80,27 +80,24 @@ public partial class ShellViewModel : ObservableObject,
|
||||
[RelayCommand]
|
||||
public async Task<bool> LoadAsync()
|
||||
{
|
||||
// First, do any loading that the root page service needs to do before we can
|
||||
// display the root page. For example, this might include loading
|
||||
// the built-in commands, or loading the settings.
|
||||
await _rootPageService.PreLoadAsync();
|
||||
|
||||
var tlcManager = _serviceProvider.GetService<TopLevelCommandManager>();
|
||||
await tlcManager!.LoadBuiltinsAsync();
|
||||
IsLoaded = true;
|
||||
|
||||
// Now that the basics are set up, we can load the root page.
|
||||
_rootPage = _rootPageService.GetRootPage();
|
||||
// Built-ins have loaded. We can display our page at this point.
|
||||
_mainListPage = new MainListPage(_serviceProvider);
|
||||
WeakReferenceMessenger.Default.Send<PerformCommandMessage>(new(new ExtensionObject<ICommand>(_mainListPage)));
|
||||
|
||||
// This sends a message to us to load the root page view model.
|
||||
WeakReferenceMessenger.Default.Send<PerformCommandMessage>(new(new ExtensionObject<ICommand>(_rootPage)));
|
||||
|
||||
// Now that the root page is loaded, do any post-load work that the root page service needs to do.
|
||||
// This runs asynchronously, on a background thread.
|
||||
// This might include starting extensions, for example.
|
||||
// Note: We don't await this, so that we can return immediately.
|
||||
// This is important because we don't want to block the UI thread.
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
await _rootPageService.PostLoadRootPageAsync();
|
||||
// After loading built-ins, and starting navigation, kick off a thread to load extensions.
|
||||
tlcManager.LoadExtensionsCommand.Execute(null);
|
||||
|
||||
await tlcManager.LoadExtensionsCommand.ExecutionTask!;
|
||||
if (tlcManager.LoadExtensionsCommand.ExecutionTask.Status != TaskStatus.RanToCompletion)
|
||||
{
|
||||
// TODO: Handle failure case
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
@@ -175,7 +172,15 @@ public partial class ShellViewModel : ObservableObject,
|
||||
|
||||
public void PerformTopLevelCommand(PerformCommandMessage message)
|
||||
{
|
||||
_rootPageService.OnPerformTopLevelCommand(message.Context);
|
||||
if (_mainListPage == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.Context is IListItem listItem)
|
||||
{
|
||||
_mainListPage.UpdateHistory(listItem);
|
||||
}
|
||||
}
|
||||
|
||||
public void Receive(PerformCommandMessage message)
|
||||
@@ -250,11 +255,10 @@ public partial class ShellViewModel : ObservableObject,
|
||||
{
|
||||
Logger.LogDebug($"Navigating to page");
|
||||
|
||||
var isMainPage = command == _rootPage;
|
||||
_isNested = !isMainPage;
|
||||
var isMainPage = command is MainListPage;
|
||||
|
||||
// Construct our ViewModel of the appropriate type and pass it the UI Thread context.
|
||||
var pageViewModel = _pageViewModelFactory.TryCreatePageViewModel(page, _isNested, host);
|
||||
var pageViewModel = GetViewModelForPage(page, !isMainPage, host);
|
||||
if (pageViewModel == null)
|
||||
{
|
||||
Logger.LogError($"Failed to create ViewModel for page {page.GetType().Name}");
|
||||
@@ -263,6 +267,8 @@ public partial class ShellViewModel : ObservableObject,
|
||||
|
||||
// Kick off async loading of our ViewModel
|
||||
LoadPageViewModel(pageViewModel);
|
||||
_isNested = !isMainPage;
|
||||
|
||||
OnUIThread(() => { WeakReferenceMessenger.Default.Send<UpdateCommandBarMessage>(new(null)); });
|
||||
WeakReferenceMessenger.Default.Send<NavigateToPageMessage>(new(pageViewModel, message.WithAnimation));
|
||||
|
||||
@@ -399,6 +405,19 @@ public partial class ShellViewModel : ObservableObject,
|
||||
}
|
||||
}
|
||||
|
||||
private PageViewModel? GetViewModelForPage(IPage page, bool nested, CommandPaletteHost host)
|
||||
{
|
||||
return page switch
|
||||
{
|
||||
IListPage listPage => new ListViewModel(listPage, _scheduler, host)
|
||||
{
|
||||
IsNested = nested,
|
||||
},
|
||||
IContentPage contentPage => new ContentPageViewModel(contentPage, _scheduler, host),
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
public void SetActiveExtension(IExtensionWrapper? extension)
|
||||
{
|
||||
if (extension != _activeExtension)
|
||||
|
||||
@@ -26,7 +26,6 @@ public partial class TopLevelCommandManager : ObservableObject,
|
||||
|
||||
private readonly List<CommandProviderWrapper> _builtInCommands = [];
|
||||
private readonly List<CommandProviderWrapper> _extensionCommandProviders = [];
|
||||
private readonly Lock _commandProvidersLock = new();
|
||||
|
||||
TaskScheduler IPageContext.Scheduler => _taskScheduler;
|
||||
|
||||
@@ -42,26 +41,14 @@ public partial class TopLevelCommandManager : ObservableObject,
|
||||
[ObservableProperty]
|
||||
public partial bool IsLoading { get; private set; } = true;
|
||||
|
||||
public IEnumerable<CommandProviderWrapper> CommandProviders
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_commandProvidersLock)
|
||||
{
|
||||
return _builtInCommands.Concat(_extensionCommandProviders).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
public IEnumerable<CommandProviderWrapper> CommandProviders => _builtInCommands.Concat(_extensionCommandProviders);
|
||||
|
||||
public async Task<bool> LoadBuiltinsAsync()
|
||||
{
|
||||
var s = new Stopwatch();
|
||||
s.Start();
|
||||
|
||||
lock (_commandProvidersLock)
|
||||
{
|
||||
_builtInCommands.Clear();
|
||||
}
|
||||
_builtInCommands.Clear();
|
||||
|
||||
// Load built-In commands first. These are all in-proc, and
|
||||
// owned by our ServiceProvider.
|
||||
@@ -69,11 +56,7 @@ public partial class TopLevelCommandManager : ObservableObject,
|
||||
foreach (var provider in builtInCommands)
|
||||
{
|
||||
CommandProviderWrapper wrapper = new(provider, _taskScheduler);
|
||||
lock (_commandProvidersLock)
|
||||
{
|
||||
_builtInCommands.Add(wrapper);
|
||||
}
|
||||
|
||||
_builtInCommands.Add(wrapper);
|
||||
var commands = await LoadTopLevelCommandsFromProvider(wrapper);
|
||||
lock (TopLevelCommands)
|
||||
{
|
||||
@@ -98,28 +81,19 @@ public partial class TopLevelCommandManager : ObservableObject,
|
||||
|
||||
await commandProvider.LoadTopLevelCommands(_serviceProvider, weakSelf);
|
||||
|
||||
var commands = await Task.Factory.StartNew(
|
||||
() =>
|
||||
{
|
||||
List<TopLevelViewModel> commands = [];
|
||||
foreach (var item in commandProvider.TopLevelItems)
|
||||
{
|
||||
commands.Add(item);
|
||||
}
|
||||
var settings = _serviceProvider.GetService<SettingsModel>()!;
|
||||
|
||||
foreach (var item in commandProvider.FallbackItems)
|
||||
{
|
||||
if (item.IsEnabled)
|
||||
{
|
||||
commands.Add(item);
|
||||
}
|
||||
}
|
||||
List<TopLevelViewModel> commands = [];
|
||||
|
||||
return commands;
|
||||
},
|
||||
CancellationToken.None,
|
||||
TaskCreationOptions.None,
|
||||
_taskScheduler);
|
||||
foreach (var item in commandProvider.TopLevelItems)
|
||||
{
|
||||
commands.Add(item);
|
||||
}
|
||||
|
||||
foreach (var item in commandProvider.FallbackItems)
|
||||
{
|
||||
commands.Add(item);
|
||||
}
|
||||
|
||||
commandProvider.CommandsChanged -= CommandProvider_CommandsChanged;
|
||||
commandProvider.CommandsChanged += CommandProvider_CommandsChanged;
|
||||
@@ -185,10 +159,7 @@ public partial class TopLevelCommandManager : ObservableObject,
|
||||
|
||||
foreach (var i in sender.FallbackItems)
|
||||
{
|
||||
if (i.IsEnabled)
|
||||
{
|
||||
newItems.Add(i);
|
||||
}
|
||||
newItems.Add(i);
|
||||
}
|
||||
|
||||
// Slice out the old commands
|
||||
@@ -214,7 +185,6 @@ public partial class TopLevelCommandManager : ObservableObject,
|
||||
IsLoading = true;
|
||||
var extensionService = _serviceProvider.GetService<IExtensionService>()!;
|
||||
await extensionService.SignalStopExtensionsAsync();
|
||||
|
||||
lock (TopLevelCommands)
|
||||
{
|
||||
TopLevelCommands.Clear();
|
||||
@@ -240,11 +210,7 @@ public partial class TopLevelCommandManager : ObservableObject,
|
||||
extensionService.OnExtensionRemoved -= ExtensionService_OnExtensionRemoved;
|
||||
|
||||
var extensions = (await extensionService.GetInstalledExtensionsAsync()).ToImmutableList();
|
||||
lock (_commandProvidersLock)
|
||||
{
|
||||
_extensionCommandProviders.Clear();
|
||||
}
|
||||
|
||||
_extensionCommandProviders.Clear();
|
||||
if (extensions != null)
|
||||
{
|
||||
await StartExtensionsAndGetCommands(extensions);
|
||||
@@ -281,9 +247,9 @@ public partial class TopLevelCommandManager : ObservableObject,
|
||||
// Wait for all extensions to start
|
||||
var wrappers = (await Task.WhenAll(startTasks)).Where(wrapper => wrapper != null).Select(w => w!).ToList();
|
||||
|
||||
lock (_commandProvidersLock)
|
||||
foreach (var wrapper in wrappers)
|
||||
{
|
||||
_extensionCommandProviders.AddRange(wrappers);
|
||||
_extensionCommandProviders.Add(wrapper!);
|
||||
}
|
||||
|
||||
// Load the commands from the providers in parallel
|
||||
@@ -409,13 +375,4 @@ public partial class TopLevelCommandManager : ObservableObject,
|
||||
var errorMessage = $"A bug occurred in {$"the \"{extensionHint}\"" ?? "an unknown's"} extension's code:\n{ex.Message}\n{ex.Source}\n{ex.StackTrace}\n\n";
|
||||
CommandPaletteHost.Instance.Log(errorMessage);
|
||||
}
|
||||
|
||||
internal bool IsProviderActive(string id)
|
||||
{
|
||||
lock (_commandProvidersLock)
|
||||
{
|
||||
return _builtInCommands.Any(wrapper => wrapper.Id == id && wrapper.IsActive)
|
||||
|| _extensionCommandProviders.Any(wrapper => wrapper.Id == id && wrapper.IsActive);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,7 @@
|
||||
|
||||
using System.Collections.ObjectModel;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using ManagedCommon;
|
||||
using Microsoft.CmdPal.UI.ViewModels.Messages;
|
||||
using Microsoft.CmdPal.UI.ViewModels.Settings;
|
||||
using Microsoft.CommandPalette.Extensions;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
@@ -19,7 +17,6 @@ namespace Microsoft.CmdPal.UI.ViewModels;
|
||||
public sealed partial class TopLevelViewModel : ObservableObject, IListItem
|
||||
{
|
||||
private readonly SettingsModel _settings;
|
||||
private readonly ProviderSettings _providerSettings;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private readonly CommandItemViewModel _commandItemViewModel;
|
||||
|
||||
@@ -80,9 +77,6 @@ public sealed partial class TopLevelViewModel : ObservableObject, IListItem
|
||||
////// INotifyPropChanged
|
||||
public event TypedEventHandler<object, IPropChangedEventArgs>? PropChanged;
|
||||
|
||||
// Fallback items
|
||||
public string DisplayTitle { get; private set; } = string.Empty;
|
||||
|
||||
public HotkeySettings? Hotkey
|
||||
{
|
||||
get => _hotkey;
|
||||
@@ -139,32 +133,16 @@ public sealed partial class TopLevelViewModel : ObservableObject, IListItem
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsEnabled
|
||||
{
|
||||
get => _providerSettings.IsFallbackEnabled(this);
|
||||
set
|
||||
{
|
||||
if (value != IsEnabled)
|
||||
{
|
||||
_providerSettings.SetFallbackEnabled(this, value);
|
||||
Save();
|
||||
WeakReferenceMessenger.Default.Send<ReloadCommandsMessage>(new());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TopLevelViewModel(
|
||||
CommandItemViewModel item,
|
||||
bool isFallback,
|
||||
CommandPaletteHost extensionHost,
|
||||
string commandProviderId,
|
||||
SettingsModel settings,
|
||||
ProviderSettings providerSettings,
|
||||
IServiceProvider serviceProvider)
|
||||
{
|
||||
_serviceProvider = serviceProvider;
|
||||
_settings = settings;
|
||||
_providerSettings = providerSettings;
|
||||
_commandProviderId = commandProviderId;
|
||||
_commandItemViewModel = item;
|
||||
|
||||
@@ -178,22 +156,6 @@ public sealed partial class TopLevelViewModel : ObservableObject, IListItem
|
||||
// UpdateTags();
|
||||
}
|
||||
|
||||
internal void InitializeProperties()
|
||||
{
|
||||
ItemViewModel.SlowInitializeProperties();
|
||||
|
||||
if (IsFallback)
|
||||
{
|
||||
var model = _commandItemViewModel.Model.Unsafe;
|
||||
|
||||
// RPC to check type
|
||||
if (model is IFallbackCommandItem fallback)
|
||||
{
|
||||
DisplayTitle = fallback.DisplayTitle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Item_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(e.PropertyName))
|
||||
@@ -278,7 +240,7 @@ public sealed partial class TopLevelViewModel : ObservableObject, IListItem
|
||||
{
|
||||
// Use WyHash64 to generate stable ID hashes.
|
||||
// manually seeding with 0, so that the hash is stable across launches
|
||||
var result = WyHash64.ComputeHash64(_commandProviderId + DisplayTitle + Title + Subtitle, seed: 0);
|
||||
var result = WyHash64.ComputeHash64(_commandProviderId + Title + Subtitle, seed: 0);
|
||||
_generatedId = $"{_commandProviderId}{result}";
|
||||
}
|
||||
|
||||
@@ -301,11 +263,6 @@ public sealed partial class TopLevelViewModel : ObservableObject, IListItem
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!IsEnabled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return UnsafeUpdateFallbackSynchronous(newQuery);
|
||||
|
||||
@@ -144,12 +144,10 @@ public partial class App : Application
|
||||
services.AddSingleton<IExtensionService, ExtensionService>();
|
||||
services.AddSingleton<TrayIconService>();
|
||||
|
||||
services.AddSingleton<IRootPageService, PowerToysRootPageService>();
|
||||
services.AddSingleton(new TelemetryForwarder());
|
||||
|
||||
// ViewModels
|
||||
services.AddSingleton<ShellViewModel>();
|
||||
services.AddSingleton<IPageViewModelFactoryService, PageViewModelFactory>();
|
||||
|
||||
return services.BuildServiceProvider();
|
||||
}
|
||||
|
||||
@@ -162,6 +162,10 @@ public sealed partial class SearchBar : UserControl,
|
||||
CurrentPageViewModel.Filter = FilterBox.Text;
|
||||
}
|
||||
}
|
||||
else if (e.Key == VirtualKey.Left && altPressed)
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send<NavigateBackMessage>(new());
|
||||
}
|
||||
|
||||
if (!e.Handled)
|
||||
{
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="using:Microsoft.CmdPal.UI.Controls"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:labToolkit="using:CommunityToolkit.Labs.WinUI.MarkdownTextBlock"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:tk7controls="using:CommunityToolkit.WinUI.UI.Controls"
|
||||
x:Name="ShortcutContentControl"
|
||||
mc:Ignorable="d">
|
||||
<Grid MinWidth="498" MinHeight="220">
|
||||
@@ -66,7 +66,7 @@
|
||||
IsTabStop="{Binding ElementName=ShortcutContentControl, Path=IsWarningAltGr, Mode=OneWay}"
|
||||
Severity="Warning" />
|
||||
</Grid>
|
||||
<labToolkit:MarkdownTextBlock
|
||||
<tk7controls:MarkdownTextBlock
|
||||
x:Uid="InvalidShortcutWarningLabel"
|
||||
Background="Transparent"
|
||||
FontSize="12"
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="using:Microsoft.CmdPal.UI.Controls"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:labToolkit="using:CommunityToolkit.Labs.WinUI.MarkdownTextBlock"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:tk7controls="using:CommunityToolkit.WinUI.UI.Controls"
|
||||
d:DesignHeight="300"
|
||||
d:DesignWidth="400"
|
||||
mc:Ignorable="d">
|
||||
@@ -36,7 +36,7 @@
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
<labToolkit:MarkdownTextBlock
|
||||
<tk7controls:MarkdownTextBlock
|
||||
Grid.Column="1"
|
||||
VerticalAlignment="Center"
|
||||
Background="Transparent"
|
||||
|
||||
@@ -10,9 +10,7 @@
|
||||
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
|
||||
xmlns:converters="using:CommunityToolkit.WinUI.Converters"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:labToolkit="using:CommunityToolkit.Labs.WinUI.MarkdownTextBlock"
|
||||
xmlns:local="using:Microsoft.CmdPal.UI"
|
||||
xmlns:markdownTextBlockRns="using:CommunityToolkit.WinUI.Controls.MarkdownTextBlockRns"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:toolkit="using:CommunityToolkit.WinUI.UI.Controls"
|
||||
xmlns:viewModels="using:Microsoft.CmdPal.UI.ViewModels"
|
||||
@@ -21,12 +19,6 @@
|
||||
|
||||
<Page.Resources>
|
||||
<ResourceDictionary>
|
||||
<markdownTextBlockRns:MarkdownThemes
|
||||
x:Key="DefaultMarkdownThemeConfig"
|
||||
H3FontSize="12"
|
||||
H3FontWeight="Normal" />
|
||||
<labToolkit:MarkdownConfig x:Key="DefaultMarkdownConfig" Themes="{StaticResource DefaultMarkdownThemeConfig}" />
|
||||
|
||||
<StackLayout
|
||||
x:Name="VerticalStackLayout"
|
||||
Orientation="Vertical"
|
||||
@@ -51,9 +43,12 @@
|
||||
|
||||
<DataTemplate x:Key="MarkdownContentTemplate" x:DataType="viewModels:ContentMarkdownViewModel">
|
||||
<Grid Margin="0,4,4,4" Padding="12,8,8,8">
|
||||
<labToolkit:MarkdownTextBlock
|
||||
<toolkit:MarkdownTextBlock
|
||||
Background="Transparent"
|
||||
Config="{StaticResource DefaultMarkdownConfig}"
|
||||
Header3FontSize="12"
|
||||
Header3FontWeight="Normal"
|
||||
Header3Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
||||
IsTextSelectionEnabled="True"
|
||||
Text="{x:Bind Body, Mode=OneWay}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
@@ -66,9 +61,12 @@
|
||||
|
||||
<DataTemplate x:Key="NestedMarkdownContentTemplate" x:DataType="viewModels:ContentMarkdownViewModel">
|
||||
<Grid>
|
||||
<labToolkit:MarkdownTextBlock
|
||||
<toolkit:MarkdownTextBlock
|
||||
Background="Transparent"
|
||||
Config="{StaticResource DefaultMarkdownConfig}"
|
||||
Header3FontSize="12"
|
||||
Header3FontWeight="Normal"
|
||||
Header3Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
||||
IsTextSelectionEnabled="True"
|
||||
Text="{x:Bind Body, Mode=OneWay}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
@@ -6,7 +6,6 @@ using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using CmdPalKeyboardService;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using ManagedCommon;
|
||||
using Microsoft.CmdPal.Common.Helpers;
|
||||
using Microsoft.CmdPal.Common.Messages;
|
||||
using Microsoft.CmdPal.Common.Services;
|
||||
@@ -107,7 +106,7 @@ public sealed partial class MainWindow : WindowEx,
|
||||
App.Current.Services.GetService<SettingsModel>()!.SettingsChanged += SettingsChangedHandler;
|
||||
|
||||
// Make sure that we update the acrylic theme when the OS theme changes
|
||||
RootShellPage.ActualThemeChanged += (s, e) => DispatcherQueue.TryEnqueue(UpdateAcrylic);
|
||||
RootShellPage.ActualThemeChanged += (s, e) => UpdateAcrylic();
|
||||
|
||||
// Hardcoding event name to avoid bringing in the PowerToys.interop dependency. Event name must match CMDPAL_SHOW_EVENT from shared_constants.h
|
||||
NativeEventWaiter.WaitForEventLoop("Local\\PowerToysCmdPal-ShowEvent-62336fcd-8611-4023-9b30-091a6af4cc5a", () =>
|
||||
@@ -175,8 +174,6 @@ public sealed partial class MainWindow : WindowEx,
|
||||
|
||||
private void UpdateAcrylic()
|
||||
{
|
||||
_acrylicController?.RemoveAllSystemBackdropTargets();
|
||||
|
||||
_acrylicController = GetAcrylicConfig(Content);
|
||||
|
||||
// Enable the system backdrop.
|
||||
@@ -236,10 +233,6 @@ public sealed partial class MainWindow : WindowEx,
|
||||
|
||||
PInvoke.SetForegroundWindow(hwnd);
|
||||
PInvoke.SetActiveWindow(hwnd);
|
||||
|
||||
// Push our window to the top of the Z-order and make it the topmost, so that it appears above all other windows.
|
||||
// We want to remove the topmost status when we hide the window (because we cloak it instead of hiding it).
|
||||
PInvoke.SetWindowPos(hwnd, HWND.HWND_TOPMOST, 0, 0, 0, 0, SET_WINDOW_POS_FLAGS.SWP_NOMOVE | SET_WINDOW_POS_FLAGS.SWP_NOSIZE);
|
||||
}
|
||||
|
||||
private DisplayArea GetScreen(HWND currentHwnd, MonitorBehavior target)
|
||||
@@ -309,14 +302,8 @@ public sealed partial class MainWindow : WindowEx,
|
||||
// This might come in on a background thread
|
||||
DispatcherQueue.TryEnqueue(() => Close());
|
||||
|
||||
public void Receive(DismissMessage message)
|
||||
{
|
||||
// This might come in off the UI thread. Make sure to hop back.
|
||||
DispatcherQueue.TryEnqueue(() =>
|
||||
{
|
||||
HideWindow();
|
||||
});
|
||||
}
|
||||
public void Receive(DismissMessage message) =>
|
||||
HideWindow();
|
||||
|
||||
private void HideWindow()
|
||||
{
|
||||
@@ -344,10 +331,6 @@ public sealed partial class MainWindow : WindowEx,
|
||||
BOOL value = true;
|
||||
PInvoke.DwmSetWindowAttribute(_hwnd, DWMWINDOWATTRIBUTE.DWMWA_CLOAK, &value, (uint)sizeof(BOOL));
|
||||
}
|
||||
|
||||
// Because we're only cloaking the window, bury it at the bottom in case something can
|
||||
// see it - e.g. some accessibility helper (note: this also removes the top-most status).
|
||||
PInvoke.SetWindowPos(_hwnd, HWND.HWND_BOTTOM, 0, 0, 0, 0, SET_WINDOW_POS_FLAGS.SWP_NOMOVE | SET_WINDOW_POS_FLAGS.SWP_NOSIZE);
|
||||
}
|
||||
|
||||
private void Uncloak()
|
||||
@@ -467,42 +450,30 @@ public sealed partial class MainWindow : WindowEx,
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
if (activatedEventArgs.Kind == Microsoft.Windows.AppLifecycle.ExtendedActivationKind.Protocol)
|
||||
{
|
||||
if (activatedEventArgs.Kind == ExtendedActivationKind.StartupTask)
|
||||
if (activatedEventArgs.Data is IProtocolActivatedEventArgs protocolArgs)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (activatedEventArgs.Kind == ExtendedActivationKind.Protocol)
|
||||
{
|
||||
if (activatedEventArgs.Data is IProtocolActivatedEventArgs protocolArgs)
|
||||
if (protocolArgs.Uri.ToString() is string uri)
|
||||
{
|
||||
if (protocolArgs.Uri.ToString() is string uri)
|
||||
// was the URI "x-cmdpal://background" ?
|
||||
if (uri.StartsWith("x-cmdpal://background", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// was the URI "x-cmdpal://background" ?
|
||||
if (uri.StartsWith("x-cmdpal://background", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// we're running, we don't want to activate our window. bail
|
||||
return;
|
||||
}
|
||||
else if (uri.StartsWith("x-cmdpal://settings", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send<OpenSettingsMessage>(new());
|
||||
return;
|
||||
}
|
||||
// we're running, we don't want to activate our window. bail
|
||||
return;
|
||||
}
|
||||
else if (uri.StartsWith("x-cmdpal://settings", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send<OpenSettingsMessage>(new());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (COMException ex)
|
||||
{
|
||||
// Accessing properties activatedEventArgs.Kind and activatedEventArgs.Data might cause COMException
|
||||
// if the args are not valid or not passed correctly.
|
||||
Logger.LogError("COM exception when activating the application", ex);
|
||||
}
|
||||
|
||||
Summon(string.Empty);
|
||||
Activate();
|
||||
}
|
||||
|
||||
public void Summon(string commandId) =>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="..\..\..\Common.Dotnet.CsWinRT.props" />
|
||||
<Import Project="..\..\..\Common.Dotnet.AotCompatibility.props" />
|
||||
<Import Project="..\..\..\CmdPalVersion.props" />
|
||||
<Import Project="CmdPal.pre.props" />
|
||||
<Import Project="CmdPal.Branding.props" />
|
||||
@@ -24,13 +23,6 @@
|
||||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(EnableCmdPalAOT)' == 'true'">
|
||||
<SelfContained>true</SelfContained>
|
||||
<PublishSingleFile>false</PublishSingleFile>
|
||||
<DisableRuntimeMarshalling>false</DisableRuntimeMarshalling>
|
||||
<PublishAot>true</PublishAot>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(CIBuild)'=='true'">
|
||||
<GenerateAppxPackageOnBuild>true</GenerateAppxPackageOnBuild>
|
||||
</PropertyGroup>
|
||||
@@ -79,7 +71,7 @@
|
||||
<PackageReference Include="CommunityToolkit.WinUI.Converters" />
|
||||
<PackageReference Include="CommunityToolkit.WinUI.Animations" />
|
||||
<PackageReference Include="CommunityToolkit.WinUI.Extensions" />
|
||||
<PackageReference Include="CommunityToolkit.Labs.WinUI.Controls.MarkdownTextBlock" />
|
||||
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls.Markdown" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
|
||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" />
|
||||
<PackageReference Include="Microsoft.WindowsAppSDK" />
|
||||
|
||||
@@ -6,8 +6,6 @@ SetForegroundWindow
|
||||
GetWindowRect
|
||||
GetCursorPos
|
||||
SetWindowPos
|
||||
HWND_TOPMOST
|
||||
HWND_BOTTOM
|
||||
IsIconic
|
||||
RegisterHotKey
|
||||
UnregisterHotKey
|
||||
@@ -22,6 +20,7 @@ SetActiveWindow
|
||||
MonitorFromWindow
|
||||
GetMonitorInfo
|
||||
GetDpiForMonitor
|
||||
CoAllowSetForegroundWindow
|
||||
WM_HOTKEY
|
||||
WM_NCLBUTTONDBLCLK
|
||||
|
||||
@@ -44,7 +43,3 @@ MessageBox
|
||||
DwmGetWindowAttribute
|
||||
DwmSetWindowAttribute
|
||||
DWM_CLOAKED_APP
|
||||
|
||||
CoWaitForMultipleObjects
|
||||
INFINITE
|
||||
CWMO_FLAGS
|
||||
@@ -9,10 +9,8 @@
|
||||
xmlns:cpcontrols="using:Microsoft.CmdPal.UI.Controls"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:help="using:Microsoft.CmdPal.UI.Helpers"
|
||||
xmlns:labToolkit="using:CommunityToolkit.Labs.WinUI.MarkdownTextBlock"
|
||||
xmlns:markdownTextBlockRns="using:CommunityToolkit.WinUI.Controls.MarkdownTextBlockRns"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:toolkit="using:CommunityToolkit.WinUI.Controls"
|
||||
xmlns:toolkit="using:CommunityToolkit.WinUI.UI.Controls"
|
||||
xmlns:ui="using:CommunityToolkit.WinUI"
|
||||
xmlns:viewModels="using:Microsoft.CmdPal.UI.ViewModels"
|
||||
Background="Transparent"
|
||||
@@ -146,11 +144,6 @@
|
||||
</ItemsControl>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
<markdownTextBlockRns:MarkdownThemes
|
||||
x:Key="DefaultMarkdownThemeConfig"
|
||||
H3FontSize="12"
|
||||
H3FontWeight="Normal" />
|
||||
<labToolkit:MarkdownConfig x:Key="DefaultMarkdownConfig" Themes="{StaticResource DefaultMarkdownThemeConfig}" />
|
||||
</ResourceDictionary>
|
||||
</Page.Resources>
|
||||
|
||||
@@ -413,11 +406,14 @@
|
||||
TextWrapping="WrapWholeWords"
|
||||
Visibility="{x:Bind ViewModel.Details.Title, Converter={StaticResource StringNotEmptyToVisibilityConverter}, Mode=OneWay}" />
|
||||
|
||||
<labToolkit:MarkdownTextBlock
|
||||
<toolkit:MarkdownTextBlock
|
||||
Grid.Row="2"
|
||||
Margin="0,4,0,24"
|
||||
Background="Transparent"
|
||||
Config="{StaticResource DefaultMarkdownConfig}"
|
||||
Header3FontSize="12"
|
||||
Header3FontWeight="Normal"
|
||||
Header3Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
||||
IsTextSelectionEnabled="True"
|
||||
Text="{x:Bind ViewModel.Details.Body, Mode=OneWay}" />
|
||||
|
||||
<ItemsRepeater
|
||||
|
||||
@@ -14,13 +14,10 @@ using Microsoft.CommandPalette.Extensions;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using Microsoft.UI.Dispatching;
|
||||
using Microsoft.UI.Input;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Controls.Primitives;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
using Microsoft.UI.Xaml.Media.Animation;
|
||||
using DispatcherQueue = Microsoft.UI.Dispatching.DispatcherQueue;
|
||||
using VirtualKey = Windows.System.VirtualKey;
|
||||
|
||||
namespace Microsoft.CmdPal.UI.Pages;
|
||||
|
||||
@@ -82,9 +79,6 @@ public sealed partial class ShellPage : Microsoft.UI.Xaml.Controls.Page,
|
||||
WeakReferenceMessenger.Default.Register<ShowToastMessage>(this);
|
||||
WeakReferenceMessenger.Default.Register<NavigateToPageMessage>(this);
|
||||
|
||||
AddHandler(PreviewKeyDownEvent, new KeyEventHandler(ShellPage_OnPreviewKeyDown), true);
|
||||
AddHandler(PointerPressedEvent, new PointerEventHandler(ShellPage_OnPointerPressed), true);
|
||||
|
||||
RootFrame.Navigate(typeof(LoadingPage), ViewModel);
|
||||
}
|
||||
|
||||
@@ -448,32 +442,4 @@ public sealed partial class ShellPage : Microsoft.UI.Xaml.Controls.Page,
|
||||
WeakReferenceMessenger.Default.Send<PerformCommandMessage>(new(commandViewModel.Model));
|
||||
}
|
||||
}
|
||||
|
||||
private void ShellPage_OnPreviewKeyDown(object sender, KeyRoutedEventArgs e)
|
||||
{
|
||||
if (e.Key == VirtualKey.Left && e.KeyStatus.IsMenuKeyDown)
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send<NavigateBackMessage>(new());
|
||||
}
|
||||
}
|
||||
|
||||
private void ShellPage_OnPointerPressed(object sender, PointerRoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var ptr = e.Pointer;
|
||||
if (ptr.PointerDeviceType == PointerDeviceType.Mouse)
|
||||
{
|
||||
var ptrPt = e.GetCurrentPoint(this);
|
||||
if (ptrPt.Properties.IsXButton1Pressed)
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send(new NavigateBackMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError("Error handling mouse button press event", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using ManagedCommon;
|
||||
using Microsoft.CmdPal.Common.Services;
|
||||
using Microsoft.CmdPal.UI.ViewModels;
|
||||
using Microsoft.CmdPal.UI.ViewModels.MainPage;
|
||||
using Microsoft.CommandPalette.Extensions;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
// To learn more about WinUI, the WinUI project structure,
|
||||
// and more about our project templates, see: http://aka.ms/winui-project-info.
|
||||
namespace Microsoft.CmdPal.UI;
|
||||
|
||||
internal sealed class PowerToysRootPageService : IRootPageService
|
||||
{
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private Lazy<MainListPage> _mainListPage;
|
||||
|
||||
public PowerToysRootPageService(IServiceProvider serviceProvider)
|
||||
{
|
||||
_serviceProvider = serviceProvider;
|
||||
|
||||
_mainListPage = new Lazy<MainListPage>(() =>
|
||||
{
|
||||
return new MainListPage(_serviceProvider);
|
||||
});
|
||||
}
|
||||
|
||||
public async Task PreLoadAsync()
|
||||
{
|
||||
var tlcManager = _serviceProvider.GetService<TopLevelCommandManager>()!;
|
||||
await tlcManager.LoadBuiltinsAsync();
|
||||
}
|
||||
|
||||
public Microsoft.CommandPalette.Extensions.IPage GetRootPage()
|
||||
{
|
||||
return _mainListPage.Value;
|
||||
}
|
||||
|
||||
public async Task PostLoadRootPageAsync()
|
||||
{
|
||||
var tlcManager = _serviceProvider.GetService<TopLevelCommandManager>()!;
|
||||
|
||||
// After loading built-ins, and starting navigation, kick off a thread to load extensions.
|
||||
tlcManager.LoadExtensionsCommand.Execute(null);
|
||||
|
||||
await tlcManager.LoadExtensionsCommand.ExecutionTask!;
|
||||
if (tlcManager.LoadExtensionsCommand.ExecutionTask.Status != TaskStatus.RanToCompletion)
|
||||
{
|
||||
// TODO: Handle failure case
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPerformTopLevelCommand(object? context)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (context is IListItem listItem)
|
||||
{
|
||||
_mainListPage.Value.UpdateHistory(listItem);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError("Failed to update history in PowerToysRootPageService");
|
||||
Logger.LogError(ex.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,11 +6,9 @@ using System.Runtime.InteropServices;
|
||||
using ManagedCommon;
|
||||
using Microsoft.CmdPal.UI.Events;
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using Microsoft.UI.Dispatching;
|
||||
using Microsoft.Windows.AppLifecycle;
|
||||
using Windows.Win32;
|
||||
using Windows.Win32.Foundation;
|
||||
using Windows.Win32.System.Com;
|
||||
using Windows.Win32.UI.WindowsAndMessaging;
|
||||
|
||||
namespace Microsoft.CmdPal.UI;
|
||||
@@ -20,7 +18,6 @@ namespace Microsoft.CmdPal.UI;
|
||||
// https://github.com/microsoft/WindowsAppSDK-Samples/tree/main/Samples/AppLifecycle/Instancing/cs2/cs-winui-packaged/CsWinUiDesktopInstancing
|
||||
internal sealed class Program
|
||||
{
|
||||
private static DispatcherQueueSynchronizationContext? uiContext;
|
||||
private static App? app;
|
||||
|
||||
// LOAD BEARING
|
||||
@@ -73,8 +70,8 @@ internal sealed class Program
|
||||
{
|
||||
Microsoft.UI.Xaml.Application.Start((p) =>
|
||||
{
|
||||
uiContext = new DispatcherQueueSynchronizationContext(DispatcherQueue.GetForCurrentThread());
|
||||
SynchronizationContext.SetSynchronizationContext(uiContext);
|
||||
Microsoft.UI.Dispatching.DispatcherQueueSynchronizationContext context = new(Microsoft.UI.Dispatching.DispatcherQueue.GetForCurrentThread());
|
||||
SynchronizationContext.SetSynchronizationContext(context);
|
||||
app = new App();
|
||||
});
|
||||
}
|
||||
@@ -97,29 +94,12 @@ internal sealed class Program
|
||||
{
|
||||
isRedirect = true;
|
||||
PowerToysTelemetry.Log.WriteEvent(new ReactivateInstance());
|
||||
RedirectActivationTo(args, keyInstance);
|
||||
keyInstance.RedirectActivationToAsync(args).AsTask().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
return isRedirect;
|
||||
}
|
||||
|
||||
private static void RedirectActivationTo(AppActivationArguments args, AppInstance keyInstance)
|
||||
{
|
||||
// Do the redirection on another thread, and use a non-blocking
|
||||
// wait method to wait for the redirection to complete.
|
||||
var redirectSemaphore = new Semaphore(0, 1);
|
||||
Task.Run(() =>
|
||||
{
|
||||
keyInstance.RedirectActivationToAsync(args).AsTask().Wait();
|
||||
redirectSemaphore.Release();
|
||||
});
|
||||
_ = PInvoke.CoWaitForMultipleObjects(
|
||||
(uint)CWMO_FLAGS.CWMO_DEFAULT,
|
||||
PInvoke.INFINITE,
|
||||
[new HANDLE(redirectSemaphore.SafeWaitHandle.DangerousGetHandle())],
|
||||
out _);
|
||||
}
|
||||
|
||||
private static void OnActivated(object? sender, AppActivationArguments args)
|
||||
{
|
||||
// If we already have a form, display the message now.
|
||||
@@ -129,7 +109,9 @@ internal sealed class Program
|
||||
if (thisApp.AppWindow is not null and
|
||||
MainWindow mainWindow)
|
||||
{
|
||||
uiContext?.Post(_ => mainWindow.HandleLaunch(args), null);
|
||||
mainWindow.HandleLaunch(args);
|
||||
|
||||
// mainWindow.Summon(string.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
<PublishSingleFile>False</PublishSingleFile>
|
||||
<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>
|
||||
<PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">True</PublishReadyToRun>
|
||||
<PublishTrimmed Condition="'$(EnableCmdPalAOT)' == 'true'">True</PublishTrimmed>
|
||||
<PublishTrimmed Condition="'$(EnableCmdPalAOT)' != 'true'">False</PublishTrimmed>
|
||||
<PublishTrimmed Condition="'$(Configuration)' == 'Debug'">False</PublishTrimmed>
|
||||
<PublishTrimmed Condition="'$(Configuration)' != 'Debug'">False</PublishTrimmed>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -13,7 +13,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
<PublishSingleFile>False</PublishSingleFile>
|
||||
<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>
|
||||
<PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">True</PublishReadyToRun>
|
||||
<PublishTrimmed Condition="'$(EnableCmdPalAOT)' == 'true'">True</PublishTrimmed>
|
||||
<PublishTrimmed Condition="'$(EnableCmdPalAOT)' != 'true'">False</PublishTrimmed>
|
||||
<PublishTrimmed Condition="'$(Configuration)' == 'Debug'">False</PublishTrimmed>
|
||||
<PublishTrimmed Condition="'$(Configuration)' != 'Debug'">False</PublishTrimmed>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -106,40 +106,6 @@
|
||||
</ItemsRepeater.ItemTemplate>
|
||||
</ItemsRepeater>
|
||||
|
||||
<TextBlock
|
||||
x:Uid="ExtensionFallbackCommandsHeader"
|
||||
Style="{StaticResource SettingsSectionHeaderTextBlockStyle}"
|
||||
Visibility="{x:Bind ViewModel.HasFallbackCommands}" />
|
||||
|
||||
<ItemsRepeater
|
||||
ItemsSource="{x:Bind ViewModel.FallbackCommands, Mode=OneWay}"
|
||||
Layout="{StaticResource VerticalStackLayout}"
|
||||
Visibility="{x:Bind ViewModel.HasFallbackCommands}">
|
||||
<ItemsRepeater.ItemTemplate>
|
||||
<DataTemplate x:DataType="viewModels:TopLevelViewModel">
|
||||
<controls:SettingsCard DataContext="{x:Bind}" Header="{x:Bind DisplayTitle, Mode=OneWay}">
|
||||
<controls:SettingsCard.HeaderIcon>
|
||||
<cpcontrols:ContentIcon>
|
||||
<cpcontrols:ContentIcon.Content>
|
||||
<cpcontrols:IconBox
|
||||
Width="20"
|
||||
Height="20"
|
||||
AutomationProperties.AccessibilityView="Raw"
|
||||
SourceKey="{x:Bind Icon, Mode=OneWay}"
|
||||
SourceRequested="{x:Bind helpers:IconCacheProvider.SourceRequested}" />
|
||||
</cpcontrols:ContentIcon.Content>
|
||||
</cpcontrols:ContentIcon>
|
||||
</controls:SettingsCard.HeaderIcon>
|
||||
|
||||
<!-- Content goes here -->
|
||||
<ToggleSwitch IsOn="{x:Bind IsEnabled, Mode=TwoWay}" />
|
||||
|
||||
|
||||
</controls:SettingsCard>
|
||||
</DataTemplate>
|
||||
</ItemsRepeater.ItemTemplate>
|
||||
</ItemsRepeater>
|
||||
|
||||
<TextBlock
|
||||
x:Uid="ExtensionSettingsHeader"
|
||||
Style="{StaticResource SettingsSectionHeaderTextBlockStyle}"
|
||||
|
||||
@@ -241,10 +241,6 @@ Right-click to remove the key combination, thereby deactivating the shortcut.</v
|
||||
<value>Commands</value>
|
||||
<comment>A section header for information about the app</comment>
|
||||
</data>
|
||||
<data name="ExtensionFallbackCommandsHeader.Text" xml:space="preserve">
|
||||
<value>Fallback commands</value>
|
||||
<comment>A section header for information about the commands presented to the user when the search text doesn't exactly match the name of a command.</comment>
|
||||
</data>
|
||||
<data name="ExtensionDisabledHeader.Text" xml:space="preserve">
|
||||
<value>This extension is disabled</value>
|
||||
<comment>A header to inform the user that an extension is not currently active</comment>
|
||||
|
||||
@@ -2,12 +2,8 @@
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.CmdPal.Ext.Apps.Programs;
|
||||
using Microsoft.CmdPal.Ext.Apps.Properties;
|
||||
using Microsoft.CmdPal.Ext.Apps.State;
|
||||
using Microsoft.CommandPalette.Extensions;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
|
||||
@@ -15,15 +11,13 @@ namespace Microsoft.CmdPal.Ext.Apps;
|
||||
|
||||
public partial class AllAppsCommandProvider : CommandProvider
|
||||
{
|
||||
public const string WellKnownId = "AllApps";
|
||||
|
||||
public static readonly AllAppsPage Page = new();
|
||||
|
||||
private readonly CommandItem _listItem;
|
||||
|
||||
public AllAppsCommandProvider()
|
||||
{
|
||||
Id = WellKnownId;
|
||||
Id = "AllApps";
|
||||
DisplayName = Resources.installed_apps;
|
||||
Icon = IconHelpers.FromRelativePath("Assets\\AllApps.svg");
|
||||
Settings = AllAppsSettings.Instance.Settings;
|
||||
@@ -33,12 +27,9 @@ public partial class AllAppsCommandProvider : CommandProvider
|
||||
Subtitle = Resources.search_installed_apps,
|
||||
MoreCommands = [new CommandContextItem(AllAppsSettings.Instance.Settings.SettingsPage)],
|
||||
};
|
||||
|
||||
// Subscribe to pin state changes to refresh the command provider
|
||||
PinnedAppsManager.Instance.PinStateChanged += OnPinStateChanged;
|
||||
}
|
||||
|
||||
public override ICommandItem[] TopLevelCommands() => [_listItem, ..Page.GetPinnedApps()];
|
||||
public override ICommandItem[] TopLevelCommands() => [_listItem];
|
||||
|
||||
public ICommandItem? LookupApp(string displayName)
|
||||
{
|
||||
@@ -69,9 +60,4 @@ public partial class AllAppsCommandProvider : CommandProvider
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void OnPinStateChanged(object? sender, System.EventArgs e)
|
||||
{
|
||||
RaiseItemsChanged(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,20 +2,14 @@
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using ManagedCommon;
|
||||
using Microsoft.CmdPal.Ext.Apps.Commands;
|
||||
using Microsoft.CmdPal.Ext.Apps.Helpers;
|
||||
using Microsoft.CmdPal.Ext.Apps.Programs;
|
||||
using Microsoft.CmdPal.Ext.Apps.Properties;
|
||||
using Microsoft.CmdPal.Ext.Apps.State;
|
||||
using Microsoft.CommandPalette.Extensions;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
|
||||
@@ -24,22 +18,16 @@ namespace Microsoft.CmdPal.Ext.Apps;
|
||||
public sealed partial class AllAppsPage : ListPage
|
||||
{
|
||||
private readonly Lock _listLock = new();
|
||||
|
||||
private AppItem[] allApps = [];
|
||||
private AppListItem[] unpinnedApps = [];
|
||||
private AppListItem[] pinnedApps = [];
|
||||
private AppListItem[] allAppsSection = [];
|
||||
|
||||
public AllAppsPage()
|
||||
{
|
||||
this.Name = Resources.all_apps;
|
||||
this.Icon = Icons.AllAppsIcon;
|
||||
this.Icon = IconHelpers.FromRelativePath("Assets\\AllApps.svg");
|
||||
this.ShowDetails = true;
|
||||
this.IsLoading = true;
|
||||
this.PlaceholderText = Resources.search_installed_apps_placeholder;
|
||||
|
||||
// Subscribe to pin state changes to refresh the command provider
|
||||
PinnedAppsManager.Instance.PinStateChanged += OnPinStateChanged;
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
lock (_listLock)
|
||||
@@ -49,139 +37,89 @@ public sealed partial class AllAppsPage : ListPage
|
||||
});
|
||||
}
|
||||
|
||||
internal AppListItem[] GetPinnedApps()
|
||||
{
|
||||
BuildListItems();
|
||||
return pinnedApps;
|
||||
}
|
||||
|
||||
public override IListItem[] GetItems()
|
||||
{
|
||||
// Build or update the list if needed
|
||||
BuildListItems();
|
||||
return pinnedApps.Concat(unpinnedApps).ToArray();
|
||||
if (allAppsSection.Length == 0 || AppCache.Instance.Value.ShouldReload())
|
||||
{
|
||||
lock (_listLock)
|
||||
{
|
||||
BuildListItems();
|
||||
}
|
||||
}
|
||||
|
||||
return allAppsSection;
|
||||
}
|
||||
|
||||
private void BuildListItems()
|
||||
{
|
||||
if (allApps.Length == 0 || AppCache.Instance.Value.ShouldReload())
|
||||
{
|
||||
lock (_listLock)
|
||||
{
|
||||
this.IsLoading = true;
|
||||
this.IsLoading = true;
|
||||
|
||||
Stopwatch stopwatch = new();
|
||||
stopwatch.Start();
|
||||
Stopwatch stopwatch = new();
|
||||
stopwatch.Start();
|
||||
|
||||
var apps = GetPrograms();
|
||||
this.allApps = apps.AllApps;
|
||||
this.pinnedApps = apps.PinnedItems;
|
||||
this.unpinnedApps = apps.UnpinnedItems;
|
||||
var apps = GetPrograms();
|
||||
|
||||
this.IsLoading = false;
|
||||
this.allAppsSection = apps
|
||||
.Select((app) => new AppListItem(app, true))
|
||||
.ToArray();
|
||||
|
||||
AppCache.Instance.Value.ResetReloadFlag();
|
||||
this.IsLoading = false;
|
||||
|
||||
stopwatch.Stop();
|
||||
Logger.LogTrace($"{nameof(AllAppsPage)}.{nameof(BuildListItems)} took: {stopwatch.ElapsedMilliseconds} ms");
|
||||
}
|
||||
}
|
||||
AppCache.Instance.Value.ResetReloadFlag();
|
||||
|
||||
stopwatch.Stop();
|
||||
Logger.LogTrace($"{nameof(AllAppsPage)}.{nameof(BuildListItems)} took: {stopwatch.ElapsedMilliseconds} ms");
|
||||
}
|
||||
|
||||
private AppItem[] GetAllApps()
|
||||
internal List<AppItem> GetPrograms()
|
||||
{
|
||||
var uwpResults = AppCache.Instance.Value.UWPs
|
||||
.Where((application) => application.Enabled)
|
||||
.Select(app => app.ToAppItem());
|
||||
.Where((application) => application.Enabled)
|
||||
.Select(UwpToAppItem);
|
||||
|
||||
var win32Results = AppCache.Instance.Value.Win32s
|
||||
.Where((application) => application.Enabled && application.Valid)
|
||||
.Select(app => app.ToAppItem());
|
||||
.Select(app =>
|
||||
{
|
||||
var icoPath = string.IsNullOrEmpty(app.IcoPath) ?
|
||||
(app.AppType == Win32Program.ApplicationType.InternetShortcutApplication ?
|
||||
app.IcoPath :
|
||||
app.FullPath) :
|
||||
app.IcoPath;
|
||||
|
||||
var allApps = uwpResults.Concat(win32Results).ToArray();
|
||||
return allApps;
|
||||
// icoPath = icoPath.EndsWith(".lnk", System.StringComparison.InvariantCultureIgnoreCase) ? (icoPath + ",0") : icoPath;
|
||||
icoPath = icoPath.EndsWith(".lnk", System.StringComparison.InvariantCultureIgnoreCase) ?
|
||||
app.FullPath :
|
||||
icoPath;
|
||||
return new AppItem()
|
||||
{
|
||||
Name = app.Name,
|
||||
Subtitle = app.Description,
|
||||
Type = app.Type(),
|
||||
IcoPath = icoPath,
|
||||
ExePath = !string.IsNullOrEmpty(app.LnkFilePath) ? app.LnkFilePath : app.FullPath,
|
||||
DirPath = app.Location,
|
||||
Commands = app.GetCommands(),
|
||||
};
|
||||
});
|
||||
|
||||
return uwpResults.Concat(win32Results).OrderBy(app => app.Name).ToList();
|
||||
}
|
||||
|
||||
internal (AppItem[] AllApps, AppListItem[] PinnedItems, AppListItem[] UnpinnedItems) GetPrograms()
|
||||
private AppItem UwpToAppItem(UWPApplication app)
|
||||
{
|
||||
var allApps = GetAllApps();
|
||||
var pinned = new List<AppListItem>();
|
||||
var unpinned = new List<AppListItem>();
|
||||
|
||||
foreach (var app in allApps)
|
||||
var iconPath = app.LogoType != LogoType.Error ? app.LogoPath : string.Empty;
|
||||
var item = new AppItem()
|
||||
{
|
||||
var isPinned = PinnedAppsManager.Instance.IsAppPinned(app.AppIdentifier);
|
||||
var appListItem = new AppListItem(app, true, isPinned);
|
||||
|
||||
if (isPinned)
|
||||
{
|
||||
appListItem.Tags = appListItem.Tags
|
||||
.Concat([new Tag() { Icon = Icons.PinIcon }])
|
||||
.ToArray();
|
||||
pinned.Add(appListItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
unpinned.Add(appListItem);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
allApps
|
||||
.ToArray(),
|
||||
pinned
|
||||
.OrderBy(app => app.Title)
|
||||
.ToArray(),
|
||||
unpinned
|
||||
.OrderBy(app => app.Title)
|
||||
.ToArray());
|
||||
}
|
||||
|
||||
private void OnPinStateChanged(object? sender, PinStateChangedEventArgs e)
|
||||
{
|
||||
/*
|
||||
* Rebuilding all the lists is pretty expensive.
|
||||
* So, instead, we'll just compare pinned items to move existing
|
||||
* items between the two lists.
|
||||
*/
|
||||
var existingAppItem = allApps.FirstOrDefault(f => f.AppIdentifier == e.AppIdentifier);
|
||||
|
||||
if (existingAppItem != null)
|
||||
{
|
||||
var appListItem = new AppListItem(existingAppItem, true, e.IsPinned);
|
||||
|
||||
if (e.IsPinned)
|
||||
{
|
||||
// Remove it from the unpinned apps array
|
||||
this.unpinnedApps = this.unpinnedApps
|
||||
.Where(app => app.AppIdentifier != existingAppItem.AppIdentifier)
|
||||
.OrderBy(app => app.Title)
|
||||
.ToArray();
|
||||
|
||||
var newPinned = this.pinnedApps.ToList();
|
||||
newPinned.Add(appListItem);
|
||||
|
||||
this.pinnedApps = newPinned
|
||||
.OrderBy(app => app.Title)
|
||||
.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Remove it from the pinned apps array
|
||||
this.pinnedApps = this.pinnedApps
|
||||
.Where(app => app.AppIdentifier != existingAppItem.AppIdentifier)
|
||||
.OrderBy(app => app.Title)
|
||||
.ToArray();
|
||||
|
||||
var newUnpinned = this.unpinnedApps.ToList();
|
||||
newUnpinned.Add(appListItem);
|
||||
|
||||
this.unpinnedApps = newUnpinned
|
||||
.OrderBy(app => app.Title)
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
RaiseItemsChanged(0);
|
||||
}
|
||||
Name = app.Name,
|
||||
Subtitle = app.Description,
|
||||
Type = UWPApplication.Type(),
|
||||
IcoPath = iconPath,
|
||||
DirPath = app.Location,
|
||||
UserModelId = app.UserModelId,
|
||||
IsPackaged = true,
|
||||
Commands = app.GetCommands(),
|
||||
};
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.CmdPal.Ext.Apps.Programs;
|
||||
using Microsoft.CommandPalette.Extensions;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
|
||||
namespace Microsoft.CmdPal.Ext.Apps;
|
||||
@@ -27,9 +26,7 @@ internal sealed class AppItem
|
||||
|
||||
public bool IsPackaged { get; set; }
|
||||
|
||||
public List<IContextItem>? Commands { get; set; }
|
||||
|
||||
public string AppIdentifier { get; set; } = string.Empty;
|
||||
public List<CommandContextItem>? Commands { get; set; }
|
||||
|
||||
public AppItem()
|
||||
{
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.CmdPal.Ext.Apps.Commands;
|
||||
using Microsoft.CommandPalette.Extensions;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
using Windows.Storage.Streams;
|
||||
@@ -24,17 +23,14 @@ internal sealed partial class AppListItem : ListItem
|
||||
|
||||
public override IIconInfo? Icon { get => _icon.Value; set => base.Icon = value; }
|
||||
|
||||
public string AppIdentifier => _app.AppIdentifier;
|
||||
|
||||
public AppListItem(AppItem app, bool useThumbnails, bool isPinned)
|
||||
public AppListItem(AppItem app, bool useThumbnails)
|
||||
: base(new AppCommand(app))
|
||||
{
|
||||
_app = app;
|
||||
Title = app.Name;
|
||||
Subtitle = app.Subtitle;
|
||||
Tags = [_appTag];
|
||||
|
||||
MoreCommands = AddPinCommands(_app.Commands!, isPinned);
|
||||
MoreCommands = _app.Commands!.ToArray();
|
||||
|
||||
_details = new Lazy<Details>(() =>
|
||||
{
|
||||
@@ -125,37 +121,4 @@ internal sealed partial class AppListItem : ListItem
|
||||
|
||||
return icon;
|
||||
}
|
||||
|
||||
private IContextItem[] AddPinCommands(List<IContextItem> commands, bool isPinned)
|
||||
{
|
||||
var newCommands = new List<IContextItem>();
|
||||
newCommands.AddRange(commands);
|
||||
|
||||
newCommands.Add(new SeparatorContextItem());
|
||||
|
||||
// 0x50 = P
|
||||
// Full key chord would be Ctrl+P
|
||||
var pinKeyChord = KeyChordHelpers.FromModifiers(true, false, false, false, 0x50, 0);
|
||||
|
||||
if (isPinned)
|
||||
{
|
||||
newCommands.Add(
|
||||
new CommandContextItem(
|
||||
new UnpinAppCommand(this.AppIdentifier))
|
||||
{
|
||||
RequestedShortcut = pinKeyChord,
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
newCommands.Add(
|
||||
new CommandContextItem(
|
||||
new PinAppCommand(this.AppIdentifier))
|
||||
{
|
||||
RequestedShortcut = pinKeyChord,
|
||||
});
|
||||
}
|
||||
|
||||
return newCommands.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ using System;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using ManagedCommon;
|
||||
using Microsoft.CmdPal.Ext.Apps.Helpers;
|
||||
using Microsoft.CmdPal.Ext.Apps.Properties;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
|
||||
@@ -14,12 +13,14 @@ namespace Microsoft.CmdPal.Ext.Apps.Commands;
|
||||
|
||||
internal sealed partial class CopyPathCommand : InvokableCommand
|
||||
{
|
||||
private static readonly IconInfo TheIcon = new("\ue8c8");
|
||||
|
||||
private readonly string _target;
|
||||
|
||||
public CopyPathCommand(string target)
|
||||
{
|
||||
Name = Resources.copy_path;
|
||||
Icon = Icons.CopyIcon;
|
||||
Icon = TheIcon;
|
||||
|
||||
_target = target;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using ManagedCommon;
|
||||
using Microsoft.CmdPal.Ext.Apps.Helpers;
|
||||
using Microsoft.CmdPal.Ext.Apps.Properties;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
|
||||
@@ -14,12 +13,14 @@ namespace Microsoft.CmdPal.Ext.Apps.Commands;
|
||||
|
||||
internal sealed partial class OpenInConsoleCommand : InvokableCommand
|
||||
{
|
||||
private static readonly IconInfo TheIcon = new("\ue838");
|
||||
|
||||
private readonly string _target;
|
||||
|
||||
public OpenInConsoleCommand(string target)
|
||||
{
|
||||
Name = Resources.open_path_in_console;
|
||||
Icon = Icons.OpenConsoleIcon;
|
||||
Icon = TheIcon;
|
||||
|
||||
_target = target;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.CmdPal.Ext.Apps.Helpers;
|
||||
using Microsoft.CmdPal.Ext.Apps.Properties;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
|
||||
@@ -12,12 +11,14 @@ namespace Microsoft.CmdPal.Ext.Apps.Commands;
|
||||
|
||||
internal sealed partial class OpenPathCommand : InvokableCommand
|
||||
{
|
||||
private static readonly IconInfo TheIcon = new("\ue838");
|
||||
|
||||
private readonly string _target;
|
||||
|
||||
public OpenPathCommand(string target)
|
||||
{
|
||||
Name = Resources.open_location;
|
||||
Icon = Icons.OpenPathIcon;
|
||||
Icon = TheIcon;
|
||||
|
||||
_target = target;
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Microsoft.CmdPal.Ext.Apps.Helpers;
|
||||
using Microsoft.CmdPal.Ext.Apps.Properties;
|
||||
using Microsoft.CmdPal.Ext.Apps.State;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
|
||||
namespace Microsoft.CmdPal.Ext.Apps.Commands;
|
||||
|
||||
internal sealed partial class PinAppCommand : InvokableCommand
|
||||
{
|
||||
private readonly string _appIdentifier;
|
||||
|
||||
public PinAppCommand(string appIdentifier)
|
||||
{
|
||||
_appIdentifier = appIdentifier;
|
||||
Name = Resources.pin_app;
|
||||
Icon = Icons.PinIcon;
|
||||
}
|
||||
|
||||
public override CommandResult Invoke()
|
||||
{
|
||||
PinnedAppsManager.Instance.PinApp(_appIdentifier);
|
||||
return CommandResult.KeepOpen();
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.CmdPal.Ext.Apps.Helpers;
|
||||
using Microsoft.CmdPal.Ext.Apps.Properties;
|
||||
using Microsoft.CmdPal.Ext.Apps.Utils;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
@@ -14,6 +13,8 @@ namespace Microsoft.CmdPal.Ext.Apps.Commands;
|
||||
|
||||
internal sealed partial class RunAsAdminCommand : InvokableCommand
|
||||
{
|
||||
private static readonly IconInfo TheIcon = new("\uE7EF");
|
||||
|
||||
private readonly string _target;
|
||||
private readonly string _parentDir;
|
||||
private readonly bool _packaged;
|
||||
@@ -21,7 +22,7 @@ internal sealed partial class RunAsAdminCommand : InvokableCommand
|
||||
public RunAsAdminCommand(string target, string parentDir, bool packaged)
|
||||
{
|
||||
Name = Resources.run_as_administrator;
|
||||
Icon = Icons.RunAsIcon;
|
||||
Icon = TheIcon;
|
||||
|
||||
_target = target;
|
||||
_parentDir = parentDir;
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.CmdPal.Ext.Apps.Helpers;
|
||||
using Microsoft.CmdPal.Ext.Apps.Properties;
|
||||
using Microsoft.CmdPal.Ext.Apps.Utils;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
@@ -14,19 +13,21 @@ namespace Microsoft.CmdPal.Ext.Apps.Commands;
|
||||
|
||||
internal sealed partial class RunAsUserCommand : InvokableCommand
|
||||
{
|
||||
private static readonly IconInfo TheIcon = new("\uE7EE");
|
||||
|
||||
private readonly string _target;
|
||||
private readonly string _parentDir;
|
||||
|
||||
public RunAsUserCommand(string target, string parentDir)
|
||||
{
|
||||
Name = Resources.run_as_different_user;
|
||||
Icon = Icons.RunAsUserIcon;
|
||||
Icon = TheIcon;
|
||||
|
||||
_target = target;
|
||||
_parentDir = parentDir;
|
||||
}
|
||||
|
||||
internal static async Task RunAsUser(string target, string parentDir)
|
||||
internal static async Task RunAsAdmin(string target, string parentDir)
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
@@ -38,7 +39,7 @@ internal sealed partial class RunAsUserCommand : InvokableCommand
|
||||
|
||||
public override CommandResult Invoke()
|
||||
{
|
||||
_ = RunAsUser(_target, _parentDir).ConfigureAwait(false);
|
||||
_ = RunAsAdmin(_target, _parentDir).ConfigureAwait(false);
|
||||
|
||||
return CommandResult.Dismiss();
|
||||
}
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.CmdPal.Ext.Apps.Helpers;
|
||||
using Microsoft.CmdPal.Ext.Apps.Properties;
|
||||
using Microsoft.CmdPal.Ext.Apps.State;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
|
||||
namespace Microsoft.CmdPal.Ext.Apps.Commands;
|
||||
|
||||
internal sealed partial class UnpinAppCommand : InvokableCommand
|
||||
{
|
||||
private readonly string _appIdentifier;
|
||||
|
||||
public UnpinAppCommand(string appIdentifier)
|
||||
{
|
||||
_appIdentifier = appIdentifier;
|
||||
Name = Resources.unpin_app;
|
||||
Icon = Icons.UnpinIcon;
|
||||
}
|
||||
|
||||
public override CommandResult Invoke()
|
||||
{
|
||||
PinnedAppsManager.Instance.UnpinApp(_appIdentifier);
|
||||
return CommandResult.KeepOpen();
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
|
||||
namespace Microsoft.CmdPal.Ext.Apps.Helpers;
|
||||
|
||||
public static partial class Icons
|
||||
{
|
||||
public static IconInfo UnpinIcon { get; } = new("\uE77A");
|
||||
|
||||
public static IconInfo PinIcon { get; } = new("\uE840");
|
||||
|
||||
public static IconInfo RunAsIcon { get; } = new("\uE7EF");
|
||||
|
||||
public static IconInfo RunAsUserIcon { get; } = new("\uE7EE");
|
||||
|
||||
public static IconInfo CopyIcon { get; } = new("\ue8c8");
|
||||
|
||||
public static IconInfo OpenConsoleIcon { get; } = new("\ue838");
|
||||
|
||||
public static IconInfo OpenPathIcon { get; } = new("\ue838");
|
||||
|
||||
public static IconInfo AllAppsIcon { get; } = IconHelpers.FromRelativePath("Assets\\AllApps.svg");
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.CmdPal.Ext.Apps.State;
|
||||
|
||||
namespace Microsoft.CmdPal.Ext.Apps;
|
||||
|
||||
[JsonSerializable(typeof(string))]
|
||||
[JsonSerializable(typeof(PinnedApps))]
|
||||
[JsonSerializable(typeof(List<string>), TypeInfoPropertyName = "StringList")]
|
||||
[JsonSourceGenerationOptions(UseStringEnumConverter = true, WriteIndented = true, IncludeFields = true, PropertyNameCaseInsensitive = true, AllowTrailingCommas = true)]
|
||||
internal sealed partial class JsonSerializationContext : JsonSerializerContext
|
||||
{
|
||||
}
|
||||
@@ -10,11 +10,8 @@ using System.Xml;
|
||||
using ManagedCommon;
|
||||
using Microsoft.CmdPal.Ext.Apps.Commands;
|
||||
using Microsoft.CmdPal.Ext.Apps.Properties;
|
||||
using Microsoft.CmdPal.Ext.Apps.State;
|
||||
using Microsoft.CmdPal.Ext.Apps.Utils;
|
||||
using Microsoft.CommandPalette.Extensions;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
using Windows.System;
|
||||
using Windows.Win32;
|
||||
using Windows.Win32.Storage.Packaging.Appx;
|
||||
using PackageVersion = Microsoft.CmdPal.Ext.Apps.Programs.UWP.PackageVersion;
|
||||
@@ -72,34 +69,22 @@ public class UWPApplication : IProgram
|
||||
return Resources.packaged_application;
|
||||
}
|
||||
|
||||
public string GetAppIdentifier()
|
||||
public List<CommandContextItem> GetCommands()
|
||||
{
|
||||
// Use UserModelId for UWP apps as it's unique
|
||||
return UserModelId;
|
||||
}
|
||||
|
||||
public List<IContextItem> GetCommands()
|
||||
{
|
||||
List<IContextItem> commands = [];
|
||||
List<CommandContextItem> commands = [];
|
||||
|
||||
if (CanRunElevated)
|
||||
{
|
||||
commands.Add(
|
||||
new CommandContextItem(
|
||||
new RunAsAdminCommand(UniqueIdentifier, string.Empty, true))
|
||||
{
|
||||
RequestedShortcut = KeyChordHelpers.FromModifiers(ctrl: true, shift: true, vkey: VirtualKey.Enter),
|
||||
});
|
||||
new RunAsAdminCommand(UniqueIdentifier, string.Empty, true)));
|
||||
|
||||
// We don't add context menu to 'run as different user', because UWP applications normally installed per user and not for all users.
|
||||
}
|
||||
|
||||
commands.Add(
|
||||
new CommandContextItem(
|
||||
new CopyPathCommand(Location))
|
||||
{
|
||||
RequestedShortcut = KeyChordHelpers.FromModifiers(ctrl: true, shift: true, vkey: VirtualKey.C),
|
||||
});
|
||||
new CopyPathCommand(Location)));
|
||||
|
||||
commands.Add(
|
||||
new CommandContextItem(
|
||||
@@ -107,17 +92,11 @@ public class UWPApplication : IProgram
|
||||
{
|
||||
Name = Resources.open_containing_folder,
|
||||
Icon = new("\ue838"),
|
||||
})
|
||||
{
|
||||
RequestedShortcut = KeyChordHelpers.FromModifiers(ctrl: true, shift: true, vkey: VirtualKey.E),
|
||||
});
|
||||
}));
|
||||
|
||||
commands.Add(
|
||||
new CommandContextItem(
|
||||
new OpenInConsoleCommand(Package.Location))
|
||||
{
|
||||
RequestedShortcut = KeyChordHelpers.FromModifiers(ctrl: true, shift: true, vkey: VirtualKey.R),
|
||||
});
|
||||
new OpenInConsoleCommand(Package.Location)));
|
||||
|
||||
return commands;
|
||||
}
|
||||
@@ -519,25 +498,6 @@ public class UWPApplication : IProgram
|
||||
}
|
||||
}
|
||||
|
||||
internal AppItem ToAppItem()
|
||||
{
|
||||
var app = this;
|
||||
var iconPath = app.LogoType != LogoType.Error ? app.LogoPath : string.Empty;
|
||||
var item = new AppItem()
|
||||
{
|
||||
Name = app.Name,
|
||||
Subtitle = app.Description,
|
||||
Type = UWPApplication.Type(),
|
||||
IcoPath = iconPath,
|
||||
DirPath = app.Location,
|
||||
UserModelId = app.UserModelId,
|
||||
IsPackaged = true,
|
||||
Commands = app.GetCommands(),
|
||||
AppIdentifier = app.GetAppIdentifier(),
|
||||
};
|
||||
return item;
|
||||
}
|
||||
|
||||
/*
|
||||
public ImageSource Logo()
|
||||
{
|
||||
|
||||
@@ -19,12 +19,9 @@ using System.Windows.Input;
|
||||
using ManagedCommon;
|
||||
using Microsoft.CmdPal.Ext.Apps.Commands;
|
||||
using Microsoft.CmdPal.Ext.Apps.Properties;
|
||||
using Microsoft.CmdPal.Ext.Apps.State;
|
||||
using Microsoft.CmdPal.Ext.Apps.Utils;
|
||||
using Microsoft.CommandPalette.Extensions;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
using Microsoft.Win32;
|
||||
using Windows.System;
|
||||
|
||||
namespace Microsoft.CmdPal.Ext.Apps.Programs;
|
||||
|
||||
@@ -188,42 +185,27 @@ public class Win32Program : IProgram
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<IContextItem> GetCommands()
|
||||
public List<CommandContextItem> GetCommands()
|
||||
{
|
||||
List<IContextItem> commands = new List<IContextItem>();
|
||||
List<CommandContextItem> commands = new List<CommandContextItem>();
|
||||
|
||||
if (AppType != ApplicationType.InternetShortcutApplication && AppType != ApplicationType.Folder && AppType != ApplicationType.GenericFile)
|
||||
{
|
||||
commands.Add(new CommandContextItem(
|
||||
new RunAsAdminCommand(!string.IsNullOrEmpty(LnkFilePath) ? LnkFilePath : FullPath, ParentDirectory, false))
|
||||
{
|
||||
RequestedShortcut = KeyChordHelpers.FromModifiers(ctrl: true, shift: true, vkey: VirtualKey.Enter),
|
||||
});
|
||||
new RunAsAdminCommand(!string.IsNullOrEmpty(LnkFilePath) ? LnkFilePath : FullPath, ParentDirectory, false)));
|
||||
|
||||
commands.Add(new CommandContextItem(
|
||||
new RunAsUserCommand(!string.IsNullOrEmpty(LnkFilePath) ? LnkFilePath : FullPath, ParentDirectory))
|
||||
{
|
||||
RequestedShortcut = KeyChordHelpers.FromModifiers(ctrl: true, shift: true, vkey: VirtualKey.U),
|
||||
});
|
||||
new RunAsUserCommand(!string.IsNullOrEmpty(LnkFilePath) ? LnkFilePath : FullPath, ParentDirectory)));
|
||||
}
|
||||
|
||||
commands.Add(new CommandContextItem(
|
||||
new CopyPathCommand(FullPath))
|
||||
{
|
||||
RequestedShortcut = KeyChordHelpers.FromModifiers(ctrl: true, shift: true, vkey: VirtualKey.C),
|
||||
});
|
||||
new CopyPathCommand(FullPath)));
|
||||
|
||||
commands.Add(new CommandContextItem(
|
||||
new OpenPathCommand(ParentDirectory))
|
||||
{
|
||||
RequestedShortcut = KeyChordHelpers.FromModifiers(ctrl: true, shift: true, vkey: VirtualKey.E),
|
||||
});
|
||||
new OpenPathCommand(ParentDirectory)));
|
||||
|
||||
commands.Add(new CommandContextItem(
|
||||
new OpenInConsoleCommand(ParentDirectory))
|
||||
{
|
||||
RequestedShortcut = KeyChordHelpers.FromModifiers(ctrl: true, shift: true, vkey: VirtualKey.R),
|
||||
});
|
||||
new OpenInConsoleCommand(ParentDirectory)));
|
||||
|
||||
return commands;
|
||||
}
|
||||
@@ -233,12 +215,6 @@ public class Win32Program : IProgram
|
||||
return ExecutableName;
|
||||
}
|
||||
|
||||
public string GetAppIdentifier()
|
||||
{
|
||||
// Use a combination of name and path to create a unique identifier
|
||||
return $"{Name}|{FullPath}";
|
||||
}
|
||||
|
||||
private static Win32Program CreateWin32Program(string path)
|
||||
{
|
||||
try
|
||||
@@ -941,29 +917,4 @@ public class Win32Program : IProgram
|
||||
return Array.Empty<Win32Program>();
|
||||
}
|
||||
}
|
||||
|
||||
internal AppItem ToAppItem()
|
||||
{
|
||||
var app = this;
|
||||
var icoPath = string.IsNullOrEmpty(app.IcoPath) ?
|
||||
(app.AppType == Win32Program.ApplicationType.InternetShortcutApplication ?
|
||||
app.IcoPath :
|
||||
app.FullPath) :
|
||||
app.IcoPath;
|
||||
|
||||
icoPath = icoPath.EndsWith(".lnk", System.StringComparison.InvariantCultureIgnoreCase) ?
|
||||
app.FullPath :
|
||||
icoPath;
|
||||
return new AppItem()
|
||||
{
|
||||
Name = app.Name,
|
||||
Subtitle = app.Description,
|
||||
Type = app.Type(),
|
||||
IcoPath = icoPath,
|
||||
ExePath = !string.IsNullOrEmpty(app.LnkFilePath) ? app.LnkFilePath : app.FullPath,
|
||||
DirPath = app.Location,
|
||||
Commands = app.GetCommands(),
|
||||
AppIdentifier = app.GetAppIdentifier(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,15 +213,6 @@ namespace Microsoft.CmdPal.Ext.Apps.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Pin.
|
||||
/// </summary>
|
||||
internal static string pin_app {
|
||||
get {
|
||||
return ResourceManager.GetString("pin_app", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Run as administrator.
|
||||
/// </summary>
|
||||
@@ -276,15 +267,6 @@ namespace Microsoft.CmdPal.Ext.Apps.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Unpin.
|
||||
/// </summary>
|
||||
internal static string unpin_app {
|
||||
get {
|
||||
return ResourceManager.GetString("unpin_app", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Experimental: When enabled, Command Palette will load thumbnails from the Windows Shell. Using thumbnails may cause the app to crash on launch.
|
||||
/// </summary>
|
||||
|
||||
@@ -199,10 +199,4 @@
|
||||
<value>Experimental: When enabled, Command Palette will load thumbnails from the Windows Shell. Using thumbnails may cause the app to crash on launch</value>
|
||||
<comment>A description for "use_thumbnails_setting_label"</comment>
|
||||
</data>
|
||||
<data name="pin_app" xml:space="preserve">
|
||||
<value>Pin</value>
|
||||
</data>
|
||||
<data name="unpin_app" xml:space="preserve">
|
||||
<value>Unpin</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -1,34 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.CmdPal.Ext.Apps.State;
|
||||
|
||||
public class PinStateChangedEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the identifier of the application whose pin state has changed.
|
||||
/// </summary>
|
||||
public string AppIdentifier { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the specified app identifier was pinned or not.
|
||||
/// </summary>
|
||||
public bool IsPinned { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PinStateChangedEventArgs"/> class.
|
||||
/// </summary>
|
||||
/// <param name="appIdentifier">The identifier of the application whose pin state has changed.</param>
|
||||
public PinStateChangedEventArgs(string appIdentifier, bool isPinned)
|
||||
{
|
||||
AppIdentifier = appIdentifier ?? throw new ArgumentNullException(nameof(appIdentifier));
|
||||
IsPinned = isPinned;
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Microsoft.CmdPal.Ext.Apps.State;
|
||||
|
||||
public sealed class PinnedApps
|
||||
{
|
||||
public List<string> PinnedAppIdentifiers { get; set; } = [];
|
||||
|
||||
public static PinnedApps ReadFromFile(string path)
|
||||
{
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
return new PinnedApps();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var jsonString = File.ReadAllText(path);
|
||||
var result = JsonSerializer.Deserialize<PinnedApps>(jsonString, JsonSerializationContext.Default.PinnedApps);
|
||||
return result ?? new PinnedApps();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new PinnedApps();
|
||||
}
|
||||
}
|
||||
|
||||
public static void WriteToFile(string path, PinnedApps data)
|
||||
{
|
||||
try
|
||||
{
|
||||
var jsonString = JsonSerializer.Serialize(data, JsonSerializationContext.Default.PinnedApps);
|
||||
File.WriteAllText(path, jsonString);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Silently fail - we don't want pinning issues to crash the extension
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using ManagedCommon;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
|
||||
namespace Microsoft.CmdPal.Ext.Apps.State;
|
||||
|
||||
public sealed class PinnedAppsManager
|
||||
{
|
||||
private static readonly Lazy<PinnedAppsManager> _instance = new(() => new PinnedAppsManager());
|
||||
private readonly string _pinnedAppsFilePath;
|
||||
|
||||
public static PinnedAppsManager Instance => _instance.Value;
|
||||
|
||||
private PinnedApps _pinnedApps = new();
|
||||
|
||||
// Add event for when pinning state changes
|
||||
public event EventHandler<PinStateChangedEventArgs>? PinStateChanged;
|
||||
|
||||
private PinnedAppsManager()
|
||||
{
|
||||
_pinnedAppsFilePath = GetPinnedAppsFilePath();
|
||||
LoadPinnedApps();
|
||||
}
|
||||
|
||||
public bool IsAppPinned(string appIdentifier)
|
||||
{
|
||||
return _pinnedApps.PinnedAppIdentifiers.Contains(appIdentifier, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public void PinApp(string appIdentifier)
|
||||
{
|
||||
if (!IsAppPinned(appIdentifier))
|
||||
{
|
||||
_pinnedApps.PinnedAppIdentifiers.Add(appIdentifier);
|
||||
SavePinnedApps();
|
||||
Logger.LogTrace($"Pinned app: {appIdentifier}");
|
||||
PinStateChanged?.Invoke(this, new PinStateChangedEventArgs(appIdentifier, true));
|
||||
}
|
||||
}
|
||||
|
||||
public string[] GetPinnedAppIdentifiers()
|
||||
{
|
||||
return _pinnedApps.PinnedAppIdentifiers.ToArray();
|
||||
}
|
||||
|
||||
public void UnpinApp(string appIdentifier)
|
||||
{
|
||||
var removed = _pinnedApps.PinnedAppIdentifiers.RemoveAll(id =>
|
||||
string.Equals(id, appIdentifier, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
if (removed > 0)
|
||||
{
|
||||
SavePinnedApps();
|
||||
Logger.LogTrace($"Unpinned app: {appIdentifier}");
|
||||
PinStateChanged?.Invoke(this, new PinStateChangedEventArgs(appIdentifier, false));
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadPinnedApps()
|
||||
{
|
||||
_pinnedApps = PinnedApps.ReadFromFile(_pinnedAppsFilePath);
|
||||
}
|
||||
|
||||
private void SavePinnedApps()
|
||||
{
|
||||
PinnedApps.WriteToFile(_pinnedAppsFilePath, _pinnedApps);
|
||||
}
|
||||
|
||||
private static string GetPinnedAppsFilePath()
|
||||
{
|
||||
var directory = Utilities.BaseSettingsPath("Microsoft.CmdPal");
|
||||
Directory.CreateDirectory(directory);
|
||||
return Path.Combine(directory, "apps.pinned.json");
|
||||
}
|
||||
}
|
||||
@@ -148,16 +148,13 @@ public class NumberTranslator
|
||||
|
||||
private static Regex GetSplitRegex(CultureInfo culture)
|
||||
{
|
||||
var groupSeparator = culture.NumberFormat.NumberGroupSeparator;
|
||||
|
||||
// if the group separator is a no-break space, we also add a normal space to the regex
|
||||
if (groupSeparator == "\u00a0")
|
||||
var splitPattern = $"((?:\\d|{Regex.Escape(culture.NumberFormat.NumberDecimalSeparator)}";
|
||||
if (!string.IsNullOrEmpty(culture.NumberFormat.NumberGroupSeparator))
|
||||
{
|
||||
groupSeparator = "\u0020\u00a0";
|
||||
splitPattern += $"|{Regex.Escape(culture.NumberFormat.NumberGroupSeparator)}";
|
||||
}
|
||||
|
||||
var splitPattern = $"([0-9{Regex.Escape(culture.NumberFormat.NumberDecimalSeparator)}" +
|
||||
$"{Regex.Escape(groupSeparator)}]+)";
|
||||
splitPattern += ")+)";
|
||||
return new Regex(splitPattern);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@ namespace Microsoft.CmdPal.Ext.Indexer;
|
||||
|
||||
internal sealed partial class FallbackOpenFileItem : FallbackCommandItem, System.IDisposable
|
||||
{
|
||||
private static readonly NoOpCommand _baseCommandWithId = new() { Id = "com.microsoft.indexer.fallback" };
|
||||
|
||||
private readonly CompositeFormat fallbackItemSearchPageTitleCompositeFormat = CompositeFormat.Parse(Resources.Indexer_fallback_searchPage_title);
|
||||
|
||||
private readonly SearchEngine _searchEngine = new();
|
||||
@@ -24,11 +22,10 @@ internal sealed partial class FallbackOpenFileItem : FallbackCommandItem, System
|
||||
private uint _queryCookie = 10;
|
||||
|
||||
public FallbackOpenFileItem()
|
||||
: base(_baseCommandWithId, Resources.Indexer_Find_Path_fallback_display_title)
|
||||
: base(new NoOpCommand(), Resources.Indexer_Find_Path_fallback_display_title)
|
||||
{
|
||||
Title = string.Empty;
|
||||
Subtitle = string.Empty;
|
||||
Icon = Icons.FileExplorer;
|
||||
}
|
||||
|
||||
public override void UpdateQuery(string query)
|
||||
|
||||
@@ -6,6 +6,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using ManagedCommon;
|
||||
using Microsoft.CmdPal.Ext.Indexer.Commands;
|
||||
using Microsoft.CmdPal.Ext.Indexer.Data;
|
||||
|
||||
@@ -15,9 +15,7 @@ internal sealed partial class FallbackExecuteItem : FallbackCommandItem
|
||||
private readonly SettingsManager _settings;
|
||||
|
||||
public FallbackExecuteItem(SettingsManager settings)
|
||||
: base(
|
||||
new ExecuteItem(string.Empty, settings) { Id = "com.microsoft.run.fallback" },
|
||||
Resources.shell_command_display_title)
|
||||
: base(new ExecuteItem(string.Empty, settings), Resources.shell_command_display_title)
|
||||
{
|
||||
_settings = settings;
|
||||
_executeItem = (ExecuteItem)this.Command!;
|
||||
|
||||
@@ -17,7 +17,7 @@ internal sealed partial class FallbackExecuteSearchItem : FallbackCommandItem
|
||||
private static readonly CompositeFormat PluginOpen = System.Text.CompositeFormat.Parse(Properties.Resources.plugin_open);
|
||||
|
||||
public FallbackExecuteSearchItem(SettingsManager settings)
|
||||
: base(new SearchWebCommand(string.Empty, settings) { Id = "com.microsoft.websearch.fallback" }, Resources.command_item_title)
|
||||
: base(new SearchWebCommand(string.Empty, settings), Resources.command_item_title)
|
||||
{
|
||||
_executeItem = (SearchWebCommand)this.Command!;
|
||||
Title = string.Empty;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user