private void OnThemeTabSelected() { using (new Timeit("theme load")) { var s = Fonts.SystemFontFamilies; } if (themeTabLoaded) { return; } themeTabLoaded = true; if (!string.IsNullOrEmpty(UserSettingStorage.Instance.QueryBoxFont) && Fonts.SystemFontFamilies.Count(o => o.FamilyNames.Values.Contains(UserSettingStorage.Instance.QueryBoxFont)) > 0) { cbQueryBoxFont.Text = UserSettingStorage.Instance.QueryBoxFont; cbQueryBoxFontFaces.SelectedItem = SyntaxSugars.CallOrRescueDefault(() => ((FontFamily)cbQueryBoxFont.SelectedItem).ConvertFromInvariantStringsOrNormal( UserSettingStorage.Instance.QueryBoxFontStyle, UserSettingStorage.Instance.QueryBoxFontWeight, UserSettingStorage.Instance.QueryBoxFontStretch )); } if (!string.IsNullOrEmpty(UserSettingStorage.Instance.ResultItemFont) && Fonts.SystemFontFamilies.Count(o => o.FamilyNames.Values.Contains(UserSettingStorage.Instance.ResultItemFont)) > 0) { cbResultItemFont.Text = UserSettingStorage.Instance.ResultItemFont; cbResultItemFontFaces.SelectedItem = SyntaxSugars.CallOrRescueDefault(() => ((FontFamily)cbResultItemFont.SelectedItem).ConvertFromInvariantStringsOrNormal( UserSettingStorage.Instance.ResultItemFontStyle, UserSettingStorage.Instance.ResultItemFontWeight, UserSettingStorage.Instance.ResultItemFontStretch )); } resultPanelPreview.AddResults(new List <Result>() { new Result() { Title = "Wox is an effective launcher for windows", SubTitle = "Wox provide bundles of features let you access infomations quickly.", IcoPath = "Images/app.png", PluginDirectory = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) }, new Result() { Title = "Search applications", SubTitle = "Search applications, files (via everything plugin) and browser bookmarks", IcoPath = "Images/app.png", PluginDirectory = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) }, new Result() { Title = "Search web contents with shortcuts", SubTitle = "e.g. search google with g keyword or youtube keyword)", IcoPath = "Images/app.png", PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath) }, new Result() { Title = "clipboard history ", IcoPath = "Images/app.png", PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath) }, new Result() { Title = "Themes support", SubTitle = "get more themes from http://www.getwox.com/theme", IcoPath = "Images/app.png", PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath) }, new Result() { Title = "Plugins support", SubTitle = "get more plugins from http://www.getwox.com/plugin", IcoPath = "Images/app.png", PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath) }, new Result() { Title = "Wox is an open-source software", SubTitle = "Wox benefits from the open-source community a lot", IcoPath = "Images/app.png", PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath) } }); foreach (string theme in ThemeManager.Theme.LoadAvailableThemes()) { string themeName = System.IO.Path.GetFileNameWithoutExtension(theme); themeComboBox.Items.Add(themeName); } themeComboBox.SelectedItem = UserSettingStorage.Instance.Theme; var wallpaper = WallpaperPathRetrieval.GetWallpaperPath(); if (wallpaper != null && File.Exists(wallpaper)) { var brush = new ImageBrush(new BitmapImage(new Uri(wallpaper))); brush.Stretch = Stretch.UniformToFill; PreviewPanel.Background = brush; } else { var wallpaperColor = WallpaperPathRetrieval.GetWallpaperColor(); PreviewPanel.Background = new SolidColorBrush(wallpaperColor); } }
private void OnThemeTabSelected() { Stopwatch.Debug("theme load", () => { var s = Fonts.SystemFontFamilies; }); if (themeTabLoaded) { return; } themeTabLoaded = true; if (!string.IsNullOrEmpty(_settings.QueryBoxFont) && Fonts.SystemFontFamilies.Count(o => o.FamilyNames.Values.Contains(_settings.QueryBoxFont)) > 0) { cbQueryBoxFont.Text = _settings.QueryBoxFont; cbQueryBoxFontFaces.SelectedItem = SyntaxSugars.CallOrRescueDefault( () => ((FontFamily)cbQueryBoxFont.SelectedItem).ConvertFromInvariantStringsOrNormal( _settings.QueryBoxFontStyle, _settings.QueryBoxFontWeight, _settings.QueryBoxFontStretch )); } if (!string.IsNullOrEmpty(_settings.ResultFont) && Fonts.SystemFontFamilies.Count(o => o.FamilyNames.Values.Contains(_settings.ResultFont)) > 0) { ResultFontComboBox.Text = _settings.ResultFont; ResultFontFacesComboBox.SelectedItem = SyntaxSugars.CallOrRescueDefault( () => ((FontFamily)ResultFontComboBox.SelectedItem).ConvertFromInvariantStringsOrNormal( _settings.ResultFontStyle, _settings.ResultFontWeight, _settings.ResultFontStretch )); } ResultListBoxPreview.AddResults(new List <Result> { new Result { Title = "Wox is an effective launcher for windows", SubTitle = "Wox provide bundles of features let you access infomations quickly.", IcoPath = "Images/app.png", PluginDirectory = Path.GetDirectoryName(Infrastructure.Constant.ProgramDirectory) }, new Result { Title = "Search applications", SubTitle = "Search applications, files (via everything plugin) and browser bookmarks", IcoPath = "Images/app.png", PluginDirectory = Path.GetDirectoryName(Infrastructure.Constant.ProgramDirectory) }, new Result { Title = "Search web contents with shortcuts", SubTitle = "e.g. search google with g keyword or youtube keyword)", IcoPath = "Images/app.png", PluginDirectory = Path.GetDirectoryName(Infrastructure.Constant.ProgramDirectory) }, new Result { Title = "clipboard history ", IcoPath = "Images/app.png", PluginDirectory = Path.GetDirectoryName(Infrastructure.Constant.ProgramDirectory) }, new Result { Title = "Themes support", SubTitle = "get more themes from http://www.getwox.com/theme", IcoPath = "Images/app.png", PluginDirectory = Path.GetDirectoryName(Infrastructure.Constant.ProgramDirectory) }, new Result { Title = "Plugins support", SubTitle = "get more plugins from http://www.getwox.com/plugin", IcoPath = "Images/app.png", PluginDirectory = Path.GetDirectoryName(Infrastructure.Constant.ProgramDirectory) }, new Result { Title = "Wox is an open-source software", SubTitle = "Wox benefits from the open-source community a lot", IcoPath = "Images/app.png", PluginDirectory = Path.GetDirectoryName(Infrastructure.Constant.ProgramDirectory) } }); foreach (string theme in ThemeManager.Instance.LoadAvailableThemes()) { string themeName = Path.GetFileNameWithoutExtension(theme); themeComboBox.Items.Add(themeName); } themeComboBox.SelectedItem = _settings.Theme; var wallpaper = WallpaperPathRetrieval.GetWallpaperPath(); if (wallpaper != null && File.Exists(wallpaper)) { var memStream = new MemoryStream(File.ReadAllBytes(wallpaper)); var bitmap = new BitmapImage(); bitmap.BeginInit(); bitmap.StreamSource = memStream; bitmap.EndInit(); var brush = new ImageBrush(bitmap); brush.Stretch = Stretch.UniformToFill; PreviewPanel.Background = brush; } else { var wallpaperColor = WallpaperPathRetrieval.GetWallpaperColor(); PreviewPanel.Background = new SolidColorBrush(wallpaperColor); } }
private void Setting_Loaded(object sender, RoutedEventArgs ev) { ctlHotkey.OnHotkeyChanged += ctlHotkey_OnHotkeyChanged; ctlHotkey.SetHotkey(UserSettingStorage.Instance.Hotkey, false); cbReplaceWinR.Checked += (o, e) => { UserSettingStorage.Instance.ReplaceWinR = true; UserSettingStorage.Instance.Save(); }; cbReplaceWinR.Unchecked += (o, e) => { UserSettingStorage.Instance.ReplaceWinR = false; UserSettingStorage.Instance.Save(); }; cbEnablePythonPlugins.Checked += (o, e) => { UserSettingStorage.Instance.EnablePythonPlugins = true; UserSettingStorage.Instance.Save(); }; cbEnablePythonPlugins.Unchecked += (o, e) => { UserSettingStorage.Instance.EnablePythonPlugins = false; UserSettingStorage.Instance.Save(); }; cbEnableBookmarkPlugin.Checked += (o, e) => { UserSettingStorage.Instance.EnableBookmarkPlugin = true; UserSettingStorage.Instance.Save(); }; cbEnableBookmarkPlugin.Unchecked += (o, e) => { UserSettingStorage.Instance.EnableBookmarkPlugin = false; UserSettingStorage.Instance.Save(); }; cbLeaveCmdOpen.Checked += (o, e) => { UserSettingStorage.Instance.LeaveCmdOpen = true; UserSettingStorage.Instance.Save(); }; cbLeaveCmdOpen.Unchecked += (o, e) => { UserSettingStorage.Instance.LeaveCmdOpen = false; UserSettingStorage.Instance.Save(); }; cbHideWhenDeactive.Checked += (o, e) => { UserSettingStorage.Instance.HideWhenDeactive = true; UserSettingStorage.Instance.Save(); }; cbHideWhenDeactive.Unchecked += (o, e) => { UserSettingStorage.Instance.HideWhenDeactive = false; UserSettingStorage.Instance.Save(); }; #region Load Theme Data if (!string.IsNullOrEmpty(UserSettingStorage.Instance.QueryBoxFont) && Fonts.SystemFontFamilies.Count(o => o.FamilyNames.Values.Contains(UserSettingStorage.Instance.QueryBoxFont)) > 0) { cbQueryBoxFont.Text = UserSettingStorage.Instance.QueryBoxFont; cbQueryBoxFontFaces.SelectedItem = SyntaxSugars.CallOrRescueDefault(() => ((FontFamily)cbQueryBoxFont.SelectedItem).ConvertFromInvariantStringsOrNormal( UserSettingStorage.Instance.QueryBoxFontStyle, UserSettingStorage.Instance.QueryBoxFontWeight, UserSettingStorage.Instance.QueryBoxFontStretch )); } if (!string.IsNullOrEmpty(UserSettingStorage.Instance.ResultItemFont) && Fonts.SystemFontFamilies.Count(o => o.FamilyNames.Values.Contains(UserSettingStorage.Instance.ResultItemFont)) > 0) { cbResultItemFont.Text = UserSettingStorage.Instance.ResultItemFont; cbResultItemFontFaces.SelectedItem = SyntaxSugars.CallOrRescueDefault(() => ((FontFamily)cbResultItemFont.SelectedItem).ConvertFromInvariantStringsOrNormal( UserSettingStorage.Instance.ResultItemFontStyle, UserSettingStorage.Instance.ResultItemFontWeight, UserSettingStorage.Instance.ResultItemFontStretch )); } resultPanelPreview.AddResults(new List <Result>() { new Result() { Title = "Wox is an effective launcher for windows", SubTitle = "Wox provide bundles of features let you access infomations quickly.", IcoPath = "Images/work.png", PluginDirectory = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) }, new Result() { Title = "Search applications", SubTitle = "Search applications, files (via everything plugin) and browser bookmarks", IcoPath = "Images/work.png", PluginDirectory = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) }, new Result() { Title = "Search web contents with shortcuts", SubTitle = "e.g. search google with g keyword or youtube keyword)", IcoPath = "Images/work.png", PluginDirectory = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) }, new Result() { Title = "clipboard history ", IcoPath = "Images/work.png", PluginDirectory = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) }, new Result() { Title = "Themes support", SubTitle = "get more themes from http://www.getwox.com/theme", IcoPath = "Images/work.png", PluginDirectory = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) }, new Result() { Title = "Plugins support", SubTitle = "get more plugins from http://www.getwox.com/plugin", IcoPath = "Images/work.png", PluginDirectory = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) }, new Result() { Title = "Wox is an open-source software", SubTitle = "Wox benefits from the open-source community a lot", IcoPath = "Images/work.png", PluginDirectory = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) } }); #endregion foreach (string theme in LoadAvailableThemes()) { string themeName = System.IO.Path.GetFileNameWithoutExtension(theme); themeComboBox.Items.Add(themeName); } themeComboBox.SelectedItem = UserSettingStorage.Instance.Theme; cbReplaceWinR.IsChecked = UserSettingStorage.Instance.ReplaceWinR; lvCustomHotkey.ItemsSource = UserSettingStorage.Instance.CustomPluginHotkeys; cbEnablePythonPlugins.IsChecked = UserSettingStorage.Instance.EnablePythonPlugins; cbStartWithWindows.IsChecked = File.Exists(woxLinkPath); cbEnableBookmarkPlugin.IsChecked = UserSettingStorage.Instance.EnableBookmarkPlugin; cbLeaveCmdOpen.IsChecked = UserSettingStorage.Instance.LeaveCmdOpen; cbHideWhenDeactive.IsChecked = UserSettingStorage.Instance.HideWhenDeactive; var features = new CompositeCollection { new CollectionContainer() { Collection = PluginLoader.Plugins.AllPlugins.Where(o => o.Metadata.PluginType == PluginType.System) .Select(o => o.Plugin) .Cast <Wox.Plugin.SystemPlugins.ISystemPlugin>() }, FindResource("FeatureBoxSeperator"), new CollectionContainer() { Collection = PluginLoader.Plugins.AllPlugins.Where(o => o.Metadata.PluginType == PluginType.ThirdParty) } }; featureBox.ItemsSource = features; slOpacity.Value = UserSettingStorage.Instance.Opacity; CbOpacityMode.SelectedItem = UserSettingStorage.Instance.OpacityMode; var wallpaper = WallpaperPathRetrieval.GetWallpaperPath(); if (wallpaper != null && File.Exists(wallpaper)) { var brush = new ImageBrush(new BitmapImage(new Uri(wallpaper))); brush.Stretch = Stretch.UniformToFill; this.PreviewPanel.Background = brush; } else { var wallpaperColor = WallpaperPathRetrieval.GetWallpaperColor(); this.PreviewPanel.Background = new SolidColorBrush(wallpaperColor); } //PreviewPanel settingsLoaded = true; App.Window.SetTheme(UserSettingStorage.Instance.Theme); }