/// <summary> /// 加载插件 /// </summary> private void LoadEditorPlugInList() { this._editorPlugInList = ContainerHelper.GetExport <IEditorPlugIn>(Path.Combine(Environment.CurrentDirectory, ConfigurationManager.AppSettings["AppStartPath"])); this.labPlugInCount.Text = string.Format("加载插件数:{0}", this._editorPlugInList.Count()); foreach (var item in this._editorPlugInList.OrderBy(d => d.Order)) { var btn = new ToolStripButton() { AutoToolTip = true, //Name = string.Format("btn{0}", item.Order), Size = new Size(0x24, 0x24), Text = item.ToolTipText, ToolTipText = item.ToolTipText }; if (string.IsNullOrEmpty(item.ToolImgUrl)) { btn.DisplayStyle = ToolStripItemDisplayStyle.Text; } else { try { var img = Image.FromFile(item.ToolImgUrl); btn.DisplayStyle = ToolStripItemDisplayStyle.Image; btn.Image = img; btn.ImageTransparentColor = Color.Magenta; } catch { } } btn.Click += (s2, e2) => { bool isHave = false; foreach (TabPage tab in this.tabControl1.TabPages) { if (tab.Text == item.ToolTipText) { isHave = true; this.tabControl1.SelectedTab = tab; break; } } if (!isHave) { var uc = item.PlugInUC; uc.Dock = DockStyle.Fill; var tab = new TabPage(item.ToolTipText); tab.Controls.Add(uc); this.tabControl1.SelectedTab = tab; this.tabControl1.TabPages.Add(tab); } }; this.toolBar1.Items.Add(btn); } }