Conversation
Adds the infrastructure, no commands or invokes included in this push
Added shell-related commands Created new interfaces for commands to declare ShellFolder/ShellItem support Removed old SupportingClasses commands implementations
|
In the latest push, I've added interfaces which commands can implement to indicate their support for displaying in shell context menus. All of the old implementations have been removed and replaced with this new dynamic system. The builds will fail until cairoshell/ManagedShell#109 merges. |
|
@josuave One thing I am on the fence regarding is the |
|
@dremin i know what your saying. I would not implement anything yet unless needed to do the job right now. Keep it simple and to the point. Handling what if scenarios will usually back you into a corner and get your hands tied. |
|
@josuave Thanks! I went ahead and removed it. I think this is ready now. |
|
@josuave Not sure if you saw but this is ready for review :) |
| public struct CommandInvokedEventArgs | ||
| { | ||
| public ICairoCommandInfo CommandInfo; | ||
| public (string name, object value)[] Parameters; |
There was a problem hiding this comment.
Due to this being a public part of the api or sdk it may be worth having a real type here
| public string Name; | ||
| public string Description; | ||
| public bool IsRequired; | ||
| public object Value; |
There was a problem hiding this comment.
Not a fan of the boxing, but I don't have another solution at the moment
|
|
||
| namespace CairoDesktop.Application.Interfaces | ||
| { | ||
| public interface ICairoCommand : IDisposable |
There was a problem hiding this comment.
I'm not sure if we need to inherit IDisposable here considering that not all commands will need it. I would propose that we ignorantly test the command in the command service to check if is.
|
|
||
| foreach (var command in _commands) | ||
| { | ||
| command.Dispose(); |
There was a problem hiding this comment.
if(command is IDisposable disposable)
{
disposable.dispose();
}
Introduces an ICairoCommand interface. Cairo and extensions can register commands in the same way shell extensions are registered. Commands consist of an action and metadata that describes the command--its identifier, label, description, parameters, and availability. Commands can can dynamically change their availability, label, etc based on changes to settings or other state.
Introduces a CommandService, similar to ExtensionService, that manages the list of and lifecycle of commands. It initializes all commands and disposes of them.
The CommandService is also what is responsible for invoking commands. Commands are invoked using their unique identifier, and can accept a key/value pair list of parameters.
I've created several commands so far, mostly representing the items in the Cairo menu and a few others. Before I mark this PR as ready, I plan to continue refactoring to replace existing code with commands then removing the old implementations.
As an example usage of commands, I've converted the Cairo menu to be dynamically generated by a list of commands. The Places menu has also been re-implemented around commands. The goal here is to make the menus fully customizable in the future.
There are interfaces, such as ICairoShellFolderCommandInfo and ICairoShellItemCommandInfo, which allow commands to declare their availability and label within shell context menus. Those commands are dynamically shown in menus.
Ultimately once the commands are all implemented, we will be in a place to deconstruct the rest of the
Cairo Desktopproject (i.e. desktop, taskbar, stacks, etc) now that the code is de-tangled.Fixes #144