Beispiel #1
0
        public TextItem(XmlNode node)
        {
            _key = node.Attributes["key"].Value;
            if (!string.IsNullOrEmpty(node.InnerText))
            {
                _text = node.InnerText;
            }
            else
            {
                ReportConfig.GetAttribute(node, "text", ref _text);
            }
            ReportConfig.GetAttribute(node, "data", ref _datamember);
            ReportConfig.GetAttribute(node, "format", ref _format);
            string    font_name      = _font.Name;
            string    font_bold      = "";
            string    font_italic    = "";
            string    font_underline = "";
            float     font_size      = Font.Size;
            FontStyle fsty           = FontStyle.Regular;

            ReportConfig.GetAttribute(node, "font-name", ref font_name);
            ReportConfig.GetAttribute(node, "font-size", ref font_size);
            ReportConfig.GetAttribute(node, "font-bold", ref font_bold);
            ReportConfig.GetAttribute(node, "font-italic", ref font_italic);
            ReportConfig.GetAttribute(node, "font-underline", ref font_underline);
            if (font_bold.Equals("1"))
            {
                fsty |= FontStyle.Bold;
            }
            if (font_italic.Equals("1"))
            {
                fsty |= FontStyle.Italic;
            }
            if (font_underline.Equals("1"))
            {
                fsty |= FontStyle.Underline;
            }
            _font = new Font(font_name, font_size, fsty);

            font_name      = _font.Name;
            font_bold      = "";
            font_italic    = "";
            font_underline = "";
            font_size      = Font.Size;
            fsty           = FontStyle.Regular;
            ReportConfig.GetAttribute(node, "header-font-name", ref font_name);
            ReportConfig.GetAttribute(node, "header-font-size", ref font_size);
            ReportConfig.GetAttribute(node, "header-font-bold", ref font_bold);
            ReportConfig.GetAttribute(node, "header-font-italic", ref font_italic);
            ReportConfig.GetAttribute(node, "header-font-underline", ref font_underline);
            if (font_bold.Equals("1"))
            {
                fsty |= FontStyle.Bold;
            }
            if (font_italic.Equals("1"))
            {
                fsty |= FontStyle.Italic;
            }
            if (font_underline.Equals("1"))
            {
                fsty |= FontStyle.Underline;
            }
            _headerfont = new Font(font_name, font_size, fsty);

            int left = 0, top = 0, width = 0, height = 0;

            ReportConfig.GetAttribute(node, "left", ref left);
            ReportConfig.GetAttribute(node, "top", ref top);
            ReportConfig.GetAttribute(node, "width", ref width);
            ReportConfig.GetAttribute(node, "height", ref height);
            _rect = new Rectangle(left, top, width, height);

            string align = "left";

            ReportConfig.GetAttribute(node, "align", ref align);
            string valign = "top";

            ReportConfig.GetAttribute(node, "valign", ref valign);
            _align = new StringFormat();
            if (align.Equals("right", StringComparison.OrdinalIgnoreCase))
            {
                _align.Alignment = StringAlignment.Far;
            }
            else if (align.Equals("center", StringComparison.OrdinalIgnoreCase))
            {
                _align.Alignment = StringAlignment.Center;
            }
            if (valign.Equals("bottom", StringComparison.OrdinalIgnoreCase))
            {
                _align.LineAlignment = StringAlignment.Far;
            }
            else if (valign.Equals("middle", StringComparison.OrdinalIgnoreCase))
            {
                _align.LineAlignment = StringAlignment.Center;
            }

            string count = "";

            ReportConfig.GetAttribute(node, "count", ref count);
            if (count.Equals("1"))
            {
                _count = true;
            }
        }
Beispiel #2
0
        public ReportConfig(string frpFile)
        {
            _filename = frpFile;
            XmlDocument xdoc = new XmlDocument();

            xdoc.Load(frpFile);
            XmlNode pnode = xdoc.SelectSingleNode("//configuration/pageset");

            ReportConfig.GetAttribute(pnode, "unit", ref _unit);
            if (string.IsNullOrEmpty(_unit)) //没有单位
            {
                //页面大小
                int w = 0, h = 0;
                ReportConfig.GetAttribute(pnode, "width", ref w);
                ReportConfig.GetAttribute(pnode, "height", ref h);
                _autosize       = h == 0;
                _pset.PaperSize = new PaperSize(frpFile, w, h);
                //页边距
                int m_left = 0, m_top = 0, m_right = 0, m_bottom = 0;
                ReportConfig.GetAttribute(pnode, "margin-left", ref m_left);
                ReportConfig.GetAttribute(pnode, "margin-top", ref m_top);
                ReportConfig.GetAttribute(pnode, "margin-right", ref m_right);
                ReportConfig.GetAttribute(pnode, "margin-bottom", ref m_bottom);
                _pset.Margins = new Margins(m_left, m_right, m_top, m_bottom);
            }
            else
            {
                ReportConfig.GetAttribute(pnode, "width", ref _width);
                ReportConfig.GetAttribute(pnode, "height", ref _height);
                ReportConfig.GetAttribute(pnode, "margin-left", ref _lm);
                ReportConfig.GetAttribute(pnode, "margin-top", ref _tm);
                ReportConfig.GetAttribute(pnode, "margin-right", ref _rm);
                ReportConfig.GetAttribute(pnode, "margin-bottom", ref _bm);
            }
            //头
            pnode = xdoc.SelectSingleNode("//configuration/header");
            ReportConfig.GetAttribute(pnode, "height", ref _headheight);
            //字段
            foreach (XmlNode node in xdoc.SelectNodes("//configuration/header/textitem"))
            {
                TextItem item = new TextItem(node);
                if (_header == null)
                {
                    _header = new Dictionary <string, TextItem>();
                }
                _header.Add(item.Key, item);
            }
            //尾
            pnode = xdoc.SelectSingleNode("//configuration/footer");
            ReportConfig.GetAttribute(pnode, "height", ref _footheight);
            //字段
            foreach (XmlNode node in xdoc.SelectNodes("//configuration/footer/textitem"))
            {
                TextItem item = new TextItem(node);
                if (_footer == null)
                {
                    _footer = new Dictionary <string, TextItem>();
                }
                _footer.Add(item.Key, item);
            }
            //数据字段
            foreach (XmlNode node in xdoc.SelectNodes("//configuration/dataitem/textitem"))
            {
                TextItem item = new TextItem(node);
                if (_dataitem == null)
                {
                    _dataitem = new Dictionary <string, TextItem>();
                }
                _dataitem.Add(item.Key, item);
            }
        }