diff --git a/WinAlfred/Helper/Settings.cs b/WinAlfred/Helper/Settings.cs index 40beac986..96f7c2932 100644 --- a/WinAlfred/Helper/Settings.cs +++ b/WinAlfred/Helper/Settings.cs @@ -9,20 +9,21 @@ namespace WinAlfred.Helper public class Settings { private string configPath = Directory.GetCurrentDirectory() + "\\config.ini"; - private static readonly Settings settings = new Settings(); - IniParser parser = new IniParser("config.ini"); + private static readonly Settings settings = new Settings(); + IniParser parser; public string Theme { get; set; } public bool ReplaceWinR { get; set; } private Settings() - { + { + if (!File.Exists(configPath)) File.Create(configPath); + parser = new IniParser(configPath); LoadSettings(); } private void LoadSettings() { - if (!File.Exists(configPath)) File.Create(configPath); Theme = parser.GetSetting("ui", "theme"); string replaceWinRStr = parser.GetSetting("hotkey", "replaceWinR"); diff --git a/WinAlfred/MainWindow.xaml.cs b/WinAlfred/MainWindow.xaml.cs index 50ced85aa..75a6d2b76 100644 --- a/WinAlfred/MainWindow.xaml.cs +++ b/WinAlfred/MainWindow.xaml.cs @@ -29,7 +29,9 @@ namespace WinAlfred SelectedRecords selectedRecords = new SelectedRecords(); private KeyboardListener keyboardListener = new KeyboardListener(); - private bool WinRStroked = false; + private bool WinRStroked = false; + + private WindowsInput.KeyboardSimulator keyboardSimulator = new WindowsInput.KeyboardSimulator(new WindowsInput.InputSimulator()); public MainWindow() { @@ -39,11 +41,17 @@ namespace WinAlfred hook.RegisterHotKey(XModifierKeys.Alt, Keys.Space); resultCtrl.resultItemChangedEvent += resultCtrl_resultItemChangedEvent; ThreadPool.SetMaxThreads(30, 10); - InitProgressbarAnimation(); - - - ChangeStyles(Settings.Instance.Theme); + InitProgressbarAnimation(); + + try + { + ChangeStyles(Settings.Instance.Theme); + } + catch (System.IO.IOException) + { + ChangeStyles(Settings.Instance.Theme = "Default"); + } } private void WakeupApp() @@ -239,7 +247,7 @@ namespace WinAlfred if (keyevent == KeyEvent.WM_KEYUP && WinRStroked && vkcode == (int)Keys.LWin) { WinRStroked = false; - WindowsInput.InputSimulator.SimulateModifiedKeyStroke(WindowsInput.VirtualKeyCode.LWIN, WindowsInput.VirtualKeyCode.CONTROL); + keyboardSimulator.ModifiedKeyStroke(WindowsInput.Native.VirtualKeyCode.LWIN, WindowsInput.Native.VirtualKeyCode.CONTROL); return false; } } diff --git a/WinAlfred/PluginLoader/BasePluginLoader.cs b/WinAlfred/PluginLoader/BasePluginLoader.cs index ea8161bd8..17bbe9736 100644 --- a/WinAlfred/PluginLoader/BasePluginLoader.cs +++ b/WinAlfred/PluginLoader/BasePluginLoader.cs @@ -41,7 +41,10 @@ namespace WinAlfred.PluginLoader } private static void ParseThirdPartyPlugins() - { + { + if (!Directory.Exists(PluginPath)) + Directory.CreateDirectory(PluginPath); + string[] directories = Directory.GetDirectories(PluginPath); foreach (string directory in directories) { diff --git a/WinAlfred/WinAlfred.csproj b/WinAlfred/WinAlfred.csproj index 9fe39639d..739f0155e 100644 --- a/WinAlfred/WinAlfred.csproj +++ b/WinAlfred/WinAlfred.csproj @@ -1,284 +1,282 @@ - - - - - Debug - AnyCPU - {DB90F671-D861-46BB-93A3-F1304F5BA1C5} - WinExe - Properties - WinAlfred - WinAlfred - v3.5 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - ..\ - true - - 发布\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - app.ico - - - true - bin\x64\Debug\ - DEBUG;TRACE - full - x64 - prompt - MinimumRecommendedRules.ruleset - - - bin\x64\Release\ - TRACE - true - pdbonly - x64 - prompt - MinimumRecommendedRules.ruleset - - - WinAlfred.EntryPoint - - - - - C:\Users\Scott\Desktop\InputSimulator.dll - - - ..\packages\log4net.2.0.3\lib\net35-full\log4net.dll - - - - ..\packages\Newtonsoft.Json.5.0.8\lib\net35\Newtonsoft.Json.dll - - - - - - - - - - - - - - - - - - - - - - - MSBuild:Compile - Designer - - - - - - - - - - - - - - - Msg.xaml - - - - - - - - - - ResultPanel.xaml - - - ResultItem.xaml - - - - SettingWindow.xaml - - - MSBuild:Compile - Designer - - - App.xaml - Code - - - MainWindow.xaml - Code - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - - - Code - - - True - True - Resources.resx - - - True - Settings.settings - True - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - Designer - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - - {097b4ac0-74e9-4c58-bcf8-c69746ec8271} - Python.Runtime - - - {69ce0206-cb41-453d-88af-df86092ef9b8} - WinAlfred.Plugin.System - - - {8451ECDD-2EA4-4966-BB0A-7BBC40138E80} - WinAlfred.Plugin - - - - - - - - - - - - - - Always - - - - - - - - - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - true - - - - - - - - - - - - - - - - - + + + + + Debug + AnyCPU + {DB90F671-D861-46BB-93A3-F1304F5BA1C5} + WinExe + Properties + WinAlfred + WinAlfred + v3.5 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + ..\ + true + + 发布\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + app.ico + + + true + bin\x64\Debug\ + DEBUG;TRACE + full + x64 + prompt + MinimumRecommendedRules.ruleset + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + prompt + MinimumRecommendedRules.ruleset + + + WinAlfred.EntryPoint + + + + + ..\packages\log4net.2.0.3\lib\net35-full\log4net.dll + + + + ..\packages\Newtonsoft.Json.5.0.8\lib\net35\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + + + ..\packages\InputSimulator.1.0.4.0\lib\net20\WindowsInput.dll + + + + + MSBuild:Compile + Designer + + + + + + + + + + + + + + + Msg.xaml + + + + + + + + + + ResultPanel.xaml + + + ResultItem.xaml + + + + SettingWindow.xaml + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + MainWindow.xaml + Code + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + Designer + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + {097b4ac0-74e9-4c58-bcf8-c69746ec8271} + Python.Runtime + + + {69ce0206-cb41-453d-88af-df86092ef9b8} + WinAlfred.Plugin.System + + + {8451ECDD-2EA4-4966-BB0A-7BBC40138E80} + WinAlfred.Plugin + + + + + + + + + + + + + + Always + + + + + + + + + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + true + + + + + + + + + + + + + + + + + xcopy /Y $(ProjectDir)Images\*.* $(TargetDir)Images\ xcopy /Y $(ProjectDir)app.ico $(TargetDir) -xcopy /Y $(ProjectDir)Themes\*.* $(TargetDir)Themes\ - +xcopy /Y $(ProjectDir)Themes\*.* $(TargetDir)Themes\ + + --> \ No newline at end of file diff --git a/WinAlfred/packages.config b/WinAlfred/packages.config index 0db9c4556..f46c1ba8d 100644 --- a/WinAlfred/packages.config +++ b/WinAlfred/packages.config @@ -1,5 +1,6 @@ - - - - + + + + + \ No newline at end of file