private void pluginItem_Click(object sender, EventArgs e) { if (lv_shell.SelectedItems.Count > 0) { ToolStripMenuItem item = sender as ToolStripMenuItem; if (item != null) { IPlugin plugin = item.Tag as IPlugin; ShellStruct shellStruct = (ShellStruct)lv_shell.SelectedItems[0].Tag; shellStruct.TimeOut = 8000; UserControl view = plugin.GetUi(shellStruct); //创建新的tab标签 TabCore.CreateNewTabPage(plugin.PluginAttribute.Title, view); } } }
private void pluginRun_Click(object sender, EventArgs e) { IPlugin plugin = (IPlugin)(sender as ToolStripMenuItem).Tag; if (plugin == null) { return; } if (plugin is IControlPlugin) { UserControl view = (plugin as IControlPlugin).GetUi(new Shell()); //创建新的tab标签 //设置标题为FileManager|TargetId string title = plugin.PluginInfo.Name; TabCore.CreateNewTabPage(title, view); } else if (plugin is IFormPlugin) { Form form = (plugin as IFormPlugin).GetUi(new Shell()); form.Show(); } }
private void AutoLoadPlugins(IEnumerable <IPlugin> plugins) { //IsAutoLoad foreach (var plugin in plugins) { //IsAutoLoad if (plugin.PluginSetting.IsAutoLoad) { string title = plugin.PluginInfo.Name; if (plugin is IControlPlugin) { UserControl view = (plugin as IControlPlugin).GetUi(new Shell()); //创建新的tab标签 TabCore.CreateNewTabPage(title, view); } else if (plugin is IFormPlugin) { Form form = (plugin as IFormPlugin).GetUi(new Shell()); form.Show(); } } } }
public void CreateNewTabPage(string tabPageName, UserControl control) { TabCore.CreateNewTabPage(tabPageName, control); }
public FormMain() { InitializeComponent(); //CheckForIllegalCrossThreadCalls = false; //目录初始化 if (!Directory.Exists("Bin")) { Directory.CreateDirectory("Bin"); } if (!Directory.Exists("Plugins")) { Directory.CreateDirectory("Plugins"); } if (!Directory.Exists("Plugins/Config")) { Directory.CreateDirectory("Plugins/Config"); } if (!Directory.Exists("Languages")) { Directory.CreateDirectory("Languages"); } //----导入插件---- _pluginsImport = new PluginsImport(); _host = new Host(this); Compose(); //----导入插件结束---- //----数据初始化---- InitUi.InitCustomShellType(); InitUi.InitGlobalSetting(); //----数据初始化结束---- //----UI处理---- //tabControl事件绑定 tabControl1.DoubleClick += tabControl1_DoubleClick; //设置版本号 toolStripStatusLabel_productVersion.Text = string.Format("Version:{0}@KeePwn", Assembly.GetExecutingAssembly().GetName().Version); //tabControl初始化 TabCore.Init(this, this.tabControl1); //treenode TreeNode treeNodeRoot1; treeNodeRoot1 = InitUi.GetCustomShellTypeTree(); treeNodeRoot1.Name = "ShellType"; treeNodeRoot1.Text = "ShellType"; this.treeView_func.Nodes.AddRange(new TreeNode[] { treeNodeRoot1 }); //plugins LoadPluginsInUi(_pluginsImport.Plugins.OrderBy(p => p.PluginSetting.IndexInList).ThenBy(p => p.PluginInfo.Name)); //----UI处理结束---- //显示免责声明 InitUi.InitWelcome(); //auto load plugins AutoLoadPlugins(_pluginsImport.Plugins); }
public FormMain() { InitializeComponent(); //CheckForIllegalCrossThreadCalls = false; //目录初始化 if (!Directory.Exists("Bin")) { Directory.CreateDirectory("Bin"); } if (!Directory.Exists("Plugins")) { Directory.CreateDirectory("Plugins"); } if (!Directory.Exists("Plugins/Config")) { Directory.CreateDirectory("Plugins/Config"); } if (!Directory.Exists("Languages")) { Directory.CreateDirectory("Languages"); } /*使用MEF导入插件 * MEF的使用步骤: * 1.导出标指定对象[Export]; * 2.在宿主代码中设定[Import]; * 3.组合部件(主要是将宿主中Import和导出Export对象进行引用链接); * 4.使用导入的对象。*/ //----导入插件---- _pluginsImport = new PluginsImport(); _host = new Host(this);//该接口类实例将作为参数传递给MEF导入类的构造函数,方便导入对象使用 Compose(); //----导入插件结束---- //----数据初始化---- InitUi.InitCustomShellType(); //读取指定目录的CustomShellType文件内容到程序中,并进行相关设置 InitUi.InitGlobalSetting(); //读取指定目录的Setting文件内容到程序中,并进行相关设置 //----数据初始化结束---- //----UI处理---- //tabControl事件绑定 tabControl1.DoubleClick += tabControl1_DoubleClick;//添加双击Tab选项卡标题则关闭选项卡的事件处理函数 //设置版本号 toolStripStatusLabel_productVersion.Text = string.Format("Version:{0}@KeePwn", Assembly.GetExecutingAssembly().GetName().Version); //tabControl初始化 TabCore.Init(this, this.tabControl1);//TabCore类的作用主要是在TabControl中添加新的TabPage //treenode TreeNode treeNodeRoot1; treeNodeRoot1 = InitUi.GetCustomShellTypeTree(); treeNodeRoot1.Name = "ShellType"; treeNodeRoot1.Text = "ShellType"; this.treeView_func.Nodes.AddRange(new TreeNode[] { treeNodeRoot1 }); //加载Plugins菜单项 LoadPluginsInUi(_pluginsImport.Plugins.OrderBy(p => p.PluginSetting.IndexInList).ThenBy(p => p.PluginInfo.Name)); //----UI处理结束---- //显示免责声明 InitUi.InitWelcome(); //auto load plugins AutoLoadPlugins(_pluginsImport.Plugins); }