public void ChangeTheme(string themeName) { string themePath = GetThemePath(themeName); if (string.IsNullOrEmpty(themePath)) { themePath = GetThemePath("Dark"); if (string.IsNullOrEmpty(themePath)) { throw new System.Exception("Change theme failed"); } } UserSettingStorage.Instance.Theme = themeName; UserSettingStorage.Instance.Save(); ResourceMerger.UpdateResource(this); // Exception of FindResource can't be cathed if global exception handle is set var isBlur = Application.Current.TryFindResource("ThemeBlurEnabled"); if (isBlur is bool) { SetBlurForWindow(Application.Current.MainWindow, (bool)isBlur); } }
/// <summary> /// Load and init all Wox plugins /// </summary> public static void Init(IPublicAPI api) { if (api == null) { throw new WoxFatalException("api is null"); } SetupPluginDirectories(); API = api; var metadatas = PluginConfig.Parse(pluginDirectories); AllPlugins = (new CSharpPluginLoader().LoadPlugin(metadatas)). Concat(new JsonRPCPluginLoader <PythonPlugin>().LoadPlugin(metadatas)); //load plugin i18n languages ResourceMerger.UpdatePluginLanguages(); foreach (PluginPair pluginPair in AllPlugins) { PluginPair pair = pluginPair; ThreadPool.QueueUserWorkItem(o => { var milliseconds = Stopwatch.Normal($"Plugin init: {pair.Metadata.Name}", () => { pair.Plugin.Init(new PluginInitContext { CurrentPluginMetadata = pair.Metadata, Proxy = HttpProxy.Instance, API = API }); }); pair.InitTime = milliseconds; InternationalizationManager.Instance.UpdatePluginMetadataTranslations(pair); }); } ThreadPool.QueueUserWorkItem(o => { InstantQueryPlugins = GetPluginsForInterface <IInstantQuery>(); contextMenuPlugins = GetPluginsForInterface <IContextMenu>(); foreach (var plugin in AllPlugins) { if (IsGlobalPlugin(plugin.Metadata)) { GlobalPlugins.Add(plugin); } else { foreach (string actionKeyword in plugin.Metadata.ActionKeywords) { NonGlobalPlugins[actionKeyword] = plugin; } } } }); }
private static void Merge(string solutionPath, string translationsXlsx) { Console.WriteLine("Reading solution resources..."); var solutionResources = new SolutionReader().GetSolutionResources(solutionPath); Console.WriteLine("Reading xlsx resources..."); var excelReader = ExcelReader.CreateReader(translationsXlsx); var xlsxResources = excelReader.ReadXlsx(); Console.WriteLine("Merging resources..."); var resources = new ResourceMerger().MergeResources(solutionResources, xlsxResources); Console.WriteLine($"Writing resources to file: {Path.GetFileName(translationsXlsx)}"); var excelWriter = new ExcelWriter(); excelWriter.WriteXlsx(translationsXlsx, resources); }
public void ChangeTheme(string themeName) { string themePath = GetThemePath(themeName); if (string.IsNullOrEmpty(themePath)) { themePath = GetThemePath("Dark"); if (string.IsNullOrEmpty(themePath)) { throw new System.Exception("Change theme failed"); } } UserSettingStorage.Instance.Theme = themeName; UserSettingStorage.Instance.Save(); ResourceMerger.ApplyResources(); }
public static void InitializePlugins(IPublicAPI api) { //load plugin i18n languages ResourceMerger.UpdatePluginLanguages(); API = api; foreach (PluginPair pluginPair in AllPlugins) { PluginPair pair = pluginPair; ThreadPool.QueueUserWorkItem(o => { var milliseconds = Stopwatch.Normal($"Plugin init: {pair.Metadata.Name}", () => { pair.Plugin.Init(new PluginInitContext { CurrentPluginMetadata = pair.Metadata, Proxy = HttpProxy.Instance, API = API }); }); pair.InitTime = milliseconds; InternationalizationManager.Instance.UpdatePluginMetadataTranslations(pair); }); } ThreadPool.QueueUserWorkItem(o => { _contextMenuPlugins = GetPluginsForInterface <IContextMenu>(); foreach (var plugin in AllPlugins) { if (IsGlobalPlugin(plugin.Metadata)) { GlobalPlugins.Add(plugin); } else { foreach (string actionKeyword in plugin.Metadata.ActionKeywords) { NonGlobalPlugins[actionKeyword] = plugin; } } } }); }
/// <summary> /// Load and init all Wox plugins /// </summary> public static void Init(IPublicAPI api) { if (api == null) { throw new WoxCritialException("api is null"); } SetupPluginDirectories(); API = api; plugins.Clear(); pluginMetadatas = PluginConfig.Parse(pluginDirectories); plugins.AddRange(new CSharpPluginLoader().LoadPlugin(pluginMetadatas)); plugins.AddRange(new JsonRPCPluginLoader <PythonPlugin>().LoadPlugin(pluginMetadatas)); //load plugin i18n languages ResourceMerger.ApplyPluginLanguages(); foreach (PluginPair pluginPair in plugins) { PluginPair pair = pluginPair; ThreadPool.QueueUserWorkItem(o => { Stopwatch sw = new Stopwatch(); sw.Start(); pair.Plugin.Init(new PluginInitContext() { CurrentPluginMetadata = pair.Metadata, Proxy = HttpProxy.Instance, API = API }); sw.Stop(); DebugHelper.WriteLine(string.Format("Plugin init:{0} - {1}", pair.Metadata.Name, sw.ElapsedMilliseconds)); pair.InitTime = sw.ElapsedMilliseconds; InternationalizationManager.Instance.UpdatePluginMetadataTranslations(pair); }); } ThreadPool.QueueUserWorkItem(o => { LoadInstantSearches(); }); }
public int Generate(string wszInputFilePath, string bstrInputFileContents, string wszDefaultNamespace, IntPtr[] rgbOutputFileContents, out uint pcbOutput, IVsGeneratorProgress pGenerateProgress) { //GetProjectPath string projectPath = GetProjectPath(wszInputFilePath); //GetProjectName string projectName = GetProjectName(projectPath); //GetRelativeSourcePathOfFile string relativeSourceFilePath = GetRelativeSourceFilePath(projectPath, wszInputFilePath); XDocument mergedDocument = ResourceMerger.CreateOutputDocument(projectPath, projectName, relativeSourceFilePath); using (MemoryStream ms = new MemoryStream()) { mergedDocument.Save(ms); byte[] bytes = ms.ToArray(); int length = bytes.Length; rgbOutputFileContents[0] = Marshal.AllocCoTaskMem(length); Marshal.Copy(bytes, 0, rgbOutputFileContents[0], length); pcbOutput = (uint)length; return(0); } }
public void ChangeLanguage(Language language) { if (language == null) { throw new WoxI18nException("language can't be null"); } string path = GetLanguagePath(language); if (string.IsNullOrEmpty(path)) { path = GetLanguagePath(AvailableLanguages.English); if (string.IsNullOrEmpty(path)) { throw new System.Exception("Change Language failed"); } } UserSettingStorage.Instance.Language = language.LanguageCode; UserSettingStorage.Instance.Save(); ResourceMerger.ApplyLanguageResources(this); }
public static void InitializePlugins(IPublicAPI api) { //load plugin i18n languages ResourceMerger.UpdatePluginLanguages(); API = api; Parallel.ForEach(AllPlugins, pair => { var milliseconds = Stopwatch.Debug($"|PluginManager.InitializePlugins|Init method time cost for <{pair.Metadata.Name}>", () => { pair.Plugin.Init(new PluginInitContext { CurrentPluginMetadata = pair.Metadata, API = API }); }); pair.Metadata.InitTime += milliseconds; Log.Info($"|PluginManager.InitializePlugins|Total init cost for <{pair.Metadata.Name}> is <{pair.Metadata.InitTime}ms>"); InternationalizationManager.Instance.UpdatePluginMetadataTranslations(pair); }); _contextMenuPlugins = GetPluginsForInterface <IContextMenu>(); foreach (var plugin in AllPlugins) { if (IsGlobalPlugin(plugin.Metadata)) { GlobalPlugins.Add(plugin); } else { foreach (string actionKeyword in plugin.Metadata.ActionKeywords) { NonGlobalPlugins[actionKeyword] = plugin; } } } }