Пример #1
0
 /// <summary>
 /// 初始化插件内容
 /// </summary>
 /// <param name="plugin"></param>
 /// <param name="pApplication"></param>
 private void PluginOnCreate(IPlugin plugin, IApplicationRef pApplication)
 {
     if (plugin is ICommandRef)
     {
         ICommandRef cmd = plugin as ICommandRef;
         cmd.OnCreate(pApplication);
     }
     else if (plugin is IToolRef)
     {
         IToolRef atool = plugin as IToolRef;
         atool.OnCreate(pApplication);
     }
     else if (plugin is IMenuRef)
     {
         IMenuRef aMenu = plugin as IMenuRef;
         aMenu.OnCreate(pApplication);
     }
     else if (plugin is IToolBarRef)
     {
         IToolBarRef aToolBar = plugin as IToolBarRef;
         aToolBar.OnCreate(pApplication);
     }
     else if (plugin is IDockableWindowRef)
     {
         IDockableWindowRef aDockableWindow = plugin as IDockableWindowRef;
         aDockableWindow.OnCreate(pApplication);
     }
     else if (plugin is IControlRef)
     {
         IControlRef aControl = plugin as IControlRef;
         aControl.OnCreate(pApplication);
     }
 }
Пример #2
0
        /// <summary>
        /// 初始化插件内容
        /// </summary>
        /// <param name="plugin"></param>
        /// <param name="pApplication"></param>
        private void PluginOnLoadData(IPlugin plugin, IApplicationRef pApplication)
        {
            IControlRef aControl = plugin as IControlRef;

            if (aControl != null)
            {
                aControl.LoadData();
            }
        }
Пример #3
0
        public bool LoadData(IApplicationRef pApplication)
        {
            if (pApplication == null)
            {
                return(false);
            }

            _pIAppFrm = pApplication as IAppFormRef;

            return(LoadDataByXmlNode(pApplication));
        }
Пример #4
0
        /// <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);
        }
Пример #5
0
 public virtual void OnCreate(IApplicationRef hook)
 {
 }
Пример #6
0
        private bool AddItemsByXmlNode(object aControl, XmlNode xmlNodeCol, bool bImageAndText, IApplicationRef pApplication)
        {
            //if (xmlNodeCol.HasChildNodes == false)
            //{
            //    return false;
            //}

            //string sNodeNameImage = "";
            //string sNodeName = "";
            //string sNodeID = "";
            //string sNodeCaption = "";
            //string sControlType = "";
            //string sVisible = "";
            //string sEnabled = "";
            //string sTips = "";
            //string sNewGroup = "";
            //string strWritelog = "";

            //bool bRes = true;

            //foreach (XmlNode aXmlnode in xmlNodeCol.ChildNodes)
            //{
            //    try
            //    {
            //        XmlElement xmlelementChild = aXmlnode as XmlElement;
            //        IAppFormRef pAppFormRef = pApplication as IAppFormRef;
            //        if(xmlelementChild.Name.ToLower()!="subitems") continue;

            //        sNodeName = xmlelementChild.GetAttribute("Name").Trim();
            //        sNodeID = xmlelementChild.GetAttribute("ID").Trim();
            //        sNodeNameImage = sNodeName;
            //        sNodeCaption = xmlelementChild.GetAttribute("Caption").Trim();
            //        sControlType = xmlelementChild.GetAttribute("ControlType").Trim();
            //        sVisible = xmlelementChild.GetAttribute("Visible").Trim();
            //        sEnabled = xmlelementChild.GetAttribute("Enabled").Trim();
            //        try
            //        {
            //            strWritelog = xmlelementChild.GetAttribute("WriteLog").Trim();
            //        }
            //        catch
            //        { }
            //        if(xmlelementChild.HasAttribute("Tips"))
            //        {
            //            sTips = xmlelementChild.GetAttribute("Tips").Trim();
            //        }
            //        if (pAppFormRef.ConnUser.UserCode.ToLower() != "admin")
            //        {
            //            if (sNodeID == "") continue;
            //            if (!_ListUserPrivilegeID.Contains(sNodeID)) continue;
            //        }
            //        sNewGroup = xmlelementChild.GetAttribute("NewGroup").Trim();

            //        if (sVisible == bool.FalseString.ToLower()) continue;
            //        _SysLocalLog.WriteLocalLog("加载" + sNodeName);

            //        Fan.Common.SysLogInfoChangedEvent newEvent = new Fan.Common.SysLogInfoChangedEvent("加载" + sNodeCaption + "...");
            //        SysLogInfoChnaged(null, newEvent);

            //        //判断插件中是否存在该项(注意:sNodeName中可能是组合字符串——代表要实例化插件用于避免冲突)
            //        if (v_dicPlugins.ContainsKey(sNodeName))
            //        {
            //            // 初始化插件内容
            //            PluginOnCreate(v_dicPlugins[sNodeName], pApplication);
            //            PluginOnWriteLog(v_dicPlugins[sNodeName], strWritelog);
            //        }
            //        else
            //        {
            //            //实例化插件
            //            bool bTemp = false;
            //            foreach (string key in v_dicPlugins.Keys)
            //            {
            //                if (sNodeName.Contains(key))    //loged by chulili 20111214 @@重要 为什么用Contains不用Equal
            //                {
            //                    Type aTypeTemp = v_dicPlugins[key].GetType();
            //                    IPlugin plugin = Activator.CreateInstance(aTypeTemp) as IPlugin;
            //                    if(plugin!=null)
            //                    {
            //                        v_dicPlugins.Add(sNodeName, plugin);
            //                    }

            //                    ICommandRef cmd = plugin as ICommandRef;
            //                    if (cmd != null)
            //                    {
            //                        v_dicCommands.Add(sNodeName, cmd);
            //                    }
            //                    IToolRef atool = plugin as IToolRef;
            //                    if (atool != null)
            //                    {
            //                        v_dicTools.Add(sNodeName, atool);
            //                    }

            //                    // 初始化插件内容
            //                    PluginOnCreate(v_dicPlugins[sNodeName], pApplication);

            //                    bTemp = true;
            //                    sNodeNameImage = key;
            //                    break;
            //                }
            //            }

            //            if (bTemp == false && aXmlnode.HasChildNodes == false)
            //            {
            //                bRes = false;
            //                _SysLocalLog.WriteLocalLog("加载" + sNodeName + "异常:" + "未找到对应的插件");
            //                continue;
            //            }
            //        }

            //        //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
            //        {
            //             bRes = false;
            //            _SysLocalLog.WriteLocalLog("加载" + sNodeName + "异常:" + "未能获取UI对象" + sControlType + "类型");
            //            continue;
            //        }
            //        if (aType == null)
            //        {
            //            bRes = false;
            //            _SysLocalLog.WriteLocalLog("加载" + sNodeName + "异常:" + "未能获取UI对象" + sControlType + "类型");
            //            continue;
            //        }
            //        Object newObject = Activator.CreateInstance(aType);

            //        DevExpress.XtraBars.BarItem aBaseItem = newObject as DevExpress.XtraBars.BarItem;
            //        if (aBaseItem == null)
            //        {
            //            bRes = false;
            //            _SysLocalLog.WriteLocalLog("加载" + sNodeName + "异常:" + "未能创建UI对象" + sControlType);
            //            continue;
            //        }

            //        aBaseItem.Name = sNodeName;
            //        aBaseItem.Enabled = Convert.ToBoolean(sEnabled);


            //        XmlElement xmlelementTips = (XmlElement)aXmlnode.SelectSingleNode(".//Tips");
            //        if(xmlelementTips==null || sTips!="")
            //        {
            //        }
            //        else if(xmlelementTips!=null)
            //        {
            //            string strbogyImage=xmlelementTips.GetAttribute("BodyImage");
            //            string strfooterImage=xmlelementTips.GetAttribute("FooterImage");
            //            Image bogyImage = null;
            //            Image footerImage=null;
            //            if(File.Exists(_ResPath + "\\"+strbogyImage+".png"))
            //            {
            //                bogyImage=Image.FromFile(_ResPath + "\\"+strbogyImage+".png");
            //            }
            //            if (File.Exists(_ResPath + "\\" + strfooterImage + ".png"))
            //            {
            //                footerImage = Image.FromFile(_ResPath + "\\" + strfooterImage + ".png");
            //            }
            //        }

            //        //状态栏提示
            //        _dicBaseItems.Add(aBaseItem, sNodeName);
            //       DevExpress.XtraBars.Bar aRibbonBar = aControl as DevExpress.XtraBars.Bar;
            //        if (aRibbonBar != null)
            //        {
            //        }

            //        DevExpress.XtraBars.BarButtonItem contextMemuButtonItem = aControl as DevExpress.XtraBars.BarButtonItem;
            //        if (contextMemuButtonItem != null)
            //        {
            //        }


            //        if (aXmlnode.HasChildNodes == true)
            //        {
            //            if (AddItemsByXmlNode(aBaseItem, aXmlnode, bImageAndText, pApplication) == false)
            //            {
            //                bRes = false;
            //            }
            //        }
            //    }
            //    catch (Exception e)
            //    {
            //        bRes = false;
            //        _SysLocalLog.WriteLocalLog("出错:" + e.Message);
            //    }
            //}


            return(true);
        }
Пример #7
0
        /// <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);
        }
Пример #8
0
        /// <summary>
        /// 匹配所有的Xml节点(菜单栏、工具栏、右键菜单)来构造界面
        /// </summary>
        public bool LoadButtonViewByXmlNode(Control aControl, string xPath, IApplicationRef pApplication)
        {
            return(true);
            // if (aControl == null || xPath == string.Empty || _SysXmlDocument == null || v_dicPlugins == null || pApplication == null)
            // {
            //     _SysLocalLog.WriteLocalLog("异常:" + "存在未设置的变量");
            //     return false;
            // }

            //RibbonControl aRibbonControl = aControl as RibbonControl;
            // if (aRibbonControl == null)
            // {
            //     _SysLocalLog.WriteLocalLog("异常:" + "控件容器类型不是RibbonControl");
            //     return false;
            // }

            // XmlNode xmlnode = _SysXmlDocument.SelectSingleNode(xPath);
            // if (xmlnode == null)
            // {
            //     _SysLocalLog.WriteLocalLog("异常:" + "XML中未找到" + xPath + "节点");
            //     return false;
            // }

            // XmlElement XmlElementSys=xmlnode as XmlElement;
            // string strNameSys=XmlElementSys.GetAttribute("Name");

            // if (xmlnode.HasChildNodes == false)
            // {
            //     _SysLocalLog.WriteLocalLog("异常:" + xPath + "节点下无相关内容");
            //     return false;
            // }
            // aRibbonControl.Height = 120;        //added by chulili 限制整栏菜单的高度
            // //右键菜单集合
            // Dictionary<string, DevExpress.XtraBars.PopupMenu> dicContextMenu = new Dictionary<string, DevExpress.XtraBars.PopupMenu>();
            // IAppFormRef pAppFormRef = pApplication as IAppFormRef;
            // bool bRes = true;
            // foreach (XmlNode xmlnodeChild in xmlnode.ChildNodes)
            // {
            //     try
            //     {
            //         XmlElement xmlelementChild = xmlnodeChild as XmlElement;

            //         string sNodeName = xmlelementChild.GetAttribute("Name").Trim();
            //         string sNodeID = xmlelementChild.GetAttribute("ID").Trim();
            //         string sNodeCaption = xmlelementChild.GetAttribute("Caption").Trim();
            //         string sControlType = xmlelementChild.GetAttribute("ControlType").Trim();
            //         string sVisible = xmlelementChild.GetAttribute("Visible").Trim();
            //         string sEnabled = xmlelementChild.GetAttribute("Enabled").Trim();
            //         if (pAppFormRef.ConnUser.UserCode.ToLower() != "admin")
            //         {
            //             if (sNodeID == "")
            //             {
            //                 continue;
            //             }
            //             if (!_ListUserPrivilegeID.Contains(sNodeID)) continue;
            //         }
            //         Fan.Common.SysLogInfoChangedEvent newEvent = new Fan.Common.SysLogInfoChangedEvent("加载" + sNodeCaption + "...");
            //         SysLogInfoChnaged(null, newEvent);

            //         if (sControlType == "RibbonTabItem")   //菜单类型节点  根据XML中xmlnodeChild相关属性UI化界面Tab
            //         {
            //             DevExpress.XtraBars.Ribbon.RibbonPage aRibbonPanel = new DevExpress.XtraBars.Ribbon.RibbonPage();
            //             aRibbonPanel.Name = "RibbonPanel" + sNodeName;

            //             DevExpress.XtraBars.Ribbon.RibbonPage aRibbonTabItem = new DevExpress.XtraBars.Ribbon.RibbonPage();
            //             aRibbonTabItem.Name = sNodeName;
            //             aRibbonTabItem.Text = sNodeCaption;
            //             aRibbonTabItem.Visible = Convert.ToBoolean(sVisible);

            //             //if (aRibbonControl.Controls.ContainsKey(aRibbonPanel.Name) || aRibbonControl.Items.Contains(aRibbonTabItem.Name))
            //             //{
            //             //    bRes = false;
            //             //     _SysLocalLog.WriteLocalLog("异常:存在相同名称的RibbonTabItem节点");
            //             //    continue;
            //             //}

            //             //aRibbonControl.Controls.Add(aRibbonPanel);
            //             //aRibbonControl.Items.Add(aRibbonTabItem);
            //             //aRibbonControl.Expanded = true;

            //             _dicTabs.Add(aRibbonTabItem, strNameSys);
            //             //绑定菜单事件
            //             //aRibbonTabItem.Click += new EventHandler(RibbonTabItem_Click);

            //             foreach (XmlNode aXmlnode in xmlnodeChild.ChildNodes)
            //             {
            //                 //if (LoadButtonView(aRibbonPanel, aXmlnode, pApplication, dicContextMenu) == null)
            //                 //{
            //                 //    bRes = false;
            //                 //}
            //             }
            //             continue;
            //         }

            //         //右键菜单
            //         //if (LoadButtonView(null, xmlnodeChild, pApplication, dicContextMenu) == null)
            //         //{
            //         //    bRes = false;
            //         //}
            //     }
            //     catch (Exception e)
            //     {
            //         bRes = false;
            //         _SysLocalLog.WriteLocalLog("出错:" + e.Message);
            //     }
            // }

            // //IAppFormRef pAppFormRef = pApplication as IAppFormRef;
            // if (pAppFormRef != null)
            // {
            //     //pAppFormRef.DicContextMenu = dicContextMenu;
            // }


            // return bRes;
        }
Пример #9
0
        /// <summary>
        /// 根据XML加载系统界面
        /// </summary>
        private bool LoadDataByXmlNode(IApplicationRef pApplication)
        {
            return(true);
            // IAppFormRef pAppFormRef = pApplication as IAppFormRef;
            // if (pAppFormRef == null)
            // {
            //     _SysLocalLog.WriteLocalLog("异常:" + "AppFormRef未设置");
            //     return false;
            // }
            // if (pAppFormRef.MainForm == null)
            // {
            //     _SysLocalLog.WriteLocalLog("异常:" + "AppFormRef中变量MainForm未设置");
            //     return false;
            // }
            // //修改窗体标题
            // string xPath = "//Main";
            // XmlNode xmlnode = _SysXmlDocument.SelectSingleNode(xPath);
            // if (xmlnode == null)
            // {
            //     _SysLocalLog.WriteLocalLog("异常:" + "XML中未找到Main节点");
            //     return false;
            // }
            //string sNodeName = "";
            // string sControlType = "";
            // string sVisible = "";
            // //初始化加载控件
            // bool bRes = true;
            // foreach (XmlNode xmlnodeChild in xmlnode.ChildNodes)
            // {
            //     try
            //     {
            //         XmlElement xmlelementChild = xmlnodeChild as XmlElement;
            //         sNodeName = xmlelementChild.GetAttribute("Name").Trim();
            //         sControlType = xmlelementChild.GetAttribute("ControlType").Trim();
            //         if (sVisible == bool.FalseString.ToLower())  //获取子系统是否加载 对应Visible
            //             continue;
            //         _SysLocalLog.WriteLocalLog("***************************************");
            //         _SysLocalLog.WriteLocalLog("开始加载" + sNodeName);
            //         if (sControlType == "UserControl")
            //         {
            //             //判断插件中是否存在该项
            //             if (v_dicPlugins.ContainsKey(sNodeName))
            //             {
            //                 //根据IControlRef初始化加载用户自定义控件内容
            //                 PluginOnLoadData(v_dicPlugins[sNodeName], pApplication);
            //             }
            //             else
            //             {
            //                 bRes = false;
            //                 _SysLocalLog.WriteLocalLog("加载" + sNodeName + "异常:" + "未找到对应的插件");
            //                 _SysLocalLog.WriteLocalLog("完成加载" + sNodeName);
            //                 _SysLocalLog.WriteLocalLog("***************************************");
            //                 continue;
            //             }
            //         }
            //         _SysLocalLog.WriteLocalLog("完成加载" + sNodeName);
            //         _SysLocalLog.WriteLocalLog("***************************************");

            //     }
            //     catch (Exception e)
            //     {
            //         bRes = false;
            //         _SysLocalLog.WriteLocalLog("出错:" + e.Message);
            //     }
            // }
            // _SysLocalLog.LogClose();
            // return bRes;
        }