Ejemplo n.º 1
0
        /// <summary>
        /// 保存当前网格的布局
        /// </summary>
        private void SavePageSetting()
        {
            try
            {
                XtraPageSettings setting = _printingSystem.PageSettings;
                PrintPageSetting pps     = new PrintPageSetting();
                pps.Landscape   = setting.Landscape;
                pps.Left        = setting.Margins.Left;
                pps.Right       = setting.Margins.Right;
                pps.Top         = setting.Margins.Top;
                pps.Bottom      = setting.Margins.Bottom;
                pps.PaperKind   = (int)setting.PaperKind;
                pps.PrinterName = setting.PrinterName;
                PageHeaderFooter pageHf = _printableComponentLink.PageHeaderFooter as PageHeaderFooter;
                pps.headerAlign      = pageHf.Header.LineAlignment;
                pps.headerContent    = pageHf.Header.Content;
                pps.headerFont.Name  = pageHf.Header.Font.Name;
                pps.headerFont.Size  = pageHf.Header.Font.Size;
                pps.headerFont.Style = pageHf.Header.Font.Style;

                pps.footerAlign      = pageHf.Footer.LineAlignment;
                pps.footerContent    = pageHf.Footer.Content;
                pps.footerFont.Name  = pageHf.Footer.Font.Name;
                pps.footerFont.Size  = pageHf.Footer.Font.Size;
                pps.footerFont.Style = pageHf.Footer.Font.Style;

                XmlSerializer ser = new XmlSerializer(pps.GetType());
                ser.Serialize(new FileStream(_PrintSettingFile, FileMode.Create, FileAccess.Write, FileShare.ReadWrite), pps);
            }
            catch (Exception ex) { }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取页面设置信息
        /// </summary>
        private void LoadPageSetting()
        {
            try
            {
                if (!System.IO.File.Exists(_PrintSettingFile))
                {
                    return;
                }
                XmlSerializer    ser     = new XmlSerializer(typeof(PrintPageSetting));
                PrintPageSetting setting = (PrintPageSetting)ser.Deserialize(new FileStream(_PrintSettingFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
                Margins          m       = new Margins(setting.Left, setting.Right, setting.Top, setting.Bottom);
                _printingSystem.PageSettings.Assign(m, (PaperKind)setting.PaperKind, setting.Landscape);
                _printingSystem.PageSettings.PrinterName = setting.PrinterName;
                System.Drawing.Font headerfont = new System.Drawing.Font(setting.headerFont.Name, setting.headerFont.Size, setting.headerFont.Style);
                string[]            arrheader  = getStringArray(setting.headerContent);
                PageHeaderArea      header     = new PageHeaderArea(arrheader, headerfont, setting.headerAlign);

                System.Drawing.Font footerfont = new System.Drawing.Font(setting.footerFont.Name, setting.footerFont.Size, setting.footerFont.Style);
                string[]            arrfoot    = getStringArray(setting.footerContent);
                PageFooterArea      footer     = new PageFooterArea(arrfoot, footerfont, setting.footerAlign);
                PageHeaderFooter    pagehf     = new PageHeaderFooter(header, footer);
                _printableComponentLink.PageHeaderFooter = pagehf;
            }
            catch { }
        }