diff --git a/Flow.Launcher.Core/Plugin/PythonPlugin.cs b/Flow.Launcher.Core/Plugin/PythonPlugin.cs index 5711ed6aa..855e5c901 100644 --- a/Flow.Launcher.Core/Plugin/PythonPlugin.cs +++ b/Flow.Launcher.Core/Plugin/PythonPlugin.cs @@ -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; } } -} \ No newline at end of file +} diff --git a/Flow.Launcher.Core/Resource/Internationalization.cs b/Flow.Launcher.Core/Resource/Internationalization.cs index 78e8c5cbf..374f7c71f 100644 --- a/Flow.Launcher.Core/Resource/Internationalization.cs +++ b/Flow.Launcher.Core/Resource/Internationalization.cs @@ -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) diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index ef99dbab4..1c08da0d6 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -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, diff --git a/Flow.Launcher.Plugin/Interfaces/IPluginI18n.cs b/Flow.Launcher.Plugin/Interfaces/IPluginI18n.cs index e332d450e..61662b671 100644 --- a/Flow.Launcher.Plugin/Interfaces/IPluginI18n.cs +++ b/Flow.Launcher.Plugin/Interfaces/IPluginI18n.cs @@ -1,4 +1,6 @@ -namespace Flow.Launcher.Plugin +using System.Globalization; + +namespace Flow.Launcher.Plugin { /// /// Represent plugins that support internationalization @@ -8,5 +10,13 @@ string GetTranslatedPluginTitle(); string GetTranslatedPluginDescription(); + + /// + /// The method will be invoked when language of flow changed + /// + void OnCultureInfoChanged(CultureInfo newCulture) + { + + } } } \ No newline at end of file diff --git a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs index 908284bb9..0b59371f8 100644 --- a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs +++ b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs @@ -37,6 +37,12 @@ namespace Flow.Launcher.Plugin /// Thrown when unable to find the file specified in the command /// Thrown when error occurs during the execution of the command void ShellRun(string cmd, string filename = "cmd.exe"); + + /// + /// Copy Text to clipboard + /// + /// Text to save on clipboard + public void CopyToClipboard(string text); /// /// Save everything, all of Flow Launcher and plugins' data and settings diff --git a/Flow.Launcher.sln b/Flow.Launcher.sln index 21c3b47dc..b8deae553 100644 --- a/Flow.Launcher.sln +++ b/Flow.Launcher.sln @@ -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} diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index f58b35331..b00e8d2a6 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -87,10 +87,10 @@ Fail to load theme {0}, fallback to default theme Theme Folder Open Theme Folder - Dark Mode - System Default - Light - Dark + Color Scheme + System Default + Light + Dark Sound Effect Play a small sound when the search window opens Animation @@ -179,7 +179,7 @@ This new Action Keyword is already assigned to another plugin, please choose a different one Success Completed successfully - 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. + 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. Custom Query Hotkey diff --git a/Flow.Launcher/Languages/ko.xaml b/Flow.Launcher/Languages/ko.xaml index eaccfe022..81063e7cb 100644 --- a/Flow.Launcher/Languages/ko.xaml +++ b/Flow.Launcher/Languages/ko.xaml @@ -87,11 +87,10 @@ {0} 테마 로드에 실패했습니다. 기본 테마로 변경합니다. 테마 폴더 테마 폴더 열기 - 다크 모드 - System settings will take effect from the next run - 시스템 기본 - 밝게 - 어둡게 + 앱 색상 + 시스템 기본 + 밝게 + 어둡게 소리 효과 검색창을 열 때 작은 소리를 재생합니다. 애니메이션 diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index fb0f61baa..54c567c88 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -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; } diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs index 49788bfac..eb62733b7 100644 --- a/Flow.Launcher/PublicAPIInstance.cs +++ b/Flow.Launcher/PublicAPIInstance.cs @@ -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 } -} \ No newline at end of file +} diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index 47556949b..0bcac919f 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -1919,21 +1919,21 @@ - + + SelectionChanged="ColorSchemeSelectedIndexChanged" /> -  +  diff --git a/Flow.Launcher/SettingWindow.xaml.cs b/Flow.Launcher/SettingWindow.xaml.cs index cafe93158..4b052e2bd 100644 --- a/Flow.Launcher/SettingWindow.xaml.cs +++ b/Flow.Launcher/SettingWindow.xaml.cs @@ -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 */ diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index 96c14ebe0..342c85da2 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -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 DarkModes + + public List ColorSchemes { get { - List modes = new List(); - var enums = (Infrastructure.UserSettings.DarkMode[])Enum.GetValues(typeof(Infrastructure.UserSettings.DarkMode)); + List modes = new List(); + 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; diff --git a/Plugins/Flow.Launcher.Plugin.ControlPanel/ControlPanelItem.cs b/Plugins/Flow.Launcher.Plugin.ControlPanel/ControlPanelItem.cs deleted file mode 100644 index d821107b6..000000000 --- a/Plugins/Flow.Launcher.Plugin.ControlPanel/ControlPanelItem.cs +++ /dev/null @@ -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; - } - } -} \ No newline at end of file diff --git a/Plugins/Flow.Launcher.Plugin.ControlPanel/ControlPanelList.cs b/Plugins/Flow.Launcher.Plugin.ControlPanel/ControlPanelList.cs deleted file mode 100644 index 70afda536..000000000 --- a/Plugins/Flow.Launcher.Plugin.ControlPanel/ControlPanelList.cs +++ /dev/null @@ -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 Create(uint iconSize) - { - int size = (int)iconSize; - RegistryKey currentKey; - ProcessStartInfo executablePath; - List controlPanelItems = new List(); - 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 iconString; - IntPtr dataFilePointer; - IntPtr iconIndex; - Icon myIcon = null; - - if (currentKey.OpenSubKey("DefaultIcon") != null) - { - if (currentKey.OpenSubKey("DefaultIcon").GetValue(null) != null) - { - iconString = new List(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; - } - } -} diff --git a/Plugins/Flow.Launcher.Plugin.ControlPanel/Flow.Launcher.Plugin.ControlPanel.csproj b/Plugins/Flow.Launcher.Plugin.ControlPanel/Flow.Launcher.Plugin.ControlPanel.csproj deleted file mode 100644 index ff4a10d69..000000000 --- a/Plugins/Flow.Launcher.Plugin.ControlPanel/Flow.Launcher.Plugin.ControlPanel.csproj +++ /dev/null @@ -1,58 +0,0 @@ - - - - Library - net5.0-windows - {1EE20B48-82FB-48A2-8086-675D6DDAB4F0} - Properties - Flow.Launcher.Plugin.ControlPanel - Flow.Launcher.Plugin.ControlPanel - true - false - false - - - - true - portable - false - ..\..\Output\Debug\Plugins\Flow.Launcher.Plugin.ControlPanel\ - DEBUG;TRACE - prompt - 4 - false - - - - pdbonly - true - ..\..\Output\Release\Plugins\Flow.Launcher.Plugin.ControlPanel\ - TRACE - prompt - 4 - false - - - - - PreserveNewest - - - - - - - - - - - PreserveNewest - - - MSBuild:Compile - Designer - PreserveNewest - - - - \ No newline at end of file diff --git a/Plugins/Flow.Launcher.Plugin.ControlPanel/Images/ControlPanel.png b/Plugins/Flow.Launcher.Plugin.ControlPanel/Images/ControlPanel.png deleted file mode 100644 index 1a69112f3..000000000 Binary files a/Plugins/Flow.Launcher.Plugin.ControlPanel/Images/ControlPanel.png and /dev/null differ diff --git a/Plugins/Flow.Launcher.Plugin.ControlPanel/Languages/de.xaml b/Plugins/Flow.Launcher.Plugin.ControlPanel/Languages/de.xaml deleted file mode 100644 index d4bda14ac..000000000 --- a/Plugins/Flow.Launcher.Plugin.ControlPanel/Languages/de.xaml +++ /dev/null @@ -1,8 +0,0 @@ - - - Systemsteuerung - Suche in der Systemsteuerung - - \ No newline at end of file diff --git a/Plugins/Flow.Launcher.Plugin.ControlPanel/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.ControlPanel/Languages/en.xaml deleted file mode 100644 index 70b046174..000000000 --- a/Plugins/Flow.Launcher.Plugin.ControlPanel/Languages/en.xaml +++ /dev/null @@ -1,8 +0,0 @@ - - - Control Panel - Search within the Control Panel - - \ No newline at end of file diff --git a/Plugins/Flow.Launcher.Plugin.ControlPanel/Languages/pl.xaml b/Plugins/Flow.Launcher.Plugin.ControlPanel/Languages/pl.xaml deleted file mode 100644 index 1b731120e..000000000 --- a/Plugins/Flow.Launcher.Plugin.ControlPanel/Languages/pl.xaml +++ /dev/null @@ -1,8 +0,0 @@ - - - Panel sterowania - Szybie wyszukiwanie ustawień w panelu sterowania - - \ No newline at end of file diff --git a/Plugins/Flow.Launcher.Plugin.ControlPanel/Languages/sk.xaml b/Plugins/Flow.Launcher.Plugin.ControlPanel/Languages/sk.xaml deleted file mode 100644 index 3b9249b78..000000000 --- a/Plugins/Flow.Launcher.Plugin.ControlPanel/Languages/sk.xaml +++ /dev/null @@ -1,8 +0,0 @@ - - - Ovládací panel - Vyhľadáva položky Ovládacieho panela - - \ No newline at end of file diff --git a/Plugins/Flow.Launcher.Plugin.ControlPanel/Languages/tr.xaml b/Plugins/Flow.Launcher.Plugin.ControlPanel/Languages/tr.xaml deleted file mode 100644 index 7564b5c95..000000000 --- a/Plugins/Flow.Launcher.Plugin.ControlPanel/Languages/tr.xaml +++ /dev/null @@ -1,8 +0,0 @@ - - - Denetim Masası - Denetim Masası'nda arama yapın. - - \ No newline at end of file diff --git a/Plugins/Flow.Launcher.Plugin.ControlPanel/Languages/zh-cn.xaml b/Plugins/Flow.Launcher.Plugin.ControlPanel/Languages/zh-cn.xaml deleted file mode 100644 index 35d45260d..000000000 --- a/Plugins/Flow.Launcher.Plugin.ControlPanel/Languages/zh-cn.xaml +++ /dev/null @@ -1,8 +0,0 @@ - - - 控制面板 - 搜索控制面板 - - \ No newline at end of file diff --git a/Plugins/Flow.Launcher.Plugin.ControlPanel/Languages/zh-tw.xaml b/Plugins/Flow.Launcher.Plugin.ControlPanel/Languages/zh-tw.xaml deleted file mode 100644 index daa97d4a3..000000000 --- a/Plugins/Flow.Launcher.Plugin.ControlPanel/Languages/zh-tw.xaml +++ /dev/null @@ -1,8 +0,0 @@ - - - 控制台 - 搜尋控制台 - - diff --git a/Plugins/Flow.Launcher.Plugin.ControlPanel/Main.cs b/Plugins/Flow.Launcher.Plugin.ControlPanel/Main.cs deleted file mode 100644 index 9a721cc17..000000000 --- a/Plugins/Flow.Launcher.Plugin.ControlPanel/Main.cs +++ /dev/null @@ -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 controlPanelItems = new List(); - 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 Query(Query query) - { - List results = new List(); - - 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 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"); - } - } -} \ No newline at end of file diff --git a/Plugins/Flow.Launcher.Plugin.ControlPanel/plugin.json b/Plugins/Flow.Launcher.Plugin.ControlPanel/plugin.json deleted file mode 100644 index 23f35e9ac..000000000 --- a/Plugins/Flow.Launcher.Plugin.ControlPanel/plugin.json +++ /dev/null @@ -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" -} diff --git a/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml b/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml index 3d0f2761b..90e613280 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml +++ b/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml @@ -1,22 +1,132 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +