From 71ec4ad403d66903a3e076358779411168c52e81 Mon Sep 17 00:00:00 2001 From: Yeechan Lu Date: Sun, 26 Jan 2014 01:24:24 +0800 Subject: [PATCH] Add some workarounds for clean environment. --- WinAlfred/Helper/Settings.cs | 9 +++++---- WinAlfred/MainWindow.xaml.cs | 14 ++++++++++---- WinAlfred/PluginLoader/BasePluginLoader.cs | 5 ++++- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/WinAlfred/Helper/Settings.cs b/WinAlfred/Helper/Settings.cs index 40beac986f..96f7c29329 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 50ced85aaf..897d9445bc 100644 --- a/WinAlfred/MainWindow.xaml.cs +++ b/WinAlfred/MainWindow.xaml.cs @@ -39,11 +39,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() diff --git a/WinAlfred/PluginLoader/BasePluginLoader.cs b/WinAlfred/PluginLoader/BasePluginLoader.cs index ea8161bd8b..17bbe97361 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) {