Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        private void featureBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ISettingProvider provider = null;
            var pair = featureBox.SelectedItem as PluginPair;

            if (pair != null)
            {
                provider                 = pair.Plugin as ISettingProvider;
                pluginTitle.Text         = pair.Metadata.Name;
                pluginActionKeyword.Text = "ActionKeyword: " + pair.Metadata.ActionKeyword;
                pluginAuthor.Text        = "Author: " + pair.Metadata.Author;
                pluginWebsite.Text       = "Website: " + pair.Metadata.Website;
                pluginSubTitle.Text      = pair.Metadata.Description;
                SyntaxSugars.CallOrRescueDefault(
                    () =>
                    pluginIcon.Source =
                        (ImageSource)
                        new ImagePathConverter().Convert(
                            new object[] { pair.Metadata.IcoPath, pair.Metadata.PluginDirecotry }, null, null,
                            null));
            }
            else
            {
                provider = featureBox.SelectedItem as ISettingProvider;

                var sys = featureBox.SelectedItem as BaseSystemPlugin;
                if (sys != null)
                {
                    pluginTitle.Text         = sys.Name;
                    pluginSubTitle.Text      = sys.Description;
                    pluginAuthor.Text        = "Author: Wox";
                    pluginActionKeyword.Text = "ActionKeyword: auto trigger";
                    pluginWebsite.Text       = "Website: http://www.getwox.com";
                    SyntaxSugars.CallOrRescueDefault(
                        () =>
                        pluginIcon.Source =
                            (ImageSource)
                            new ImagePathConverter().Convert(
                                new object[] { sys.IcoPath, sys.PluginDirectory }, null, null,
                                null));
                }
            }

            this.PluginContentPanel.Content = null;
            if (provider != null)
            {
                Control control = null;
                if (!featureControls.TryGetValue(provider, out control))
                {
                    featureControls.Add(provider, control = provider.CreateSettingPanel());
                }

                PluginContentPanel.Content  = control;
                control.HorizontalAlignment = HorizontalAlignment.Stretch;
                control.VerticalAlignment   = VerticalAlignment.Stretch;
                control.Width  = Double.NaN;
                control.Height = Double.NaN;
            }
            // featureControls
            // throw new NotImplementedException();
        }
Exemplo n.º 4
0
        private static string CreateExceptionReport(string ev, object exceptionObject)
        {
            var sb = new StringBuilder();

            sb.AppendLine("## Exception");
            sb.AppendLine();
            sb.AppendLine("```");

            var ex = exceptionObject as Exception;

            if (ex != null)
            {
                var exlist = new List <StringBuilder>();

                while (ex != null)
                {
                    var exsb = new StringBuilder();
                    exsb.Append(ex.GetType().FullName);
                    exsb.Append(": ");
                    exsb.AppendLine(ex.Message);
                    if (ex.Source != null)
                    {
                        exsb.Append("   Source: ");
                        exsb.AppendLine(ex.Source);
                    }
                    if (ex.TargetSite != null)
                    {
                        exsb.Append("   TargetAssembly: ");
                        exsb.AppendLine(ex.TargetSite.Module.Assembly.ToString());
                        exsb.Append("   TargetModule: ");
                        exsb.AppendLine(ex.TargetSite.Module.ToString());
                        exsb.Append("   TargetSite: ");
                        exsb.AppendLine(ex.TargetSite.ToString());
                    }
                    exsb.AppendLine(ex.StackTrace);
                    exlist.Add(exsb);

                    ex = ex.InnerException;
                }

                foreach (var result in exlist.Select(o => o.ToString()).Reverse())
                {
                    sb.AppendLine(result);
                }
                sb.AppendLine("```");
                sb.AppendLine();
            }
            else
            {
                sb.AppendLine(exceptionObject.GetType().FullName);
                sb.AppendLine(new StackTrace().ToString());
                sb.AppendLine("```");
                sb.AppendLine();
            }

            sb.AppendLine("## Environment");
            sb.AppendLine();
            sb.Append("* Command Line: ");
            sb.AppendLine(Environment.CommandLine);
            sb.Append("* Exception Handle: ");
            sb.AppendLine(ev);
            sb.Append("* Timestamp: ");
            sb.AppendLine(XmlConvert.ToString(DateTime.Now));
            sb.Append("* IntPtr Length: ");
            sb.AppendLine(IntPtr.Size.ToString());
            sb.Append("* System Version: ");
            sb.AppendLine(Environment.OSVersion.VersionString);
            sb.Append("* CLR Version: ");
            sb.AppendLine(Environment.Version.ToString());
            sb.AppendLine("* Installed .NET Framework: ");
            foreach (var result in GetFrameworkVersionFromRegistry())
            {
                sb.Append("   * ");
                sb.AppendLine(result);
            }

            sb.AppendLine();
            sb.AppendLine("## Assemblies - " + System.AppDomain.CurrentDomain.FriendlyName);
            sb.AppendLine();
            foreach (var ass in System.AppDomain.CurrentDomain.GetAssemblies().OrderBy(o => o.GlobalAssemblyCache ? 100 : 0))
            {
                sb.Append("* ");
                sb.Append(ass.FullName);
                sb.Append(" (");
                sb.Append(SyntaxSugars.CallOrRescueDefault(() => ass.Location, "not supported"));
                sb.AppendLine(")");
            }

            var process = System.Diagnostics.Process.GetCurrentProcess();

            sb.AppendLine();
            sb.AppendLine("## Modules - " + process.ProcessName);
            sb.AppendLine();
            foreach (ProcessModule mod in process.Modules)
            {
                sb.Append("* ");
                sb.Append(mod.FileName);
                sb.Append(" (");
                sb.Append(mod.FileVersionInfo.FileDescription);
                sb.Append(", ");
                sb.Append(mod.FileVersionInfo.FileVersion);
                sb.Append(", ");
                sb.Append(mod.FileVersionInfo.ProductName);
                sb.Append(", ");
                sb.Append(mod.FileVersionInfo.ProductVersion);
                sb.Append(", ");
                sb.Append(mod.FileVersionInfo.CompanyName);
                sb.Append("), ");
                sb.Append(string.Format("0x{0:X16}", mod.BaseAddress.ToInt64()));
                sb.AppendLine();
            }

            sb.AppendLine();
            sb.AppendLine("## Threads - " + process.Threads.Count);
            sb.AppendLine();
            foreach (ProcessThread th in process.Threads)
            {
                sb.Append("* ");
                sb.AppendLine(string.Format("{0}, {1} {2}, Started: {3}, StartAddress: 0x{4:X16}", th.Id, th.ThreadState, th.PriorityLevel, th.StartTime, th.StartAddress.ToInt64()));
            }

            return(sb.ToString());
        }
Exemplo n.º 5
0
        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);
        }