Пример #1
0
        /// <summary>
        /// Restore layout của Layout control
        /// </summary>
        /// <param name="FormName"></param>
        /// <param name="lctMain"></param>
        public static void RestoreLayoutForm(string FormName, DevExpress.XtraLayout.LayoutControl lctMain)
        {
            if (!Directory.Exists(UserLayoutPath))
            {
                Directory.CreateDirectory(UserLayoutPath);
            }
            string path = UserLayoutPath + @"\" + FormName + ".xml";

            if (File.Exists(path))
            {
                lctMain.RestoreLayoutFromXml(path);
            }
        }
Пример #2
0
 /// <summary>
 /// 加载控件样式
 /// </summary>
 /// <param name="layoutControl"></param>
 /// <param name="formName"></param>
 public static void RestoreControlLayout(this DevExpress.XtraLayout.LayoutControl layoutControl, string formName)
 {
     try
     {
         string path = @"C:\TigerApp\";
         if (!Directory.Exists(path))
         {
             Directory.CreateDirectory(path);
         }
         path = path + formName + "." + layoutControl.Name + ".xml";
         if (File.Exists(path))
         {
             layoutControl.RestoreLayoutFromXml(path);
         }
     }
     catch (Exception ex)
     {
         throw new Exception("加载样式出错:" + ex.Message);
     }
 }
Пример #3
0
            /// <summary>
            ///  寻找(以className+窗体Form的名称+"_"+EFDevLayoutControl的名称)的配置文件.加载布局..根据参数(配置模式)选择对应目录下的配置文件.
            /// </summary>
            /// <param name="ConfigModule">配置模式,默认时先查找用户配置,再查找项目级配置..</param>
            /// <param name="className">类名称[当窗体名称_+EFDevLayoutControl名称不能满足唯一xml文件名需求时,在开头添加类名称</param>
            /// <param name="moduleName">一级模块名称.如DE,FI等</param>
            public void LoadLayout(DevExpress.XtraLayout.LayoutControl layoutControl, ConfigEnum ConfigModule, string className, string moduleName)
            {
                //模块名称
                string formName = layoutControl.FindForm().Name;

                if (moduleName.Trim().Equals(""))
                {
                    moduleName = formName.Length > 6 ? formName.Substring(4, 2) : formName;
                }
                if (formName.StartsWith("Form"))
                {
                    formName = formName.Substring(4);
                }
                //XML路径
                string fileDirectory = System.Reflection.Assembly.GetExecutingAssembly().Location;

                fileDirectory = Path.GetDirectoryName(fileDirectory);
                string fileDirectoryUser = fileDirectory + "\\..\\UserConfig\\" + "EF.EF_Args.formUserId" + "\\" + moduleName + "\\";
                string fileDirectoryEP   = fileDirectory + "\\..\\" + moduleName + "\\";

                //先查看用户级配置,目录不存在读取项目配置
                //  ---2011-10-27 把 XML配置名称 改为 "窗体名称_"+EFDevLayoutControl的名称+_className.XML
                string fileName = formName + "_" + layoutControl.Name + (className.Trim().Equals("") ? "" : ("_" + className.Trim())) + ".xml";
                //string fileName = className.Trim() + formName + "_" + layoutControl.Name + ".xml";
                string filePath = "";

                if (ConfigModule == ConfigEnum.EPConfig)
                {
                    filePath = fileDirectoryEP + fileName;
                }
                else if (ConfigModule == ConfigEnum.UserConfig)
                {
                    filePath = fileDirectoryUser + fileName;
                }
                else //默认配置.先读取用户级配置,不存在则读取项目级配置
                {
                    filePath = fileDirectoryUser + fileName;
                    if (!IsFileExit(ref filePath))  //不存在,则读取项目级的
                    {
                        filePath = fileDirectoryEP + fileName;
                    }
                }

                if (IsFileExit(ref filePath))      // (System.IO.File.Exists(filePath))  //存在,则读取
                {
                    //string EPConfigXML = fileDirectoryEP + fileName; //项目级配置xml
                    //项目级配置xml 如果存在就麻烦了---不存在,则直接读取配置文件
                    //---先加载项目级配置,把不可见的项,设置为不可配置
                    //---如果是用户配置则 "再加载用户级配置",否则退出
                    //---再把不可配置项设为不可见
                    //if (System.IO.File.Exists(EPConfigXML))
                    //{
                    //    layoutControl.RestoreLayoutFromXml(EPConfigXML);
                    //    if (view is DevExpress.XtraGrid.Views.Grid.GridView)
                    //    {
                    //        foreach (DevExpress.XtraGrid.Columns.GridColumn gridCol in ((DevExpress.XtraGrid.Views.Grid.GridView)view).Columns)
                    //        {
                    //            gridCol.OptionsColumn.ShowInCustomizationForm = gridCol.Visible;
                    //        }
                    //    }
                    //    //然后加载用户级配置
                    //    if (filePath.Equals(EPConfigXML))
                    //    {
                    //        break;
                    //    }
                    //    view.RestoreLayoutFromXml(filePath);
                    //    //然后再次检查,把项目级不可见的,也设为不可见
                    //    if (view is DevExpress.XtraGrid.Views.Grid.GridView)
                    //    {
                    //        foreach (DevExpress.XtraGrid.Columns.GridColumn gridCol in ((DevExpress.XtraGrid.Views.Grid.GridView)view).Columns)
                    //        {
                    //            gridCol.Visible = gridCol.OptionsColumn.ShowInCustomizationForm;
                    //        }
                    //    }
                    //}
                    //else
                    //{
                    //    view.RestoreLayoutFromXml(filePath);
                    //}
                    layoutControl.RestoreLayoutFromXml(filePath);
                    // return true;
                }
                else
                {
                    // return false;
                }
            }