private void RemoveMenuStripForApplication(WinShellApplication application) { RemoveMenuStripForApplicationDelegate del = (WinShellApplication app) => { if (ApplicationMenuStripMap.ContainsKey(app)) { // 删除菜单、Map、显示的TabPage TopMenuStrip.Items.Remove(ApplicationMenuStripMap[app]); ApplicationMenuStripMap.Remove(app); foreach (TabPage tab in WorkspaceTabControl.TabPages) { var menu = tab.Tag as WinShellMenu; if (menu.Application.Equals(app)) // 清除Selection { var index = WorkspaceTabControl.SelectedIndex; if (index > 0 && tab.Equals(WorkspaceTabControl.SelectedTab)) { WorkspaceTabControl.SelectedIndex = index - 1; } WorkspaceTabControl.TabPages.Remove(tab); } } } }; // 如果当前线程不是界面线程,则通过Invoke来处理界面变更 if (InvokeRequired) { Invoke(del, application); } else // 否则,直接操作界面 { del(application); } }
private void CreateMenuStripForApplication(WinShellApplication application) { CreateMenuStripForApplicationDelegate del = (WinShellApplication app) => { // 为WinShellApplication创建根菜单节点 var topToolStripItem = TopMenuStrip.Items.Add(app.Title, LoadImage(app.Bundle, app.Icon)) as ToolStripMenuItem; topToolStripItem.ToolTipText = app.ToolTip; // 创建子菜单节点 CreateChildMenu(app.Menus, topToolStripItem.DropDownItems); // 添加到WinShellApplication和顶层菜单节点对应表 ApplicationMenuStripMap.Add(app, topToolStripItem); }; // 如果当前线程不是界面线程,则通过Invoke来处理界面变更 if (InvokeRequired) { Invoke(del, application); } else // 否则,直接操作界面 { del(application); } }
public void btn_Click(object sender, EventArgs e) { try { WinShellApplication app = ((PictureBox)sender).Tag as WinShellApplication; ThreadMessageTransact.Instance.triggerEvent(new ProcessRecord { OPERATER_TYPE = app.OperaterType }, false); } catch (Exception ex) { LogHelper.Log.Error(ex.Message); } }
/// <summary> /// 获取子扩展点信息 /// </summary> /// <param name="EXTENS_POINT"></param> /// <returns></returns> public List <WinShellApplication> GetChildrenExtensions(IBundleContext Context) { List <WinShellApplication> WinShellAppCollections = new List <WinShellApplication>(); var extensions = Context.GetExtensions(EXTENS_POINT); string extensType = string.Empty; string extensName = string.Empty; foreach (var extension in extensions) { foreach (XmlNode node in extension.Data) { if (node is XmlComment) { continue; } WinShellApplication app = new WinShellApplication(); app.Bundle = extension.Owner; if (!string.IsNullOrEmpty(node.Attributes["Text"].Value)) { app.ExtensName = node.Attributes["Text"].Value; } if (!string.IsNullOrEmpty(node.Attributes["ToolTip"].Value)) { app.ExtensText = node.Attributes["ToolTip"].Value; } if (!string.IsNullOrEmpty(node.Attributes["Class"].Value)) { app.ExtensType = node.Attributes["Class"].Value; } if (!string.IsNullOrEmpty(node.Attributes["Icon"].Value)) { app.Icon = node.Attributes["Icon"].Value; } if (null != node.Attributes["OperaterType"] && !string.IsNullOrEmpty(node.Attributes["OperaterType"].Value)) { app.OperaterType = (enumOperaterType)(System.Enum.Parse(typeof(enumOperaterType), node.Attributes["OperaterType"].Value, false)); } WinShellAppCollections.Add(app); } } return(WinShellAppCollections); }
public void InitExtensionControl(ExtensionArgs args) { MethodInvoker method = null; try { if (base.InvokeRequired) { if (method == null) { method = () => this.InitExtensionControl(args); } base.Invoke(method); } else { List <FN_LAYOUT_SUBJECT> plugins = EngineContext.Current.Resolve <IFN_LAYOUT_SUBJECT>().GetPlugins(GlobalEnvironment.WorkStationInfo.ID, this._Plugin.ID); using (List <FN_LAYOUT_SUBJECT> .Enumerator enumerator = plugins.GetEnumerator()) { Func <WinShellApplication, bool> predicate = null; FN_LAYOUT_SUBJECT pluginInfo; while (enumerator.MoveNext()) { pluginInfo = enumerator.Current; if (predicate == null) { predicate = x => x.ExtensName == pluginInfo.CLIENT_TYPE; } WinShellApplication application = args.extensions.Where <WinShellApplication>(predicate).FirstOrDefault <WinShellApplication>(); if (null != application) { decimal? nullable2; UserControl control = System.Activator.CreateInstance(application.Bundle.LoadClass(application.ExtensType), new object[] { pluginInfo }) as UserControl; decimal? wIDTH = pluginInfo.WIDTH; decimal width = base.Width; nullable2 = (wIDTH.HasValue ? new decimal?(wIDTH.GetValueOrDefault() * width) : ((decimal?)(nullable2 = null))) / 100M; control.Width = (int)nullable2.Value; wIDTH = pluginInfo.HEIGHT; width = base.Height; nullable2 = (wIDTH.HasValue ? new decimal?(wIDTH.GetValueOrDefault() * width) : ((decimal?)(nullable2 = null))) / 100M; control.Height = (int)nullable2.Value; wIDTH = pluginInfo.LEEF_X; width = base.Width; nullable2 = (wIDTH.HasValue ? new decimal?(wIDTH.GetValueOrDefault() * width) : ((decimal?)(nullable2 = null))) / 100M; int num = (int)nullable2.Value; wIDTH = pluginInfo.LEEF_Y; width = base.Height; nullable2 = (wIDTH.HasValue ? new decimal?(wIDTH.GetValueOrDefault() * width) : ((decimal?)(nullable2 = null))) / 100M; int y = ((int)nullable2.Value) + this.topTitleHeight; y = ((y + this.topTitleHeight) > base.Height) ? (base.Height - control.Height) : y; control.Location = new Point(num, y); base.Controls.Add(control); } } } } } catch (Exception exception) { LogHelper.Log.Error(exception.Message); } }