mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-15 19:27:56 +01:00
CmdPal: Move core projects into Core/ (#41358)
Couple little things here: * Makes `Microsoft.CmdPal.Common` a `Core` project * Moves the `CmdPal.Core` projects into a single `Core/` directory * Adds the `CoreLogger` which I had stashed in https://github.com/microsoft/PowerToys/compare/dev/migrie/40113/extension-hosts-try-2...dev/migrie/b/remove-core-managedcommon-dep a while back * De-duplicates a bunch of commands that were in both Apps and Common * moves all the commands into the toolkit, instead of in the Common project
This commit is contained in:
@@ -39,6 +39,11 @@ foreach ($csprojFile in $csprojFilesArray) {
|
|||||||
if ($csprojFile -like '*TemplateCmdPalExtension.csproj') {
|
if ($csprojFile -like '*TemplateCmdPalExtension.csproj') {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# The CmdPal.Core projects use a common shared props file, so skip them
|
||||||
|
if ($csprojFile -like '*Microsoft.CmdPal.Core.*.csproj') {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
$importExists = Test-ImportSharedCsWinRTProps -filePath $csprojFile
|
$importExists = Test-ImportSharedCsWinRTProps -filePath $csprojFile
|
||||||
if (!$importExists) {
|
if (!$importExists) {
|
||||||
|
|||||||
@@ -638,7 +638,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Microsoft.CommandPalette.Ex
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CommandPalette.Extensions.Toolkit", "src\modules\cmdpal\extensionsdk\Microsoft.CommandPalette.Extensions.Toolkit\Microsoft.CommandPalette.Extensions.Toolkit.csproj", "{CA4D810F-C8F4-4B61-9DA9-71807E0B9F24}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CommandPalette.Extensions.Toolkit", "src\modules\cmdpal\extensionsdk\Microsoft.CommandPalette.Extensions.Toolkit\Microsoft.CommandPalette.Extensions.Toolkit.csproj", "{CA4D810F-C8F4-4B61-9DA9-71807E0B9F24}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CmdPal.Common", "src\modules\cmdpal\Microsoft.CmdPal.Common\Microsoft.CmdPal.Common.csproj", "{14E62033-58D0-4A7D-8990-52F50A08BBBD}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CmdPal.Core.Common", "src\modules\cmdpal\Core\Microsoft.CmdPal.Core.Common\Microsoft.CmdPal.Core.Common.csproj", "{14E62033-58D0-4A7D-8990-52F50A08BBBD}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Microsoft.Terminal.UI", "src\modules\cmdpal\Microsoft.Terminal.UI\Microsoft.Terminal.UI.vcxproj", "{6515F03F-E56D-4DB4-B23D-AC4FB80DB36F}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Microsoft.Terminal.UI", "src\modules\cmdpal\Microsoft.Terminal.UI\Microsoft.Terminal.UI.vcxproj", "{6515F03F-E56D-4DB4-B23D-AC4FB80DB36F}"
|
||||||
EndProject
|
EndProject
|
||||||
@@ -728,7 +728,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerRename.UITests", "src\
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.CmdPal.Core.ViewModels", "src\modules\cmdpal\Microsoft.CmdPal.Core.ViewModels\Microsoft.CmdPal.Core.ViewModels.csproj", "{24133F7F-C1D1-DE04-EFA8-F5D5467FE027}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.CmdPal.Core.ViewModels", "src\modules\cmdpal\Core\Microsoft.CmdPal.Core.ViewModels\Microsoft.CmdPal.Core.ViewModels.csproj", "{24133F7F-C1D1-DE04-EFA8-F5D5467FE027}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{0E556541-6A45-42CB-AE49-EE5A9BE05E7C}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{0E556541-6A45-42CB-AE49-EE5A9BE05E7C}"
|
||||||
EndProject
|
EndProject
|
||||||
@@ -3160,7 +3160,7 @@ Global
|
|||||||
{F3D09629-59A2-4924-A4B9-D6BFAA2C1B49} = {3846508C-77EB-4034-A702-F8BB263C4F79}
|
{F3D09629-59A2-4924-A4B9-D6BFAA2C1B49} = {3846508C-77EB-4034-A702-F8BB263C4F79}
|
||||||
{305DD37E-C85D-4B08-AAFE-7381FA890463} = {F3D09629-59A2-4924-A4B9-D6BFAA2C1B49}
|
{305DD37E-C85D-4B08-AAFE-7381FA890463} = {F3D09629-59A2-4924-A4B9-D6BFAA2C1B49}
|
||||||
{CA4D810F-C8F4-4B61-9DA9-71807E0B9F24} = {F3D09629-59A2-4924-A4B9-D6BFAA2C1B49}
|
{CA4D810F-C8F4-4B61-9DA9-71807E0B9F24} = {F3D09629-59A2-4924-A4B9-D6BFAA2C1B49}
|
||||||
{14E62033-58D0-4A7D-8990-52F50A08BBBD} = {7520A2FE-00A2-49B8-83ED-DB216E874C04}
|
{14E62033-58D0-4A7D-8990-52F50A08BBBD} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
|
||||||
{6515F03F-E56D-4DB4-B23D-AC4FB80DB36F} = {7520A2FE-00A2-49B8-83ED-DB216E874C04}
|
{6515F03F-E56D-4DB4-B23D-AC4FB80DB36F} = {7520A2FE-00A2-49B8-83ED-DB216E874C04}
|
||||||
{071E18A4-A530-46B8-AB7D-B862EE55E24E} = {3846508C-77EB-4034-A702-F8BB263C4F79}
|
{071E18A4-A530-46B8-AB7D-B862EE55E24E} = {3846508C-77EB-4034-A702-F8BB263C4F79}
|
||||||
{C846F7A7-792A-47D9-B0CB-417C900EE03D} = {071E18A4-A530-46B8-AB7D-B862EE55E24E}
|
{C846F7A7-792A-47D9-B0CB-417C900EE03D} = {071E18A4-A530-46B8-AB7D-B862EE55E24E}
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
// 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;
|
||||||
|
|
||||||
|
namespace Microsoft.CmdPal.Core.Common;
|
||||||
|
|
||||||
|
public static class CoreLogger
|
||||||
|
{
|
||||||
|
public static void InitializeLogger(ILogger implementation)
|
||||||
|
{
|
||||||
|
_logger = implementation;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ILogger? _logger;
|
||||||
|
|
||||||
|
public static void LogError(string message, Exception ex, [System.Runtime.CompilerServices.CallerMemberName] string memberName = "", [System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath = "", [System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber = 0)
|
||||||
|
{
|
||||||
|
_logger?.LogError(message, ex, memberName, sourceFilePath, sourceLineNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void LogError(string message, [System.Runtime.CompilerServices.CallerMemberName] string memberName = "", [System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath = "", [System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber = 0)
|
||||||
|
{
|
||||||
|
_logger?.LogError(message, memberName, sourceFilePath, sourceLineNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void LogWarning(string message, [System.Runtime.CompilerServices.CallerMemberName] string memberName = "", [System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath = "", [System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber = 0)
|
||||||
|
{
|
||||||
|
_logger?.LogWarning(message, memberName, sourceFilePath, sourceLineNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void LogInfo(string message, [System.Runtime.CompilerServices.CallerMemberName] string memberName = "", [System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath = "", [System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber = 0)
|
||||||
|
{
|
||||||
|
_logger?.LogInfo(message, memberName, sourceFilePath, sourceLineNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void LogDebug(string message, [System.Runtime.CompilerServices.CallerMemberName] string memberName = "", [System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath = "", [System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber = 0)
|
||||||
|
{
|
||||||
|
_logger?.LogDebug(message, memberName, sourceFilePath, sourceLineNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void LogTrace([System.Runtime.CompilerServices.CallerMemberName] string memberName = "", [System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath = "", [System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber = 0)
|
||||||
|
{
|
||||||
|
_logger?.LogTrace(memberName, sourceFilePath, sourceLineNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface ILogger
|
||||||
|
{
|
||||||
|
void LogError(string message, [System.Runtime.CompilerServices.CallerMemberName] string memberName = "", [System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath = "", [System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber = 0);
|
||||||
|
|
||||||
|
void LogError(string message, Exception ex, [System.Runtime.CompilerServices.CallerMemberName] string memberName = "", [System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath = "", [System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber = 0);
|
||||||
|
|
||||||
|
void LogWarning(string message, [System.Runtime.CompilerServices.CallerMemberName] string memberName = "", [System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath = "", [System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber = 0);
|
||||||
|
|
||||||
|
void LogInfo(string message, [System.Runtime.CompilerServices.CallerMemberName] string memberName = "", [System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath = "", [System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber = 0);
|
||||||
|
|
||||||
|
void LogDebug(string message, [System.Runtime.CompilerServices.CallerMemberName] string memberName = "", [System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath = "", [System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber = 0);
|
||||||
|
|
||||||
|
void LogTrace([System.Runtime.CompilerServices.CallerMemberName] string memberName = "", [System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath = "", [System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber = 0);
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Microsoft.CmdPal.Common.Helpers;
|
namespace Microsoft.CmdPal.Core.Common.Helpers;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Provides utility methods for building diagnostic and error messages.
|
/// Provides utility methods for building diagnostic and error messages.
|
||||||
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
|||||||
using Microsoft.CommandPalette.Extensions;
|
using Microsoft.CommandPalette.Extensions;
|
||||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||||
|
|
||||||
namespace Microsoft.CmdPal.Common;
|
namespace Microsoft.CmdPal.Core.Common;
|
||||||
|
|
||||||
public partial class ExtensionHostInstance
|
public partial class ExtensionHostInstance
|
||||||
{
|
{
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
namespace Microsoft.CmdPal.Common.Helpers;
|
namespace Microsoft.CmdPal.Core.Common.Helpers;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Thread-safe boolean implementation using atomic operations
|
/// Thread-safe boolean implementation using atomic operations
|
||||||
@@ -7,7 +7,7 @@ using System.Threading;
|
|||||||
|
|
||||||
using Microsoft.UI.Dispatching;
|
using Microsoft.UI.Dispatching;
|
||||||
|
|
||||||
namespace Microsoft.CmdPal.Common.Helpers;
|
namespace Microsoft.CmdPal.Core.Common.Helpers;
|
||||||
|
|
||||||
public static partial class NativeEventWaiter
|
public static partial class NativeEventWaiter
|
||||||
{
|
{
|
||||||
@@ -6,14 +6,14 @@ using System;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Microsoft.CmdPal.Common.Helpers;
|
namespace Microsoft.CmdPal.Core.Common.Helpers;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An async gate that ensures only one operation runs at a time.
|
/// An async gate that ensures only one operation runs at a time.
|
||||||
/// If ExecuteAsync is called while already executing, it cancels the current execution
|
/// If ExecuteAsync is called while already executing, it cancels the current execution
|
||||||
/// and starts the operation again (superseding behavior).
|
/// and starts the operation again (superseding behavior).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SupersedingAsyncGate : IDisposable
|
public partial class SupersedingAsyncGate : IDisposable
|
||||||
{
|
{
|
||||||
private readonly Func<CancellationToken, Task> _action;
|
private readonly Func<CancellationToken, Task> _action;
|
||||||
private readonly Lock _lock = new();
|
private readonly Lock _lock = new();
|
||||||
@@ -7,7 +7,7 @@ using Microsoft.CommandPalette.Extensions.Toolkit;
|
|||||||
|
|
||||||
using Windows.System;
|
using Windows.System;
|
||||||
|
|
||||||
namespace Microsoft.CmdPal.Common.Helpers;
|
namespace Microsoft.CmdPal.Core.Common.Helpers;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Well-known key chords used in the Command Palette and extensions.
|
/// Well-known key chords used in the Command Palette and extensions.
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<Import Project="..\..\CoreCommonProps.props" />
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<RootNamespace>Microsoft.CmdPal.Core.Common</RootNamespace>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Hosting" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -6,7 +6,7 @@ using System.Collections.Generic;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Windows.Foundation;
|
using Windows.Foundation;
|
||||||
|
|
||||||
namespace Microsoft.CmdPal.Common.Services;
|
namespace Microsoft.CmdPal.Core.Common.Services;
|
||||||
|
|
||||||
public interface IExtensionService
|
public interface IExtensionService
|
||||||
{
|
{
|
||||||
@@ -8,7 +8,7 @@ using System.Threading.Tasks;
|
|||||||
using Microsoft.CommandPalette.Extensions;
|
using Microsoft.CommandPalette.Extensions;
|
||||||
using Windows.ApplicationModel;
|
using Windows.ApplicationModel;
|
||||||
|
|
||||||
namespace Microsoft.CmdPal.Common.Services;
|
namespace Microsoft.CmdPal.Core.Common.Services;
|
||||||
|
|
||||||
public interface IExtensionWrapper
|
public interface IExtensionWrapper
|
||||||
{
|
{
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Microsoft.CmdPal.Common.Services;
|
namespace Microsoft.CmdPal.Core.Common.Services;
|
||||||
|
|
||||||
public interface IRunHistoryService
|
public interface IRunHistoryService
|
||||||
{
|
{
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using ManagedCommon;
|
using Microsoft.CmdPal.Core.Common;
|
||||||
using Microsoft.CommandPalette.Extensions;
|
using Microsoft.CommandPalette.Extensions;
|
||||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||||
using Windows.Foundation;
|
using Windows.Foundation;
|
||||||
@@ -60,7 +60,7 @@ public abstract partial class AppExtensionHost : IExtensionHost
|
|||||||
return Task.CompletedTask.AsAsyncAction();
|
return Task.CompletedTask.AsAsyncAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.LogDebug(message.Message);
|
CoreLogger.LogDebug(message.Message);
|
||||||
|
|
||||||
_ = Task.Run(() =>
|
_ = Task.Run(() =>
|
||||||
{
|
{
|
||||||
@@ -146,14 +146,13 @@ public partial class CommandBarViewModel : ObservableObject,
|
|||||||
return ContextKeybindingResult.Unhandled;
|
return ContextKeybindingResult.Unhandled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WeakReferenceMessenger.Default.Send<PerformCommandMessage>(new(command.Command.Model, command.Model));
|
||||||
if (command.HasMoreCommands)
|
if (command.HasMoreCommands)
|
||||||
{
|
{
|
||||||
WeakReferenceMessenger.Default.Send<PerformCommandMessage>(new(command.Command.Model, command.Model));
|
|
||||||
return ContextKeybindingResult.KeepOpen;
|
return ContextKeybindingResult.KeepOpen;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WeakReferenceMessenger.Default.Send<PerformCommandMessage>(new(command.Command.Model, command.Model));
|
|
||||||
return ContextKeybindingResult.Hide;
|
return ContextKeybindingResult.Hide;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -39,14 +39,9 @@ public partial class CommandContextItemViewModel(ICommandContextItem contextItem
|
|||||||
|
|
||||||
IsCritical = contextItem.IsCritical;
|
IsCritical = contextItem.IsCritical;
|
||||||
|
|
||||||
// I actually don't think this will ever actually be null, because
|
RequestedShortcut = new(
|
||||||
// KeyChord is a struct, which isn't nullable in WinRT
|
contextItem.RequestedShortcut.Modifiers,
|
||||||
if (contextItem.RequestedShortcut != null)
|
contextItem.RequestedShortcut.Vkey,
|
||||||
{
|
contextItem.RequestedShortcut.ScanCode);
|
||||||
RequestedShortcut = new(
|
|
||||||
contextItem.RequestedShortcut.Modifiers,
|
|
||||||
contextItem.RequestedShortcut.Vkey,
|
|
||||||
contextItem.RequestedShortcut.ScanCode);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using ManagedCommon;
|
using Microsoft.CmdPal.Core.Common;
|
||||||
using Microsoft.CmdPal.Core.ViewModels.Messages;
|
using Microsoft.CmdPal.Core.ViewModels.Messages;
|
||||||
using Microsoft.CmdPal.Core.ViewModels.Models;
|
using Microsoft.CmdPal.Core.ViewModels.Models;
|
||||||
using Microsoft.CommandPalette.Extensions;
|
using Microsoft.CommandPalette.Extensions;
|
||||||
@@ -184,14 +184,7 @@ public partial class CommandItemViewModel : ExtensionObjectViewModel, ICommandBa
|
|||||||
MoreCommands = more
|
MoreCommands = more
|
||||||
.Select<IContextItem, IContextItemViewModel>(item =>
|
.Select<IContextItem, IContextItemViewModel>(item =>
|
||||||
{
|
{
|
||||||
if (item is ICommandContextItem contextItem)
|
return item is ICommandContextItem contextItem ? new CommandContextItemViewModel(contextItem, PageContext) : new SeparatorViewModel();
|
||||||
{
|
|
||||||
return new CommandContextItemViewModel(contextItem, PageContext);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return new SeparatorViewModel();
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
@@ -240,7 +233,7 @@ public partial class CommandItemViewModel : ExtensionObjectViewModel, ICommandBa
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.LogError("error fast initializing CommandItemViewModel", ex);
|
CoreLogger.LogError("error fast initializing CommandItemViewModel", ex);
|
||||||
Command = new(null, PageContext);
|
Command = new(null, PageContext);
|
||||||
_itemTitle = "Error";
|
_itemTitle = "Error";
|
||||||
Subtitle = "Item failed to load";
|
Subtitle = "Item failed to load";
|
||||||
@@ -262,7 +255,7 @@ public partial class CommandItemViewModel : ExtensionObjectViewModel, ICommandBa
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Initialized |= InitializedState.Error;
|
Initialized |= InitializedState.Error;
|
||||||
Logger.LogError("error slow initializing CommandItemViewModel", ex);
|
CoreLogger.LogError("error slow initializing CommandItemViewModel", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -277,7 +270,7 @@ public partial class CommandItemViewModel : ExtensionObjectViewModel, ICommandBa
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.LogError("error initializing CommandItemViewModel", ex);
|
CoreLogger.LogError("error initializing CommandItemViewModel", ex);
|
||||||
Command = new(null, PageContext);
|
Command = new(null, PageContext);
|
||||||
_itemTitle = "Error";
|
_itemTitle = "Error";
|
||||||
Subtitle = "Item failed to load";
|
Subtitle = "Item failed to load";
|
||||||
@@ -348,14 +341,7 @@ public partial class CommandItemViewModel : ExtensionObjectViewModel, ICommandBa
|
|||||||
var newContextMenu = more
|
var newContextMenu = more
|
||||||
.Select<IContextItem, IContextItemViewModel>(item =>
|
.Select<IContextItem, IContextItemViewModel>(item =>
|
||||||
{
|
{
|
||||||
if (item is ICommandContextItem contextItem)
|
return item is ICommandContextItem contextItem ? new CommandContextItemViewModel(contextItem, PageContext) : new SeparatorViewModel();
|
||||||
{
|
|
||||||
return new CommandContextItemViewModel(contextItem, PageContext);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return new SeparatorViewModel();
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.ToList();
|
.ToList();
|
||||||
lock (MoreCommands)
|
lock (MoreCommands)
|
||||||
@@ -14,7 +14,7 @@ using Microsoft.CommandPalette.Extensions.Toolkit;
|
|||||||
|
|
||||||
namespace Microsoft.CmdPal.Core.ViewModels;
|
namespace Microsoft.CmdPal.Core.ViewModels;
|
||||||
|
|
||||||
public abstract partial class ContentPageViewModel : PageViewModel, ICommandBarContext
|
public partial class ContentPageViewModel : PageViewModel, ICommandBarContext
|
||||||
{
|
{
|
||||||
private readonly ExtensionObject<IContentPage> _model;
|
private readonly ExtensionObject<IContentPage> _model;
|
||||||
|
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using CommunityToolkit.Mvvm.Messaging;
|
using CommunityToolkit.Mvvm.Messaging;
|
||||||
using ManagedCommon;
|
using Microsoft.CmdPal.Core.Common;
|
||||||
using Microsoft.CmdPal.Core.ViewModels.Messages;
|
using Microsoft.CmdPal.Core.ViewModels.Messages;
|
||||||
using Microsoft.CommandPalette.Extensions;
|
using Microsoft.CommandPalette.Extensions;
|
||||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||||
@@ -83,7 +83,7 @@ public partial class ContextMenuViewModel : ObservableObject,
|
|||||||
|
|
||||||
if (string.IsNullOrEmpty(searchText))
|
if (string.IsNullOrEmpty(searchText))
|
||||||
{
|
{
|
||||||
ListHelpers.InPlaceUpdateList(FilteredItems, [.. CurrentContextMenu]);
|
ListHelpers.InPlaceUpdateList(FilteredItems, CurrentContextMenu);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,7 +141,7 @@ public partial class ContextMenuViewModel : ObservableObject,
|
|||||||
var added = result.TryAdd(key, cmd);
|
var added = result.TryAdd(key, cmd);
|
||||||
if (!added)
|
if (!added)
|
||||||
{
|
{
|
||||||
Logger.LogWarning($"Ignoring duplicate keyboard shortcut {KeyChordHelpers.FormatForDebug(key)} on command '{cmd.Title ?? cmd.Name ?? "(unknown)"}'");
|
CoreLogger.LogWarning($"Ignoring duplicate keyboard shortcut {KeyChordHelpers.FormatForDebug(key)} on command '{cmd.Title ?? cmd.Name ?? "(unknown)"}'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -155,12 +155,7 @@ public partial class ContextMenuViewModel : ObservableObject,
|
|||||||
|
|
||||||
// Does the pressed key match any of the keybindings?
|
// Does the pressed key match any of the keybindings?
|
||||||
var pressedKeyChord = KeyChordHelpers.FromModifiers(ctrl, alt, shift, win, key, 0);
|
var pressedKeyChord = KeyChordHelpers.FromModifiers(ctrl, alt, shift, win, key, 0);
|
||||||
if (keybindings.TryGetValue(pressedKeyChord, out var item))
|
return keybindings.TryGetValue(pressedKeyChord, out var item) ? InvokeCommand(item) : null;
|
||||||
{
|
|
||||||
return InvokeCommand(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanPopContextStack()
|
public bool CanPopContextStack()
|
||||||
@@ -178,7 +173,7 @@ public partial class ContextMenuViewModel : ObservableObject,
|
|||||||
OnPropertyChanging(nameof(CurrentContextMenu));
|
OnPropertyChanging(nameof(CurrentContextMenu));
|
||||||
OnPropertyChanged(nameof(CurrentContextMenu));
|
OnPropertyChanged(nameof(CurrentContextMenu));
|
||||||
|
|
||||||
ListHelpers.InPlaceUpdateList(FilteredItems, [.. CurrentContextMenu!]);
|
ListHelpers.InPlaceUpdateList(FilteredItems, CurrentContextMenu!);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PushContextStack(IEnumerable<IContextItemViewModel> commands)
|
private void PushContextStack(IEnumerable<IContextItemViewModel> commands)
|
||||||
@@ -187,7 +182,7 @@ public partial class ContextMenuViewModel : ObservableObject,
|
|||||||
OnPropertyChanging(nameof(CurrentContextMenu));
|
OnPropertyChanging(nameof(CurrentContextMenu));
|
||||||
OnPropertyChanged(nameof(CurrentContextMenu));
|
OnPropertyChanged(nameof(CurrentContextMenu));
|
||||||
|
|
||||||
ListHelpers.InPlaceUpdateList(FilteredItems, [.. CurrentContextMenu!]);
|
ListHelpers.InPlaceUpdateList(FilteredItems, CurrentContextMenu!);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResetContextMenu()
|
public void ResetContextMenu()
|
||||||
@@ -202,7 +197,7 @@ public partial class ContextMenuViewModel : ObservableObject,
|
|||||||
|
|
||||||
if (CurrentContextMenu is not null)
|
if (CurrentContextMenu is not null)
|
||||||
{
|
{
|
||||||
ListHelpers.InPlaceUpdateList(FilteredItems, [.. CurrentContextMenu!]);
|
ListHelpers.InPlaceUpdateList(FilteredItems, CurrentContextMenu!);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using ManagedCommon;
|
using Microsoft.CmdPal.Core.Common;
|
||||||
|
|
||||||
namespace Microsoft.CmdPal.Core.ViewModels;
|
namespace Microsoft.CmdPal.Core.ViewModels;
|
||||||
|
|
||||||
@@ -11,13 +11,13 @@ public abstract partial class ExtensionObjectViewModel : ObservableObject
|
|||||||
{
|
{
|
||||||
public WeakReference<IPageContext> PageContext { get; set; }
|
public WeakReference<IPageContext> PageContext { get; set; }
|
||||||
|
|
||||||
public ExtensionObjectViewModel(IPageContext? context)
|
internal ExtensionObjectViewModel(IPageContext? context)
|
||||||
{
|
{
|
||||||
var realContext = context ?? (this is IPageContext c ? c : throw new ArgumentException("You need to pass in an IErrorContext"));
|
var realContext = context ?? (this is IPageContext c ? c : throw new ArgumentException("You need to pass in an IErrorContext"));
|
||||||
PageContext = new(realContext);
|
PageContext = new(realContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExtensionObjectViewModel(WeakReference<IPageContext> context)
|
internal ExtensionObjectViewModel(WeakReference<IPageContext> context)
|
||||||
{
|
{
|
||||||
PageContext = context;
|
PageContext = context;
|
||||||
}
|
}
|
||||||
@@ -114,7 +114,7 @@ public abstract partial class ExtensionObjectViewModel : ObservableObject
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.LogDebug(ex.ToString());
|
CoreLogger.LogDebug(ex.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,7 @@ namespace Microsoft.CmdPal.Core.ViewModels;
|
|||||||
|
|
||||||
public partial class FilterItemViewModel : ExtensionObjectViewModel, IFilterItemViewModel
|
public partial class FilterItemViewModel : ExtensionObjectViewModel, IFilterItemViewModel
|
||||||
{
|
{
|
||||||
private ExtensionObject<IFilter> _model;
|
private readonly ExtensionObject<IFilter> _model;
|
||||||
|
|
||||||
public string Id { get; set; } = string.Empty;
|
public string Id { get; set; } = string.Empty;
|
||||||
|
|
||||||
@@ -28,6 +28,8 @@ public partial class ListItemViewModel(IListItem model, WeakReference<IPageConte
|
|||||||
[MemberNotNullWhen(true, nameof(Details))]
|
[MemberNotNullWhen(true, nameof(Details))]
|
||||||
public bool HasDetails => Details is not null;
|
public bool HasDetails => Details is not null;
|
||||||
|
|
||||||
|
public string AccessibleName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public override void InitializeProperties()
|
public override void InitializeProperties()
|
||||||
{
|
{
|
||||||
if (IsInitialized)
|
if (IsInitialized)
|
||||||
@@ -49,6 +51,8 @@ public partial class ListItemViewModel(IListItem model, WeakReference<IPageConte
|
|||||||
Section = li.Section ?? string.Empty;
|
Section = li.Section ?? string.Empty;
|
||||||
|
|
||||||
UpdateProperty(nameof(Section));
|
UpdateProperty(nameof(Section));
|
||||||
|
|
||||||
|
UpdateAccessibleName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SlowInitializeProperties()
|
public override void SlowInitializeProperties()
|
||||||
@@ -101,6 +105,10 @@ public partial class ListItemViewModel(IListItem model, WeakReference<IPageConte
|
|||||||
UpdateProperty(nameof(Details));
|
UpdateProperty(nameof(Details));
|
||||||
UpdateProperty(nameof(HasDetails));
|
UpdateProperty(nameof(HasDetails));
|
||||||
break;
|
break;
|
||||||
|
case nameof(Title):
|
||||||
|
case nameof(Subtitle):
|
||||||
|
UpdateAccessibleName();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateProperty(propertyName);
|
UpdateProperty(propertyName);
|
||||||
@@ -152,4 +160,10 @@ public partial class ListItemViewModel(IListItem model, WeakReference<IPageConte
|
|||||||
// piggy-backing off their PropChanged
|
// piggy-backing off their PropChanged
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void UpdateAccessibleName()
|
||||||
|
{
|
||||||
|
AccessibleName = Title + ", " + Subtitle;
|
||||||
|
UpdateProperty(nameof(AccessibleName));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,7 @@ using System.Collections.ObjectModel;
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
using CommunityToolkit.Mvvm.Messaging;
|
using CommunityToolkit.Mvvm.Messaging;
|
||||||
using Microsoft.CmdPal.Common.Helpers;
|
using Microsoft.CmdPal.Core.Common.Helpers;
|
||||||
using Microsoft.CmdPal.Core.ViewModels.Messages;
|
using Microsoft.CmdPal.Core.ViewModels.Messages;
|
||||||
using Microsoft.CmdPal.Core.ViewModels.Models;
|
using Microsoft.CmdPal.Core.ViewModels.Models;
|
||||||
using Microsoft.CommandPalette.Extensions;
|
using Microsoft.CommandPalette.Extensions;
|
||||||
@@ -18,6 +18,7 @@ namespace Microsoft.CmdPal.Core.ViewModels;
|
|||||||
public partial class ListViewModel : PageViewModel, IDisposable
|
public partial class ListViewModel : PageViewModel, IDisposable
|
||||||
{
|
{
|
||||||
// private readonly HashSet<ListItemViewModel> _itemCache = [];
|
// private readonly HashSet<ListItemViewModel> _itemCache = [];
|
||||||
|
private readonly TaskFactory filterTaskFactory = new(new ConcurrentExclusiveSchedulerPair().ExclusiveScheduler);
|
||||||
|
|
||||||
// TODO: Do we want a base "ItemsPageViewModel" for anything that's going to have items?
|
// TODO: Do we want a base "ItemsPageViewModel" for anything that's going to have items?
|
||||||
|
|
||||||
@@ -68,9 +69,16 @@ public partial class ListViewModel : PageViewModel, IDisposable
|
|||||||
private bool _isDynamic;
|
private bool _isDynamic;
|
||||||
|
|
||||||
private Task? _initializeItemsTask;
|
private Task? _initializeItemsTask;
|
||||||
|
|
||||||
|
// For cancelling the task to load the properties from the items in the list
|
||||||
private CancellationTokenSource? _cancellationTokenSource;
|
private CancellationTokenSource? _cancellationTokenSource;
|
||||||
|
|
||||||
|
// For cancelling the task for calling GetItems on the extension
|
||||||
private CancellationTokenSource? _fetchItemsCancellationTokenSource;
|
private CancellationTokenSource? _fetchItemsCancellationTokenSource;
|
||||||
|
|
||||||
|
// For cancelling ongoing calls to update the extension's SearchText
|
||||||
|
private CancellationTokenSource? filterCancellationTokenSource;
|
||||||
|
|
||||||
private ListItemViewModel? _lastSelectedItem;
|
private ListItemViewModel? _lastSelectedItem;
|
||||||
|
|
||||||
public override bool IsInitialized
|
public override bool IsInitialized
|
||||||
@@ -102,10 +110,20 @@ public partial class ListViewModel : PageViewModel, IDisposable
|
|||||||
// something needs to change, by raising ItemsChanged.
|
// something needs to change, by raising ItemsChanged.
|
||||||
if (_isDynamic)
|
if (_isDynamic)
|
||||||
{
|
{
|
||||||
// We're getting called on the UI thread.
|
filterCancellationTokenSource?.Cancel();
|
||||||
// Hop off to a BG thread to update the extension.
|
filterCancellationTokenSource?.Dispose();
|
||||||
_ = Task.Run(() =>
|
filterCancellationTokenSource = new CancellationTokenSource();
|
||||||
|
|
||||||
|
// Hop off to an exclusive scheduler background thread to update the
|
||||||
|
// extension. We do this to ensure that all filter update requests
|
||||||
|
// are serialized and in-order, so providers know to cancel previous
|
||||||
|
// requests when a new one comes in. Otherwise, they may execute
|
||||||
|
// concurrently.
|
||||||
|
_ = filterTaskFactory.StartNew(
|
||||||
|
() =>
|
||||||
{
|
{
|
||||||
|
filterCancellationTokenSource.Token.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_model.Unsafe is IDynamicListPage dynamic)
|
if (_model.Unsafe is IDynamicListPage dynamic)
|
||||||
@@ -113,11 +131,17 @@ public partial class ListViewModel : PageViewModel, IDisposable
|
|||||||
dynamic.SearchText = searchTextBox;
|
dynamic.SearchText = searchTextBox;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (OperationCanceledException)
|
||||||
|
{
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ShowException(ex, _model?.Unsafe?.Name);
|
ShowException(ex, _model?.Unsafe?.Name);
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
filterCancellationTokenSource.Token,
|
||||||
|
TaskCreationOptions.None,
|
||||||
|
filterTaskFactory.Scheduler!);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -697,6 +721,10 @@ public partial class ListViewModel : PageViewModel, IDisposable
|
|||||||
_cancellationTokenSource?.Dispose();
|
_cancellationTokenSource?.Dispose();
|
||||||
_cancellationTokenSource = null;
|
_cancellationTokenSource = null;
|
||||||
|
|
||||||
|
filterCancellationTokenSource?.Cancel();
|
||||||
|
filterCancellationTokenSource?.Dispose();
|
||||||
|
filterCancellationTokenSource = null;
|
||||||
|
|
||||||
_fetchItemsCancellationTokenSource?.Cancel();
|
_fetchItemsCancellationTokenSource?.Cancel();
|
||||||
_fetchItemsCancellationTokenSource?.Dispose();
|
_fetchItemsCancellationTokenSource?.Dispose();
|
||||||
_fetchItemsCancellationTokenSource = null;
|
_fetchItemsCancellationTokenSource = null;
|
||||||
@@ -710,6 +738,7 @@ public partial class ListViewModel : PageViewModel, IDisposable
|
|||||||
EmptyContent = new(new(null), PageContext); // necessary?
|
EmptyContent = new(new(null), PageContext); // necessary?
|
||||||
|
|
||||||
_cancellationTokenSource?.Cancel();
|
_cancellationTokenSource?.Cancel();
|
||||||
|
filterCancellationTokenSource?.Cancel();
|
||||||
_fetchItemsCancellationTokenSource?.Cancel();
|
_fetchItemsCancellationTokenSource?.Cancel();
|
||||||
|
|
||||||
lock (_listLock)
|
lock (_listLock)
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using ManagedCommon;
|
using Microsoft.CmdPal.Core.Common;
|
||||||
using Microsoft.CommandPalette.Extensions;
|
using Microsoft.CommandPalette.Extensions;
|
||||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ public interface IContextMenuContext : INotifyPropertyChanged
|
|||||||
var added = result.TryAdd(key, cmd);
|
var added = result.TryAdd(key, cmd);
|
||||||
if (!added)
|
if (!added)
|
||||||
{
|
{
|
||||||
Logger.LogWarning($"Ignoring duplicate keyboard shortcut {KeyChordHelpers.FormatForDebug(key)} on command '{cmd.Title ?? cmd.Name ?? "(unknown)"}'");
|
CoreLogger.LogWarning($"Ignoring duplicate keyboard shortcut {KeyChordHelpers.FormatForDebug(key)} on command '{cmd.Title ?? cmd.Name ?? "(unknown)"}'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<Import Project="..\..\CoreCommonProps.props" />
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="CommunityToolkit.Common" />
|
||||||
|
<PackageReference Include="CommunityToolkit.Mvvm" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Microsoft.CmdPal.Core.Common\Microsoft.CmdPal.Core.Common.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://aka.ms/CsWin32.schema.json",
|
||||||
|
"allowMarshaling": false
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
using Microsoft.CmdPal.Common.Helpers;
|
using Microsoft.CmdPal.Core.Common.Helpers;
|
||||||
using Microsoft.CmdPal.Core.ViewModels.Models;
|
using Microsoft.CmdPal.Core.ViewModels.Models;
|
||||||
using Microsoft.CommandPalette.Extensions;
|
using Microsoft.CommandPalette.Extensions;
|
||||||
|
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
using CommunityToolkit.Mvvm.Messaging;
|
using CommunityToolkit.Mvvm.Messaging;
|
||||||
using ManagedCommon;
|
using Microsoft.CmdPal.Core.Common;
|
||||||
using Microsoft.CmdPal.Core.ViewModels.Messages;
|
using Microsoft.CmdPal.Core.ViewModels.Messages;
|
||||||
using Microsoft.CmdPal.Core.ViewModels.Models;
|
using Microsoft.CmdPal.Core.ViewModels.Models;
|
||||||
using Microsoft.CommandPalette.Extensions;
|
using Microsoft.CommandPalette.Extensions;
|
||||||
@@ -50,7 +50,7 @@ public partial class ShellViewModel : ObservableObject,
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.LogError(ex.ToString());
|
CoreLogger.LogError(ex.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -61,7 +61,7 @@ public partial class ShellViewModel : ObservableObject,
|
|||||||
|
|
||||||
private bool _isNested;
|
private bool _isNested;
|
||||||
|
|
||||||
public bool IsNested { get => _isNested; }
|
public bool IsNested => _isNested;
|
||||||
|
|
||||||
public ShellViewModel(
|
public ShellViewModel(
|
||||||
TaskScheduler scheduler,
|
TaskScheduler scheduler,
|
||||||
@@ -110,7 +110,7 @@ public partial class ShellViewModel : ObservableObject,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadPageViewModel(PageViewModel viewModel)
|
public async Task LoadPageViewModelAsync(PageViewModel viewModel)
|
||||||
{
|
{
|
||||||
// Note: We removed the general loading state, extensions sometimes use their `IsLoading`, but it's inconsistently implemented it seems.
|
// Note: We removed the general loading state, extensions sometimes use their `IsLoading`, but it's inconsistently implemented it seems.
|
||||||
// IsInitialized is our main indicator of the general overall state of loading props/items from a page we use for the progress bar
|
// IsInitialized is our main indicator of the general overall state of loading props/items from a page we use for the progress bar
|
||||||
@@ -122,7 +122,7 @@ public partial class ShellViewModel : ObservableObject,
|
|||||||
if (!viewModel.IsInitialized
|
if (!viewModel.IsInitialized
|
||||||
&& viewModel.InitializeCommand is not null)
|
&& viewModel.InitializeCommand is not null)
|
||||||
{
|
{
|
||||||
_ = Task.Run(async () =>
|
var outer = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
// You know, this creates the situation where we wait for
|
// You know, this creates the situation where we wait for
|
||||||
// both loading page properties, AND the items, before we
|
// both loading page properties, AND the items, before we
|
||||||
@@ -138,42 +138,29 @@ public partial class ShellViewModel : ObservableObject,
|
|||||||
|
|
||||||
if (viewModel.InitializeCommand.ExecutionTask.Status != TaskStatus.RanToCompletion)
|
if (viewModel.InitializeCommand.ExecutionTask.Status != TaskStatus.RanToCompletion)
|
||||||
{
|
{
|
||||||
// TODO: Handle failure case
|
|
||||||
if (viewModel.InitializeCommand.ExecutionTask.Exception is AggregateException ex)
|
if (viewModel.InitializeCommand.ExecutionTask.Exception is AggregateException ex)
|
||||||
{
|
{
|
||||||
Logger.LogError(ex.ToString());
|
CoreLogger.LogError(ex.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO GH #239 switch back when using the new MD text block
|
|
||||||
// _ = _queue.EnqueueAsync(() =>
|
|
||||||
/*_queue.TryEnqueue(new(() =>
|
|
||||||
{
|
|
||||||
LoadedState = ViewModelLoadedState.Error;
|
|
||||||
}));*/
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TODO GH #239 switch back when using the new MD text block
|
var t = Task.Factory.StartNew(
|
||||||
// _ = _queue.EnqueueAsync(() =>
|
|
||||||
_ = Task.Factory.StartNew(
|
|
||||||
() =>
|
() =>
|
||||||
{
|
{
|
||||||
// bool f = await viewModel.InitializeCommand.ExecutionTask.;
|
CurrentPage = viewModel;
|
||||||
// var result = viewModel.InitializeCommand.ExecutionTask.GetResultOrDefault()!;
|
|
||||||
// var result = viewModel.InitializeCommand.ExecutionTask.GetResultOrDefault<bool?>()!;
|
|
||||||
CurrentPage = viewModel; // result ? viewModel : null;
|
|
||||||
////LoadedState = result ? ViewModelLoadedState.Loaded : ViewModelLoadedState.Error;
|
|
||||||
},
|
},
|
||||||
CancellationToken.None,
|
CancellationToken.None,
|
||||||
TaskCreationOptions.None,
|
TaskCreationOptions.None,
|
||||||
_scheduler);
|
_scheduler);
|
||||||
|
await t;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
await outer;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CurrentPage = viewModel;
|
CurrentPage = viewModel;
|
||||||
////LoadedState = ViewModelLoadedState.Loaded;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +185,7 @@ public partial class ShellViewModel : ObservableObject,
|
|||||||
{
|
{
|
||||||
if (command is IPage page)
|
if (command is IPage page)
|
||||||
{
|
{
|
||||||
Logger.LogDebug($"Navigating to page");
|
CoreLogger.LogDebug($"Navigating to page");
|
||||||
|
|
||||||
var isMainPage = command == _rootPage;
|
var isMainPage = command == _rootPage;
|
||||||
_isNested = !isMainPage;
|
_isNested = !isMainPage;
|
||||||
@@ -207,21 +194,26 @@ public partial class ShellViewModel : ObservableObject,
|
|||||||
var pageViewModel = _pageViewModelFactory.TryCreatePageViewModel(page, _isNested, host);
|
var pageViewModel = _pageViewModelFactory.TryCreatePageViewModel(page, _isNested, host);
|
||||||
if (pageViewModel is null)
|
if (pageViewModel is null)
|
||||||
{
|
{
|
||||||
Logger.LogError($"Failed to create ViewModel for page {page.GetType().Name}");
|
CoreLogger.LogError($"Failed to create ViewModel for page {page.GetType().Name}");
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kick off async loading of our ViewModel
|
// Kick off async loading of our ViewModel
|
||||||
LoadPageViewModel(pageViewModel);
|
LoadPageViewModelAsync(pageViewModel)
|
||||||
OnUIThread(() => { WeakReferenceMessenger.Default.Send<UpdateCommandBarMessage>(new(null)); });
|
.ContinueWith(
|
||||||
WeakReferenceMessenger.Default.Send<NavigateToPageMessage>(new(pageViewModel, message.WithAnimation));
|
(Task t) =>
|
||||||
|
{
|
||||||
|
OnUIThread(() => { WeakReferenceMessenger.Default.Send<UpdateCommandBarMessage>(new(null)); });
|
||||||
|
WeakReferenceMessenger.Default.Send<NavigateToPageMessage>(new(pageViewModel, message.WithAnimation));
|
||||||
|
},
|
||||||
|
_scheduler);
|
||||||
|
|
||||||
// Note: Originally we set our page back in the ViewModel here, but that now happens in response to the Frame navigating triggered from the above
|
// Note: Originally we set our page back in the ViewModel here, but that now happens in response to the Frame navigating triggered from the above
|
||||||
// See RootFrame_Navigated event handler.
|
// See RootFrame_Navigated event handler.
|
||||||
}
|
}
|
||||||
else if (command is IInvokableCommand invokable)
|
else if (command is IInvokableCommand invokable)
|
||||||
{
|
{
|
||||||
Logger.LogDebug($"Invoking command");
|
CoreLogger.LogDebug($"Invoking command");
|
||||||
|
|
||||||
WeakReferenceMessenger.Default.Send<BeginInvokeMessage>();
|
WeakReferenceMessenger.Default.Send<BeginInvokeMessage>();
|
||||||
StartInvoke(message, invokable, host);
|
StartInvoke(message, invokable, host);
|
||||||
@@ -287,7 +279,7 @@ public partial class ShellViewModel : ObservableObject,
|
|||||||
}
|
}
|
||||||
|
|
||||||
var kind = result.Kind;
|
var kind = result.Kind;
|
||||||
Logger.LogDebug($"handling {kind.ToString()}");
|
CoreLogger.LogDebug($"handling {kind.ToString()}");
|
||||||
|
|
||||||
WeakReferenceMessenger.Default.Send<CmdPalInvokeResultMessage>(new(kind));
|
WeakReferenceMessenger.Default.Send<CmdPalInvokeResultMessage>(new(kind));
|
||||||
switch (kind)
|
switch (kind)
|
||||||
@@ -1,48 +1,39 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<Import Project="..\..\..\Common.Dotnet.CsWinRT.props" />
|
<Import Project="..\..\Common.Dotnet.CsWinRT.props" />
|
||||||
<Import Project="..\..\..\Common.Dotnet.AotCompatibility.props" />
|
<Import Project="..\..\Common.Dotnet.AotCompatibility.props" />
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
|
||||||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
|
||||||
<OutputPath>$(SolutionDir)$(Platform)\$(Configuration)\WinUI3Apps\CmdPal</OutputPath>
|
|
||||||
<!-- For MVVM Toolkit Partial Properties/AOT support -->
|
<!-- For MVVM Toolkit Partial Properties/AOT support -->
|
||||||
<LangVersion>preview</LangVersion>
|
<LangVersion>preview</LangVersion>
|
||||||
|
|
||||||
|
<OutputPath>$(SolutionDir)$(Platform)\$(Configuration)\WinUI3Apps\CmdPal\</OutputPath>
|
||||||
|
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||||
|
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
||||||
|
<!-- MRT from windows app sdk will search for a pri file with the same name of the module before defaulting to resources.pri -->
|
||||||
|
<ProjectPriFileName>$(RootNamespace).pri</ProjectPriFileName>
|
||||||
|
|
||||||
<!-- Disable SA1313 for Primary Constructor fields conflict https://learn.microsoft.com/dotnet/csharp/programming-guide/classes-and-structs/instance-constructors#primary-constructors -->
|
<!-- Disable SA1313 for Primary Constructor fields conflict https://learn.microsoft.com/dotnet/csharp/programming-guide/classes-and-structs/instance-constructors#primary-constructors -->
|
||||||
<NoWarn>SA1313;</NoWarn>
|
<NoWarn>SA1313;</NoWarn>
|
||||||
|
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<CsWinRTAotOptimizerEnabled>true</CsWinRTAotOptimizerEnabled>
|
<CsWinRTAotOptimizerEnabled>true</CsWinRTAotOptimizerEnabled>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="CommunityToolkit.Common" />
|
|
||||||
<PackageReference Include="CommunityToolkit.Mvvm" />
|
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Windows.CsWin32">
|
<PackageReference Include="Microsoft.Windows.CsWin32">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.WindowsAppSDK" />
|
||||||
<PackageReference Include="WyHash" />
|
<PackageReference Include="Microsoft.Web.WebView2" />
|
||||||
|
<!-- This line forces the WebView2 version used by Windows App SDK to be the one we expect from Directory.Packages.props . -->
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\Microsoft.CmdPal.Common\Microsoft.CmdPal.Common.csproj" />
|
|
||||||
<ProjectReference Include="..\extensionsdk\Microsoft.CommandPalette.Extensions.Toolkit\Microsoft.CommandPalette.Extensions.Toolkit.csproj" />
|
|
||||||
<ProjectReference Include="..\..\..\common\ManagedCommon\ManagedCommon.csproj" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Update="Properties\Resources.Designer.cs">
|
<ProjectReference Include="$(MSBuildThisFileDirectory)\extensionsdk\Microsoft.CommandPalette.Extensions.Toolkit\Microsoft.CommandPalette.Extensions.Toolkit.csproj" />
|
||||||
<DependentUpon>Resources.resx</DependentUpon>
|
|
||||||
<DesignTime>True</DesignTime>
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,56 +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.Security.Principal;
|
|
||||||
using Windows.Win32;
|
|
||||||
using Windows.Win32.Foundation;
|
|
||||||
|
|
||||||
namespace Microsoft.CmdPal.Common.Helpers;
|
|
||||||
|
|
||||||
public static partial class RuntimeHelper
|
|
||||||
{
|
|
||||||
public static bool IsMSIX
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
// TODO: for whatever reason, when I ported this into the PT
|
|
||||||
// codebase, this no longer compiled. We're only ever using it for
|
|
||||||
// the hacked up settings and ignoring it anyways, so I'm leaving
|
|
||||||
// it commented out for now.
|
|
||||||
//
|
|
||||||
// See also:
|
|
||||||
// * https://github.com/microsoft/win32metadata/commit/6fee67ba73bfe1b126ce524f7de8d367f0317715
|
|
||||||
// * https://github.com/microsoft/win32metadata/issues/1311
|
|
||||||
// uint length = 0;
|
|
||||||
// return PInvoke.GetCurrentPackageFullName(ref length, null) != WIN32_ERROR.APPMODEL_ERROR_NO_PACKAGE;
|
|
||||||
#pragma warning disable IDE0025 // Use expression body for property
|
|
||||||
return true;
|
|
||||||
#pragma warning restore IDE0025 // Use expression body for property
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool IsOnWindows11
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
var version = Environment.OSVersion.Version;
|
|
||||||
return version.Major >= 10 && version.Build >= 22000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool IsCurrentProcessRunningAsAdmin()
|
|
||||||
{
|
|
||||||
var identity = WindowsIdentity.GetCurrent();
|
|
||||||
return identity.Owner?.IsWellKnown(WellKnownSidType.BuiltinAdministratorsSid) ?? false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void VerifyCurrentProcessRunningAsAdmin()
|
|
||||||
{
|
|
||||||
if (!IsCurrentProcessRunningAsAdmin())
|
|
||||||
{
|
|
||||||
throw new UnauthorizedAccessException("This operation requires elevated privileges.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +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.CmdPal.Common.Messages;
|
|
||||||
|
|
||||||
public partial record HideWindowMessage()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
<Import Project="..\..\..\Common.Dotnet.CsWinRT.props" />
|
|
||||||
<Import Project="..\..\..\Common.Dotnet.AotCompatibility.props" />
|
|
||||||
<PropertyGroup>
|
|
||||||
<RootNamespace>Microsoft.CmdPal.Common</RootNamespace>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<UseWinUI>true</UseWinUI>
|
|
||||||
<LangVersion>preview</LangVersion>
|
|
||||||
|
|
||||||
<OutputPath>$(SolutionDir)$(Platform)\$(Configuration)\WinUI3Apps\CmdPal\</OutputPath>
|
|
||||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
|
||||||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
|
||||||
<!-- MRT from windows app sdk will search for a pri file with the same name of the module before defaulting to resources.pri -->
|
|
||||||
<ProjectPriFileName>Microsoft.CmdPal.Common.pri</ProjectPriFileName>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting" />
|
|
||||||
|
|
||||||
<PackageReference Include="Microsoft.Windows.CsWin32">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Microsoft.WindowsAppSDK" />
|
|
||||||
<PackageReference Include="Microsoft.Web.WebView2" />
|
|
||||||
<!-- This line forces the WebView2 version used by Windows App SDK to be the one we expect from Directory.Packages.props . -->
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\..\..\common\ManagedCommon\ManagedCommon.csproj" />
|
|
||||||
<ProjectReference Include="..\..\..\common\ManagedCsWin32\ManagedCsWin32.csproj" />
|
|
||||||
<ProjectReference Include="..\extensionsdk\Microsoft.CommandPalette.Extensions.Toolkit\Microsoft.CommandPalette.Extensions.Toolkit.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Update="Properties\Resources.Designer.cs">
|
|
||||||
<DesignTime>True</DesignTime>
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DependentUpon>Resources.resx</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<EmbeddedResource Update="Properties\Resources.resx">
|
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
|
||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
|
||||||
</EmbeddedResource>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@@ -1,99 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
// <auto-generated>
|
|
||||||
// This code was generated by a tool.
|
|
||||||
// Runtime Version:4.0.30319.42000
|
|
||||||
//
|
|
||||||
// Changes to this file may cause incorrect behavior and will be lost if
|
|
||||||
// the code is regenerated.
|
|
||||||
// </auto-generated>
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
namespace Microsoft.CmdPal.Common.Properties {
|
|
||||||
using System;
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
|
||||||
/// </summary>
|
|
||||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
|
||||||
// class via a tool like ResGen or Visual Studio.
|
|
||||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
|
||||||
// with the /str option, or rebuild your VS project.
|
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
|
||||||
internal class Resources {
|
|
||||||
|
|
||||||
private static global::System.Resources.ResourceManager resourceMan;
|
|
||||||
|
|
||||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
|
||||||
|
|
||||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
|
||||||
internal Resources() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns the cached ResourceManager instance used by this class.
|
|
||||||
/// </summary>
|
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
|
||||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
|
||||||
get {
|
|
||||||
if (object.ReferenceEquals(resourceMan, null)) {
|
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.CmdPal.Common.Properties.Resources", typeof(Resources).Assembly);
|
|
||||||
resourceMan = temp;
|
|
||||||
}
|
|
||||||
return resourceMan;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides the current thread's CurrentUICulture property for all
|
|
||||||
/// resource lookups using this strongly typed resource class.
|
|
||||||
/// </summary>
|
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
|
||||||
internal static global::System.Globalization.CultureInfo Culture {
|
|
||||||
get {
|
|
||||||
return resourceCulture;
|
|
||||||
}
|
|
||||||
set {
|
|
||||||
resourceCulture = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Looks up a localized string similar to Open path in console.
|
|
||||||
/// </summary>
|
|
||||||
internal static string Indexer_Command_OpenPathInConsole {
|
|
||||||
get {
|
|
||||||
return ResourceManager.GetString("Indexer_Command_OpenPathInConsole", resourceCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Looks up a localized string similar to Properties.
|
|
||||||
/// </summary>
|
|
||||||
internal static string Indexer_Command_OpenProperties {
|
|
||||||
get {
|
|
||||||
return ResourceManager.GetString("Indexer_Command_OpenProperties", resourceCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Looks up a localized string similar to Open with.
|
|
||||||
/// </summary>
|
|
||||||
internal static string Indexer_Command_OpenWith {
|
|
||||||
get {
|
|
||||||
return ResourceManager.GetString("Indexer_Command_OpenWith", resourceCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Looks up a localized string similar to Show in folder.
|
|
||||||
/// </summary>
|
|
||||||
internal static string Indexer_Command_ShowInFolder {
|
|
||||||
get {
|
|
||||||
return ResourceManager.GetString("Indexer_Command_ShowInFolder", resourceCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,132 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<data name="Indexer_Command_OpenPathInConsole" xml:space="preserve">
|
|
||||||
<value>Open path in console</value>
|
|
||||||
</data>
|
|
||||||
<data name="Indexer_Command_OpenProperties" xml:space="preserve">
|
|
||||||
<value>Properties</value>
|
|
||||||
</data>
|
|
||||||
<data name="Indexer_Command_OpenWith" xml:space="preserve">
|
|
||||||
<value>Open with</value>
|
|
||||||
</data>
|
|
||||||
<data name="Indexer_Command_ShowInFolder" xml:space="preserve">
|
|
||||||
<value>Show in folder</value>
|
|
||||||
</data>
|
|
||||||
</root>
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
using Microsoft.CmdPal.Common.Services;
|
using Microsoft.CmdPal.Core.Common.Services;
|
||||||
using Microsoft.CmdPal.Core.ViewModels;
|
using Microsoft.CmdPal.Core.ViewModels;
|
||||||
using Microsoft.CommandPalette.Extensions;
|
using Microsoft.CommandPalette.Extensions;
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
using ManagedCommon;
|
using ManagedCommon;
|
||||||
using Microsoft.CmdPal.Common.Services;
|
using Microsoft.CmdPal.Core.Common.Services;
|
||||||
using Microsoft.CmdPal.Core.ViewModels;
|
using Microsoft.CmdPal.Core.ViewModels;
|
||||||
using Microsoft.CmdPal.Core.ViewModels.Models;
|
using Microsoft.CmdPal.Core.ViewModels.Models;
|
||||||
using Microsoft.CommandPalette.Extensions;
|
using Microsoft.CommandPalette.Extensions;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
using ManagedCommon;
|
using Microsoft.CmdPal.Core.Common;
|
||||||
using Microsoft.CmdPal.Core.ViewModels;
|
using Microsoft.CmdPal.Core.ViewModels;
|
||||||
using Microsoft.CmdPal.Core.ViewModels.Models;
|
using Microsoft.CmdPal.Core.ViewModels.Models;
|
||||||
using Microsoft.CommandPalette.Extensions;
|
using Microsoft.CommandPalette.Extensions;
|
||||||
@@ -44,7 +44,7 @@ public partial class CommandSettingsViewModel(ICommandSettings? _unsafeSettings,
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.LogError($"Failed to load settings page", ex: ex);
|
CoreLogger.LogError($"Failed to load settings page", ex: ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
Initialized = true;
|
Initialized = true;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
using Microsoft.CmdPal.Common;
|
using Microsoft.CmdPal.Core.Common;
|
||||||
|
|
||||||
namespace Microsoft.CmdPal.UI.ViewModels.BuiltinCommands;
|
namespace Microsoft.CmdPal.UI.ViewModels.BuiltinCommands;
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ using System.Collections.Specialized;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using CommunityToolkit.Mvvm.Messaging;
|
using CommunityToolkit.Mvvm.Messaging;
|
||||||
using ManagedCommon;
|
using ManagedCommon;
|
||||||
using Microsoft.CmdPal.Common.Helpers;
|
using Microsoft.CmdPal.Core.Common.Helpers;
|
||||||
using Microsoft.CmdPal.Core.ViewModels.Messages;
|
using Microsoft.CmdPal.Core.ViewModels.Messages;
|
||||||
using Microsoft.CmdPal.Ext.Apps;
|
using Microsoft.CmdPal.Ext.Apps;
|
||||||
using Microsoft.CmdPal.UI.ViewModels.Messages;
|
using Microsoft.CmdPal.UI.ViewModels.Messages;
|
||||||
|
|||||||
@@ -55,8 +55,8 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Microsoft.CmdPal.Common\Microsoft.CmdPal.Common.csproj" />
|
<ProjectReference Include="..\Core\Microsoft.CmdPal.Core.Common\Microsoft.CmdPal.Core.Common.csproj" />
|
||||||
<ProjectReference Include="..\Microsoft.CmdPal.Core.ViewModels\Microsoft.CmdPal.Core.ViewModels.csproj" />
|
<ProjectReference Include="..\Core\Microsoft.CmdPal.Core.ViewModels\Microsoft.CmdPal.Core.ViewModels.csproj" />
|
||||||
<ProjectReference Include="..\extensionsdk\Microsoft.CommandPalette.Extensions.Toolkit\Microsoft.CommandPalette.Extensions.Toolkit.csproj" />
|
<ProjectReference Include="..\extensionsdk\Microsoft.CommandPalette.Extensions.Toolkit\Microsoft.CommandPalette.Extensions.Toolkit.csproj" />
|
||||||
|
|
||||||
<ProjectReference Include="..\ext\Microsoft.CmdPal.Ext.Apps\Microsoft.CmdPal.Ext.Apps.csproj" />
|
<ProjectReference Include="..\ext\Microsoft.CmdPal.Ext.Apps\Microsoft.CmdPal.Ext.Apps.csproj" />
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
using ManagedCommon;
|
using ManagedCommon;
|
||||||
using Microsoft.CmdPal.Common.Services;
|
using Microsoft.CmdPal.Core.Common.Services;
|
||||||
using Microsoft.CommandPalette.Extensions;
|
using Microsoft.CommandPalette.Extensions;
|
||||||
using Windows.ApplicationModel;
|
using Windows.ApplicationModel;
|
||||||
using Windows.ApplicationModel.AppExtensions;
|
using Windows.ApplicationModel.AppExtensions;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using ManagedCommon;
|
using ManagedCommon;
|
||||||
using Microsoft.CmdPal.Common.Services;
|
using Microsoft.CmdPal.Core.Common.Services;
|
||||||
using Microsoft.CommandPalette.Extensions;
|
using Microsoft.CommandPalette.Extensions;
|
||||||
using Windows.ApplicationModel;
|
using Windows.ApplicationModel;
|
||||||
using Windows.ApplicationModel.AppExtensions;
|
using Windows.ApplicationModel.AppExtensions;
|
||||||
|
|||||||
@@ -17,3 +17,7 @@ SHCreateStreamOnFileEx
|
|||||||
CoAllowSetForegroundWindow
|
CoAllowSetForegroundWindow
|
||||||
SHCreateStreamOnFileEx
|
SHCreateStreamOnFileEx
|
||||||
SHLoadIndirectString
|
SHLoadIndirectString
|
||||||
|
CoCancelCall
|
||||||
|
CoEnableCallCancellation
|
||||||
|
CoDisableCallCancellation
|
||||||
|
GetCurrentThreadId
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using CommunityToolkit.Mvvm.Messaging;
|
using CommunityToolkit.Mvvm.Messaging;
|
||||||
using Microsoft.CmdPal.Common.Services;
|
using Microsoft.CmdPal.Core.Common.Services;
|
||||||
using Microsoft.CmdPal.Core.ViewModels;
|
using Microsoft.CmdPal.Core.ViewModels;
|
||||||
using Microsoft.CmdPal.UI.ViewModels.Messages;
|
using Microsoft.CmdPal.UI.ViewModels.Messages;
|
||||||
using Microsoft.CmdPal.UI.ViewModels.Properties;
|
using Microsoft.CmdPal.UI.ViewModels.Properties;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user