예제 #1
0
        private void lbPlugins_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ISettingProvider provider = null;
            var    pair     = lbPlugins.SelectedItem as PluginPair;
            string pluginId = string.Empty;

            if (pair != null)
            {
                provider = pair.Plugin as ISettingProvider;
                pluginAuthor.Visibility        = Visibility.Visible;
                pluginActionKeyword.Visibility = Visibility.Visible;
                pluginInitTime.Text            =
                    string.Format(InternationalizationManager.Instance.GetTranslation("plugin_init_time"), pair.InitTime);
                pluginQueryTime.Text =
                    string.Format(InternationalizationManager.Instance.GetTranslation("plugin_query_time"), pair.AvgQueryTime);
                pluginActionKeywordTitle.Visibility = Visibility.Visible;
                tbOpenPluginDirecoty.Visibility     = Visibility.Visible;
                pluginTitle.Text         = pair.Metadata.Name;
                pluginTitle.Cursor       = Cursors.Hand;
                pluginActionKeyword.Text = pair.Metadata.ActionKeyword;
                pluginAuthor.Text        = InternationalizationManager.Instance.GetTranslation("author") + ": " + pair.Metadata.Author;
                pluginSubTitle.Text      = pair.Metadata.Description;
                pluginId          = pair.Metadata.ID;
                pluginIcon.Source = ImageLoader.ImageLoader.Load(pair.Metadata.FullIcoPath);
            }

            var customizedPluginConfig = UserSettingStorage.Instance.CustomizedPluginConfigs.FirstOrDefault(o => o.ID == pluginId);

            cbDisablePlugin.IsChecked = customizedPluginConfig != null && customizedPluginConfig.Disabled;

            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;
            }
        }
예제 #2
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();
        }
예제 #3
0
        private void lbPlugins_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ISettingProvider provider = null;
            var    pair     = lbPlugins.SelectedItem as PluginPair;
            string pluginId = string.Empty;

            if (pair != null)
            {
                //third-party plugin
                provider = pair.Plugin as ISettingProvider;
                pluginAuthor.Visibility             = Visibility.Visible;
                pluginActionKeyword.Visibility      = Visibility.Visible;
                pluginActionKeywordTitle.Visibility = Visibility.Visible;
                tbOpenPluginDirecoty.Visibility     = Visibility.Visible;
                pluginTitle.Text         = pair.Metadata.Name;
                pluginTitle.Cursor       = Cursors.Hand;
                pluginActionKeyword.Text = pair.Metadata.ActionKeyword;
                pluginAuthor.Text        = "By: " + pair.Metadata.Author;
                pluginSubTitle.Text      = pair.Metadata.Description;
                pluginId          = pair.Metadata.ID;
                pluginIcon.Source = ImageLoader.Load(pair.Metadata.FullIcoPath);
            }
            else
            {
                //system plugin
                provider = lbPlugins.SelectedItem as ISettingProvider;
                var sys = lbPlugins.SelectedItem as BaseSystemPlugin;
                if (sys != null)
                {
                    pluginTitle.Text                    = sys.Name;
                    pluginId                            = sys.ID;
                    pluginSubTitle.Text                 = sys.Description;
                    pluginAuthor.Visibility             = Visibility.Collapsed;
                    pluginActionKeyword.Visibility      = Visibility.Collapsed;
                    tbOpenPluginDirecoty.Visibility     = Visibility.Collapsed;
                    pluginActionKeywordTitle.Visibility = Visibility.Collapsed;
                    pluginTitle.Cursor                  = Cursors.Arrow;
                    pluginIcon.Source                   = ImageLoader.Load(sys.FullIcoPath);
                }
            }

            var customizedPluginConfig = UserSettingStorage.Instance.CustomizedPluginConfigs.FirstOrDefault(o => o.ID == pluginId);

            cbDisablePlugin.IsChecked = customizedPluginConfig != null && customizedPluginConfig.Disabled;

            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();
        }