Exemplo n.º 1
0
        public override bool FromXML(System.Xml.XmlElement myElement)
        {
            if (null != myElement)
            {
                this.cells.Clear();

                foreach (XmlNode node in myElement.ChildNodes)
                {
                    if (node.Name == "table-cell")
                    {
                        TPTextCell cellEle = OwnerDocument.CreateElementByXML(node as XmlElement) as TPTextCell;
                        cellEle.Parent   = this;
                        cellEle.OwnerRow = this;

                        this.cells.Add(cellEle);
                        this.ChildElements.Add(cellEle);
                    }
                }
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Froms the XML.
        /// </summary>
        /// <param name="myElement">My element.</param>
        /// <returns></returns>
        public override bool FromXML(System.Xml.XmlElement myElement)
        {
            if (null != myElement)
            {
                myAttributes.FromXML(myElement);
                this.Width = myAttributes.GetInt32("width");
                //this.Height = myAttributes.GetInt32("height");
                this.Header = myAttributes.GetString("title");
                this.horizontalAlignment = myAttributes.GetInt32("align");
                this.IsFixWidth          = myAttributes.GetInt32("fixwidth") == 1 ? true : false;
                this.HiddenAllBorder     = (myAttributes.GetInt32("hidden-all-border") == 1) ? true : false;

                this.allRows.Clear();
                this.ChildElements.Clear();

                for (int i = 0; i < myElement.ChildNodes.Count; i++)
                {
                    XmlElement ele = myElement.ChildNodes.Item(i) as XmlElement;
                    if (ele != null)
                    {
                        if (ele.Name == "table-column")
                        {
                            this.columns = Convert.ToInt32(ele.GetAttribute("columns-number"));
                            List <int> relwidths = new List <int>();
                            for (int j = 0; j < ele.ChildNodes.Count; j++)
                            {
                                XmlElement colwidthEle = ele.ChildNodes.Item(j) as XmlElement;
                                if (colwidthEle != null)
                                {
                                    if (colwidthEle.Name == "column-width")
                                    {
                                        relwidths.Add(Convert.ToInt32(colwidthEle.GetAttribute("width")));
                                    }
                                }
                            }
                            this.relativeWidths = new int[relwidths.Count];
                            for (int k = 0; k < relwidths.Count; k++)
                            {
                                relativeWidths[k] = relwidths[k];
                            }
                            SetWidth(relativeWidths);
                        }
                        if (ele.Name == "table-row")
                        {
                            TPTextRow row = OwnerDocument.CreateElementByXML(ele) as TPTextRow;
                            row.Widths     = this.absoluteWidths;
                            row.Columns    = this.IntColumns;
                            row.Width      = this.Width;
                            row.OwnerTable = this;
                            row.Parent     = this;

                            this.allRows.Add(row);
                            this.ChildElements.Add(row);
                        }
                    }
                }
                CalculateHeights();
                return(true);
            }
            return(false);
        }