示例#1
0
        private void App_Startup(object sender, StartupEventArgs e)
        {
            // Load skins:
            if (!DirectoryEx.Exists(InstanceManager.Instance.SkinsFolderPath))
            {
                DirectoryEx.CreateDirectory(InstanceManager.Instance.SkinsFolderPath);
            }
            SkinManager.Instance.LoadAllSkins(InstanceManager.Instance.SkinsFolderPath);

            // Load settings:
            SettingsManager.Init(InstanceManager.Instance.SettingsFilePath);

            // Set skin:
            if (!IconManager.Instance.LoadFromSkin((string)SettingsManager.Instance["SelectedSkin"].Value))
            {
                MessageBox.Show("Failed to load skin: " + SettingsManager.Instance["SelectedSkin"].Value, "Error", MessageBoxButton.OK, MessageBoxImage.Asterisk);
                SettingsManager.Instance["SelectedSkin"].ResetValue();
                if (!IconManager.Instance.LoadFromSkin((string)SettingsManager.Instance["SelectedSkin"].Value))
                {
                    MessageBox.Show("Failed to load fallback default skin!", "This is a bug!", MessageBoxButton.OK, MessageBoxImage.Asterisk);
                }
            }

            // Load key bindings:
            KeyBindingManager.Init(InstanceManager.Instance.KeyConfigFilePath);
            //
            KeyBindingManager.Instance.Disable = !(bool)SettingsManager.Instance["EnableGlobalKeyBindings"].Value;
            SettingsManager.Instance["EnableGlobalKeyBindings"].PropertyChanged +=
                (s, args) => KeyBindingManager.Instance.Disable = !(bool)SettingsManager.Instance["EnableGlobalKeyBindings"].Value;

            // Load plugins:
            // VERY IMPORTANT: Force evaluation of IEnumerable
            InstanceManager.Instance.LoadedExtensions = ExtensionLoader.GetCompatibleExtensions <IExtension>(Lib.PathStringUtils.GetExePath()).ToList();
            _extAccess = new ExtensionAccess();
            foreach (var ex in InstanceManager.Instance.LoadedExtensions)
            {
                ex.Instance.Init(_extAccess);
            }
        }