Beispiel #1
0
 /******************************8
 /// <summary>
 /// �Դ���Form������+"_"+EFDevLayoutControl������,�Լ�Ĭ������ģʽ[�ݶ��û���]����grid����
 /// </summary>
 public void SaveLayout(DevExpress.XtraLayout.LayoutControl layoutControl)
 {
     SaveLayout(layoutControl, ConfigEnum.Default);
 }
 /// <summary>
 /// �Դ���Form������+"_"+gridView������,�Լ��ƶ�������ģʽ����grid����
 /// </summary>
 /// <param name="ConfigModule">�û�������Ŀ��</param>
 public void SaveLayout(DevExpress.XtraLayout.LayoutControl layoutControl, ConfigEnum ConfigModule)
 {
     this.SaveLayout(layoutControl, ConfigModule, string.Empty, string.Empty);
 }
 ******************************/
 /// <summary>
 ///  �ļ�Ŀ¼�������򴴽�,XML��������Ϊ: className +"��������_"+EFDevLayoutControl������.XML. 
 ///  ---2011-10-27 �� XML�������� ��Ϊ "��������_"+EFDevLayoutControl������+_className.XML
 /// </summary>  
 /// <param name="ConfigModule">����Ĭ��,�û�������Ŀ��</param>
 /// <param name="className">����,�����������û���ʱ,Ϊ�����ֲ�ͬ������������ </param>   
 /// <param name="moduleName">һ��ģ������(��DE,Ϊ��ʱȡ�������Ƶĵ�4��6λ)</param>
 public void SaveLayout(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);
     if (ConfigModule == ConfigEnum.UserConfig)
     {
         //λ��UserConfig��,�û����ļ�����,һ��ģ����
         fileDirectory = fileDirectory + "\\..\\UserConfig\\" + "EF.EF_Args.formUserId" + "\\" + moduleName + "\\";
     }
     else if (ConfigModule == ConfigEnum.EPConfig)
     {
         //λ��һ��ģ����
         fileDirectory = fileDirectory + "\\..\\" + moduleName + "\\";
     }
     else
     {
         //λ��UserConfig��,�û����ļ�����,һ��ģ���� (Ĭ���û�����)
         fileDirectory = fileDirectory + "\\..\\UserConfig\\" + "EF.EF_Args.formUserId" + "\\" + moduleName + "\\";
     }
     string fileDirectory2 = "";
     try
     {
         fileDirectory2 = fileDirectory + "EC.UserConfig.Instance.Culture" + "\\";
     }
     catch { }
     //�ļ�Ŀ¼�������򴴽�[�߼���,������Ŀ����ʱ,ģ��Ŀ¼һ������,���򱨴�]
     if (!System.IO.Directory.Exists(fileDirectory))
     {
         System.IO.Directory.CreateDirectory(fileDirectory);
     }
     if (fileDirectory2 != "" && !System.IO.Directory.Exists(fileDirectory2))
     {
         System.IO.Directory.CreateDirectory(fileDirectory2);
     }
     //�����ļ���
     //string fileName = className.Trim() + formName + "_" + layoutControl.Name + ".xml";
     //  ---2011-10-27 �� XML�������� ��Ϊ "��������_"+EFDevLayoutControl������+_className.XML
     string fileName = formName + "_" + layoutControl.Name +(className.Trim().Equals("")?"":("_"+className.Trim()))+ ".xml";
     string filePath = fileDirectory + fileName;
     string filePath2 = fileDirectory2 + fileName;
     bool isFirstConfig = false;
     if (System.IO.File.Exists(filePath))
     {
         if (System.IO.File.Exists(filePath2))
         {
             //�ļ��Ѵ���,����ʾ,�Ƿ񸲸�
             if (EF.EFMessageBox.Show("�����ļ��Ѵ���,�Ƿ��滻��","��ʾ", MessageBoxButtons.YesNo) != DialogResult.Yes)
             {
                 return;
             }
         }
     }
     else
     {
         isFirstConfig = false;
     }
     if (isFirstConfig)
     {
         //��ʹ�ǵ�һ������Ҳ�����浽Ĭ��Ŀ¼��.ֻ�ŵ���Ӧ����Ŀ¼��
        // layoutControl.SaveLayoutToXml(filePath);
     }
     layoutControl.SaveLayoutToXml(filePath2);
 }
Beispiel #2
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;
                }
            }