public QuickPlugin() { m_additionMethod = new IQuickPluginMethod[] { new QuickCalc(), new QuickRun(), new QuickFind(), }; }
private void RefreshList() { var list = m_hostWindow.GetList(); list.Items.Clear(); for (int i = 0; i < MAX_DISPLAY_ACTION; i++) { int idx = m_page * MAX_DISPLAY_ACTION + i; if (idx == m_availableMethods.Count) { break; } var currentMethod = m_availableMethods[idx]; string title = Regex.Replace(currentMethod.MethodName, REG_TITLE_RULES, ""); string description = null; ImageSource icon = null; IQuickPluginMethod plugin = currentMethod.GetPluginInterface(); // 如果是一个加载项,可以调用其函数获取 if (plugin != null) { description = plugin.GetDescription(this); ImageSource tmp = null; bool needIcon = plugin.GetIcon(this, out tmp); if (needIcon) { icon = tmp; } else { icon = QuickUIResource.GetDefaultPluginIcon(); } } else { description = currentMethod.MethodDescription; if (!m_isGlobalModel) //非全局的情况下,使用当前应用程序的图标 { icon = m_bitmapSourceCache; } } QuickListItem item = new QuickListItem(title, description, icon); item.CreateListBoxItemTo(m_hostWindow.GetList()); } if (GetSelectedIndex() == -1 && m_hostWindow.GetList().HasItems) { m_hostWindow.GetList().SelectedIndex = 0; } AutoResize(); }
private static void AddToCorrectModel(Dictionary <String, QuickModel> models, IQuickPluginMethod method) { QuickMethod coreMethod = new QuickMethod(); coreMethod.MethodDefArgs = " "; coreMethod.MethodName = method.GetName(); coreMethod.MethodDescription = method.GetDescription(null); bool acceptArgs = method.AcceptArgs(); coreMethod.MethodParamRegex = acceptArgs ? "." : ""; coreMethod.SetAdditionMethod(method); bool bAddedToSpecificModel = false; foreach (var modelName in QuickConfig.ThisConfig.ModelName) { var availStr = method.AvailableApplicationName(); string[] avails = availStr != null?availStr.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries) : null; if (avails != null && avails.Contains(modelName, new ModelNameComparer())) { models[modelName].MethodList.Insert(0, coreMethod); bAddedToSpecificModel = true; } } if (!bAddedToSpecificModel) { // 如果没有加到特定的模块,则加到global中 models[QuickModel.GlobalModelName].MethodList.Insert(0, coreMethod); } }
public QuickSafePluginMethodRef(IQuickPluginMethod method) { m_method = method; }
public void SetAdditionMethod(IQuickPluginMethod method) { m_method = method; }