Example #1
0
 public Row(SectionLine sl, SemiRow semirow, string baseid, Graphics g) : this(g)
 {
     if (baseid != null && semirow.Contains(baseid))
     {
         _baseid = Convert.ToInt32(semirow[baseid]);
     }
     _bminorlevel = semirow.bMinorLevel;
     _sectionline = sl;
     _level       = semirow.Level;
     _area        = sl.Section.Type;
     _bfirst      = sl.Index == 0;
     AddCells(semirow);
 }
Example #2
0
        private void AddCells(SemiRow semirow)
        {
            ArrayList superlabels = new ArrayList();
            Graphics  g           = null;

            try
            {
                if (_g == null)
                {
                    g = CreateGraphics();
                }
                foreach (Cell ctmp in _sectionline.Cells)
                {
                    Cell cell = ctmp.Clone() as Cell;

                    #region handler alternative style
                    if (_sectionline.Section is IAlternativeStyle)
                    {
                        IAlternativeStyle ias = _sectionline.Section as IAlternativeStyle;
                        if (ias.bApplyAlternative && ias.bApplySecondStyle)
                        {
                            //if (cell is CommonLabel && (cell as CommonLabel).LabelType != LabelType.SummaryLabel)
                            //    continue;
                            //if (cell is Label)
                            //    continue;
                            if (//!(cell is CommonLabel && (cell as CommonLabel).LabelType != LabelType.SummaryLabel) &&
                                cell.Type != "Label" && cell.Type != "SuperLabel")
                            {
                                if (!(cell is IApplyColorStyle) || (cell as IApplyColorStyle).bApplyColorStyle)
                                {
                                    cell.SetAlternativeStyle(ias);
                                }
                            }
                        }
                    }
                    #endregion

                    if (semirow != null && semirow.Contains(cell.Name))
                    {
                        if (cell is IImage)
                        {
                            (cell as IImage).ImageString = semirow[cell.Name].ToString();
                        }
                        else
                        {
                            cell.Caption = semirow[cell.Name].ToString();

                            try
                            {
                                if (!string.IsNullOrEmpty(cell.Caption) && (cell.VisiblePosition != -1 || cell is Indicator || cell is CalculateIndicator || cell is CalculatorIndicator) && cell is IDecimal && cell is IFormat && !string.IsNullOrEmpty((cell as IFormat).FormatString))
                                {
                                    cell.Caption = Convert.ToDouble(cell.Caption).ToString((cell as IFormat).FormatString);
                                }
                            }
                            catch
                            {
                            }
                        }
                    }

                    if (semirow != null)
                    {
                        if (semirow.BackColorContains(cell.Name))
                        {
                            cell.BackColor = semirow.BackColors(cell.Name);
                        }
                        if (semirow.ForeColorContains(cell.Name))
                        {
                            cell.ForeColor = semirow.ForeColors(cell.Name);
                        }
                        if (semirow.VisibleContains(cell.Name))
                        {
                            cell.Visible = semirow.Visibles(cell.Name);
                        }
                        if (semirow.XContains(cell.Name))
                        {
                            cell.X = semirow.Xs(cell.Name);
                        }
                        if (semirow.WidthContains(cell.Name))
                        {
                            cell.Width = semirow.Widths(cell.Name);
                        }
                        if (cell is IIndicator)
                        {
                            if (semirow.CompareValue1Contains(cell.Name))
                            {
                                (cell as IIndicator).CompareValue.Expression1 = semirow.CompareValue1s(cell.Name).ToString();
                            }
                            if (semirow.CompareValue2Contains(cell.Name))
                            {
                                (cell as IIndicator).CompareValue.Expression2 = semirow.CompareValue2s(cell.Name).ToString();
                            }
                        }
                    }
                    if (cell.Visible)
                    {
                        cell.SetRuntimeHeight(_g == null ? g : _g, cell.Caption);
                        _cells.CalcRuntimeHeight(cell);
                    }

                    if ((cell is ICenterAlign) && (cell as ICenterAlign).CenterAlign)
                    {
                        if (_containerwidth != -1)
                        {
                            if (_containerwidth > cell.Width)
                            {
                                cell.X = (_containerwidth - cell.Width) / 2;
                            }
                            else
                            {
                                cell.X = 0;
                            }
                            ctmp.X = cell.X;
                        }
                    }

                    _cells.AddByVisiblePosition(cell);

                    if (cell.Visible)
                    {
                        if (_sectionline.Section is IAutoSequence && (_sectionline.Section as IAutoSequence).bAutoSequence)
                        {
                            if (cell is SuperLabel)
                            {
                                cell.Width = (cell as SuperLabel).CalcWidth();
                                if (cell.Width == 0)
                                {
                                    cell.Visible = false;
                                }
                                else
                                {
                                    superlabels.Add(cell);
                                }
                            }
                        }
                        else if (cell is SuperLabel)// && cell.Visible)
                        {
                            cell.Width = (cell as SuperLabel).CalcWidth();
                            superlabels.Add(cell);
                        }
                    }
                }
            }
            finally
            {
                if (g != null)
                {
                    g.Dispose();
                }
            }
            _x            = _cells.X;
            _ybase        = _cells.Y;
            _expandheight = _cells.ExpandHeight;
            _metaheight   = _cells.MetaHeight;

            _cells.AutoLayOut();

            foreach (Cell sp in superlabels)
            {
                HandleSuperLabel(sp);
            }
        }