* Architecture and (#7267) * Added debugging steps for PT Run * Updated architecture markdown for launcher * updated project architecture markdown for launcher * Added telemetry docs for launcher * Added the basic folder structure and files * Added a basic overview of all common functionalities of the plugins * Added information about the functioning of the calculator plugin * update score section of overview * added information about the uri plugin * added info about the indexer plugin * Added the documentation for the indexer plugin * Added information about the program plugin * Added info about the shell plugin * updated some plugin info and added information about the ww plugin * documenting the folder plugin * updated window walker docs * dev docs for the folder plugin * added images to each of the plugins * Added link to pt run documents * fix typos and some minor corrections * Add table of contents for pt run dev docs * Fix image path and project link for Wox.plugin Co-authored-by: Divyansh Srivastava <somm14divi@gmail.com>
4.3 KiB
Architecture
Overview
PowerToys Run
is a plugin-based .net core desktop application. It is written in WPF using Model-View-ViewModel (MVVM)
structural design pattern. This article provides an overview of PowerToys Run
architecture and introduces major components in the data flow.
Note : We refer to base application without plugins as PowerLauncher
, which is same as the name of startup WPF project.
UI
PowerToys Run UI is written in the WPF framework. The UI code is present in the Powerlauncher project and is spanned across three high-level components: MainWindow.xaml
, LauncherControl.xaml
and ResultList.xaml
. These components are discussed below.
Fig 1: PowerToys Run UI architecture
MainWindow.xaml
: This is the outermost-level UI control. It is composed of lower-level UI components such asLauncherControl.xaml
andResultList.xaml
. The corresponding code-behind file implements all the UI related functionalities such as autosuggest, key-bindings, toggling visibility of WPF window and animations.LauncherControl.xaml
: This control implements the UI component for editing query text.(marked in red in Fig 1) It consists of two overlapping WPF controls,TextBox
andTextBlock
. The outerTextBox
is used for editing query whereas the innerTextBlock
is used to display autosuggest text.ResultList.xaml
: This control implements the UI component for displaying results (marked in green in Fig 1). It consists of aListView
WPF control with a customItemTemplate
to display application logo, name, tooltip text, and context menu.
Data flow
The backend code is written using the Model-View-ViewModel (MVVM)
structural design pattern. Plugins act as Model
in this project. A detailed overview of the project's structure is given here.
Flow of data between UI(view) and ViewModels
Data flow between View and ViewModel follows typical MVVM
scheme. Properties in viewModels are bound to WPF controls and when these properties are updated, INotifyPropertyChanged
handler is invoked, which in turn updates UI. The diagram below provides a rough sketch of the components involved.
Fig 2: Flow of data between UI and ViewModels.
Flow of data between ViewModels and Plugins(Model)
PowerLauncher
interact with plugins using IPlugin
and IDelayedExecutionPlugin
interface. IPlugin
is used for initialization and making queries which are fast (typically return results in less than 100ms).IDelayedExecutionPlugin
is used for long-running queries and is implemented only when required. For example, IDelayedExecutionPlugin
is implemented by indexer plugin for searching files with names of form *abc*.
public interface IPlugin
{
// Query plugin
List<Result> Query(Query query);
// Initialize plugin
void Init(PluginInitContext context);
}
public interface IDelayedExecutionPlugin : IFeatures
{
// Query plugin
List<Result> Query(Query query, bool delayedExecution);
}
Fig 3: Flow of data between ViewModels and Plugins.
Requesting services from powerlauncher
Plugins could use the IPublicAPI
interface to request services such as getting the current theme (for deciding logo background), displaying messages to the user, and toggling the visibility of PowerLauncher.