Merge branch 'dev' into WelcomeWindow

This commit is contained in:
DB p 2021-12-03 06:31:32 +09:00
commit cffdb07dbc
70 changed files with 44009 additions and 758 deletions

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Diagnostics;
using System.IO;
using System.Threading;
@ -28,6 +28,11 @@ namespace Flow.Launcher.Core.Plugin
var path = Path.Combine(Constant.ProgramDirectory, JsonRPC);
_startInfo.EnvironmentVariables["PYTHONPATH"] = path;
_startInfo.EnvironmentVariables["FLOW_VERSION"] = Constant.Version;
_startInfo.EnvironmentVariables["FLOW_PROGRAM_DIRECTORY"] = Constant.ProgramDirectory;
_startInfo.EnvironmentVariables["FLOW_APPLICATION_DIRECTORY"] = Constant.ApplicationDirectory;
//Add -B flag to tell python don't write .py[co] files. Because .pyc contains location infos which will prevent python portable
_startInfo.ArgumentList.Add("-B");
}
@ -57,4 +62,4 @@ namespace Flow.Launcher.Core.Plugin
return Task.CompletedTask;
}
}
}
}

View file

@ -10,6 +10,7 @@ using Flow.Launcher.Infrastructure.Logger;
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Plugin;
using System.Globalization;
using System.Threading.Tasks;
namespace Flow.Launcher.Core.Resource
{
@ -95,10 +96,13 @@ namespace Flow.Launcher.Core.Resource
{
LoadLanguage(language);
}
UpdatePluginMetadataTranslations();
Settings.Language = language.LanguageCode;
CultureInfo.CurrentCulture = new CultureInfo(language.LanguageCode);
CultureInfo.CurrentUICulture = CultureInfo.CurrentCulture;
Task.Run(() =>
{
UpdatePluginMetadataTranslations();
});
}
public bool PromptShouldUsePinyin(string languageCodeToSet)

View file

@ -15,7 +15,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings
private string language = "en";
public string Hotkey { get; set; } = $"{KeyConstant.Alt} + {KeyConstant.Space}";
public string OpenResultModifiers { get; set; } = KeyConstant.Alt;
public string DarkMode { get; set; } = "System";
public string ColorScheme { get; set; } = "System";
public bool ShowOpenResultHotkey { get; set; } = true;
public double WindowSize { get; set; } = 580;
@ -168,7 +168,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings
Preserved
}
public enum DarkMode
public enum ColorSchemes
{
System,
Light,

View file

@ -1,4 +1,6 @@
namespace Flow.Launcher.Plugin
using System.Globalization;
namespace Flow.Launcher.Plugin
{
/// <summary>
/// Represent plugins that support internationalization
@ -8,5 +10,13 @@
string GetTranslatedPluginTitle();
string GetTranslatedPluginDescription();
/// <summary>
/// The method will be invoked when language of flow changed
/// </summary>
void OnCultureInfoChanged(CultureInfo newCulture)
{
}
}
}

View file

@ -37,6 +37,12 @@ namespace Flow.Launcher.Plugin
/// <exception cref="FileNotFoundException">Thrown when unable to find the file specified in the command </exception>
/// <exception cref="Win32Exception">Thrown when error occurs during the execution of the command </exception>
void ShellRun(string cmd, string filename = "cmd.exe");
/// <summary>
/// Copy Text to clipboard
/// </summary>
/// <param name="Text">Text to save on clipboard</param>
public void CopyToClipboard(string text);
/// <summary>
/// Save everything, all of Flow Launcher and plugins' data and settings

View file

@ -13,7 +13,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugins", "Plugins", "{3A73
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Flow.Launcher", "Flow.Launcher\Flow.Launcher.csproj", "{DB90F671-D861-46BB-93A3-F1304F5BA1C5}"
ProjectSection(ProjectDependencies) = postProject
{1EE20B48-82FB-48A2-8086-675D6DDAB4F0} = {1EE20B48-82FB-48A2-8086-675D6DDAB4F0}
{0B9DE348-9361-4940-ADB6-F5953BFFCCEC} = {0B9DE348-9361-4940-ADB6-F5953BFFCCEC}
{4792A74A-0CEA-4173-A8B2-30E6764C6217} = {4792A74A-0CEA-4173-A8B2-30E6764C6217}
{FDB3555B-58EF-4AE6-B5F1-904719637AB4} = {FDB3555B-58EF-4AE6-B5F1-904719637AB4}
@ -23,6 +22,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Flow.Launcher", "Flow.Launc
{9B130CC5-14FB-41FF-B310-0A95B6894C37} = {9B130CC5-14FB-41FF-B310-0A95B6894C37}
{FDED22C8-B637-42E8-824A-63B5B6E05A3A} = {FDED22C8-B637-42E8-824A-63B5B6E05A3A}
{A3DCCBCA-ACC1-421D-B16E-210896234C26} = {A3DCCBCA-ACC1-421D-B16E-210896234C26}
{5043CECE-E6A7-4867-9CBE-02D27D83747A} = {5043CECE-E6A7-4867-9CBE-02D27D83747A}
{403B57F2-1856-4FC7-8A24-36AB346B763E} = {403B57F2-1856-4FC7-8A24-36AB346B763E}
{588088F4-3262-4F9F-9663-A05DE12534C3} = {588088F4-3262-4F9F-9663-A05DE12534C3}
EndProjectSection
@ -35,8 +35,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Flow.Launcher.Plugin.Progra
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Flow.Launcher.Plugin.WebSearch", "Plugins\Flow.Launcher.Plugin.WebSearch\Flow.Launcher.Plugin.WebSearch.csproj", "{403B57F2-1856-4FC7-8A24-36AB346B763E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Flow.Launcher.Plugin.ControlPanel", "Plugins\Flow.Launcher.Plugin.ControlPanel\Flow.Launcher.Plugin.ControlPanel.csproj", "{1EE20B48-82FB-48A2-8086-675D6DDAB4F0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Flow.Launcher.Plugin.PluginIndicator", "Plugins\Flow.Launcher.Plugin.PluginIndicator\Flow.Launcher.Plugin.PluginIndicator.csproj", "{FDED22C8-B637-42E8-824A-63B5B6E05A3A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Flow.Launcher.Plugin.Sys", "Plugins\Flow.Launcher.Plugin.Sys\Flow.Launcher.Plugin.Sys.csproj", "{0B9DE348-9361-4940-ADB6-F5953BFFCCEC}"
@ -68,6 +66,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Flow.Launcher.Plugin.Proces
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Flow.Launcher.Plugin.PluginsManager", "Plugins\Flow.Launcher.Plugin.PluginsManager\Flow.Launcher.Plugin.PluginsManager.csproj", "{4792A74A-0CEA-4173-A8B2-30E6764C6217}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Flow.Launcher.Plugin.WindowsSettings", "Plugins\Flow.Launcher.Plugin.WindowsSettings\Flow.Launcher.Plugin.WindowsSettings.csproj", "{5043CECE-E6A7-4867-9CBE-02D27D83747A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -162,18 +162,6 @@ Global
{403B57F2-1856-4FC7-8A24-36AB346B763E}.Release|x64.Build.0 = Release|Any CPU
{403B57F2-1856-4FC7-8A24-36AB346B763E}.Release|x86.ActiveCfg = Release|Any CPU
{403B57F2-1856-4FC7-8A24-36AB346B763E}.Release|x86.Build.0 = Release|Any CPU
{1EE20B48-82FB-48A2-8086-675D6DDAB4F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1EE20B48-82FB-48A2-8086-675D6DDAB4F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1EE20B48-82FB-48A2-8086-675D6DDAB4F0}.Debug|x64.ActiveCfg = Debug|Any CPU
{1EE20B48-82FB-48A2-8086-675D6DDAB4F0}.Debug|x64.Build.0 = Debug|Any CPU
{1EE20B48-82FB-48A2-8086-675D6DDAB4F0}.Debug|x86.ActiveCfg = Debug|Any CPU
{1EE20B48-82FB-48A2-8086-675D6DDAB4F0}.Debug|x86.Build.0 = Debug|Any CPU
{1EE20B48-82FB-48A2-8086-675D6DDAB4F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1EE20B48-82FB-48A2-8086-675D6DDAB4F0}.Release|Any CPU.Build.0 = Release|Any CPU
{1EE20B48-82FB-48A2-8086-675D6DDAB4F0}.Release|x64.ActiveCfg = Release|Any CPU
{1EE20B48-82FB-48A2-8086-675D6DDAB4F0}.Release|x64.Build.0 = Release|Any CPU
{1EE20B48-82FB-48A2-8086-675D6DDAB4F0}.Release|x86.ActiveCfg = Release|Any CPU
{1EE20B48-82FB-48A2-8086-675D6DDAB4F0}.Release|x86.Build.0 = Release|Any CPU
{FDED22C8-B637-42E8-824A-63B5B6E05A3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FDED22C8-B637-42E8-824A-63B5B6E05A3A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FDED22C8-B637-42E8-824A-63B5B6E05A3A}.Debug|x64.ActiveCfg = Debug|Any CPU
@ -283,6 +271,18 @@ Global
{4792A74A-0CEA-4173-A8B2-30E6764C6217}.Release|x64.Build.0 = Release|Any CPU
{4792A74A-0CEA-4173-A8B2-30E6764C6217}.Release|x86.ActiveCfg = Release|Any CPU
{4792A74A-0CEA-4173-A8B2-30E6764C6217}.Release|x86.Build.0 = Release|Any CPU
{5043CECE-E6A7-4867-9CBE-02D27D83747A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5043CECE-E6A7-4867-9CBE-02D27D83747A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5043CECE-E6A7-4867-9CBE-02D27D83747A}.Debug|x64.ActiveCfg = Debug|Any CPU
{5043CECE-E6A7-4867-9CBE-02D27D83747A}.Debug|x64.Build.0 = Debug|Any CPU
{5043CECE-E6A7-4867-9CBE-02D27D83747A}.Debug|x86.ActiveCfg = Debug|Any CPU
{5043CECE-E6A7-4867-9CBE-02D27D83747A}.Debug|x86.Build.0 = Debug|Any CPU
{5043CECE-E6A7-4867-9CBE-02D27D83747A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5043CECE-E6A7-4867-9CBE-02D27D83747A}.Release|Any CPU.Build.0 = Release|Any CPU
{5043CECE-E6A7-4867-9CBE-02D27D83747A}.Release|x64.ActiveCfg = Release|Any CPU
{5043CECE-E6A7-4867-9CBE-02D27D83747A}.Release|x64.Build.0 = Release|Any CPU
{5043CECE-E6A7-4867-9CBE-02D27D83747A}.Release|x86.ActiveCfg = Release|Any CPU
{5043CECE-E6A7-4867-9CBE-02D27D83747A}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -290,7 +290,6 @@ Global
GlobalSection(NestedProjects) = preSolution
{FDB3555B-58EF-4AE6-B5F1-904719637AB4} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
{403B57F2-1856-4FC7-8A24-36AB346B763E} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
{1EE20B48-82FB-48A2-8086-675D6DDAB4F0} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
{FDED22C8-B637-42E8-824A-63B5B6E05A3A} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
{0B9DE348-9361-4940-ADB6-F5953BFFCCEC} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
{A3DCCBCA-ACC1-421D-B16E-210896234C26} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
@ -300,6 +299,7 @@ Global
{F9C4C081-4CC3-4146-95F1-E102B4E10A5F} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
{588088F4-3262-4F9F-9663-A05DE12534C3} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
{4792A74A-0CEA-4173-A8B2-30E6764C6217} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
{5043CECE-E6A7-4867-9CBE-02D27D83747A} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F26ACB50-3F6C-4907-B0C9-1ADACC1D0DED}

View file

@ -87,10 +87,10 @@
<system:String x:Key="theme_load_failure_parse_error">Fail to load theme {0}, fallback to default theme</system:String>
<system:String x:Key="ThemeFolder">Theme Folder</system:String>
<system:String x:Key="OpenThemeFolder">Open Theme Folder</system:String>
<system:String x:Key="DarkMode">Dark Mode</system:String>
<system:String x:Key="DarkModeSystem">System Default</system:String>
<system:String x:Key="DarkModeLight">Light</system:String>
<system:String x:Key="DarkModeDark">Dark</system:String>
<system:String x:Key="ColorScheme">Color Scheme</system:String>
<system:String x:Key="ColorSchemeSystem">System Default</system:String>
<system:String x:Key="ColorSchemeLight">Light</system:String>
<system:String x:Key="ColorSchemeDark">Dark</system:String>
<system:String x:Key="SoundEffect">Sound Effect</system:String>
<system:String x:Key="SoundEffectTip">Play a small sound when the search window opens</system:String>
<system:String x:Key="Animation">Animation</system:String>
@ -179,7 +179,7 @@
<system:String x:Key="newActionKeywordsHasBeenAssigned">This new Action Keyword is already assigned to another plugin, please choose a different one</system:String>
<system:String x:Key="success">Success</system:String>
<system:String x:Key="completedSuccessfully">Completed successfully</system:String>
<system:String x:Key="actionkeyword_tips">Enter the action keyword you need to start the plug-in. Use * if you don't want to specify an action keyword. In the case, The plug-in works without keywords.</system:String>
<system:String x:Key="actionkeyword_tips">Enter the action keyword you like to use to start the plugin. Use * if you don't want to specify any, and the plugin will be triggered without any action keywords.</system:String>
<!-- Custom Query Hotkey Dialog -->
<system:String x:Key="customeQueryHotkeyTitle">Custom Query Hotkey</system:String>

View file

@ -87,11 +87,10 @@
<system:String x:Key="theme_load_failure_parse_error">{0} 테마 로드에 실패했습니다. 기본 테마로 변경합니다.</system:String>
<system:String x:Key="ThemeFolder">테마 폴더</system:String>
<system:String x:Key="OpenThemeFolder">테마 폴더 열기</system:String>
<system:String x:Key="DarkMode">다크 모드</system:String>
<system:String x:Key="DarkModeTip">System settings will take effect from the next run</system:String>
<system:String x:Key="DarkModeSystem">시스템 기본</system:String>
<system:String x:Key="DarkModeLight">밝게</system:String>
<system:String x:Key="DarkModeDark">어둡게</system:String>
<system:String x:Key="ColorScheme">앱 색상</system:String>
<system:String x:Key="ColorSchemeSystem">시스템 기본</system:String>
<system:String x:Key="ColorSchemeLight">밝게</system:String>
<system:String x:Key="ColorSchemeDark">어둡게</system:String>
<system:String x:Key="SoundEffect">소리 효과</system:String>
<system:String x:Key="SoundEffectTip">검색창을 열 때 작은 소리를 재생합니다.</system:String>
<system:String x:Key="Animation">애니메이션</system:String>

View file

@ -69,7 +69,7 @@ namespace Flow.Launcher
HideStartup();
// show notify icon when flowlauncher is hidden
InitializeNotifyIcon();
InitializeDarkMode();
InitializeColorScheme();
WindowsInteropHelper.DisableControlBox(this);
InitProgressbarAnimation();
// since the default main window visibility is visible
@ -495,13 +495,13 @@ namespace Flow.Launcher
QueryTextBox.CaretIndex = QueryTextBox.Text.Length;
}
public void InitializeDarkMode()
public void InitializeColorScheme()
{
if (_settings.DarkMode == Constant.Light)
if (_settings.ColorScheme == Constant.Light)
{
ModernWpf.ThemeManager.Current.ApplicationTheme = ModernWpf.ApplicationTheme.Light;
}
else if (_settings.DarkMode == Constant.Dark)
else if (_settings.ColorScheme == Constant.Dark)
{
ModernWpf.ThemeManager.Current.ApplicationTheme = ModernWpf.ApplicationTheme.Dark;
}

View file

@ -114,6 +114,11 @@ namespace Flow.Launcher
var startInfo = ShellCommand.SetProcessStartInfo(filename, arguments: args, createNoWindow: true);
ShellCommand.Execute(startInfo);
}
public void CopyToClipboard(string text)
{
Clipboard.SetDataObject(text);
}
public void StartLoadingBar() => _mainVM.ProgressBarVisibility = Visibility.Visible;
@ -222,4 +227,4 @@ namespace Flow.Launcher
#endregion
}
}
}

View file

@ -1919,21 +1919,21 @@
<Border Margin="0,12,0,12" Style="{DynamicResource SettingGroupBox}">
<ItemsControl Style="{StaticResource SettingGrid}">
<StackPanel Style="{StaticResource TextPanel}">
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource DarkMode}" />
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource ColorScheme}" />
</StackPanel>
<ComboBox
x:Name="DarkModeComboBox"
x:Name="ColorSchemeComboBox"
Grid.Column="2"
Width="180"
Margin="0,0,18,0"
DisplayMemberPath="Display"
FontSize="14"
ItemsSource="{Binding DarkModes}"
SelectedValue="{Binding Settings.DarkMode}"
ItemsSource="{Binding ColorSchemes}"
SelectedValue="{Binding Settings.ColorScheme}"
SelectedValuePath="Value"
SelectionChanged="DarkModeSelectedIndexChanged" />
SelectionChanged="ColorSchemeSelectedIndexChanged" />
<TextBlock Style="{StaticResource Glyph}">
&#xe708;
&#xe793;
</TextBlock>
</ItemsControl>
</Border>

View file

@ -310,13 +310,14 @@ namespace Flow.Launcher
textBox.MoveFocus(tRequest);
}
private void DarkModeSelectedIndexChanged(object sender, EventArgs e) => ThemeManager.Current.ApplicationTheme = settings.DarkMode switch
{
Constant.Light => ApplicationTheme.Light,
Constant.Dark => ApplicationTheme.Dark,
Constant.System => null,
_ => ThemeManager.Current.ApplicationTheme
};
private void ColorSchemeSelectedIndexChanged(object sender, EventArgs e)
=> ThemeManager.Current.ApplicationTheme = settings.ColorScheme switch
{
Constant.Light => ApplicationTheme.Light,
Constant.Dark => ApplicationTheme.Dark,
Constant.System => null,
_ => ThemeManager.Current.ApplicationTheme
};
/* Custom TitleBar */

View file

@ -315,22 +315,23 @@ namespace Flow.Launcher.ViewModel
}
}
public class DarkMode
public class ColorScheme
{
public string Display { get; set; }
public Infrastructure.UserSettings.DarkMode Value { get; set; }
public ColorSchemes Value { get; set; }
}
public List<DarkMode> DarkModes
public List<ColorScheme> ColorSchemes
{
get
{
List<DarkMode> modes = new List<DarkMode>();
var enums = (Infrastructure.UserSettings.DarkMode[])Enum.GetValues(typeof(Infrastructure.UserSettings.DarkMode));
List<ColorScheme> modes = new List<ColorScheme>();
var enums = (ColorSchemes[])Enum.GetValues(typeof(ColorSchemes));
foreach (var e in enums)
{
var key = $"DarkMode{e}";
var key = $"ColorScheme{e}";
var display = _translater.GetTranslation(key);
var m = new DarkMode { Display = display, Value = e, };
var m = new ColorScheme { Display = display, Value = e, };
modes.Add(m);
}
return modes;

View file

@ -1,25 +0,0 @@
using System.Diagnostics;
using System.Drawing;
namespace Flow.Launcher.Plugin.ControlPanel
{
//from:https://raw.githubusercontent.com/CoenraadS/Windows-Control-Panel-Items
public class ControlPanelItem
{
public string LocalizedString { get; private set; }
public string InfoTip { get; private set; }
public string GUID { get; private set; }
public ProcessStartInfo ExecutablePath { get; private set; }
public Icon Icon { get; private set; }
public int Score { get; set; }
public ControlPanelItem(string newLocalizedString, string newInfoTip, string newGUID, ProcessStartInfo newExecutablePath, Icon newIcon)
{
LocalizedString = newLocalizedString;
InfoTip = newInfoTip;
ExecutablePath = newExecutablePath;
Icon = newIcon;
GUID = newGUID;
}
}
}

View file

@ -1,339 +0,0 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Text;
using Microsoft.Win32;
namespace Flow.Launcher.Plugin.ControlPanel
{
//from:https://raw.githubusercontent.com/CoenraadS/Windows-Control-Panel-Items
public static class ControlPanelList
{
private const uint GROUP_ICON = 14;
private const uint LOAD_LIBRARY_AS_DATAFILE = 0x00000002;
private const string CONTROL = @"%SystemRoot%\System32\control.exe";
private delegate bool EnumResNameDelegate(
IntPtr hModule,
IntPtr lpszType,
IntPtr lpszName,
IntPtr lParam);
[DllImport("kernel32.dll", EntryPoint = "EnumResourceNamesW", CharSet = CharSet.Unicode, SetLastError = true)]
static extern bool EnumResourceNamesWithID(IntPtr hModule, uint lpszType, EnumResNameDelegate lpEnumFunc, IntPtr lParam);
[DllImport("kernel32.dll", SetLastError = true)]
static extern IntPtr LoadLibraryEx(string lpFileName, IntPtr hFile, uint dwFlags);
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool FreeLibrary(IntPtr hModule);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern int LoadString(IntPtr hInstance, uint uID, StringBuilder lpBuffer, int nBufferMax);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
static extern IntPtr LoadImage(IntPtr hinst, IntPtr lpszName, uint uType,
int cxDesired, int cyDesired, uint fuLoad);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern bool DestroyIcon(IntPtr handle);
[DllImport("kernel32.dll")]
static extern IntPtr FindResource(IntPtr hModule, IntPtr lpName, IntPtr lpType);
static IntPtr defaultIconPtr;
static RegistryKey nameSpace = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ControlPanel\\NameSpace");
static RegistryKey clsid = Registry.ClassesRoot.OpenSubKey("CLSID");
public static List<ControlPanelItem> Create(uint iconSize)
{
int size = (int)iconSize;
RegistryKey currentKey;
ProcessStartInfo executablePath;
List<ControlPanelItem> controlPanelItems = new List<ControlPanelItem>();
string localizedString;
string infoTip;
Icon myIcon;
foreach (string key in nameSpace.GetSubKeyNames())
{
currentKey = clsid.OpenSubKey(key);
if (currentKey != null)
{
executablePath = getExecutablePath(currentKey);
if (!(executablePath == null)) //Cannot have item without executable path
{
localizedString = getLocalizedString(currentKey);
if (!string.IsNullOrEmpty(localizedString))//Cannot have item without Title
{
infoTip = getInfoTip(currentKey);
myIcon = getIcon(currentKey, size);
controlPanelItems.Add(new ControlPanelItem(localizedString, infoTip, key, executablePath, myIcon));
}
}
}
}
return controlPanelItems;
}
private static ProcessStartInfo getExecutablePath(RegistryKey currentKey)
{
ProcessStartInfo executablePath = new ProcessStartInfo();
string applicationName;
if (currentKey.GetValue("System.ApplicationName") != null)
{
//CPL Files (usually native MS items)
applicationName = currentKey.GetValue("System.ApplicationName").ToString();
executablePath.FileName = Environment.ExpandEnvironmentVariables(CONTROL);
executablePath.Arguments = "-name " + applicationName;
}
else if (currentKey.OpenSubKey("Shell\\Open\\Command") != null && currentKey.OpenSubKey("Shell\\Open\\Command").GetValue(null) != null)
{
//Other files (usually third party items)
string input = "\"" + Environment.ExpandEnvironmentVariables(currentKey.OpenSubKey("Shell\\Open\\Command").GetValue(null).ToString()) + "\"";
executablePath.FileName = "cmd.exe";
executablePath.Arguments = "/C " + input;
executablePath.WindowStyle = ProcessWindowStyle.Hidden;
}
else
{
return null;
}
return executablePath;
}
private static string getLocalizedString(RegistryKey currentKey)
{
IntPtr dataFilePointer;
string[] localizedStringRaw;
uint stringTableIndex;
StringBuilder resource;
string localizedString;
if (currentKey.GetValue("LocalizedString") != null)
{
localizedStringRaw = currentKey.GetValue("LocalizedString").ToString().Split(new[] { ",-" }, StringSplitOptions.None);
if (localizedStringRaw.Length > 1)
{
if (localizedStringRaw[0][0] == '@')
{
localizedStringRaw[0] = localizedStringRaw[0].Substring(1);
}
localizedStringRaw[0] = Environment.ExpandEnvironmentVariables(localizedStringRaw[0]);
dataFilePointer = LoadLibraryEx(localizedStringRaw[0], IntPtr.Zero, LOAD_LIBRARY_AS_DATAFILE); //Load file with strings
stringTableIndex = sanitizeUint(localizedStringRaw[1]);
resource = new StringBuilder(255);
LoadString(dataFilePointer, stringTableIndex, resource, resource.Capacity + 1); //Extract needed string
FreeLibrary(dataFilePointer);
localizedString = resource.ToString();
//Some apps don't return a string, although they do have a stringIndex. Use Default value.
if (String.IsNullOrEmpty(localizedString))
{
if (currentKey.GetValue(null) != null)
{
localizedString = currentKey.GetValue(null).ToString();
}
else
{
return null; //Cannot have item without title.
}
}
}
else
{
localizedString = localizedStringRaw[0];
}
}
else if (currentKey.GetValue(null) != null)
{
localizedString = currentKey.GetValue(null).ToString();
}
else
{
return null; //Cannot have item without title.
}
return localizedString;
}
private static string getInfoTip(RegistryKey currentKey)
{
IntPtr dataFilePointer;
string[] infoTipRaw;
uint stringTableIndex;
StringBuilder resource;
string infoTip = "";
if (currentKey.GetValue("InfoTip") != null)
{
infoTipRaw = currentKey.GetValue("InfoTip").ToString().Split(new[] { ",-" }, StringSplitOptions.None);
if (infoTipRaw.Length == 2)
{
if (infoTipRaw[0][0] == '@')
{
infoTipRaw[0] = infoTipRaw[0].Substring(1);
}
infoTipRaw[0] = Environment.ExpandEnvironmentVariables(infoTipRaw[0]);
dataFilePointer = LoadLibraryEx(infoTipRaw[0], IntPtr.Zero, LOAD_LIBRARY_AS_DATAFILE); //Load file with strings
stringTableIndex = sanitizeUint(infoTipRaw[1]);
resource = new StringBuilder(255);
LoadString(dataFilePointer, stringTableIndex, resource, resource.Capacity + 1); //Extract needed string
FreeLibrary(dataFilePointer);
infoTip = resource.ToString();
}
else
{
infoTip = currentKey.GetValue("InfoTip").ToString();
}
}
else
{
infoTip = "";
}
return infoTip;
}
private static Icon getIcon(RegistryKey currentKey, int iconSize)
{
IntPtr iconPtr = IntPtr.Zero;
List<string> iconString;
IntPtr dataFilePointer;
IntPtr iconIndex;
Icon myIcon = null;
if (currentKey.OpenSubKey("DefaultIcon") != null)
{
if (currentKey.OpenSubKey("DefaultIcon").GetValue(null) != null)
{
iconString = new List<string>(currentKey.OpenSubKey("DefaultIcon").GetValue(null).ToString().Split(new[] { ',' }, 2));
if (string.IsNullOrEmpty(iconString[0]))
{
// fallback to default icon
return null;
}
if (iconString[0][0] == '@')
{
iconString[0] = iconString[0].Substring(1);
}
dataFilePointer = LoadLibraryEx(iconString[0], IntPtr.Zero, LOAD_LIBRARY_AS_DATAFILE);
if (iconString.Count == 2)
{
iconIndex = (IntPtr)sanitizeUint(iconString[1]);
iconPtr = LoadImage(dataFilePointer, iconIndex, 1, iconSize, iconSize, 0);
}
if (iconPtr == IntPtr.Zero)
{
defaultIconPtr = IntPtr.Zero;
EnumResourceNamesWithID(dataFilePointer, GROUP_ICON, EnumRes, IntPtr.Zero); //Iterate through resources.
iconPtr = LoadImage(dataFilePointer, defaultIconPtr, 1, iconSize, iconSize, 0);
}
FreeLibrary(dataFilePointer);
if (iconPtr != IntPtr.Zero)
{
try
{
myIcon = Icon.FromHandle(iconPtr);
myIcon = (Icon)myIcon.Clone(); //Remove pointer dependancy.
}
catch
{
//Silently fail for now.
}
}
}
}
if (iconPtr != IntPtr.Zero)
{
DestroyIcon(iconPtr);
}
return myIcon;
}
private static uint sanitizeUint(string args) //Remove all chars before and after first set of digits.
{
int x = 0;
while (x < args.Length && !Char.IsDigit(args[x]))
{
args = args.Substring(1);
}
x = 0;
while (x < args.Length && Char.IsDigit(args[x]))
{
x++;
}
if (x < args.Length)
{
args = args.Remove(x);
}
/*If the logic is correct, this should never through an exception.
* If there is an exception, then need to analyze what the input is.
* Returning the wrong number will cause more errors */
return Convert.ToUInt32(args);
}
private static bool IS_INTRESOURCE(IntPtr value)
{
if (((uint)value) > ushort.MaxValue)
return false;
return true;
}
private static uint GET_RESOURCE_ID(IntPtr value)
{
if (IS_INTRESOURCE(value))
return (uint)value;
throw new NotSupportedException("value is not an ID!");
}
private static string GET_RESOURCE_NAME(IntPtr value)
{
if (IS_INTRESOURCE(value))
return value.ToString();
return Marshal.PtrToStringUni(value);
}
private static bool EnumRes(IntPtr hModule, IntPtr lpszType, IntPtr lpszName, IntPtr lParam)
{
defaultIconPtr = lpszName;
return false;
}
}
}

View file

@ -1,58 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<ProjectGuid>{1EE20B48-82FB-48A2-8086-675D6DDAB4F0}</ProjectGuid>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Flow.Launcher.Plugin.ControlPanel</RootNamespace>
<AssemblyName>Flow.Launcher.Plugin.ControlPanel</AssemblyName>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\Output\Debug\Plugins\Flow.Launcher.Plugin.ControlPanel\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Output\Release\Plugins\Flow.Launcher.Plugin.ControlPanel\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<None Include="plugin.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Flow.Launcher.Infrastructure\Flow.Launcher.Infrastructure.csproj" />
<ProjectReference Include="..\..\Flow.Launcher.Plugin\Flow.Launcher.Plugin.csproj" />
</ItemGroup>
<ItemGroup>
<Content Include="Images\*.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Languages\*.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -1,8 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="flowlauncher_plugin_controlpanel_plugin_name">Systemsteuerung</system:String>
<system:String x:Key="flowlauncher_plugin_controlpanel_plugin_description">Suche in der Systemsteuerung</system:String>
</ResourceDictionary>

View file

@ -1,8 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="flowlauncher_plugin_controlpanel_plugin_name">Control Panel</system:String>
<system:String x:Key="flowlauncher_plugin_controlpanel_plugin_description">Search within the Control Panel</system:String>
</ResourceDictionary>

View file

@ -1,8 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="flowlauncher_plugin_controlpanel_plugin_name">Panel sterowania</system:String>
<system:String x:Key="flowlauncher_plugin_controlpanel_plugin_description">Szybie wyszukiwanie ustawień w panelu sterowania</system:String>
</ResourceDictionary>

View file

@ -1,8 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="flowlauncher_plugin_controlpanel_plugin_name">Ovládací panel</system:String>
<system:String x:Key="flowlauncher_plugin_controlpanel_plugin_description">Vyhľadáva položky Ovládacieho panela</system:String>
</ResourceDictionary>

View file

@ -1,8 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="flowlauncher_plugin_controlpanel_plugin_name">Denetim Masası</system:String>
<system:String x:Key="flowlauncher_plugin_controlpanel_plugin_description">Denetim Masası'nda arama yapın.</system:String>
</ResourceDictionary>

View file

@ -1,8 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="flowlauncher_plugin_controlpanel_plugin_name">控制面板</system:String>
<system:String x:Key="flowlauncher_plugin_controlpanel_plugin_description">搜索控制面板</system:String>
</ResourceDictionary>

View file

@ -1,8 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="flowlauncher_plugin_controlpanel_plugin_name">控制台</system:String>
<system:String x:Key="flowlauncher_plugin_controlpanel_plugin_description">搜尋控制台</system:String>
</ResourceDictionary>

View file

@ -1,99 +0,0 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Flow.Launcher.Infrastructure;
namespace Flow.Launcher.Plugin.ControlPanel
{
public class Main : IPlugin, IPluginI18n
{
private PluginInitContext context;
private List<ControlPanelItem> controlPanelItems = new List<ControlPanelItem>();
private string iconFolder;
private string fileType;
public void Init(PluginInitContext context)
{
this.context = context;
controlPanelItems = ControlPanelList.Create(48);
iconFolder = Path.Combine(context.CurrentPluginMetadata.PluginDirectory, @"Images\ControlPanelIcons\");
fileType = ".bmp";
if (!Directory.Exists(iconFolder))
{
Directory.CreateDirectory(iconFolder);
}
foreach (ControlPanelItem item in controlPanelItems)
{
if (!File.Exists(iconFolder + item.GUID + fileType) && item.Icon != null)
{
item.Icon.ToBitmap().Save(iconFolder + item.GUID + fileType);
}
}
}
public List<Result> Query(Query query)
{
List<Result> results = new List<Result>();
foreach (var item in controlPanelItems)
{
var titleMatch = StringMatcher.FuzzySearch(query.Search, item.LocalizedString);
var subTitleMatch = StringMatcher.FuzzySearch(query.Search, item.InfoTip);
item.Score = Math.Max(titleMatch.Score, subTitleMatch.Score);
if (item.Score > 0)
{
var result = new Result
{
Title = item.LocalizedString,
SubTitle = item.InfoTip,
Score = item.Score,
IcoPath = Path.Combine(context.CurrentPluginMetadata.PluginDirectory,
@"Images\\ControlPanelIcons\\" + item.GUID + fileType),
Action = e =>
{
try
{
Process.Start(item.ExecutablePath);
}
catch (Exception)
{
//Silently Fail for now.. todo
}
return true;
}
};
if (item.Score == titleMatch.Score)
{
result.TitleHighlightData = titleMatch.MatchData;
}
else
{
result.SubTitleHighlightData = subTitleMatch.MatchData;
}
results.Add(result);
}
}
List<Result> panelItems = results.OrderByDescending(o => o.Score).Take(5).ToList();
return panelItems;
}
public string GetTranslatedPluginTitle()
{
return context.API.GetTranslation("flowlauncher_plugin_controlpanel_plugin_name");
}
public string GetTranslatedPluginDescription()
{
return context.API.GetTranslation("flowlauncher_plugin_controlpanel_plugin_description");
}
}
}

View file

@ -1,12 +0,0 @@
{
"ID": "209621585B9B4D81813913C507C058C6",
"ActionKeyword": "*",
"Name": "Control Panel",
"Description": "Search within the Control Panel.",
"Author": "CoenraadS",
"Version": "1.1.2",
"Language": "csharp",
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
"ExecuteFileName": "Flow.Launcher.Plugin.ControlPanel.dll",
"IcoPath": "Images\\ControlPanel.png"
}

View file

@ -1,22 +1,132 @@
<Window x:Class="Flow.Launcher.Plugin.Program.AddProgramSource"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
Width="400"
Height="130"
WindowStartupLocation="CenterScreen">
<Window
x:Class="Flow.Launcher.Plugin.Program.AddProgramSource"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="{DynamicResource flowlauncher_plugin_program_directory}"
Width="400"
Background="{DynamicResource PopuBGColor}"
Foreground="{DynamicResource PopupTextColor}"
SizeToContent="Height"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<WindowChrome.WindowChrome>
<WindowChrome CaptionHeight="32" ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}" />
</WindowChrome.WindowChrome>
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="80" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0">
<StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Button
Grid.Column="4"
Click="BtnCancel_OnClick"
Style="{StaticResource TitleBarCloseButtonStyle}">
<Path
Width="46"
Height="32"
Data="M 18,11 27,20 M 18,20 27,11"
Stroke="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
StrokeThickness="1">
<Path.Style>
<Style TargetType="Path">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsActive, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" Value="False">
<Setter Property="Opacity" Value="0.5" />
</DataTrigger>
</Style.Triggers>
</Style>
</Path.Style>
</Path>
</Button>
</Grid>
</StackPanel>
<StackPanel Margin="26,12,26,0">
<StackPanel Margin="0,0,0,12">
<TextBlock
Grid.Column="0"
Margin="0,0,0,0"
FontFamily="Segoe UI"
FontSize="20"
FontWeight="SemiBold"
Text="{DynamicResource flowlauncher_plugin_program_directory}"
TextAlignment="Left" />
</StackPanel>
<StackPanel Margin="0,0,0,10" Orientation="Horizontal">
<TextBox
Name="Directory"
Width="268"
Margin="0,7"
VerticalAlignment="Center" />
<Button
Width="70"
Margin="10"
HorizontalAlignment="Right"
Click="BrowseButton_Click"
Content="{DynamicResource flowlauncher_plugin_program_browse}" />
</StackPanel>
</StackPanel>
</StackPanel>
<Border
Grid.Row="1"
Background="{DynamicResource PopupButtonAreaBGColor}"
BorderBrush="{DynamicResource PopupButtonAreaBorderColor}"
BorderThickness="0,1,0,0">
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
<Button
x:Name="btnCancel"
Width="100"
Margin="0,0,5,0"
Click="BtnCancel_OnClick"
Content="{DynamicResource cancel}" />
<Button
Width="100"
Margin="5,0,0,0"
HorizontalAlignment="Right"
Click="ButtonAdd_OnClick"
Content="{DynamicResource flowlauncher_plugin_program_update}" />
</StackPanel>
</Border>
</Grid>
<!--
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<Label Content="{DynamicResource flowlauncher_plugin_program_directory}" Margin="15,10"/>
<TextBox Name="Directory" VerticalAlignment="Center" Width="278" Margin="10,7" />
<Label Margin="15,10" Content="{DynamicResource flowlauncher_plugin_program_directory}" />
<TextBox
Name="Directory"
Width="278"
Margin="10,7"
VerticalAlignment="Center" />
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button Click="BrowseButton_Click" Content="{DynamicResource flowlauncher_plugin_program_browse}"
HorizontalAlignment="Right" Margin="10" Height="31" Width="70" />
<Button Click="ButtonAdd_OnClick" Content="{DynamicResource flowlauncher_plugin_program_update}"
HorizontalAlignment="Right" Margin="10" Height="31" Width="70" />
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<Button
Width="70"
Height="31"
Margin="10"
HorizontalAlignment="Right"
Click="BrowseButton_Click"
Content="{DynamicResource flowlauncher_plugin_program_browse}" />
<Button
Width="70"
Height="31"
Margin="10"
HorizontalAlignment="Right"
Click="ButtonAdd_OnClick"
Content="{DynamicResource flowlauncher_plugin_program_update}" />
</StackPanel>
</StackPanel>
-->
</Window>

View file

@ -42,6 +42,11 @@ namespace Flow.Launcher.Plugin.Program
}
}
private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
{
Close();
}
private void ButtonAdd_OnClick(object sender, RoutedEventArgs e)
{
string s = Directory.Text;

View file

@ -1,8 +1,9 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<!--Program setting-->
<!-- Program setting -->
<system:String x:Key="flowlauncher_plugin_program_delete">Delete</system:String>
<system:String x:Key="flowlauncher_plugin_program_edit">Edit</system:String>
<system:String x:Key="flowlauncher_plugin_program_add">Add</system:String>
@ -16,12 +17,14 @@
<system:String x:Key="flowlauncher_plugin_program_index_start_tooltip">When enabled, Flow will load programs from the start menu</system:String>
<system:String x:Key="flowlauncher_plugin_program_index_registry">Index Registry</system:String>
<system:String x:Key="flowlauncher_plugin_program_index_registry_tooltip">When enabled, Flow will load programs from the registry</system:String>
<system:String x:Key="flowlauncher_plugin_program_enable_description">Enable Program Description</system:String>
<system:String x:Key="flowlauncher_plugin_program_enable_hidelnkpath">Hide app path</system:String>
<system:String x:Key="flowlauncher_plugin_program_enable_hidelnkpath_tooltip">For executable files such as UWP or lnk, hide the file path from being visible</system:String>
<system:String x:Key="flowlauncher_plugin_program_enable_description">Search in Program Description</system:String>
<system:String x:Key="flowlauncher_plugin_program_enable_description_tooltip">Disabling this will also stop Flow from searching via the program desciption</system:String>
<system:String x:Key="flowlauncher_plugin_program_suffixes_header">Suffixes</system:String>
<system:String x:Key="flowlauncher_plugin_program_max_depth_header">Max Depth</system:String>
<system:String x:Key="flowlauncher_plugin_program_directory">Directory:</system:String>
<system:String x:Key="flowlauncher_plugin_program_directory">Directory</system:String>
<system:String x:Key="flowlauncher_plugin_program_browse">Browse</system:String>
<system:String x:Key="flowlauncher_plugin_program_file_suffixes">File Suffixes:</system:String>
<system:String x:Key="flowlauncher_plugin_program_max_search_depth">Maximum Search Depth (-1 is unlimited):</system:String>
@ -30,8 +33,7 @@
<system:String x:Key="flowlauncher_plugin_program_delete_program_source">Are you sure you want to delete the selected program sources?</system:String>
<system:String x:Key="flowlauncher_plugin_program_update">OK</system:String>
<system:String x:Key="flowlauncher_plugin_program_only_index_tip">Flow Launcher will only index files that end with the following suffixes:</system:String>
<system:String x:Key="flowlauncher_plugin_program_split_by_tip">(Each suffix should split by ';' )</system:String>
<system:String x:Key="flowlauncher_plugin_program_only_index_tip">Flow Launcher will only index files that end with the following suffixes. (Each suffix should split by ';' )</system:String>
<system:String x:Key="flowlauncher_plugin_program_update_file_suffixes">Successfully updated file suffixes</system:String>
<system:String x:Key="flowlauncher_plugin_program_suffixes_cannot_empty">File suffixes can't be empty</system:String>
@ -50,7 +52,7 @@
<system:String x:Key="flowlauncher_plugin_program_tooltip_customizedexplorer">You can customized the explorer used for opening the container folder by inputing the Environmental Variable of the explorer you want to use. It will be useful to use CMD to test whether the Environmental Variable is avaliable.</system:String>
<system:String x:Key="flowlauncher_plugin_program_tooltip_args">Enter the customized args you want to add for your customized explorer. %s for parent directory, %f for full path (which only works for win32). Check the explorer's website for details.</system:String>
<!--Dialogs-->
<!-- Dialogs -->
<system:String x:Key="flowlauncher_plugin_program_disable_dlgtitle_success">Success</system:String>
<system:String x:Key="flowlauncher_plugin_program_disable_dlgtitle_success_message">Successfully disabled this program from displaying in your query</system:String>
<system:String x:Key="flowlauncher_plugin_program_run_as_administrator_not_supported_message">This app is not intended to be run as administrator</system:String>

View file

@ -147,10 +147,15 @@ namespace Flow.Launcher.Plugin.Program
var t1 = Task.Run(IndexWin32Programs);
var t2 = Task.Run(IndexUwpPrograms);
await Task.WhenAll(t1, t2).ConfigureAwait(false);
ResetCache();
_settings.LastIndexTime = DateTime.Today;
}
internal static void ResetCache()
{
var oldCache = cache;
cache = new MemoryCache(cacheOptions);
oldCache.Dispose();
_settings.LastIndexTime = DateTime.Today;
}
public Control CreateSettingPanel()

View file

@ -1,19 +1,101 @@
<Window x:Class="Flow.Launcher.Plugin.Program.ProgramSuffixes"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
Width="400"
Height="180"
WindowStartupLocation="CenterScreen"
d:DesignHeight="400" d:DesignWidth="300">
<StackPanel>
<TextBlock Margin="10 10 0 0" Foreground="Gray" Text="{DynamicResource flowlauncher_plugin_program_only_index_tip}" />
<TextBlock Margin="10 10 0 0" Foreground="Gray" Text="{DynamicResource flowlauncher_plugin_program_split_by_tip}" />
<TextBox x:Name="tbSuffixes" Margin="10"/>
<Button HorizontalAlignment="Right" Height="30" Width="80" Click="ButtonBase_OnClick" Margin="0 0 10 0" Content="{DynamicResource flowlauncher_plugin_program_update}" />
</StackPanel>
<Window
x:Class="Flow.Launcher.Plugin.Program.ProgramSuffixes"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="{DynamicResource flowlauncher_plugin_program_suffixes}"
Width="400"
Background="{DynamicResource PopuBGColor}"
Foreground="{DynamicResource PopupTextColor}"
ResizeMode="NoResize"
SizeToContent="Height"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<WindowChrome.WindowChrome>
<WindowChrome CaptionHeight="32" ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}" />
</WindowChrome.WindowChrome>
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="80" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0">
<StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Button
Grid.Column="4"
Click="BtnCancel_OnClick"
Style="{StaticResource TitleBarCloseButtonStyle}">
<Path
Width="46"
Height="32"
Data="M 18,11 27,20 M 18,20 27,11"
Stroke="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
StrokeThickness="1">
<Path.Style>
<Style TargetType="Path">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsActive, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" Value="False">
<Setter Property="Opacity" Value="0.5" />
</DataTrigger>
</Style.Triggers>
</Style>
</Path.Style>
</Path>
</Button>
</Grid>
</StackPanel>
<StackPanel Margin="26,12,26,0">
<StackPanel Margin="0,0,0,12">
<TextBlock
Grid.Column="0"
Margin="0,0,0,0"
FontFamily="Segoe UI"
FontSize="20"
FontWeight="SemiBold"
Text="{DynamicResource flowlauncher_plugin_program_suffixes}"
TextAlignment="Left" />
</StackPanel>
<TextBlock
FontSize="14"
Text="{DynamicResource flowlauncher_plugin_program_only_index_tip}"
TextWrapping="Wrap" />
<TextBox x:Name="tbSuffixes" Margin="0,20,0,20" />
</StackPanel>
</StackPanel>
<Border
Grid.Row="1"
Background="{DynamicResource PopupButtonAreaBGColor}"
BorderBrush="{DynamicResource PopupButtonAreaBorderColor}"
BorderThickness="0,1,0,0">
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
<Button
x:Name="btnCancel"
Width="100"
Height="30"
Margin="0,0,5,0"
Click="BtnCancel_OnClick"
Content="{DynamicResource cancel}" />
<Button
Width="100"
Height="30"
Margin="5,0,0,0"
HorizontalAlignment="Right"
Click="ButtonBase_OnClick"
Content="{DynamicResource flowlauncher_plugin_program_update}" />
</StackPanel>
</Border>
</Grid>
</Window>

View file

@ -18,7 +18,10 @@ namespace Flow.Launcher.Plugin.Program
_settings = settings;
tbSuffixes.Text = string.Join(Settings.SuffixSeperator.ToString(), _settings.ProgramSuffixes);
}
private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
{
Close();
}
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
var suffixes = tbSuffixes.Text.Split(Settings.SuffixSeperator, StringSplitOptions.RemoveEmptyEntries);

View file

@ -314,7 +314,7 @@ namespace Flow.Launcher.Plugin.Program.Programs
var result = new Result
{
Title = title,
SubTitle = Package.Location,
SubTitle = Main._settings.HideAppsPath ? string.Empty : Package.Location,
Icon = Logo,
Score = matchResult.Score,
TitleHighlightData = matchResult.MatchData,

View file

@ -97,7 +97,7 @@ namespace Flow.Launcher.Plugin.Program.Programs
var result = new Result
{
Title = title,
SubTitle = LnkResolvedPath ?? FullPath,
SubTitle = Main._settings.HideAppsPath ? string.Empty : LnkResolvedPath ?? FullPath,
IcoPath = IcoPath,
Score = matchResult.Score,
TitleHighlightData = matchResult.MatchData,

View file

@ -13,7 +13,8 @@ namespace Flow.Launcher.Plugin.Program
public bool EnableStartMenuSource { get; set; } = true;
public bool EnableDescription { get; set; } = true;
public bool EnableDescription { get; set; } = false;
public bool HideAppsPath { get; set; } = true;
public bool EnableRegistrySource { get; set; } = true;
public string CustomizedExplorer { get; set; } = Explorer;
public string CustomizedArgs { get; set; } = ExplorerArgs;

View file

@ -5,75 +5,110 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:program="clr-namespace:Flow.Launcher.Plugin.Program"
Height="450"
d:DesignHeight="404.508"
d:DesignWidth="600"
Height="520"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
mc:Ignorable="d">
<Grid Margin="20">
<Grid Margin="0">
<Grid.RowDefinitions>
<RowDefinition Height="120" />
<RowDefinition Height="170" />
<RowDefinition Height="*" />
<RowDefinition Height="50" />
<RowDefinition Height="60" />
</Grid.RowDefinitions>
<StackPanel
Grid.Row="0"
HorizontalAlignment="Stretch"
Orientation="Horizontal">
Orientation="Vertical">
<StackPanel Width="Auto" Orientation="Vertical">
<CheckBox
Name="StartMenuEnabled"
Margin="5"
Content="{DynamicResource flowlauncher_plugin_program_index_start}"
IsChecked="{Binding EnableStartMenuSource}"
ToolTip="{DynamicResource flowlauncher_plugin_program_index_start_tooltip}" />
<CheckBox
Name="RegistryEnabled"
Margin="5"
Content="{DynamicResource flowlauncher_plugin_program_index_registry}"
IsChecked="{Binding EnableRegistrySource}"
ToolTip="{DynamicResource flowlauncher_plugin_program_index_registry_tooltip}" />
<CheckBox
Name="DescriptionEnabled"
Margin="5"
Content="{DynamicResource flowlauncher_plugin_program_enable_description}"
IsChecked="{Binding EnableDescription}"
ToolTip="{DynamicResource flowlauncher_plugin_program_enable_description_tooltip}" />
<StackPanel Width="Auto" Orientation="Horizontal">
<CheckBox
Name="StartMenuEnabled"
Width="200"
Margin="70,8,10,8"
Content="{DynamicResource flowlauncher_plugin_program_index_start}"
IsChecked="{Binding EnableStartMenuSource}"
ToolTip="{DynamicResource flowlauncher_plugin_program_index_start_tooltip}" />
<CheckBox
Name="RegistryEnabled"
Margin="70,8,10,8"
Content="{DynamicResource flowlauncher_plugin_program_index_registry}"
IsChecked="{Binding EnableRegistrySource}"
ToolTip="{DynamicResource flowlauncher_plugin_program_index_registry_tooltip}" />
</StackPanel>
<Separator
Height="1"
BorderBrush="{DynamicResource Color03B}"
BorderThickness="1" />
<StackPanel Width="Auto" Orientation="Horizontal">
<CheckBox
Name="HideLnkEnabled"
Width="200"
Margin="70,8,10,8"
Content="{DynamicResource flowlauncher_plugin_program_enable_hidelnkpath}"
IsChecked="{Binding HideAppsPath}"
ToolTip="{DynamicResource flowlauncher_plugin_program_enable_hidelnkpath_tooltip}" />
<CheckBox
Name="DescriptionEnabled"
Margin="70,8,10,8"
Content="{DynamicResource flowlauncher_plugin_program_enable_description}"
IsChecked="{Binding EnableDescription}"
ToolTip="{DynamicResource flowlauncher_plugin_program_enable_description_tooltip}" />
</StackPanel>
<Separator
Height="1"
BorderBrush="{DynamicResource Color03B}"
BorderThickness="1" />
</StackPanel>
<StackPanel
Width="Auto"
HorizontalAlignment="Right"
Margin="10,6,0,0"
HorizontalAlignment="Left"
Orientation="Horizontal">
<Button
x:Name="btnLoadAllProgramSource"
Width="100"
Height="31"
Margin="10"
Width="120"
Margin="10,10,5,10"
HorizontalAlignment="Right"
Click="btnLoadAllProgramSource_OnClick"
Content="{DynamicResource flowlauncher_plugin_program_all_programs}" />
<Button
x:Name="btnProgramSuffixes"
Width="100"
Height="31"
Margin="10"
Width="120"
Margin="5,10,5,10"
HorizontalAlignment="Right"
Click="BtnProgramSuffixes_OnClick"
Content="{DynamicResource flowlauncher_plugin_program_suffixes}" />
<Button
x:Name="btnReindex"
Width="100"
Height="31"
Margin="10"
Width="120"
Margin="5,10,5,10"
HorizontalAlignment="Right"
Click="btnReindex_Click"
Content="{DynamicResource flowlauncher_plugin_program_reindex}" />
<StackPanel
x:Name="indexingPanel"
HorizontalAlignment="Left"
Orientation="Horizontal"
Visibility="Hidden">
<ProgressBar
x:Name="progressBarIndexing"
Width="80"
Height="20"
IsIndeterminate="True"
Maximum="100"
Minimum="0" />
<TextBlock
Height="20"
Margin="10,0,0,0"
HorizontalAlignment="Center"
Text="{DynamicResource flowlauncher_plugin_program_indexing}" />
</StackPanel>
</StackPanel>
</StackPanel>
<ListView
x:Name="programSourceView"
Grid.Row="1"
Margin="0,13,0,10"
Margin="20,0,20,0"
AllowDrop="True"
BorderBrush="DarkGray"
BorderThickness="1"
@ -81,14 +116,7 @@
Drop="programSourceView_Drop"
GridViewColumnHeader.Click="GridViewColumnHeaderClickedHandler"
PreviewMouseRightButtonUp="ProgramSourceView_PreviewMouseRightButtonUp"
SelectionMode="Extended"
Style="{StaticResource {x:Static GridView.GridViewStyleKey}}">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<EventSetter Event="PreviewMouseUp" Handler="Row_OnClick" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
</Style>
</ListView.ItemContainerStyle>
SelectionMode="Extended">
<ListView.View>
<GridView>
<GridViewColumn Width="150" Header="Name">
@ -121,25 +149,7 @@
<DockPanel
Grid.Row="2"
Grid.RowSpan="1"
Margin="0,0,0,0">
<StackPanel
x:Name="indexingPanel"
HorizontalAlignment="Left"
Orientation="Horizontal"
Visibility="Hidden">
<ProgressBar
x:Name="progressBarIndexing"
Width="80"
Height="20"
IsIndeterminate="True"
Maximum="100"
Minimum="0" />
<TextBlock
Height="20"
Margin="10,0,0,0"
HorizontalAlignment="Center"
Text="{DynamicResource flowlauncher_plugin_program_indexing}" />
</StackPanel>
Margin="0,0,20,10">
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<Button
x:Name="btnProgramSourceStatus"

View file

@ -30,7 +30,20 @@ namespace Flow.Launcher.Plugin.Program.Views
public bool EnableDescription
{
get => _settings.EnableDescription;
set => _settings.EnableDescription = value;
set
{
Main.ResetCache();
_settings.EnableDescription = value;
}
}
public bool HideAppsPath
{
get => _settings.HideAppsPath;
set
{
Main.ResetCache();
_settings.HideAppsPath = value;
}
}
public bool EnableRegistrySource
@ -105,7 +118,6 @@ namespace Flow.Launcher.Plugin.Program.Views
private async void ReIndexing()
{
ViewRefresh();
indexingPanel.Visibility = Visibility.Visible;
await Main.IndexPrograms();
indexingPanel.Visibility = Visibility.Hidden;

View file

@ -4,7 +4,7 @@
"Name": "Program",
"Description": "Search programs in Flow.Launcher",
"Author": "qianlifeng",
"Version": "1.7.0",
"Version": "1.8.0",
"Language": "csharp",
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
"ExecuteFileName": "Flow.Launcher.Plugin.Program.dll",

View file

@ -0,0 +1,78 @@
using System.Collections.Generic;
namespace Flow.Launcher.Plugin.WindowsSettings.Classes
{
/// <summary>
/// A windows setting
/// </summary>
internal record WindowsSetting
{
/// <summary>
/// Initializes a new instance of the <see cref="WindowsSetting"/> class.
/// </summary>
public WindowsSetting()
{
Name = string.Empty;
Area = string.Empty;
Command = string.Empty;
Type = string.Empty;
}
/// <summary>
/// Gets or sets the name of this setting.
/// </summary>
public string Name { get; set; }
/// <summary>
/// Gets or sets the area of this setting.
/// </summary>
public string Area { get; set; }
/// <summary>
/// Gets or sets the command of this setting.
/// </summary>
public string Command { get; set; }
private string type = string.Empty;
/// <summary>
/// Gets or sets the type of the windows setting.
/// </summary>
public string Type { get; set; }
/// <summary>
/// Gets or sets the type display name of this setting.
/// </summary>
public string? DisplayType { get; set; }
/// <summary>
/// Gets or sets the alternative names of this setting.
/// </summary>
public IEnumerable<string>? AltNames { get; set; }
/// <summary>
/// Gets or sets the Keywords names of this task link.
/// </summary>
public IEnumerable<IEnumerable<string>>? Keywords { get; set; }
/// <summary>
/// Gets or sets the Glyph of this setting
/// </summary>
public string? glyph { get; set; }
/// <summary>
/// Gets or sets a additional note of this settings.
/// <para>(e.g. why is not supported on your system)</para>
/// </summary>
public string? Note { get; set; }
/// <summary>
/// Gets or sets the minimum need Windows build for this setting.
/// </summary>
public uint? IntroducedInBuild { get; set; }
/// <summary>
/// Gets or sets the Windows build since this settings is not longer present.
/// </summary>
public uint? DeprecatedInBuild { get; set; }
}
}

View file

@ -0,0 +1,76 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppDesignerFolder>Properties</AppDesignerFolder>
<ErrorReport>prompt</ErrorReport>
<NeutralLanguage>en-US</NeutralLanguage>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath>..\..\Output\Debug\Plugins\Flow.Launcher.Plugin.WindowsSettings</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<Optimize>false</Optimize>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<OutputPath>..\..\Output\Release\Plugins\Flow.Launcher.Plugin.WindowsSettings</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>portable</DebugType>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<None Remove="WindowsSettings.json" />
</ItemGroup>
<ItemGroup>
<None Include="plugin.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="WindowsSettings.json">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
</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>
<ItemGroup>
<Content Include="Images\*.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Flow.Launcher.Plugin\Flow.Launcher.Plugin.csproj" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Windows;
using Flow.Launcher.Plugin;
using Flow.Launcher.Plugin.WindowsSettings.Classes;
using Flow.Launcher.Plugin.WindowsSettings.Properties;
namespace Flow.Launcher.Plugin.WindowsSettings.Helper
{
/// <summary>
/// Helper class to easier work with context menu entries
/// </summary>
internal static class ContextMenuHelper
{
/// <summary>
/// Return a list with all context menu entries for the given <see cref="Result"/>
/// <para>Symbols taken from <see href="https://docs.microsoft.com/en-us/windows/uwp/design/style/segoe-ui-symbol-font"/></para>
/// </summary>
/// <param name="result">The result for the context menu entires</param>
/// <param name="assemblyName">The name of the this assembly</param>
/// <returns>A list with context menu entries</returns>
internal static List<Result> GetContextMenu(in Result result, in string assemblyName)
{
if (result?.ContextData is not WindowsSetting entry)
{
return new List<Result>(0);
}
var list = new List<Result>(1)
{
new()
{
Action = _ => TryToCopyToClipBoard(entry.Command),
Title = $"{Resources.CopyCommand} (Ctrl+C)",
},
};
return list;
}
/// <summary>
/// Copy the given text to the clipboard
/// </summary>
/// <param name="text">The text to copy to the clipboard</param>
/// <returns><see langword="true"/>The text successful copy to the clipboard, otherwise <see langword="false"/></returns>
private static bool TryToCopyToClipBoard(in string text)
{
try
{
Clipboard.Clear();
Clipboard.SetText(text);
return true;
}
catch (Exception exception)
{
Log.Exception("Can't copy to clipboard", exception, typeof(Main));
return false;
}
}
}
}

View file

@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text.Json;
using System.Text.Json.Serialization;
using Flow.Launcher.Plugin.WindowsSettings.Classes;
namespace Flow.Launcher.Plugin.WindowsSettings.Helper
{
/// <summary>
/// Helper class to easier work with the JSON file that contains all Windows settings
/// </summary>
internal static class JsonSettingsListHelper
{
/// <summary>
/// The name of the file that contains all settings for the query
/// </summary>
private const string _settingsFile = "WindowsSettings.json";
/// <summary>
/// Read all possible Windows settings.
/// </summary>
/// <returns>A list with all possible windows settings.</returns>
internal static IEnumerable<WindowsSetting> ReadAllPossibleSettings()
{
var assembly = Assembly.GetExecutingAssembly();
var type = assembly.GetTypes().FirstOrDefault(x => x.Name == nameof(Main));
IEnumerable<WindowsSetting>? settingsList = null;
try
{
var resourceName = $"{type?.Namespace}.{_settingsFile}";
using var stream = assembly.GetManifestResourceStream(resourceName);
if (stream is null)
{
throw new Exception("stream is null");
}
var options = new JsonSerializerOptions();
options.Converters.Add(new JsonStringEnumConverter());
using var reader = new StreamReader(stream);
var text = reader.ReadToEnd();
settingsList = JsonSerializer.Deserialize<IEnumerable<WindowsSetting>>(text, options);
}
catch (Exception exception)
{
Log.Exception("Error loading settings JSON file", exception, typeof(Main));
}
return settingsList ?? Enumerable.Empty<WindowsSetting>();
}
}
}

View file

@ -0,0 +1,189 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using Flow.Launcher.Plugin;
using Flow.Launcher.Plugin.WindowsSettings.Classes;
using Flow.Launcher.Plugin.WindowsSettings.Properties;
namespace Flow.Launcher.Plugin.WindowsSettings.Helper
{
/// <summary>
/// Helper class to easier work with results
/// </summary>
internal static class ResultHelper
{
private static IPublicAPI? _api;
public static void Init(IPublicAPI api) => _api = api;
/// <summary>
/// Return a list with <see cref="Result"/>s, based on the given list.
/// </summary>
/// <param name="list">The original result list to convert.</param>
/// <param name="query">Query for specific result List</param>
/// <param name="windowsSettingIconPath">The path to the icon of each entry.</param>
/// <returns>A list with <see cref="Result"/>.</returns>
internal static List<Result> GetResultList(
in IEnumerable<WindowsSetting> list,
Query query,
string windowsSettingIconPath,
string controlPanelIconPath)
{
var resultList = new List<Result>();
foreach (var entry in list)
{
const int highScore = 20;
const int midScore = 10;
Result? result;
Debug.Assert(_api != null, nameof(_api) + " != null");
var nameMatch = _api.FuzzySearch(query.Search, entry.Name);
if (nameMatch.IsSearchPrecisionScoreMet())
{
var settingResult = NewSettingResult(nameMatch.Score + highScore, entry.Type);
settingResult.TitleHighlightData = nameMatch.MatchData;
result = settingResult;
}
else
{
var areaMatch = _api.FuzzySearch(query.Search, entry.Area);
if (areaMatch.IsSearchPrecisionScoreMet())
{
var settingResult = NewSettingResult(areaMatch.Score + midScore, entry.Type);
settingResult.SubTitleHighlightData = areaMatch.MatchData.Select(x => x + 6).ToList();
result = settingResult;
}
else
{
result = entry.AltNames?
.Select(altName => _api.FuzzySearch(query.Search, altName))
.Where(match => match.IsSearchPrecisionScoreMet())
.Select(altNameMatch => NewSettingResult(altNameMatch.Score + midScore, entry.Type))
.FirstOrDefault();
}
if (result is null && entry.Keywords is not null)
{
string[] searchKeywords = query.SearchTerms;
if (searchKeywords
.All(x => entry
.Keywords
.SelectMany(x => x)
.Contains(x, StringComparer.CurrentCultureIgnoreCase))
)
result = NewSettingResult(midScore, entry.Type);
}
}
if (result is null)
continue;
AddOptionalToolTip(entry, result);
resultList.Add(result);
Result NewSettingResult(int score, string type) => new()
{
Action = _ => DoOpenSettingsAction(entry),
IcoPath = type == "AppSettingsApp" ? windowsSettingIconPath : controlPanelIconPath,
SubTitle = GetSubtitle(entry.Area, type),
Title = entry.Name + entry.glyph,
ContextData = entry,
Score = score
};
}
return resultList;
}
private static string GetSubtitle(string section, string entryType)
{
var settingType = entryType == "AppSettingsApp" ? "System settings" : "Control Panel";
return $"{settingType} > {section}";
}
/// <summary>
/// Add a tool-tip to the given <see cref="Result"/>, based o the given <see cref="IWindowsSetting"/>.
/// </summary>
/// <param name="entry">The <see cref="WindowsSetting"/> that contain informations for the tool-tip.</param>
/// <param name="result">The <see cref="Result"/> that need a tool-tip.</param>
private static void AddOptionalToolTip(WindowsSetting entry, Result result)
{
var toolTipText = new StringBuilder();
var settingType = entry.Type == "AppSettingsApp" ? "System settings" : "Control Panel";
toolTipText.AppendLine($"{Resources.Application}: {settingType}");
toolTipText.AppendLine($"{Resources.Area}: {entry.Area}");
if (entry.AltNames != null && entry.AltNames.Any())
{
var altList = entry.AltNames.Aggregate((current, next) => $"{current}, {next}");
toolTipText.AppendLine($"{Resources.AlternativeName}: {altList}");
}
toolTipText.Append($"{Resources.Command}: {entry.Command}");
if (!string.IsNullOrEmpty(entry.Note))
{
toolTipText.AppendLine(string.Empty);
toolTipText.AppendLine(string.Empty);
toolTipText.Append($"{Resources.Note}: {entry.Note}");
}
result.TitleToolTip = toolTipText.ToString();
result.SubTitleToolTip = result.TitleToolTip;
}
/// <summary>
/// Open the settings page of the given <see cref="IWindowsSetting"/>.
/// </summary>
/// <param name="entry">The <see cref="WindowsSetting"/> that contain the information to open the setting on command level.</param>
/// <returns><see langword="true"/> if the settings could be opened, otherwise <see langword="false"/>.</returns>
private static bool DoOpenSettingsAction(WindowsSetting entry)
{
ProcessStartInfo processStartInfo;
var command = entry.Command;
command = Environment.ExpandEnvironmentVariables(command);
if (command.Contains(' '))
{
var commandSplit = command.Split(' ');
var file = commandSplit.First();
var arguments = command[file.Length..].TrimStart();
processStartInfo = new ProcessStartInfo(file, arguments)
{
UseShellExecute = false,
};
}
else
{
processStartInfo = new ProcessStartInfo(command)
{
UseShellExecute = true,
};
}
try
{
Process.Start(processStartInfo);
return true;
}
catch (Exception exception)
{
Log.Exception("can't open settings", exception, typeof(ResultHelper));
return false;
}
}
}
}

View file

@ -0,0 +1,92 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Flow.Launcher.Plugin.WindowsSettings.Classes;
using Flow.Launcher.Plugin.WindowsSettings.Properties;
namespace Flow.Launcher.Plugin.WindowsSettings.Helper
{
/// <summary>
/// Helper class to easier work with translations.
/// </summary>
internal static class TranslationHelper
{
/// <summary>
/// Translate all settings of the given list with <see cref="WindowsSetting"/>.
/// </summary>
/// <param name="settingsList">The list that contains <see cref="WindowsSetting"/> to translate.</param>
internal static IEnumerable<WindowsSetting> TranslateAllSettings(in IEnumerable<WindowsSetting>? settingsList)
{
var translatedSettings = new List<WindowsSetting>();
if (settingsList is null)
return new List<WindowsSetting>();
foreach (var settings in settingsList)
{
var area = Resources.ResourceManager.GetString($"Area{settings.Area}");
var name = Resources.ResourceManager.GetString(settings.Name);
var type = Resources.ResourceManager.GetString(settings.Type);
if (string.IsNullOrEmpty(area))
{
Log.Warn($"Resource string for [Area{settings.Area}] not found", typeof(Main));
}
if (string.IsNullOrEmpty(name))
{
Log.Warn($"Resource string for [{settings.Name}] not found", typeof(Main));
}
if (string.IsNullOrEmpty(type))
{
Log.Warn($"Resource string for [{settings.Name}] not found", typeof(Main));
}
if (!string.IsNullOrEmpty(settings.Note))
{
var note = Resources.ResourceManager.GetString(settings.Note);
if (string.IsNullOrEmpty(note))
{
Log.Warn($"Resource string for [{settings.Note}] not found", typeof(Main));
}
settings.Note = note ?? settings.Note ?? string.Empty;
}
List<string>? translatedAltNames = null;
if (settings.AltNames is not null && settings.AltNames.Any())
{
translatedAltNames = new List<string>();
foreach (var altName in settings.AltNames)
{
if (string.IsNullOrWhiteSpace(altName))
{
continue;
}
var translatedAltName = Resources.ResourceManager.GetString(altName);
if (string.IsNullOrEmpty(translatedAltName))
{
Log.Warn($"Resource string for [{altName}] not found", typeof(Main));
}
translatedAltNames.Add(translatedAltName ?? altName);
}
}
var translatedSetting = settings with
{
Area = area ?? settings.Area,
Name = name ?? settings.Name,
DisplayType = type ?? settings.Type,
AltNames = translatedAltNames
};
translatedSettings.Add(translatedSetting);
}
return translatedSettings;
}
}
}

View file

@ -0,0 +1,85 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Flow.Launcher.Plugin.WindowsSettings.Classes;
namespace Flow.Launcher.Plugin.WindowsSettings.Helper
{
/// <summary>
/// Helper class to easier work with the version of the Windows OS
/// </summary>
internal static class UnsupportedSettingsHelper
{
private const string _keyPath = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion";
private const string _keyNameBuild = "CurrentBuild";
private const string _keyNameBuildNumber = "CurrentBuildNumber";
/// <summary>
/// Remove all <see cref="WindowsSetting"/> of the given list that are not present on the current used Windows build.
/// </summary>
/// <param name="settingsList">The list with <see cref="WindowsSetting"/> to filter.</param>
/// <returns>A new list with <see cref="WindowsSetting"/> that only contain present Windows settings for this OS.</returns>
internal static IEnumerable<WindowsSetting> FilterByBuild(in IEnumerable<WindowsSetting>? settingsList)
{
if (settingsList is null)
{
return Enumerable.Empty<WindowsSetting>();
}
var currentBuild = GetNumericRegistryValue(_keyPath, _keyNameBuild);
var currentBuildNumber = GetNumericRegistryValue(_keyPath, _keyNameBuildNumber);
if (currentBuild != currentBuildNumber)
{
var usedValueName = currentBuild != uint.MinValue ? _keyNameBuild : _keyNameBuildNumber;
var warningMessage =
$"Detecting the Windows version in registry ({_keyPath}) leads to an inconclusive"
+ $" result ({_keyNameBuild}={currentBuild}, {_keyNameBuildNumber}={currentBuildNumber})!"
+ $" For resolving the conflict we use the value of '{usedValueName}'.";
Log.Warn(warningMessage, typeof(UnsupportedSettingsHelper));
}
var currentWindowsBuild = currentBuild != uint.MinValue
? currentBuild
: currentBuildNumber;
var filteredSettingsList = settingsList.Where(found
=> (found.DeprecatedInBuild == null || currentWindowsBuild < found.DeprecatedInBuild)
&& (found.IntroducedInBuild == null || currentWindowsBuild >= found.IntroducedInBuild));
filteredSettingsList = filteredSettingsList.OrderBy(found => found.Name);
return filteredSettingsList;
}
/// <summary>
/// Return a unsigned numeric value from given registry value name inside the given registry key.
/// </summary>
/// <param name="registryKey">The registry key.</param>
/// <param name="valueName">The name of the registry value.</param>
/// <returns>A registry value or <see cref="uint.MinValue"/> on error.</returns>
private static uint GetNumericRegistryValue(in string registryKey, in string valueName)
{
object? registryValueData;
try
{
registryValueData = Microsoft.Win32.Registry.GetValue(registryKey, valueName, uint.MinValue);
}
catch (Exception exception)
{
Log.Exception(
$"Can't get registry value for '{valueName}'",
exception,
typeof(UnsupportedSettingsHelper));
return uint.MinValue;
}
return uint.TryParse(registryValueData as string, out var buildNumber)
? buildNumber
: uint.MinValue;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

View file

@ -0,0 +1,24 @@
using System;
using System.Runtime.CompilerServices;
using Flow.Launcher.Plugin;
namespace Flow.Launcher.Plugin.WindowsSettings
{
public static class Log
{
private static IPublicAPI? _api;
public static void Init(IPublicAPI api)
{
_api = api;
}
public static void Exception(string message, Exception exception, Type type, [CallerMemberName] string methodName = "")
{
_api?.LogException(type.FullName, message, exception, methodName);
}
public static void Warn(string message, Type type, [CallerMemberName] string methodName = "")
{
_api?.LogWarn(type.FullName, message, methodName);
}
}
}

View file

@ -0,0 +1,150 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
using Flow.Launcher.Plugin;
using Flow.Launcher.Plugin.WindowsSettings.Classes;
using Flow.Launcher.Plugin.WindowsSettings.Helper;
using Flow.Launcher.Plugin.WindowsSettings.Properties;
namespace Flow.Launcher.Plugin.WindowsSettings
{
/// <summary>
/// Main class of this plugin that implement all used interfaces.
/// </summary>
public sealed class Main : IPlugin, IContextMenu, IPluginI18n, IDisposable
{
/// <summary>
/// The name of this assembly.
/// </summary>
private readonly string _assemblyName;
/// <summary>
/// The initial context for this plugin (contains API and meta-data).
/// </summary>
private PluginInitContext? _context;
/// <summary>
/// The path to the icon for windows setting result.
/// </summary>
private const string windowSettingsIconPath = "Images/WindowsSettings.light.png";
/// <summary>
/// The path to the icon for control panel result.
/// </summary>
private const string controlPanelIconPath = "Images/ControlPanel_Small.png";
/// <summary>
/// Indicate that the plugin is disposed.
/// </summary>
private bool _disposed;
/// <summary>
/// List that contain all settings.
/// </summary>
private IEnumerable<WindowsSetting>? _settingsList;
/// <summary>
/// List that contains translated string
/// </summary>
private IEnumerable<WindowsSetting> _translatedSettingList = new List<WindowsSetting>();
/// <summary>
/// Initializes a new instance of the <see cref="Main"/> class.
/// </summary>
public Main()
{
_assemblyName = Assembly.GetExecutingAssembly().GetName().Name ?? Name;
}
/// <summary>
/// Gets the localized name.
/// </summary>
public string Name => Resources.PluginTitle;
/// <summary>
/// Gets the localized description.
/// </summary>
public string Description => Resources.PluginDescription;
/// <summary>
/// Initialize the plugin with the given <see cref="PluginInitContext"/>.
/// </summary>
/// <param name="context">The <see cref="PluginInitContext"/> for this plugin.</param>
public void Init(PluginInitContext context)
{
_context = context ?? throw new ArgumentNullException(nameof(context));
_settingsList = JsonSettingsListHelper.ReadAllPossibleSettings();
_settingsList = UnsupportedSettingsHelper.FilterByBuild(_settingsList);
Log.Init(_context.API);
ResultHelper.Init(_context.API);
_translatedSettingList = TranslationHelper.TranslateAllSettings(_settingsList);
}
/// <summary>
/// Return a filtered list, based on the given query.
/// </summary>
/// <param name="query">The query to filter the list.</param>
/// <returns>A filtered list, can be empty when nothing was found.</returns>
public List<Result> Query(Query query)
{
var newList = ResultHelper.GetResultList(_translatedSettingList, query, windowSettingsIconPath, controlPanelIconPath);
return newList;
}
public void OnCultureInfoChanged(CultureInfo newCulture)
{
_translatedSettingList = TranslationHelper.TranslateAllSettings(_settingsList);
}
/// <summary>
/// Return a list context menu entries for a given <see cref="Result"/> (shown at the right side of the result).
/// </summary>
/// <param name="selectedResult">The <see cref="Result"/> for the list with context menu entries.</param>
/// <returns>A list context menu entries.</returns>
public List<Result> LoadContextMenus(Result selectedResult)
{
return ContextMenuHelper.GetContextMenu(selectedResult, _assemblyName);
}
/// <inheritdoc/>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
/// <summary>
/// Wrapper method for <see cref="Dispose"/> that dispose additional objects and events form the plugin itself.
/// </summary>
/// <param name="disposing">Indicate that the plugin is disposed.</param>
private void Dispose(bool disposing)
{
if (_disposed || !disposing)
{
return;
}
_disposed = true;
}
/// <summary>
/// Gets the localized name.
/// </summary>
public string GetTranslatedPluginTitle()
{
return Name;
}
/// <summary>
/// Gets the localized description.
/// </summary>
public string GetTranslatedPluginDescription()
{
return Description;
}
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,2 @@
# Flow.Launcher.Plugin.WindowsSettings
Ported from PowerToys WindowsSettings plugin

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,12 @@
{
"ID": "5043CETYU6A748679OPA02D27D99677A",
"ActionKeyword": "*",
"Description": "Search settings inside Control Panel and Settings App",
"Name": "Windows Settings",
"Author": "TobiasSekan",
"Version": "2.0.0",
"Language": "csharp",
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
"ExecuteFileName": "Flow.Launcher.Plugin.WindowsSettings.dll",
"IcoPath": "Images\\WindowsSettings.light.png"
}