Ejemplo n.º 1
0
        /// <summary>
        /// 执行PivotGrid 自定义事件。
        /// </summary>
        /// <param name="containerForm"></param>
        /// <param name="xtraGrid"></param>
        /// <param name="menuType"></param>
        public void HandleClickXtraContextMenu(MB.WinBase.IFace.IForm containerForm,
                                               PivotGridEx xtraGrid, XtraContextMenuType menuType)
        {
            if (containerForm == null)
            {
                return;
            }
            switch (menuType)
            {
            case XtraContextMenuType.Sort:
                break;

            case XtraContextMenuType.Style:
                break;

            case XtraContextMenuType.SaveDefaultStyle:
                showFrmGridLayoutManager(containerForm, xtraGrid);     //modify by aifang 2012-6-7
                //SavePivotGridLayout(containerForm, xtraGrid);
                //xtraGrid.ShowPrintPreview();
                break;

            default:
                break;
            }
        }
Ejemplo n.º 2
0
        public void SavePivotGridLayout(MB.WinBase.IFace.IForm containerForm, PivotGridEx xtraGrid)
        {
            string name = getLayoutXmlSaveName(containerForm.ClientRuleObject, xtraGrid);

            if (!System.IO.Directory.Exists(LAYOUT_XML_PATH))
            {
                System.IO.Directory.CreateDirectory(LAYOUT_XML_PATH);
            }

            xtraGrid.SaveLayoutToXml(LAYOUT_XML_PATH + name);
            //xtraGrid.SaveLayoutToXml(name);
        }
Ejemplo n.º 3
0
        public void RestoreLayout(DevExpress.XtraPivotGrid.PivotGridControl gridCtl, MB.WinBase.IFace.IClientRuleQueryBase baseRule)
        {
            PivotGridEx pivotGrid = gridCtl as PivotGridEx;

            if (pivotGrid == null)
            {
                return;
            }
            string name = getLayoutXmlSaveName(baseRule, pivotGrid);

            if (System.IO.File.Exists(LAYOUT_XML_PATH + name))
            {
                gridCtl.OptionsLayout.Columns.RemoveOldColumns = true;
                gridCtl.RestoreLayoutFromXml(LAYOUT_XML_PATH + name);
            }
        }
Ejemplo n.º 4
0
        public void DeletePivotGridLayout(MB.WinBase.IFace.IForm containerForm, PivotGridEx xtraGrid, GridLayoutInfo layoutInfo)
        {
            string name = getLayoutXmlSessionName(containerForm.ClientRuleObject, xtraGrid);

            if (layoutInfo != null)
            {
                name = name + "~" + layoutInfo.Name + ".xml";
            }

            if (string.IsNullOrEmpty(name))
            {
                return;
            }

            if (System.IO.File.Exists(LAYOUT_XML_PATH + name))
            {
                System.IO.File.Delete(LAYOUT_XML_PATH + name);
            }
        }
Ejemplo n.º 5
0
        private string getLayoutXmlSaveName(MB.WinBase.IFace.IClientRuleQueryBase baseRule, PivotGridEx xtraGrid)
        {
            try
            {
                if (xtraGrid.ParentForm == null)
                {
                    return(null);
                }
                string         layoutXmlName = getLayoutXmlSessionName(baseRule, xtraGrid);
                GridLayoutInfo layoutInfo    = GetPivotGridActiveLayout(baseRule, xtraGrid);
                //add by aifang 2012-08-29 begin
                //判断状态保存日期是否大于动态列设置日期,如是,则生效,否则不生效。
                DateTime dt             = layoutInfo.CreateTime;
                var      dynamicSetting = XtraGridDynamicHelper.Instance.GetXtraGridDynamicSettingInfo(baseRule);
                if (dynamicSetting != null)
                {
                    if (dynamicSetting.LastModifyDate.Subtract(dt).TotalMilliseconds > 0)
                    {
                        layoutInfo = null;
                    }
                }
                //end

                if (layoutInfo == null)
                {
                    return(layoutXmlName + ".xml");
                }
                else
                {
                    return(layoutXmlName + "~" + layoutInfo.Name + ".xml");
                }
            }
            catch (Exception ex)
            {
                MB.Util.TraceEx.Write(ex.Message, Util.APPMessageType.SysErrInfo);
                return(null);
            }
        }
Ejemplo n.º 6
0
        //add by aifang
        private GridLayoutInfo GetPivotGridActiveLayout(MB.WinBase.IFace.IClientRuleQueryBase baseRule, PivotGridEx xtraGrid)
        {
            try
            {
                var gridLayoutMainList = new MB.Util.Serializer.DataContractFileSerializer <List <GridLayoutMainInfo> >(GRID_LAYOUT_FILE_SETTING_FULLNAME).Read();
                if (gridLayoutMainList == null)
                {
                    return(null);
                }

                string sectionName    = getLayoutXmlSessionName(baseRule, xtraGrid);
                var    gridLayoutList = gridLayoutMainList.Find(o => o.GridSectionName.Equals(sectionName));
                if (gridLayoutList == null || gridLayoutList.GridLayoutList.Count == 0)
                {
                    return(null);
                }

                return(gridLayoutList.GridLayoutList.OrderByDescending(o => o.CreateTime).FirstOrDefault());
            }
            catch (Exception ex)
            {
                MB.Util.TraceEx.Write(ex.Message, Util.APPMessageType.SysErrInfo);
                return(null);
            }
        }
Ejemplo n.º 7
0
 public string getLayoutXmlSessionName(MB.WinBase.IFace.IClientRuleQueryBase baseRule, PivotGridEx xtraGrid)
 {
     if (xtraGrid.ParentForm == null)
     {
         return(null);
     }
     return(baseRule.GetType().FullName + "~" + xtraGrid.ParentForm.GetType().FullName + "~" + xtraGrid.Name);
 }
Ejemplo n.º 8
0
        //显示Grid状态设置窗体
        private void showFrmGridLayoutManager(MB.WinBase.IFace.IForm containerForm, PivotGridEx xtraGrid)
        {
            frmGridLayoutManager frm = new frmGridLayoutManager(containerForm, xtraGrid);

            frm.ShowDialog();
        }