public bool LoadData(IApplicationRef pApplication) { if (pApplication == null) { return(false); } _pIAppFrm = pApplication as IAppFormRef; return(LoadDataByXmlNode(pApplication)); }
/// <summary> /// 根据用户权限加载窗体 /// </summary> /// <param name="pApplication"></param> /// <returns></returns> public string LoadForm(IApplicationRef pApplication) { if (pApplication == null) { return(string.Empty); } string RStr = string.Empty; _pIAppFrm = pApplication as IAppFormRef; //根据XML内容进行插件事件绑定 LoadEventsByXmlNode(); //根据XML加载系统界面 RStr = LoadControls(); return(RStr); }
/// <summary> /// 菜单栏、工具栏、右键菜单 不执行PluginOnCreate,通过以下代码直接UI化添加 /// </summary> /// <param name="aControl"></param> /// <param name="xmlnodeChild"></param> /// <param name="pApplication"></param> /// <param name="dicContextMenu"></param> /// <returns></returns> public Control LoadButtonView(Control aControl, XmlNode xmlnodeChild, IApplicationRef pApplication, Dictionary <string, ContextMenu> dicContextMenu) { string sNodeName = ""; string sNodeID = ""; string sNodeCaption = ""; string sControlType = ""; string sVisible = ""; string sEnabled = ""; string sDockStyle = ""; XmlElement xmlelementChild = xmlnodeChild as XmlElement; IAppFormRef pAppFormRef = pApplication as IAppFormRef; sNodeName = xmlelementChild.GetAttribute("Name").Trim(); sNodeID = xmlelementChild.GetAttribute("ID").Trim(); sNodeCaption = xmlelementChild.GetAttribute("Caption").Trim(); sControlType = xmlelementChild.GetAttribute("ControlType").Trim(); sVisible = xmlelementChild.GetAttribute("Visible").Trim(); sEnabled = xmlelementChild.GetAttribute("Enabled").Trim(); if (xmlelementChild.HasAttribute("DockStyle")) { sDockStyle = xmlelementChild.GetAttribute("DockStyle").Trim(); } if (pAppFormRef.ConnUser.UserCode.ToLower() != "admin") { if (sNodeID == "") { return(null); } //if (!_ListUserPrivilegeID.Contains(sNodeID)) return null; } if (sVisible == bool.FalseString.ToLower()) { return(null); } Fan.Common.SysLogInfoChangedEvent newEvent = new Fan.Common.SysLogInfoChangedEvent("加载" + sNodeCaption + "..."); SysLogInfoChnaged(null, newEvent); //实例化菜单栏、工具栏、右键菜单插件对应UI对象 //string strType = "DevComponents.DotNetBar." + sControlType + ",DevComponents.DotNetBar2,Version=8.1.0.6,Culture=neutral,PublicKeyToken=null"; string strType = "DevComponents.DotNetBar." + sControlType + ",DevComponents.DotNetBar2,Version=8.1.0.6"; Type aType = null; try { aType = Type.GetType(strType); } catch { //_SysLocalLog.WriteLocalLog("加载" + sNodeName + "异常:" + "未能获取UI对象" + sControlType + "类型"); return(null); } if (aType == null) { //_SysLocalLog.WriteLocalLog("加载" + sNodeName + "异常:" + "未能获取UI对象" + sControlType + "类型"); return(null); } Object newObject = Activator.CreateInstance(aType); Control aBarControl = newObject as Control; if (aBarControl == null) { //_SysLocalLog.WriteLocalLog("加载" + sNodeName + "异常:" + "未能创建UI对象" + sControlType); return(null); } aBarControl.Name = sNodeName; aBarControl.Text = sNodeCaption; aBarControl.Enabled = Convert.ToBoolean(sEnabled); aBarControl.Visible = Convert.ToBoolean(sVisible); if (sDockStyle != "") { switch (sDockStyle.ToLower()) { case "top": aBarControl.Dock = System.Windows.Forms.DockStyle.Top; break; case "bottom": aBarControl.Dock = System.Windows.Forms.DockStyle.Bottom; break; case "left": aBarControl.Dock = System.Windows.Forms.DockStyle.Left; break; case "right": aBarControl.Dock = System.Windows.Forms.DockStyle.Right; break; case "fill": aBarControl.Dock = System.Windows.Forms.DockStyle.Fill; break; default: aBarControl.Dock = System.Windows.Forms.DockStyle.None; break; } } bool bNotToolBar = false; if (sControlType == "ContextMenuBar") { bNotToolBar = true; } if (xmlnodeChild.HasChildNodes == false) { //_SysLocalLog.WriteLocalLog("异常:" +sNodeName + "节点下无相关内容"); } return(aBarControl); }