Пример #1
0
        public override Region CloneEntity(ProductRule productRule, BaseEntity container)
        {
            RowHeaderRegion newRegion = new RowHeaderRegion(container as RegionTable)
            {
                _location = _location != null?_location.Clone() : null,
                                ColSpannable = ColSpannable,
                                RowSpannable = RowSpannable,
                                EmptyFill    = EmptyFill,
                                Field        = Field,
                                IsBasedOn    = IsBasedOn,
                                MaxLevel     = MaxLevel,
                                //HeaderBodyRelation = HeaderBodyRelation.Clone() as SourceRelation,
                                //HeaderTreeRelation = HeaderTreeRelation.Clone() as SourceRelation,
                                //Source = Source.Clone() as Source,
                                //TreeSource = TreeSource.Clone() as TreeSource
            };

            if (Source != null)
            {
                newRegion.Source = productRule.GetSource(Source.Name);
            }
            if (HeaderBodyRelation != null)
            {
                newRegion.HeaderBodyRelation = HeaderBodyRelation.Clone(productRule);
            }
            //if (HeaderTreeRelation != null)
            //{
            //    newRegion.HeaderTreeRelation = HeaderTreeRelation.Clone(productRule);
            //}
            //if (TreeSource != null)
            //{
            //    newRegion.TreeSource = productRule.GetSource(TreeSource.Name) as TreeSource;
            //}
            return(newRegion);
        }
Пример #2
0
        protected override List <OutputNode> CalulateNodes()
        {
            List <OutputNode>  nodes     = new List <OutputNode>();
            RowHeaderRegion    rowheader = _table.GetRegion(RegionType.RowHeader) as RowHeaderRegion;
            ColumnHeaderRegion colheader = _table.GetRegion(RegionType.ColumnHeader) as ColumnHeaderRegion;

            if (rowheader != null && colheader != null)
            {
                IEnumerable <OutputNode> rowHeaderNodes = rowheader.GetNodes().Where(p => p.Tag != null);
                IEnumerable <OutputNode> colHeaderNodes = colheader.GetNodes().Where(p => p.Tag != null);
                string refRowField = rowheader.HeaderBodyRelation.ReferecedField;
                string refColField = colheader.HeaderBodyRelation.ReferecedField;
                IEnumerable <OutputNode> tmpRowNodes = null;
                IEnumerable <OutputNode> tmpColNodes = null;
                foreach (DataRow row in Source.Table.Rows)
                {
                    tmpRowNodes = rowHeaderNodes.Where(p => p.Tag.Equals(row[refRowField]));
                    tmpColNodes = colHeaderNodes.Where(p => p.Tag.Equals(row[refColField]));
                    if (tmpColNodes.Count() > 0 && tmpRowNodes.Count() > 0)
                    {
                        nodes.Add(new OutputNode()
                        {
                            Content     = row[Field],
                            ColumnIndex = tmpRowNodes.First().ColumnIndex,
                            RowIndex    = tmpColNodes.First().RowIndex,
                            ColumnSpan  = 1,
                            RowSpan     = 1
                        });
                    }
                }

                if (!string.IsNullOrEmpty(EmptyFill))
                {
                    int rIndex = this.RowIndex;
                    int cIndex = this.ColumnIndex;
                    for (int i = 0; i < this.RowCount; i++)
                    {
                        for (int j = 0; j < this.ColumnCount; j++)
                        {
                            if (!nodes.Exists(p => p.IsInArea(rIndex + i, cIndex + j)))
                            {
                                nodes.Add(new OutputNode()
                                {
                                    Content     = EmptyFill,
                                    RowIndex    = rIndex + i,
                                    ColumnIndex = cIndex + j,
                                    RowSpan     = 1,
                                    ColumnSpan  = 1
                                });
                            }
                        }
                    }
                }
            }
            else
            {
                HeaderRegion             header      = colheader != null ? (HeaderRegion)colheader : rowheader;
                bool                     isRowHeader = header is RowHeaderRegion;
                IEnumerable <OutputNode> headerNodes = header.GetNodes().Where(p => p.Tag != null);
                DataColumnCollection     columns     = Source.Table.Columns;
                DataRowCollection        rows        = Source.Table.Rows;
                string                   refField    = header.HeaderBodyRelation.ReferecedField;
                if (!string.IsNullOrEmpty(refField))
                {
                    foreach (DataRow row in rows)
                    {
                        IEnumerable <OutputNode> tmpRowNodes = headerNodes.Where(p => p.Tag.Equals(row[refField]));
                        if (tmpRowNodes.Count() > 0)
                        {
                            OutputNode headerNode = tmpRowNodes.First();
                            for (int i = 0; i < columns.Count; i++)
                            {
                                if (/*columns[i].ColumnName != refField &&*/ row[i] != null && !string.IsNullOrEmpty(row[i].ToString()))
                                {
                                    nodes.Add(new OutputNode()
                                    {
                                        Content     = row[i],
                                        ColumnIndex = isRowHeader ? headerNode.ColumnIndex : ColumnIndex + i,
                                        RowIndex    = isRowHeader ? RowIndex + i : headerNode.RowIndex,
                                        ColumnSpan  = 1,
                                        RowSpan     = 1
                                    });
                                }
                            }
                        }
                    }
                }
                else
                {
                    for (int j = 0; j < columns.Count; j++)
                    {
                        IEnumerable <OutputNode> tmpRowNodes = headerNodes.Where(p => p.Tag.Equals(columns[j].ColumnName));
                        if (tmpRowNodes.Count() > 0)
                        {
                            OutputNode headerNode = tmpRowNodes.First();
                            for (int i = 0; i < rows.Count; i++)
                            {
                                if (rows[i][j] != null && !string.IsNullOrEmpty(rows[i][j].ToString()))
                                {
                                    nodes.Add(new OutputNode()
                                    {
                                        Content     = rows[i][j],
                                        ColumnIndex = isRowHeader ? headerNode.ColumnIndex : ColumnIndex + i,
                                        RowIndex    = isRowHeader ? RowIndex + i : headerNode.RowIndex,
                                        ColumnSpan  = 1,
                                        RowSpan     = 1
                                    });
                                }
                            }
                        }
                    }
                }
            }
            return(nodes);
        }