Пример #1
0
        public ActionKeyword(string pluginId)
        {
            InitializeComponent();
            PluginPair plugin = PluginManager.GetPlugin(pluginId);
            if (plugin == null)
            {
                MessageBox.Show(InternationalizationManager.Instance.GetTranslation("cannotFindSpecifiedPlugin"));
                Close();
                return;
            }

            pluginMetadata = plugin.Metadata;
        }
Пример #2
0
        public ActionKeyword(string pluginId)
        {
            InitializeComponent();
            PluginPair plugin = Plugins.AllPlugins.FirstOrDefault(o => o.Metadata.ID == pluginId);
            if (plugin == null)
            {
                MessageBox.Show("Can't find specific plugin");
                Close();
                return;
            }

            pluginMetadata = plugin.Metadata;
        }
Пример #3
0
        /// <summary>
        /// To avoid deadlock, this method should not called from main thread
        /// </summary>
        public void UpdateResultView(List<Result> list, PluginMetadata metadata, Query originQuery)
        {
            _queryHasReturn = true;
            ProgressBarVisibility = Visibility.Hidden;

            foreach (var result in list)
            {
                if (_topMostRecord.IsTopMost(result))
                {
                    result.Score = int.MaxValue;
                }
                else
                {
                    result.Score += _userSelectedRecord.GetSelectedCount(result)*5;
                }
            }

            if (originQuery.RawQuery == _lastQuery.RawQuery)
            {
                Results.AddResults(list, metadata.ID);
            }

            if (list.Count > 0 && !ResultListBoxVisibility.IsVisible())
            {
                ResultListBoxVisibility = Visibility.Visible;
            }
        }
Пример #4
0
 public void PushResults(Query query, PluginMetadata plugin, List<Result> results)
 {
     results.ForEach(o =>
     {
         o.PluginDirectory = plugin.PluginDirectory;
         o.PluginID = plugin.ID;
         o.OriginQuery = query;
     });
     UpdateResultView(results);
 }
Пример #5
0
 public PythonPluginWrapper(PluginMetadata metadata)
 {
     this.metadata = metadata;
     moduleName = metadata.ExecuteFileName.Replace(".py", "");
 }
Пример #6
0
        public void ShowContextMenu(PluginMetadata plugin, List<Result> results)
        {
            if (results != null && results.Count > 0)
            {
                results.ForEach(o =>
                {
                    o.PluginDirectory = plugin.PluginDirectory;
                    o.PluginID = plugin.ID;
                });

                MainVM.ShowContextMenu(results, plugin.ID);
            }
        }
Пример #7
0
 private static void ParseSystemPlugins()
 {
     PluginMetadata metadata = new PluginMetadata();
     metadata.Name = "System Plugins";
     metadata.Author = "System";
     metadata.Description = "system plugins collection";
     metadata.Language = AllowedLanguage.CSharp;
     metadata.Version = "1.0";
     metadata.PluginType = PluginType.System;
     metadata.ActionKeyword = "*";
     metadata.ExecuteFileName = "Wox.Plugin.SystemPlugins.dll";
     metadata.PluginDirecotry = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);
     pluginMetadatas.Add(metadata);
 }
Пример #8
0
        public void UpdateResultView(List<Result> list, PluginMetadata metadata, Query originQuery)
        {
            _queryHasReturn = true;
            IsProgressBarTooltipVisible = false;

            list.ForEach(o =>
            {
                o.Score += UserSelectedRecordStorage.Instance.GetSelectedCount(o) * 5;
            });
            if (originQuery.RawQuery == _lastQuery.RawQuery)
            {
                Application.Current.Dispatcher.Invoke(() =>
                {
                    UpdateResultViewInternal(list, metadata);
                });
            }

            if (list.Count > 0)
            {
                IsResultListBoxVisible = true;
            }
        }
Пример #9
0
 private void UpdateResultViewInternal(List<Result> list, PluginMetadata metadata)
 {
     Dispatcher.Invoke(new Action(() =>
     {
         Stopwatch.Normal($"UI update cost for {metadata.Name}",
             () => { pnlResult.AddResults(list, metadata.ID); });
     }));
 }
Пример #10
0
 public static bool IsGenericPlugin(PluginMetadata metadata)
 {
     return metadata.ActionKeyword == ActionKeywordWildcardSign;
 }
Пример #11
0
        private PluginMetadata GetMetadataFromIni(string directory)
        {
            string iniPath = directory + "\\plugin.ini";

            if (!File.Exists(iniPath))
            {
                return null;
            }

            try
            {
                PluginMetadata metadata = new PluginMetadata();
                IniParser ini = new IniParser(iniPath);
                metadata.Name = ini.GetSetting("plugin", "Name");
                metadata.Author = ini.GetSetting("plugin", "Author");
                metadata.Description = ini.GetSetting("plugin", "Description");
                metadata.Language = ini.GetSetting("plugin", "Language");
                metadata.Version = ini.GetSetting("plugin", "Version");
                metadata.PluginType = PluginType.ThirdParty;
                metadata.ActionKeyword = ini.GetSetting("plugin", "ActionKeyword");
                metadata.ExecuteFilePath = directory + "\\" + ini.GetSetting("plugin", "ExecuteFile");
                metadata.PluginDirecotry = directory + "\\";
                metadata.ExecuteFileName = ini.GetSetting("plugin", "ExecuteFile");

                if (!AllowedLanguage.IsAllowed(metadata.Language))
                {
                    string error = string.Format("Parse ini {0} failed: invalid language {1}", iniPath,
                                                 metadata.Language);
                    return null;
                }
                if (!File.Exists(metadata.ExecuteFilePath))
                {
                    string error = string.Format("Parse ini {0} failed: ExecuteFilePath didn't exist {1}", iniPath,
                                                 metadata.ExecuteFilePath);
                    return null;
                }

                return metadata;
            }
            catch (Exception e)
            {
                return null;
            }
        }
Пример #12
0
        private static PluginMetadata GetMetadataFromIni(string directory)
        {
            string iniPath = directory + "\\" + PluginConfigName;

            if (!File.Exists(iniPath))
            {
                Log.Error(string.Format("parse plugin {0} failed: didn't find config file.", iniPath));
                return null;
            }

            try
            {
                PluginMetadata metadata = new PluginMetadata();
                IniParser ini = new IniParser(iniPath);
                metadata.Name = ini.GetSetting("plugin", "Name");
                metadata.Author = ini.GetSetting("plugin", "Author");
                metadata.Description = ini.GetSetting("plugin", "Description");
                metadata.Language = ini.GetSetting("plugin", "Language");
                metadata.Version = ini.GetSetting("plugin", "Version");
                metadata.PluginType = PluginType.ThirdParty;
                metadata.ActionKeyword = ini.GetSetting("plugin", "ActionKeyword");
                metadata.ExecuteFilePath = directory + "\\" + ini.GetSetting("plugin", "ExecuteFile");
                metadata.PluginDirecotry = directory + "\\";
                metadata.ExecuteFileName = ini.GetSetting("plugin", "ExecuteFile");

                if (!AllowedLanguage.IsAllowed(metadata.Language))
                {
                    string error = string.Format("Parse ini {0} failed: invalid language {1}", iniPath,
                                                 metadata.Language);
                    Log.Error(error);
            #if (DEBUG)
                    {
                        throw new WoxException(error);
                    }
            #endif
                    return null;
                }
                if (!File.Exists(metadata.ExecuteFilePath))
                {
                    string error = string.Format("Parse ini {0} failed: ExecuteFilePath didn't exist {1}", iniPath,
                                                 metadata.ExecuteFilePath);
                    Log.Error(error);
            #if (DEBUG)
                    {
                        throw new WoxException(error);
                    }
            #endif
                    return null;
                }

                return metadata;
            }
            catch (Exception e)
            {
                Log.Error(string.Format("Parse ini {0} failed: {1}", iniPath, e.Message));
            #if (DEBUG)
                {
                    throw;
                }
            #endif
                return null;
            }
        }
Пример #13
0
 private void UpdateResultViewInternal(List<Result> list, PluginMetadata metadata)
 {
     Stopwatch.Normal($"UI update cost for {metadata.Name}",
             () => { Results.AddResults(list, metadata.ID); });
 }
Пример #14
0
 public void ShowContextMenu(PluginMetadata plugin, List<Result> results)
 {
     if (results != null && results.Count > 0)
     {
         results.ForEach(o =>
         {
             o.PluginDirectory = plugin.PluginDirectory;
             o.PluginID = plugin.ID;
             o.ContextMenu = null;
         });
         pnlContextMenu.Clear();
         pnlContextMenu.AddResults(results, plugin.ID);
         pnlContextMenu.Visibility = Visibility.Visible;
         pnlResult.Visibility = Visibility.Collapsed;
     }
 }
Пример #15
0
 public static bool IsInstantSearchPlugin(PluginMetadata pluginMetadata)
 {
     //todo:to improve performance, any instant search plugin that takes long than 200ms will not consider a instant plugin anymore
     return pluginMetadata.Language.ToUpper() == AllowedLanguage.CSharp &&
            LoadInstantSearches().Any(o => o.Key.Metadata.ID == pluginMetadata.ID);
 }
Пример #16
0
        private void UpdateResultView(List<Result> list, PluginMetadata metadata, Query originQuery)
        {
            Thread.Sleep(3000);
            _queryHasReturn = true;
            progressBar.Dispatcher.Invoke(new Action(StopProgress));

            list.ForEach(o =>
            {
                o.Score += UserSelectedRecordStorage.Instance.GetSelectedCount(o) * 5;
            });
            if (originQuery.RawQuery == _lastQuery.RawQuery)
            {
                UpdateResultViewInternal(list, metadata);
            }
        }
Пример #17
0
 private static void ParseSystemPlugins()
 {
     PluginMetadata metadata = new PluginMetadata();
     metadata.Name = "System Plugins";
     metadata.Author = "System";
     metadata.Description = "system plugins collection";
     metadata.Language = AllowedLanguage.CSharp;
     metadata.Version = "1.0";
     metadata.PluginType = PluginType.System;
     metadata.ActionKeyword = "*";
     metadata.ExecuteFileName = "Wox.Plugin.System.dll";
     metadata.PluginDirecotry = AppDomain.CurrentDomain.BaseDirectory;
     pluginMetadatas.Add(metadata);
 }
Пример #18
0
 public void PushResults(Query query, PluginMetadata plugin, List<Result> results)
 {
     results.ForEach(o =>
     {
         o.PluginDirectory = plugin.PluginDirectory;
         o.PluginID = plugin.ID;
         o.OriginQuery = query;
     });
     Task.Run(() =>
     {
         _mainVM.UpdateResultView(results, plugin, query);
     });
 }
Пример #19
0
 public PluginPair(PluginMetadata metadata)
 {
     this.Metadata = metadata;
     LoadPlugin();
 }