Beispiel #1
0
        protected virtual void WriteHeading(SvgDocument document, Table table)
        {
            //Add heading
            mDefinition.Path = new GraphicsPath();
            mDefinition.Path.AddRectangle(new RectangleF(0, 0, table.Width, table.HeadingHeight));

            //Add the definition
            string defId = document.AddDefinition(mDefinition.ExtractRectangle());

            //Add the class
            string gradient = Style.ExtractLinearGradient(LinearGradientMode.Horizontal, table.GradientColor, table.BackColor);
            string classId  = document.AddClass("fill:url(#none)", gradient);

            document.AddUse("Heading", defId, classId, "", 0, 0);

            //Add the rest of the background
            mDefinition.Path = new GraphicsPath();
            mDefinition.Path.AddRectangle(new RectangleF(0, 0, table.Width, table.Height - table.HeadingHeight));

            //Add the definition
            defId   = document.AddDefinition(mDefinition.ExtractRectangle());
            classId = document.AddClass("fill:" + Style.GetCompatibleColor(table.BackColor));

            document.AddUse("Fill", defId, classId, "", 0, table.HeadingHeight);

            Style style = new Style();
            Font  font  = null;

            //Add Heading text
            if (table.Heading.Trim() != "")
            {
                //Add clipping to style if required
                style.ClipPathId = ClipId;

                //Set up text object
                Text text = new Text();

                //Get style
                font    = Component.Instance.GetFont(table.FontName, table.FontSize, FontStyle.Bold);
                classId = document.AddClass(text.GetStyle(font, table.Forecolor, ClipId), "");

                //Create fragment and add to document
                XmlDocumentFragment frag           = null;
                XmlNode             newElementNode = null;

                frag          = document.CreateDocumentFragment();
                frag.InnerXml = text.ExtractText(table.Heading, font, 8, 5, table.Key + "Heading");
                frag.FirstChild.Attributes.GetNamedItem("class").InnerText = classId;
                newElementNode = document.ContainerNode.AppendChild(frag);
            }

            //Add Heading text
            if (table.SubHeading.Trim() != "")
            {
                style = new Style();

                //Add clipping to style if required
                style.ClipPathId = ClipId;

                //Set up text object
                Text text = new Text();

                //Get style
                font    = Component.Instance.GetFont(table.FontName, table.FontSize - 1, FontStyle.Regular);
                classId = document.AddClass(text.GetStyle(font, table.Forecolor, ClipId), "");

                //Create fragment and add to document
                XmlDocumentFragment frag           = null;
                XmlNode             newElementNode = null;

                frag          = document.CreateDocumentFragment();
                frag.InnerXml = text.ExtractText(table.SubHeading, font, 8, 20, table.Key + "Subheading");
                frag.FirstChild.Attributes.GetNamedItem("class").InnerText = classId;
                newElementNode = document.ContainerNode.AppendChild(frag);
            }
        }