Пример #1
0
        protected override Size ArrangeOverride(Size _arrangeSize)
        {
            foreach (var child in Children.OfType<Expander>().Where(_expander => !_expander.IsExpanded))
            {
                if (child.ExpandDirection == ExpandDirection.Down || child.ExpandDirection == ExpandDirection.Up)
                {
                    var row = GetRow(child);
                    if (!RowDefinitions.Any())
                        continue;

                    RowDefinitions[row].Height = new GridLength(0, GridUnitType.Auto);
                }
                else
                {
                    var column = GetColumn(child);
                    if (!ColumnDefinitions.Any())
                        continue;

                    ColumnDefinitions[column].Width = new GridLength(0, GridUnitType.Auto);
                }
            }
            return base.ArrangeOverride(_arrangeSize);
        }
        // -----------------------------------------------------------------------------------------
        // Rows=[Value], ColumnDefinitions=[Tech-Name, Name, Width-Percentage]
        public void PageWriteTable(string ClassName, IEnumerable <IEnumerable <string> > Rows,
                                   params Capsule <string, string, double>[] ColumnDefinitions)
        {
            if (!ColumnDefinitions.Any() || !Rows.Any())
            {
                return;
            }

            // Recalc column widths
            var PercentsSum = 0.0;

            foreach (var ColDef in ColumnDefinitions)
            {
                PercentsSum += ColDef.Value2;
            }

            if (PercentsSum != 100.0)
            {
                foreach (var ColDef in ColumnDefinitions)
                {
                    ColDef.Value2 = ((ColDef.Value2 * 100) / PercentsSum);
                }
            }

            // Generate
            this.PageWrite("<table class='" + ClassName + "'>");
            this.IncreaseIndent();

            foreach (var ColDef in ColumnDefinitions)
            {
                // Notice the use of Culture.InvariantCulture.NumberFormat as the HTML parsers requires standard number formatting.
                var Spec = "<col style='width: " + Math.Round(ColDef.Value2, 2).ToString(CultureInfo.InvariantCulture.NumberFormat) + "%;' />";
                this.PageWrite(Spec);
            }

            this.PageWrite("<thead>");
            this.IncreaseIndent();

            this.PageWrite("<tr>");
            this.IncreaseIndent();

            foreach (var ColDef in ColumnDefinitions)
            {
                var Spec = "<th>" + ColDef.Value1 + "</th>";
                this.PageWrite(Spec);
            }

            this.DecreaseIndent();
            this.PageWrite("</tr>");

            this.DecreaseIndent();
            this.PageWrite("</thead>");

            this.PageWrite("<tbody>");
            this.IncreaseIndent();

            foreach (var Row in Rows)
            {
                this.PageWrite("<tr>");
                this.IncreaseIndent();

                foreach (var Cell in Row)
                {
                    this.PageWrite("<td>");
                    this.IncreaseIndent();
                    this.PageWrite(Cell);
                    this.DecreaseIndent();
                    this.PageWrite("</td>");
                }

                this.DecreaseIndent();
                this.PageWrite("</tr>");
            }

            this.DecreaseIndent();
            this.PageWrite("</tbody>");

            this.DecreaseIndent();
            this.PageWrite("</table>");
        }