Пример #1
0
        public override void InitTitlesAndHeaders()
        {
            var content = (this.Content as AlimentadorContent);

            this.Write(content.Tablero, 0, 0);
            this.Write(content.Description, 1, 0);
            this.Table.Cells[1, 0].Alignment = CellAlignment.BottomLeft;
            this.Write("Alimentador", 5, 0);
            this.Write("Factores", 5, 14);
            this.Write(content.PageFormat, this.Table.Rows.Count - 1, 0);
            this.Table.Cells[this.Table.Rows.Count - 1, 0].Alignment = CellAlignment.MiddleRight;
            List <CellRange> mergeCells = new CellRange[]
            {
                CellRange.Create(this.Table, 1, 0, 4, 23),
                CellRange.Create(this.Table, 5, 0, 7, 2),
                CellRange.Create(this.Table, 5, 14, 7, 15),
                CellRange.Create(this.Table, this.Table.Rows.Count - 1, 0, this.Table.Rows.Count - 1, this.Table.Columns.Count - 1),
            }.Union(this.CreateHeaders(5, 3)).ToList();

            //Se actualizan las filas mezcladas
            mergeCells.ForEach(cell => this.Table.MergeCells(cell));
            var sHeaders = this.SubHeaders;

            for (int i = 0; i < sHeaders.Length; i++)
            {
                if (sHeaders[i] != null)
                {
                    this.Write(sHeaders[i].Item1, 8, i, columnWidth: sHeaders[i].Item2);
                }
            }
        }
Пример #2
0
        private void InitLines()
        {
            int startRow = 9, row;
            AlimentadorContent content = this.Content as AlimentadorContent;
            var lines = content.Lineas;

            String[]  values;
            CellRange cellRange;

            row = startRow;
            var simRows = new int[] { 1, 2, 3, 4, 18 };

            for (int i = 0; i < lines.Length; i++)
            {
                values = lines[i].GetValues();
                for (int j = 0; j < values.Length; j++)
                {
                    this.Write(values[j], row, j);
                    if (!simRows.Contains(j))
                    {
                        cellRange = CellRange.Create(this.Table, row, j, row + 1, j);
                        this.Table.MergeCells(cellRange);
                    }
                }
                //Línea descripción
                row++;
                //Descripción del Alimentador
                this.Write(lines[i].ToDesc, row, 1);
                this.Table.MergeCells(CellRange.Create(this.Table, row, 1, row, 4));
                //Canalización
                this.Write(lines[i].Canal, row, 18);
                //Nueva línea
                row++;
            }
        }
Пример #3
0
        public override void Save()
        {
            if (Spf.Count == 0)
            {
                return;
            }

            var t = MakeTable();

            t.SetSize(1, 6);
            t.Columns[0].Width = 30;
            t.Columns[1].Width = 100;
            t.Columns[2].Width = 100;
            t.Columns[3].Width = 60;
            t.Columns[4].Width = 100;
            t.Columns[5].Width = 30;

            var headers = new string[] { "Поз.", "Обозначение", "Наименование", "Размеры", "Примечание", "Кол." };

            for (int i = 0; i < headers.Length; i++)
            {
                t.Cells[0, i].TextString = headers[i];
            }

            int    cnt            = 0;
            int    pos            = 1;
            string current_header = "";

            foreach (var rec in Spf)
            {
                t.InsertRows(++cnt, 6, 1);
                if (current_header != rec["header"].StringValue.ToLower())
                {
                    current_header             = rec["header"].StringValue.ToLower();
                    t.Cells[cnt, 0].TextString = FirstCharToUpper(current_header);
                    var range = CellRange.Create(t, cnt, 0, cnt, 5);
                    range.Alignment       = CellAlignment.MiddleLeft;
                    range.BackgroundColor = Color.FromRgb(R, G, B);
                    t.MergeCells(range);
                    t.InsertRows(++cnt, 6, 1);
                }
                t.Cells[cnt, 0].TextString = (pos++).ToString();
                t.Cells[cnt, 1].TextString = rec["art"];
                t.Cells[cnt, 2].TextString = rec["name"];
                t.Cells[cnt, 3].TextString = rec["dim"];
                t.Cells[cnt, 4].TextString = rec["note"];
                t.Cells[cnt, 5].TextString = rec["qty"];
            }

            var h = AppendToPaperSpace(t);
            IAcadApplication axAcad  = System.Runtime.InteropServices.Marshal.GetActiveObject("Autocad.Application") as IAcadApplication;
            IAcadDocument    axDoc   = axAcad.ActiveDocument;
            IAcadTable       axTable = axDoc.HandleToObject(h.ToString()) as IAcadTable;

            for (int i = 0; i < axTable.Columns; i++)
            {
                TuneColumnWidth(axTable, i);
                axTable.RowHeight = 1;
            }
        }
Пример #4
0
        private void SetTitleAndCap(Table table, ref int row, string title)
        {
            var cell = table.Cells[row, 0];

            if (cell.IsMerged == null || !cell.IsMerged.Value)
            {
                var mCells = CellRange.Create(table, row, 0, row, table.Columns.Count - 1);
                table.MergeCells(mCells);
            }
            cell.TextString = title;
            row++;
            table.Rows[row].Height = 15;
            // столбец Поз.
            cell            = table.Cells[row, 0];
            cell.TextString = "Поз.";
            // столбец Артикул
            cell            = table.Cells[row, 1];
            cell.TextString = "Артикул";
            cell.Alignment  = CellAlignment.MiddleCenter;
            // столбец Образец
            cell            = table.Cells[row, 2];
            cell.TextString = "Образец";
            // столбец Расход, шт.
            cell            = table.Cells[row, 3];
            cell.TextString = "Расход, шт.";
            // столбец Расход, м.кв.
            cell            = table.Cells[row, 4];
            cell.TextString = "Расход, м.кв.";
            // столбец Цвет
            cell            = table.Cells[row, 5];
            cell.TextString = "Цвет";
            cell.Alignment  = CellAlignment.MiddleCenter;
            row++;
        }
Пример #5
0
        protected override void FillCells(Table table)
        {
            int      row = 0;
            DateTime now = DateTime.Now;

            if (data.TileInPanels.Count > 0)
            {
                SetTitleAndCap(table, ref row, "Расход плитки Сборной части " + now);
                FillTiles(table, ref row, data.TileInPanels);
            }
            if (data.TileInMonolith.Count > 0)
            {
                if (data.TileInPanels.Count > 0)
                {
                    var mCells = CellRange.Create(table, row, 0, row, table.Columns.Count - 1);
                    table.MergeCells(mCells);
                    row++;
                }

                SetTitleAndCap(table, ref row, "Расход плитки Монолитной части " + now);

                var rowHeader = table.Rows[row - 1];
                rowHeader.Borders.Bottom.LineWeight = LwBold;
                rowHeader.Borders.Top.LineWeight    = LwBold;

                FillTiles(table, ref row, data.TileInMonolith);
            }
        }
Пример #6
0
        /// <summary>
        /// Crea los headers
        /// </summary>
        /// <param name="row">La fila inicial para los headers.</param>
        /// <param name="column">La columna inicial de los headers.</param>
        /// <returns>La lista de filas a fucionar</returns>
        public virtual List <CellRange> CreateHeaders(int row, int column)
        {
            List <CellRange> cells = new List <CellRange>();
            CellRange        cell;
            String           header, subheader;
            double           colWidth;

            for (int i = 0; i < Headers.Length; i++)
            {
                if (Headers[i] != null)
                {
                    header    = Headers[i].Header;
                    subheader = Headers[i].SubHeader;
                    colWidth  = Headers[i].ColumnWidth;
                    cell      = this.AddHeader(header, subheader, row, column, i, colWidth);
                    if (subheader == String.Empty)
                    {
                        cell = CellRange.Create(this.Table, row, column + i, row + Headers[i].RowSpan, column + i);
                    }
                    //else if (subheader != string.Empty && Headers[i].RowSpan > 2)
                    //    cell = CellRange.Create(this.Table, row + 1, column + i, row +Headers[i].RowSpan, column + i);
                    cells.Add(cell);
                }
            }
            return(cells);
        }
Пример #7
0
        // Создание и Заполнение таблицы расхода плитки
        private void FillTableTiles(ObjectId idBtrLayoutMarkAR, out ObjectId idTable)
        {
            var btrLayout = idBtrLayoutMarkAR.GetObject(OpenMode.ForRead) as BlockTableRecord;

            // Поиск таблицы на листе
            using (Table table = FindTable(btrLayout))
            {
                idTable = table.ObjectId;
                // Расчет плитки
                List <TileCalc> tilesCalc = _markAR.TilesCalc;
                tilesCalc.Sort(); // Сортировка расчетных плиток по количеству.
                                  // Установка размера таблицы.
                if (table.Rows.Count > 3)
                {
                    table.DeleteRows(3, table.Rows.Count - 3);
                    table.SetSize(tilesCalc.Count + 3, table.Columns.Count);
                }
                // Заголовок
                table.Cells[0, 0].TextString = "Расход плитки на панель " + MarkArFullName;
                // Подсчет плитки
                int row = 2;

                // Нужно ли добавить столбец цвета?
                bool hasColorName = Paint.HasColorName(_markAR.Album.Colors);
                if (hasColorName)
                {
                    table.Columns[1].Width = 20;
                    table.InsertColumns(table.Columns.Count, 30, 1);
                    table.Cells[1, table.Columns.Count - 1].TextString = "Цвет";
                }

                // Заполнение строк таблицы
                foreach (var tileCalc in tilesCalc)
                {
                    table.Cells[row, 1].TextString      = tileCalc.Paint.Article;
                    table.Cells[row, 2].BackgroundColor = tileCalc.Paint.Color;
                    table.Cells[row, 3].TextString      = tileCalc.Count.ToString();
                    table.Cells[row, 3].Alignment       = CellAlignment.MiddleCenter;
                    table.Cells[row, 4].TextString      = tileCalc.TotalArea.ToString();
                    table.Cells[row, 4].Alignment       = CellAlignment.MiddleCenter;
                    if (hasColorName)
                    {
                        table.Cells[row, 5].TextString = tileCalc.Paint.Name;
                    }
                    row++;
                }
                // Строка итогов.
                // Объединить строку итогов (1,2 и 3 столбцы).
                table.MergeCells(CellRange.Create(table, row, 0, row, 2));
                table.Cells[row, 0].TextString = "Итого на панель:";
                table.Cells[row, 0].Alignment  = CellAlignment.MiddleCenter;
                table.Cells[row, 3].TextString = _markAR.Paints.Count.ToString();          //  totalCount.ToString();
                table.Cells[row, 3].Alignment  = CellAlignment.MiddleCenter;
                table.Cells[row, 4].TextString = _markAR.MarkSB.TotalAreaTiles.ToString(); //totalArea.ToString();
                table.Cells[row, 4].Alignment  = CellAlignment.MiddleCenter;
                table.RecomputeTableBlock(true);
                //table.Dispose();//???
            }
        }
Пример #8
0
        private Table getTable(Database db)
        {
            Table table = new Table();

            table.SetDatabaseDefaults(db);
            table.TableStyle = db.GetTableStylePIK(); // если нет стиля ПИк в этом чертеже, то он скопируетс из шаблона, если он найдется

            var data = _service.DataSection;

            table.SetSize(5, 3);

            table.Columns[0].Width = 40;
            table.Columns[1].Width = 40;
            table.Columns[2].Width = 40;

            table.SetRowHeight(8);

            var lwBold = LineWeight.LineWeight030;

            // Фон таблицы в зависимости от региона
            _service.Estimate.TableFormatting(table);

            table.Columns[0].Alignment = CellAlignment.MiddleLeft;
            table.Columns[1].Alignment = CellAlignment.MiddleCenter;
            table.Columns[2].Alignment = CellAlignment.MiddleCenter;
            //table.Rows[1].Height = 15;

            table.Cells[0, 0].TextString = _service.Estimate.Title;
            table.Cells[0, 0].Alignment  = CellAlignment.MiddleCenter;

            table.Cells[1, 1].TextString = "Площадь в г.н.с.";
            table.Cells[1, 2].TextString = "Жилой фонд";
            //table.Cells[1, 0].Borders.Bottom.LineWeight = LineWeight.LineWeight030;

            var titleCells = CellRange.Create(table, 1, 0, 1, table.Columns.Count - 1);

            titleCells.Borders.Bottom.LineWeight = lwBold;

            table.Cells[2, 0].TextString = "1 этаж БКФН";
            table.Cells[2, 1].TextString = data.KP_GNS_BKFN.ToString("0.0");
            table.Cells[2, 2].TextString = data.TotalAreaBKFN.ToString("0.0");
            //table.Cells[1, 1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;

            table.Cells[3, 0].TextString = "Типовой этаж квартиры";
            table.Cells[3, 1].TextString = data.KP_GNS_Typical.ToString("0.0");
            table.Cells[3, 2].TextString = data.TotalAreaApart.ToString("0.0");

            table.Cells[4, 0].TextString = "ИТОГО";
            table.Cells[4, 1].TextString = data.KP_GNS_Total.ToString("0.0");
            table.Cells[4, 2].TextString = data.TotalArea.ToString("0.0");

            var lastRow = table.Rows.Last();

            lastRow.Borders.Bottom.LineWeight = lwBold;

            table.GenerateLayout();
            return(table);
        }
Пример #9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="table"></param>
 /// <param name="header"></param>
 /// <param name="subheader"></param>
 /// <param name="startColumn"></param>
 /// <param name="columnOffset"></param>
 /// <param name="colWidth"></param>
 /// <param name="merge"></param>
 /// <returns></returns>
 public static CellRange AddHeader(this TabalimTable table, string header, string subheader,
                                   int row, int startColumn, int columnOffset, double colWidth = COLUMNWIDTH)
 {
     table.Write(header, row, startColumn + columnOffset, columnWidth: colWidth);
     table.Table.Cells[row, startColumn + columnOffset].TextHeight = HEADER_TEXTHEIGHT;
     table.Write(subheader, row + 1, startColumn + columnOffset);
     table.Table.Cells[row + 1, startColumn + columnOffset].TextHeight = SUB_HEADER_TEXTHEIGHT;
     return(CellRange.Create(table.Table, row + 1, startColumn + columnOffset, row + 2, startColumn + columnOffset));
 }
Пример #10
0
        public static void Merge(this Table table, int colStart, int rowStart, int colEnd, int rowEnd)
        {
            if (colEnd - colStart <= 0 && rowEnd - rowStart <= 0)
            {
                return;
            }
            var rangew = CellRange.Create(table, rowStart, colStart, rowEnd, colEnd);

            table.MergeCells(rangew);
        }
Пример #11
0
            private static void mergeRows(Table table, int col, int rowIndexFirst, int rowIndexLast, CellAlignment align = CellAlignment.MiddleCenter)
            {
                if (rowIndexLast <= rowIndexFirst)
                {
                    return;
                }
                var mCells = CellRange.Create(table, rowIndexFirst, col, rowIndexLast, col);

                table.MergeCells(mCells);
                mCells.Alignment = align;
            }
Пример #12
0
        private void FillTiles(Table table, ref int row, List <IGrouping <Tile, Tile> > tiles)
        {
            Cell      cell;
            CellRange mCells;
            int       index      = 1;
            int       totalCount = 0;
            double    totalArea  = 0;

            foreach (var tile in tiles)
            {
                cell            = table.Cells[row, 0];
                cell.TextString = index++.ToString();

                cell            = table.Cells[row, 1];
                cell.TextString = tile.Key.Article;

                cell = table.Cells[row, 2];
                cell.BackgroundColor = tile.Key.Color;

                int count = tile.Count();
                totalCount     += count;
                cell            = table.Cells[row, 3];
                cell.TextString = count.ToString();

                cell = table.Cells[row, 4];
                var area = Math.Round(count * Panels.TileCalc.OneTileArea, 2);
                totalArea      += area;
                cell.TextString = area.ToString("0.00");

                cell            = table.Cells[row, 5];
                cell.TextString = tile.Key.NCS;

                row++;
            }

            var rowHeader = table.Rows[row];

            rowHeader.Borders.Top.LineWeight    = LwBold;
            rowHeader.Borders.Bottom.LineWeight = LwBold;

            mCells = CellRange.Create(table, row, 0, row, 2);
            table.MergeCells(mCells);
            cell            = table.Cells[row, 0];
            cell.TextString = "Итого:";
            cell.Alignment  = CellAlignment.MiddleCenter;

            cell            = table.Cells[row, 3];
            cell.TextString = totalCount.ToString();
            cell            = table.Cells[row, 4];
            cell.TextString = totalArea.ToString();

            row++;
        }
Пример #13
0
        private void SetNorm(string title, string value, Table table, int colIndex)
        {
            var col = table.Columns[colIndex];

            col[1, colIndex].TextString = title;
            var mCells = CellRange.Create(table, 2, colIndex, 4, colIndex);

            table.MergeCells(mCells);
            col[2, colIndex].TextString = value;
            col.Alignment = CellAlignment.MiddleCenter;
            col.Width     = 20;
        }
Пример #14
0
        private void InitTotales()
        {
            int valuesStartColumn = 12;

            double[] t = new double[]
            {
                this.Content.AlumbradosVA, this.Content.ContactosVA,
                this.Content.MotoresVA, this.Content.ReservaVA,
                this.Content.TotalVA
            };
            string[] h = new string[]
            {
                "Alumbrados", "Contactos",
                "Motores", "Reserva",
                "Totales"
            };

            for (int i = 0; i < t.Length; i++)
            {
                this.Write(String.Format("{0} = {1:N2} VA", h[i], t[i]), 1 + i, valuesStartColumn);
                this.Table.Cells[1 + i, valuesStartColumn].Alignment = CellAlignment.MiddleLeft;
                this.Table.MergeCells(CellRange.Create(this.Table, 1 + i, valuesStartColumn, 1 + i, valuesStartColumn + 3));
                this.Table.MergeCells(CellRange.Create(this.Table, 1 + i, valuesStartColumn + 4, 1 + i, this.Table.Columns.Count - 1));
                if (i > 0)
                {
                    this.ChangeBorders(1 + i, valuesStartColumn, false, false, false, false);
                    this.ChangeBorders(1 + i, valuesStartColumn + 4, false, false, false, false);
                }
                else
                {
                    this.ChangeBorders(1 + i, valuesStartColumn, false, true, false, false);
                    this.ChangeBorders(1 + i, valuesStartColumn + 4, false, true, false, false);
                }
            }
            //            this.Write("Sistema:", 1, 4, COLUMNWIDTH * 2.5);
            this.Write(String.Format("DESB. MAX = {0:P2}", this.Content.DesbMax), 1, valuesStartColumn + 4);
            this.Table.MergeCells(CellRange.Create(this.Table, 1, 4, 2, 4));
            this.Table.Cells[1, 4].Alignment = CellAlignment.MiddleLeft;
            this.ChangeBorders(1, 4, leftIsVisible: true, bottomIsVisible: false);
            this.Write(this.Content.Sistema, 3, 4);
            this.ChangeBorders(3, 4, true, false, false, false);
            this.Table.MergeCells(CellRange.Create(this.Table, 3, 4, 3, 11));
            this.Table.MergeCells(CellRange.Create(this.Table, t.Length + 1, valuesStartColumn, t.Length + 2, this.Table.Columns.Count - 1));
            this.ChangeBorders(t.Length + 1, valuesStartColumn, false, false, false, false);
            //Totales de potencia
            this.Write(this.Content.TotalPTA.ToNumberFormat(), this.Table.Rows.Count - 1, this.Table.Columns.Count - 5);
            this.Write(this.Content.TotalPTB.ToNumberFormat(), this.Table.Rows.Count - 1, this.Table.Columns.Count - 4);
            this.Write(this.Content.TotalPTC.ToNumberFormat(), this.Table.Rows.Count - 1, this.Table.Columns.Count - 3);
        }
Пример #15
0
        private Table getTable()
        {
            Table table = new Table();

            table.SetDatabaseDefaults(db);
            table.TableStyle = db.GetTableStylePIK(); // если нет стиля ПИк в этом чертеже, то он скопируетс из шаблона, если он найдется

            var boldLw = LineWeight.LineWeight040;

            table.SetSize(4, 2);
            table.SetBorders(boldLw);

            table.Columns[0].Width = 30;
            table.Columns[1].Width = 30;

            table.SetRowHeight(8);

            table.Columns[0].Alignment = CellAlignment.MiddleLeft;
            table.Columns[1].Alignment = CellAlignment.MiddleCenter;

            table.Cells[0, 0].TextString = "Парковочные места";
            table.Cells[0, 0].Alignment  = CellAlignment.MiddleCenter;

            table.Cells[1, 0].TextString = "Наименование";
            table.Cells[1, 0].Alignment  = CellAlignment.MiddleCenter;
            table.Cells[1, 1].TextString = "Кол-во";
            table.Rows[1].Height         = 15;

            var cells = CellRange.Create(table, 1, 0, 1, table.Columns.Count - 1);

            cells.Borders.Bottom.LineWeight = boldLw;

            table.Cells[2, 0].TextString = "Всего Машиномест";
            table.Cells[3, 0].TextString = "Машиномест для инвалидов";

            // Машиномест
            table.Cells[2, 1].TextString = data.Places.ToString();
            // Машиномест для инвалидов
            table.Cells[3, 1].TextString = data.InvalidPlaces.ToString();

            cells = CellRange.Create(table, table.Rows.Count - 1, 0, table.Rows.Count - 1, table.Columns.Count - 1);
            cells.Borders.Bottom.LineWeight = boldLw;

            table.GenerateLayout();
            return(table);
        }
Пример #16
0
 private CellRange getTableCell(ObjectId item, Point3d pt, out Table table)
 {
     table = item.GetObject(OpenMode.ForRead) as Table;
     if (table.HasSubSelection)
     {
         return(table.SubSelection);
     }
     else
     {
         if (pt != Point3d.Origin)
         {
             var hit = table.HitTest(pt, Vector3d.ZAxis);
             if (hit.Type == TableHitTestType.Cell)
             {
                 CellRange range = CellRange.Create(table, hit.Row, hit.Column, hit.Row, hit.Column);
                 return(range);
             }
         }
     }
     return(null);
 }
Пример #17
0
        public Table MakeACTable()
        {
            var   rowCoordsList    = rowCoords.ToList();
            var   columnCoordsList = columnCoords.ToList();
            Table tbl = new Table();

            tbl.SetSize(Hcount, Vcount);
            tbl.Position = new Point3d(columnCoordsList[0], rowCoordsList[0], 0);
            for (int i = 0; i < tbl.Rows.Count; i++)
            {
                //поменяли индексы потому что получается отрицательная высота
                tbl.Rows[i].Height = rowCoordsList[i] - rowCoordsList[i + 1];
            }
            for (int j = 0; j < tbl.Columns.Count; j++)
            {
                tbl.Columns[j].Width = columnCoordsList[j + 1] - columnCoordsList[j];
            }
            for (int i = 0; i < tbl.Rows.Count; i++)
            {
                for (int j = 0; j < tbl.Columns.Count; j++)
                {
                    var    cell    = tbl.Cells[i, j];
                    string content = textcels[i, j].GetCellContent();

                    cell.Value       = @"{\W" + textcels[i, j].WidthFactor + ";" + content + "}";
                    cell.TextStyleId = format.TextStyleId;
                    cell.TextHeight  = format.TextHeight;
                    cell.Alignment   = CellAlignment.MiddleCenter;
                }
            }
            foreach (var m in merging)
            {
                tbl.MergeCells(CellRange.Create(tbl, Convert.ToInt32(m.X1), Convert.ToInt32(m.Y1),
                                                Convert.ToInt32(m.X2), Convert.ToInt32(m.Y2)));
            }

            return(tbl);
        }
Пример #18
0
        /// <summary>
        ///
        /// </summary>
        public override void InitTitlesAndHeaders()
        {
            //Se insertan los títulos de la tabla
            this.Table.Cells[0, 0].TextString = this.Content.Tablero;
            //Las filas que deben mezclarse
            List <CellRange> mergeCells = new CellRange[]
            {
                CellRange.Create(this.Table, 1, 0, 7, 3),
                CellRange.Create(this.Table, 8, 0, this.Table.Rows.Count - 1, 3),
                CellRange.Create(this.Table, 1, 4, 2, 11),
                CellRange.Create(this.Table, 4, 4, 7, 11),
                CellRange.Create(this.Table, 8, this.Content.CmpColumns.Length + 5, 8, this.Table.Columns.Count - 1),
                CellRange.Create(this.Table, 12, 4, 12, this.Table.Columns.Count - 1),
                CellRange.Create(this.Table, 13, 5, 13, this.Table.Columns.Count - 7),
                CellRange.Create(this.Table, 13, this.Table.Columns.Count - 5, 13, this.Table.Columns.Count - 1),
                CellRange.Create(this.Table, this.Table.Rows.Count - 2, 6 + this.Content.CmpColumns.Length, this.Table.Rows.Count - 2, this.Table.Columns.Count - 1),
                CellRange.Create(this.Table, this.Table.Rows.Count - 1, 6 + this.Content.CmpColumns.Length, this.Table.Rows.Count - 1, this.Table.Columns.Count - 6),
                CellRange.Create(this.Table, this.Table.Rows.Count - 1, this.Table.Columns.Count - 2, this.Table.Rows.Count - 1, this.Table.Columns.Count - 1),
            }.Union(this.CreateHeaders(9, 5 + this.Content.CmpColumns.Length)).ToList();

            this.ChangeBorders(1, 0, true, true, false, false);
            this.ChangeBorders(8, 0, true, true, false, false);
            //Se insertan los titulos de circuitos
            int rowCount = this.Table.Rows.Count - 1;

            this.Write("W", 8, 4, columnWidth: COLUMNWIDTH * 2.5);
            this.Write("Simbolo", 9, 4, rowHeight: COLUMNWIDTH * 2);
            this.Write("Potencia", 10, 4);
            this.Write("V.A.", 11, 4);
            this.Write("C.T.O", 13, 4);
            this.Write("Unidades", rowCount - 2, 4);
            this.Write("Watts", rowCount - 1, 4);
            this.Write("VA", rowCount, 4);
            this.Write(this.Content.TotalWatts.ToNumberFormat(), rowCount - 1, 5 + this.Content.CmpColumns.Length);
            this.Write(this.Content.TotalVA.ToNumberFormat(), rowCount, 5 + this.Content.CmpColumns.Length);
            //Se actualizan las filas mezcladas
            mergeCells.ForEach(cell => this.Table.MergeCells(cell));
        }
Пример #19
0
        private void buttonExportTbl_Click(object sender, EventArgs e)
        {
            if (dataGridViewTendons.Rows.Count == 0)
            {
                MessageBox.Show("表中没有数据!");
                return;
            }
            this.Visible = false;//对话框消失
            Document doc = AcadApp.DocumentManager.MdiActiveDocument;
            Database db  = doc.Database;
            Editor   ed  = doc.Editor;
            //1.提示用户输入插入点
            PromptPointResult ptRes = ed.GetPoint("\n选择表格插入点");

            if (ptRes.Status != PromptStatus.OK) //如果选择不正确
            {
                this.Visible = true;             //回到对话框
                return;
            }
            //2.先对钢束信息进行更新,类似于点击了更新并退出按钮,但显示更新成功对话框
            using (Transaction trans = db.TransactionManager.StartTransaction())//开始事务处理
            {
                //1.更新有名对象字典中的总体参数
                db.ReadDlgToNamedDic(this);
                //1.1管道偏差系数
                if (!double.TryParse(textBoxKii.Text, out kii))
                {
                    MessageBox.Show("管道偏差系数输入有误!");
                    this.Visible = true;
                    return;
                }
                //1.2摩阻系数
                if (!double.TryParse(textBoxMiu.Text, out miu))
                {
                    MessageBox.Show("摩阻系数输入有误!");
                    this.Visible = true;
                    return;
                }
                //1.3钢束弹模
                double Ep = 1.95e5;
                if (!double.TryParse(textBoxEp.Text, out Ep))
                {
                    MessageBox.Show("钢束弹模输入有误!");
                    this.Visible = true;
                    return;
                }
                //1.4张拉控制应力
                if (!double.TryParse(textBoxCtrlStress.Text, out ctrlStress))
                {
                    MessageBox.Show("张拉控制应力输入有误!");
                    this.Visible = true;
                    return;
                }
                //1.5工作长度
                if (!double.TryParse(textBoxWorkLen.Text, out workLen))
                {
                    MessageBox.Show("工作长度输入有误!");
                    this.Visible = true;
                    return;
                }
                //2.更新钢束Xrecord信息,更新表中伸长量、总长信息(如果工作长度变化的话)
                for (int i = 0; i < dataGridViewTendons.Rows.Count; i++)
                {
                    ObjectId tdId = tdIdsInTable[dataGridViewTendons.Rows[i].Cells[10].Value.ToString()];
                    tdId.ReadRowToXrecord(dataGridViewTendons.Rows[i]);
                    XrecordManipulate.UpdateXRecordToRow(this, i, tdId, kii, miu, Ep, ctrlStress, workLen);
                }
                trans.Commit();//执行事务处理
            }
            //3.输出表格
            using (Transaction trans1 = db.TransactionManager.StartTransaction())//开始事务处理
            {
                //3.1 将表格内容读入列表中便于操作
                List <string> tdNames          = new List <string>();
                List <string> tdStyles         = new List <string>();
                List <int>    tdNums           = new List <int>();
                List <double> pipeDias         = new List <double>();
                List <int>    drawTypes        = new List <int>();
                List <double> leftDrawAmounts  = new List <double>();
                List <double> rightDrawAmounts = new List <double>();
                List <double> clearLens        = new List <double>();
                List <double> totalLens        = new List <double>();
                for (int i = 0; i < dataGridViewTendons.Rows.Count; i++)
                {
                    tdNames.Add(dataGridViewTendons.Rows[i].Cells[0].Value.ToString());
                    tdStyles.Add(dataGridViewTendons.Rows[i].Cells[1].Value.ToString());
                    tdNums.Add(int.Parse(dataGridViewTendons.Rows[i].Cells[2].Value.ToString()));
                    pipeDias.Add(double.Parse(dataGridViewTendons.Rows[i].Cells[3].Value.ToString()));
                    drawTypes.Add(
                        ((bool)(dataGridViewTendons.Rows[i].Cells[4].Value) ? -1 : 0)
                        + ((bool)(dataGridViewTendons.Rows[i].Cells[5].Value) ? 1 : 0)
                        );
                    leftDrawAmounts.Add(double.Parse(dataGridViewTendons.Rows[i].Cells[6].Value.ToString()));
                    rightDrawAmounts.Add(double.Parse(dataGridViewTendons.Rows[i].Cells[7].Value.ToString()));
                    clearLens.Add(double.Parse(dataGridViewTendons.Rows[i].Cells[8].Value.ToString()));
                    totalLens.Add(double.Parse(dataGridViewTendons.Rows[i].Cells[9].Value.ToString()));
                }
                //3.2 设置表格规格
                Table tb = new Table();                           //初始化钢束表格
                tb.SetSize(dataGridViewTendons.RowCount + 3, 14); //设置表格行数(表格行数、表头2行、合计1行)、列数
                //设置列宽
                tb.SetColumnWidth(12);                            //全部设为12
                tb.Columns[1].Width = 22;                         //将钢束规格列设为22
                //设置行高
                tb.SetRowHeight(4);
                tb.Position = ptRes.Value;//插入点
                //根据所使用的波纹管直径种类增加新列
                var pipeDiasDist = pipeDias.Select(c => c).Distinct().OrderBy(c => c).ToList();
                //多一种管道直径增加一列
                if (pipeDiasDist.Count > 1)
                {
                    tb.InsertColumns(9, 12, pipeDiasDist.Count - 1);
                }
                //根据所使用的钢束规格增加新列
                var tdStylesDist = tdStyles.Select(c => c).Distinct().OrderBy(c => int.Parse(c.Remove(0, 4))).ToList();
                //多一种钢束规格增加两列,分别为固定和张拉锚具,表格成形后如果本列锚具合计为零,再进行删除
                if (tdStylesDist.Count > 1)
                {
                    tb.InsertColumns(10 + pipeDiasDist.Count, 12, (tdStylesDist.Count - 1) * 2);
                }
                //设置表格样式
                tb.TableStyle        = db.Tablestyle;              //表格样式为当前表格样式
                tb.Cells.TextStyleId = db.Textstyle;               //表格字体样式为当前样式
                tb.Cells.TextHeight  = 3;                          //表格字高为3
                tb.Cells.Alignment   = CellAlignment.MiddleCenter; //表格对其方式为对中
                tb.SetMargin(-1, -1, CellMargins.Left, 0);         //左侧边距
                tb.SetMargin(-1, -1, CellMargins.Right, 0);        //右侧边距
                tb.SetMargin(-1, -1, CellMargins.Top, 0);          //上侧边距
                tb.SetMargin(-1, -1, CellMargins.Bottom, 0);       //下侧边距
                //3.3 表头合并并填写表头
                //将标题行拆分
                tb.UnmergeCells(tb.Cells[0, 0].GetMergeRange());
                //名称
                tb.Cells[0, 0].TextString = "名称";
                tb.MergeCells(CellRange.Create(tb, 0, 0, 1, 0));
                //规格
                tb.Cells[0, 1].TextString = "规格";
                tb.MergeCells(CellRange.Create(tb, 0, 1, 1, 1));
                //钢束长度
                tb.Cells[0, 2].TextString = "钢束长度\n(mm)";
                tb.MergeCells(CellRange.Create(tb, 0, 2, 1, 2));
                //根数
                tb.Cells[0, 3].TextString = "根数";
                tb.MergeCells(CellRange.Create(tb, 0, 3, 1, 3));
                //钢束总长
                tb.Cells[0, 4].TextString = "钢束总长\n(m)";
                tb.MergeCells(CellRange.Create(tb, 0, 4, 1, 4));
                //总重
                tb.Cells[0, 5].TextString = "总重(kg)";
                tb.MergeCells(CellRange.Create(tb, 0, 5, 1, 5));
                //引伸量
                tb.Cells[0, 6].TextString = "张拉端引伸量(mm)";
                tb.MergeCells(CellRange.Create(tb, 0, 6, 0, 7));
                tb.Cells[1, 6].TextString = "左端";
                tb.Cells[1, 7].TextString = "右端";
                //波纹管长
                tb.Cells[0, 8].TextString = "波纹管长\n(mm)";
                tb.MergeCells(CellRange.Create(tb, 0, 8, 1, 8));
                //管道总长
                tb.Cells[0, 9].TextString = "管道总长(m)";
                if (pipeDiasDist.Count > 1)
                {
                    tb.MergeCells(CellRange.Create(tb, 0, 9, 0, 8 + pipeDiasDist.Count));
                }
                for (int i = 0; i < pipeDiasDist.Count; i++)
                {
                    tb.Cells[1, 9 + i].TextString = "Φ" + pipeDiasDist[i].ToString("F0");
                }
                //锚具
                tb.Cells[0, 9 + pipeDiasDist.Count].TextString = "锚具套数";
                tb.MergeCells(CellRange.Create(tb, 0, 9 + pipeDiasDist.Count, 0, 10 + pipeDiasDist.Count + (tdStylesDist.Count - 1) * 2));
                for (int i = 0; i < tdStylesDist.Count; i++)
                {
                    tb.Cells[1, 9 + pipeDiasDist.Count + 2 * i].TextString     = tdStylesDist[i].Remove(0, 1) + "张拉";
                    tb.Cells[1, 9 + pipeDiasDist.Count + 2 * i + 1].TextString = tdStylesDist[i].Remove(0, 1) + "固定";
                }
                //控制应力
                tb.Cells[0, tb.Columns.Count - 2].TextString = "控制应力\n(MPa)";
                tb.MergeCells(CellRange.Create(tb, 0, tb.Columns.Count - 2, 1, tb.Columns.Count - 2));
                //备注
                tb.Cells[0, tb.Columns.Count - 1].TextString = "备注";
                tb.MergeCells(CellRange.Create(tb, 0, tb.Columns.Count - 1, 1, tb.Columns.Count - 1));
                //3.4 填写表格内容
                for (int i = 0; i < dataGridViewTendons.Rows.Count; i++)                              //行迭代
                {
                    tb.Cells[2 + i, 0].TextString = tdNames[i];                                       //名称
                    tb.Cells[2 + i, 1].TextString = tdStyles[i];                                      //规格
                    tb.Cells[2 + i, 2].TextString = totalLens[i].ToString("F0");                      //钢束长度
                    tb.Cells[2 + i, 3].TextString = tdNums[i].ToString("F0");                         //钢束根数
                    tb.Cells[2 + i, 4].TextString = (totalLens[i] * tdNums[i] / 1000).ToString("F1"); //钢束总长
                    tb.Cells[2 + i, 5].TextString = (int.Parse(tdStyles[i].Remove(0, 4)) * 1.101      //总重
                                                     * (totalLens[i] * tdNums[i] / 1000)).ToString("F1");
                    tb.Cells[2 + i, 6].TextString = leftDrawAmounts[i].ToString("F0");                //左侧引伸量
                    tb.Cells[2 + i, 7].TextString = rightDrawAmounts[i].ToString("F0");               //右侧引伸量
                    tb.Cells[2 + i, 8].TextString = clearLens[i].ToString("F0");                      //波纹管长
                    for (int j = 0; j < pipeDiasDist.Count; j++)                                      //管道总长
                    {
                        if (pipeDias[i] == pipeDiasDist[j])                                           //找到对应直径列
                        {
                            tb.Cells[2 + i, 9 + j].TextString = (clearLens[i] * tdNums[i] / 1000).ToString("F1");
                            break;
                        }
                    }
                    for (int j = 0; j < tdStylesDist.Count; j++)                           //锚具套数
                    {
                        if (tdStyles[i] == tdStylesDist[j])                                //找到对应规格列
                        {
                            tb.Cells[2 + i, 9 + pipeDiasDist.Count + 2 * j].TextString     //张拉套数
                                = (tdNums[i] * (2 - Math.Abs(drawTypes[i]))).ToString("F0");
                            tb.Cells[2 + i, 9 + pipeDiasDist.Count + 2 * j + 1].TextString //锚固套数
                                = (tdNums[i] * Math.Abs(drawTypes[i])).ToString("F0");
                        }
                    }
                    tb.Cells[2 + i, tb.Columns.Count - 2].TextString = ctrlStress.ToString("F0");//控制应力
                    tb.Cells[2 + i, tb.Columns.Count - 1].TextString = (drawTypes[i] == 0) ? "两端张拉" : "单端张拉";
                }
                //3.5 填写最后一行合计内容并删除合计为0的锚具列
                tb.Cells[tb.Rows.Count - 1, 0].TextString = "合计";
                //总重合计
                tb.Cells[tb.Rows.Count - 1, 5].TextString = tb.Columns[5]
                                                            .Where(c => c.Row > 1 && c.Row < tb.Rows.Count - 1)
                                                            .Sum(c => double.Parse(tb.Cells[c.Row, c.Column].TextString)).ToString("F1");
                //管道总长合计
                for (int j = 0; j < pipeDiasDist.Count; j++)//管道总长
                {
                    tb.Cells[tb.Rows.Count - 1, 9 + j].TextString = tb.Columns[9 + j]
                                                                    .Where(c => c.Row > 1 && c.Row < tb.Rows.Count - 1 && (bool)!tb.Cells[c.Row, c.Column].IsEmpty)
                                                                    .Sum(c => double.Parse(tb.Cells[c.Row, c.Column].TextString)).ToString("F1");
                }
                //锚具套数合计
                for (int j = 0; j < 2 * tdStylesDist.Count; j++)
                {
                    tb.Cells[tb.Rows.Count - 1, 9 + pipeDiasDist.Count + j].TextString = tb.Columns[9 + pipeDiasDist.Count + j]
                                                                                         .Where(c => c.Row > 1 && c.Row < tb.Rows.Count - 1 && (bool)!tb.Cells[c.Row, c.Column].IsEmpty)
                                                                                         .Sum(c => int.Parse(tb.Cells[c.Row, c.Column].TextString)).ToString("F0");
                }
                //删除锚具套数合计为0的列,减小表格规模
                var voidCols = tb.Rows[tb.Rows.Count - 1]
                               .Where(c => c.Column >= 9 + pipeDiasDist.Count && c.Column <= tb.Columns.Count - 3)
                               .Where(c => int.Parse(tb.Cells[c.Row, c.Column].TextString) == 0)
                               .Select(c => c.Column)
                               .OrderByDescending(c => c);
                foreach (int iCol in voidCols)
                {
                    tb.DeleteColumns(iCol, 1);//依次删除套数为0的列
                }
                //3.6 将表格按照输入比例缩放
                double   scale = double.Parse(textBoxScale.Text);
                Matrix3d mt    = Matrix3d.Scaling(scale, ptRes.Value);
                tb.TransformBy(mt);
                tb.GenerateLayout();    //更新表格
                db.AddToModelSpace(tb); //将表格加入数据库
                trans1.Commit();        //执行事务处理
            }
            this.Dispose();
        }
Пример #20
0
        public void CreateTableFromList(List <Sheet> dict)
        {
            dict = dict.OrderBy(x => x.SheetNumber).ToList();
            Database db = Active.Database;
            Editor   ed = Active.Editor;

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                PromptPointResult pr   = ed.GetPoint("\nEnter table insertion point: ");
                BlockTable        bt   = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
                ObjectId          msId = bt[BlockTableRecord.ModelSpace];
                BlockTableRecord  btr  = (BlockTableRecord)tr.GetObject(msId, OpenMode.ForWrite);
                Table             tb   = new Table();
                tb.TableStyle = db.Tablestyle;
                //tb.TableStyle = db.Tablestyle;
                btr.AppendEntity(tb);
                // Число строк
                int RowsNum = dict.Count;
                // Число столбцов
                int ColumnsNum = 3;
                // Высота строки
                double rowheight = 8;
                // Ширина столбца
                double columnwidth = 15;
                // Добавляем строки и колонки
                tb.InsertRows(0, rowheight, RowsNum + 1);
                tb.InsertColumns(0, columnwidth, ColumnsNum - 1);
                tb.SetRowHeight(rowheight);
                tb.SetColumnWidth(columnwidth);
                tb.Position = pr.Value;
                // Объединяем ячейки
                CellRange range = CellRange.Create(tb, 0, 0, 0, 2);
                tb.MergeCells(range);
                range.Borders.Top.IsVisible    = false;
                range.Borders.Bottom.IsVisible = true;
                range.Borders.Left.IsVisible   = false;
                range.Borders.Right.IsVisible  = false;
                //var row = tb.Rows[RowsNum];
                range = CellRange.Create(tb, 1, 1, 1, 2);
                tb.UnmergeCells(range);
                tb.Columns[0].Width       = 15;
                tb.Cells[0, 0].TextHeight = 5;
                tb.Cells[0, 0].Alignment  = CellAlignment.MiddleCenter;
                tb.Cells[0, 0].TextString = "Ведомость рабочих чертежей основного комплекта";
                var row = tb.Rows[RowsNum + 1];
                tb.UnmergeCells(row);
                tb.Cells[1, 0].TextString = "Лист";
                tb.Columns[1].Width       = 140;
                tb.Cells[1, 1].TextString = "Наименование";
                tb.Columns[2].Width       = 30;
                tb.Cells[1, 2].TextString = "Примечание";
                //заполняем по одной все ячейки
                int curRow = 2;
                foreach (var item in dict)
                {
                    if (!string.IsNullOrWhiteSpace(item.DocNumber))
                    {
                        tb.Cells[curRow, 0].TextHeight = 3.5;
                        tb.Cells[curRow, 0].TextString = item.SheetNumber.ToString();
                        tb.Cells[curRow, 1].TextHeight = 3.5;
                        tb.Cells[curRow, 1].TextString = item.DocNumber + "_" + item.DocTitleRu;
                        tb.Cells[curRow, 1].Alignment  = CellAlignment.MiddleLeft;
                        if (!string.IsNullOrEmpty(item.Comment))
                        {
                            tb.Cells[curRow, 2].TextHeight = 3.5;
                            tb.Cells[curRow, 2].TextString = item.Comment;
                            tb.Cells[curRow, 2].Alignment  = CellAlignment.MiddleLeft;
                        }
                    }
                    //tb.Cells[curRow, 6].TextString = item.DocTitleEng;
                    //tb.Cells[curRow, 4].TextString = item.DocTitleRu;
                    curRow++;
                }
                range = CellRange.Create(tb, RowsNum, 0, RowsNum, RowsNum);
                tb.UnmergeCells(range);
                tb.GenerateLayout();
                tr.AddNewlyCreatedDBObject(tb, true);
                tr.Commit();
            }
        }
Пример #21
0
        private Table getTable(Database db)
        {
            Table table = new Table();

            table.SetDatabaseDefaults(db);
            table.TableStyle = db.GetTableStylePIK(); // если нет стиля ПИк в этом чертеже, то он скопируетс из шаблона, если он найдется

            var data = _service.DataSection;

            int numRows = 11;

            if (data.FC_LandArea != 0)
            {
                numRows += 3;
            }

            table.SetSize(numRows, 2);

            table.Columns[0].Width = 70;
            table.Columns[1].Width = 25;

            foreach (var item in table.Rows)
            {
                item.Height = 8;
            }

            // Фон таблицы в зависимости от региона
            _service.Estimate.TableFormatting(table);

            //foreach (var column in table.Columns)
            //{
            //    column.Width = 30;
            //    column.Alignment = CellAlignment.MiddleCenter;
            //}

            table.Columns[0].Alignment = CellAlignment.MiddleLeft;
            table.Columns[1].Alignment = CellAlignment.MiddleCenter;
            //table.Rows[1].Height = 15;

            table.Cells[0, 0].TextString = _service.Estimate.Title;;
            table.Cells[0, 0].Alignment  = CellAlignment.MiddleCenter;

            //table.Cells[1, 0].TextString = "Наименование блок-секции";
            //table.Cells[1, 0].Alignment = CellAlignment.MiddleCenter;
            //table.Cells[2, 0].TextString = "Площадь квартир, м.кв.";
            //table.Cells[2, 0].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            //table.Cells[3, 0].TextString = "Площадь БКФН, м.кв.";
            //table.Cells[3, 0].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            //table.Cells[4, 0].TextString = "Количество секций";
            //table.Cells[4, 0].Borders.Bottom.LineWeight = LineWeight.LineWeight030;

            // Площадь ГНС всех этажей
            var numForInf = new System.Globalization.CultureInfo("ru-RU", false).NumberFormat;
            int row       = 1;

            if (data.FC_LandArea != 0)
            {
                table.Cells[row, 0].TextString = "Площадь участка, га";
                table.Cells[row, 0].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
                table.Cells[row, 1].TextString = (data.FC_LandArea).ToString("N1", numForInf);
                table.Cells[row, 1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
                row++;
                table.Cells[row, 0].TextString = "Площадь квартала, га";
                table.Cells[row, 0].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
                table.Cells[row, 1].TextString = (data.FC_QuarterArea).ToString("N1", numForInf);
                table.Cells[row, 1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
                row++;
            }
            table.Cells[row, 0].TextString = "Площадь в габ.наружных стен, м.кв.";
            table.Cells[row, 0].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            table.Cells[row, 1].TextString = (data.KP_GNS_Total).ToString("N1", numForInf);
            table.Cells[row, 1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            row++;
            table.Cells[row, 0].TextString = "Площадь жилого фонда, м.кв.";
            table.Cells[row, 0].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            table.Cells[row, 1].TextString = (data.TotalArea).ToString("N1", numForInf);
            table.Cells[row, 1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            row++;
            table.Cells[row, 0].TextString = "Площадь квартир, м.кв.";
            table.Cells[row, 0].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            table.Cells[row, 1].TextString = data.TotalAreaApart.ToString("N1", numForInf);
            table.Cells[row, 1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            row++;
            table.Cells[row, 0].TextString = "Площадь БКФН, м.кв.";
            table.Cells[row, 0].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            table.Cells[row, 1].TextString = data.TotalAreaBKFN.ToString("N1", numForInf);
            table.Cells[row, 1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            row++;
            table.Cells[row, 0].TextString = "Средняя этажность";
            table.Cells[row, 0].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            table.Cells[row, 1].TextString = data.AverageFloors.ToString("N1", numForInf);
            table.Cells[row, 1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            row++;
            table.Cells[row, 0].TextString = $"Жителей, чел ({_service.Estimate.LiveAreaPerHuman}м.кв./чел)";
            table.Cells[row, 0].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            data.Population = _service.Estimate.CalcPopulation(data);// Math.Floor(data.TotalAreaApart / _service.Estimate.LiveAreaPerHuman); // Всего площадь квартир/28
            var population = data.Population;

            table.Cells[row, 1].TextString = population.ToString();
            table.Cells[row, 1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            row++;
            table.Cells[row, 0].TextString = $"ДОО, чел ({_service.Estimate.KindergartenPlacePer1000}/1000)";
            table.Cells[row, 0].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            table.Cells[row, 1].TextString = Math.Ceiling(population * 0.001 * _service.Estimate.KindergartenPlacePer1000).ToString(); //(("Всего площадь квартир"/28)/1000)*65
            table.Cells[row, 1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            row++;
            table.Cells[row, 0].TextString = $"СОШ, чел ({_service.Estimate.SchoolPlacePer1000}/1000)";
            table.Cells[row, 0].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            table.Cells[row, 1].TextString = Math.Ceiling(population * 0.001 * _service.Estimate.SchoolPlacePer1000).ToString();//  (("Всего площадь квартир"/28)/1000)*135
            table.Cells[row, 1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            row++;
            table.Cells[row, 0].TextString = $@"Машиноместа, м/м {_service.Estimate.GetParkingPlace()}"; // "\\A1;\\pxt8;Машиноместа, м/м\\P\\ptz;{\\H0.6x;420/1 000}"
            table.Cells[row, 0].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            var mm = _service.Estimate.GetParkingPlace(data);

            table.Cells[row, 1].TextString = Math.Ceiling(mm * _service.Estimate.ParkingPlacePercent * 0.01).ToString();//  (("Всего площадь квартир"/28)/1000)*420 90%
            table.Cells[row, 1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            row++;
            table.Cells[row, 0].TextString = $"Машиноместа гостевые, м/м {_service.Estimate.GetParkingPlaceGuest()}";
            table.Cells[row, 0].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            table.Cells[row, 1].TextString = Math.Ceiling(mm * _service.Estimate.ParkingPlaceGuestPercent * 0.01).ToString();//  Машиноместа %25
            table.Cells[row, 1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;

            if (data.FC_LandArea != 0)
            {
                row++;
                table.Cells[row, 0].TextString = "Плотность, га";
                table.Cells[row, 0].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
                table.Cells[row, 1].TextString = (data.FC_Density).ToString("N", numForInf);
                table.Cells[row, 1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            }

            var titleCells = CellRange.Create(table, 1, 0, 1, table.Columns.Count - 1);

            titleCells.Borders.Bottom.LineWeight = LineWeight.LineWeight030;

            // Параметры по типам секций
            //int col = 1;
            //foreach (var sectType in data.SectionTypes)
            //{
            //    table.Cells[1, col].TextString = sectType.Name; //Наименование
            //    table.Cells[2, col].TextString = sectType.AreaApartTotal.ToString("0.0");  //Площадь квартир
            //    table.Cells[3, col].TextString = sectType.AreaBKFN.ToString("0.0");  // Площадь БКФН
            //    table.Cells[4, col].TextString = sectType.Count.ToString();// Кол секций
            //    col++;
            //}
            //var mCells = CellRange.Create(table, 5, 1, 5, table.Columns.Count - 1);
            //table.MergeCells(mCells);
            //mCells = CellRange.Create(table, 6, 1, 6, table.Columns.Count - 1);
            //table.MergeCells(mCells);
            //mCells = CellRange.Create(table, 7, 1, 7, table.Columns.Count - 1);
            //table.MergeCells(mCells);
            //mCells = CellRange.Create(table, 8, 1, 8, table.Columns.Count - 1);
            //table.MergeCells(mCells);
            //mCells = CellRange.Create(table, 9, 1, 9, table.Columns.Count - 1);
            //table.MergeCells(mCells);
            //mCells = CellRange.Create(table, 10, 1, 10, table.Columns.Count - 1);
            //table.MergeCells(mCells);
            //mCells = CellRange.Create(table, 11, 1, 11, table.Columns.Count - 1);
            //table.MergeCells(mCells);
            //mCells = CellRange.Create(table, 12, 1, 12, table.Columns.Count - 1);
            //table.MergeCells(mCells);

            // Общие параметры по всем типам секций

            //// Площадь ГНС всех этажей
            //table.Cells[1, 1].TextString = (data.KP_GNS_Total).ToString("0.0");
            //table.Cells[1, 1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            //// Всего площадь жилого фонда
            //table.Cells[2, 1].TextString = (data.TotalArea).ToString("0.0");
            //table.Cells[2, 1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            //// ВСЕГО ПЛОЩАДЬ КВАРТИР
            //table.Cells[3, 1].TextString = data.TotalAreaApart.ToString("0.0");
            //table.Cells[3, 1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            //// ВСЕГО ПЛОЩАДЬ БКФН
            //table.Cells[4, 1].TextString = data.TotalAreaBKFN.ToString("0.0");
            //table.Cells[4, 1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            //// Средняя этажность
            //table.Cells[5, 1].TextString = data.AverageFloors.ToString("0.0");
            //table.Cells[5, 1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            //// Жителей
            //data.Population = _service.Estimate.CalcPopulation(data);// Math.Floor(data.TotalAreaApart / _service.Estimate.LiveAreaPerHuman); // Всего площадь квартир/28
            //var population = data.Population;
            //table.Cells[6, 1].TextString = population.ToString();
            //table.Cells[6, 1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            ////ДОО, чел
            //table.Cells[7, 1].TextString =Math.Ceiling(population*0.001*_service.Estimate.KindergartenPlacePer1000).ToString(); //(("Всего площадь квартир"/28)/1000)*65
            //table.Cells[7, 1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            ////СОШ, чел
            //table.Cells[8, 1].TextString = Math.Ceiling(population*0.001*_service.Estimate.SchoolPlacePer1000).ToString();//  (("Всего площадь квартир"/28)/1000)*135
            //table.Cells[8, 1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            ////Машиноместа, м/м
            //var mm = _service.Estimate.GetParkingPlace(data);
            //table.Cells[9, 1].TextString = Math.Ceiling(mm*_service.Estimate.ParkingPlacePercent*0.01).ToString();//  (("Всего площадь квартир"/28)/1000)*420 90%
            //table.Cells[9, 1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            ////Машиноместа гостевые, м/м
            //table.Cells[10, 1].TextString = Math.Ceiling(mm *_service.Estimate.ParkingPlaceGuestPercent*0.01).ToString();//  Машиноместа %25
            //table.Cells[10, 1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;

            table.GenerateLayout();
            return(table);
        }
Пример #22
0
        private Table getTable()
        {
            Table table = new Table();

            table.SetDatabaseDefaults(db);
            table.TableStyle = db.GetTableStylePIK(true); // если нет стиля ПИк в этом чертеже, то он скопируетс из шаблона, если он найдется
            // Измпнение отступа в стилше ПИК на 1
            UpdateTableStyle(table.TableStyle);

            bool hasTotalRow = (condRows.Count > 1);
            int  rows        = hasTotalRow ? condRows.Count + 3 : condRows.Count + 2;

            table.SetSize(rows, 5);

            table.SetRowHeight(8);

            // Название таблицы
            var rowTitle = table.Cells[0, 0];

            rowTitle.Alignment  = CellAlignment.MiddleCenter;
            rowTitle.TextString = "Спецификация на наружное ограждение блока кондиционера";

            // столбец Марка
            var col = table.Columns[0];

            col.Alignment = CellAlignment.MiddleCenter;
            col.Width     = 10;
            // столбец Цвет.
            col           = table.Columns[1];
            col.Alignment = CellAlignment.MiddleLeft;
            col.Width     = 35;
            // столбец Образец
            col           = table.Columns[2];
            col.Alignment = CellAlignment.MiddleCenter;
            col.Width     = 20;
            // столбец Кол
            col           = table.Columns[3];
            col.Alignment = CellAlignment.MiddleCenter;
            col.Width     = 20;
            // столбец Прим
            col           = table.Columns[4];
            col.Alignment = CellAlignment.MiddleCenter;
            col.Width     = hasTotalRow? 40 : 60;

            // Заголовок Маркв
            var cellColName = table.Cells[1, 0];

            cellColName.TextString = "Марка";
            //cellColName.Alignment = CellAlignment.MiddleCenter;
            // Заголовок Цвет
            cellColName            = table.Cells[1, 1];
            cellColName.TextString = "Цвет";
            cellColName.Alignment  = CellAlignment.MiddleCenter;
            // Заголовок Образец
            cellColName            = table.Cells[1, 2];
            cellColName.TextString = "Образец";
            //cellColName.Alignment = CellAlignment.MiddleCenter;
            // Заголовок Кол
            cellColName            = table.Cells[1, 3];
            cellColName.TextString = "Кол-во, шт.";
            //cellColName.Alignment = CellAlignment.MiddleCenter;
            // Заголовок прим
            cellColName            = table.Cells[1, 4];
            cellColName.TextString = "Примечание";
            //cellColName.Alignment = CellAlignment.MiddleCenter;

            // Строка заголовков столбцов
            var rowHeaders = table.Rows[1];

            rowHeaders.Height = 15;
            var lwBold = rowHeaders.Borders.Top.LineWeight;

            rowHeaders.Borders.Bottom.LineWeight = lwBold;

            int row = 2;

            foreach (var itemRow in condRows)
            {
                table.Cells[row, 0].TextString      = itemRow.Mark.ToString();
                table.Cells[row, 1].TextString      = itemRow.ColorName;
                table.Cells[row, 2].BackgroundColor = itemRow.Color;
                table.Cells[row, 3].TextString      = itemRow.Count.ToString();
                row++;
            }

            // Объединение итого
            if (hasTotalRow)
            {
                table.MergeCells(CellRange.Create(table, row, 0, row, 2));
                table.Cells[row, 0].TextString = "Итого на фасад";
                table.Cells[row, 3].TextString = condRows.Sum(c => c.Count).ToString();

                // Объединение примечания
                table.MergeCells(CellRange.Create(table, 2, 4, row, 4));
                table.Rows[row].Borders.Top.LineWeight = lwBold;
            }

            table.Cells[2, 4].TextString = "Стальной перфорированный лист, окрашенный порошковой эмалью в цвет по таблице.";

            var lastRow = table.Rows.Last();

            lastRow.Borders.Bottom.LineWeight = lwBold;

            table.GenerateLayout();
            return(table);
        }
Пример #23
0
            /// <summary>
            /// Добавление столбцов в ьаблицу
            /// </summary>
            public static void AddColumns(Table table, BillRow row, BillTable spec, BillService service)
            {
                // группировка по ячейкам
                var cells = row.Cells.GroupBy(g => g).OrderBy(o => o.Key);

                cols = new Dictionary <BillCell, BillColumn>();

                // Марка конструкции
                mergeRows(table, 0, 1, spec.rowNameIndex);
                table.Cells[1, 0].TextString = "Марка конструкции";
                table.Columns[0].Width       = 40;

                // группировка по заголовку
                int curTitleColFirst = 1;
                int curTitleColLast  = 1;

                foreach (var title in cells.GroupBy(g => g.Key.BillMaterial.BillTitle))
                {
                    int curGroupColFirst = curTitleColLast;
                    int curGroupColLast  = 0;
                    // группировка по группе материалов - Арматура класса, Прокат марки
                    foreach (var group in title.GroupBy(g => g.Key.BillMaterial.BillGroup))
                    {
                        int curMarkColFirst = curGroupColFirst;
                        int curMarkColLast  = 0;
                        // группировка по марке
                        foreach (var mark in group.GroupBy(g => g.Key.BillMaterial.BillMark))
                        {
                            int curGostColFirst = curMarkColFirst;
                            int curGostColLast  = 0;
                            // группировка по госту
                            foreach (var gost in mark.GroupBy(g => g.Key.BillMaterial.BillGOST))
                            {
                                // вставка столбцов для набора ячеек одного госта + итого
                                var countCell = gost.Count();
                                curGostColLast = curGostColFirst + countCell;
                                table.InsertColumns(curGostColFirst, 15, countCell + 1);

                                // заполенение ячеек
                                int curNameCol = curGostColFirst;
                                foreach (var name in gost)
                                {
                                    table.Cells[spec.rowNameIndex, curNameCol].TextString     = name.Key.BillMaterial.BillName;
                                    table.Cells[spec.rowNameIndex + 1, curNameCol].TextString = name.Key.Amount.ToString();
                                    BillColumn col = new BillColumn(name.Key, curNameCol);
                                    cols.Add(name.Key, col);
                                    curNameCol++;
                                }
                                // итого
                                table.Cells[spec.rowNameIndex, curNameCol].TextString     = "Итого";
                                table.Cells[spec.rowNameIndex + 1, curNameCol].TextString = gost.Sum(s => s.Key.Amount).ToString();
                                // Объединение строки госта
                                mergeColumns(table, spec.rowGostIndex, curGostColFirst, curGostColLast);
                                table.Cells[spec.rowGostIndex, curGostColFirst].TextString = gost.Key;
                                curGostColFirst = curGostColLast + 1;
                            }
                            curMarkColLast = curGostColLast;
                            // Объединение строки марки
                            mergeColumns(table, spec.rowMarkIndex, curMarkColFirst, curMarkColLast);
                            table.Cells[spec.rowMarkIndex, curMarkColFirst].TextString = mark.Key;
                            curMarkColFirst = curMarkColLast + 1;
                        }
                        curGroupColLast = curMarkColLast;
                        // Объединение строки группы
                        mergeColumns(table, spec.rowGroupIndex, curGroupColFirst, curGroupColLast);
                        table.Cells[spec.rowGroupIndex, curGroupColFirst].TextString = group.Key;
                        curGroupColFirst = curGroupColLast + 1;
                    }
                    curTitleColLast = curGroupColLast;
                    // Объединение строки заголовка
                    mergeColumns(table, spec.rowTitleIndex, curTitleColFirst, curTitleColLast);
                    table.Cells[spec.rowTitleIndex, curTitleColFirst].TextString = title.Key;
                    curTitleColFirst = curTitleColLast + 1;
                    curTitleColLast  = curTitleColFirst;
                }

                var colIndex = curTitleColLast;

                table.InsertColumns(colIndex, 15, 1);
                var mCells = CellRange.Create(table, 1, colIndex, spec.rowNameIndex, colIndex);

                table.MergeCells(mCells);
                table.Cells[1, colIndex].TextString = "Всего";
                table.Cells[spec.rowNameIndex + 1, colIndex].TextString = row.Cells.Sum(s => s.Amount).ToString();

                // всего бетона
                var concretes = service.Elements.OfType <Concrete>().GroupBy(g => g.ClassB).OrderBy(o => o.Key, AcadLib.Comparers.AlphanumComparator.New);

                //.FirstOrDefault(g => g.Type == GroupType.Materials)?.Rows.Where(r=>r.SomeElement is Concrete)?.GroupBy(g=>((Concrete)g.SomeElement).ClassB);
                if (concretes != null)
                {
                    foreach (var concrete in concretes)
                    {
                        colIndex++;
                        table.InsertColumns(colIndex, 15, 1);
                        mCells = CellRange.Create(table, 1, colIndex, spec.rowNameIndex, colIndex);
                        table.MergeCells(mCells);
                        string unitsConcrete = concrete.First().Units;// ((Concrete)concrete.First().SomeElement).Units;
                        table.Cells[1, colIndex].TextString = $"Расход бетона класса {concrete.Key}, {unitsConcrete}";
                        table.Cells[spec.rowNameIndex + 1, colIndex].TextString = concrete.Sum(c => c.Volume).ToString();
                    }
                }
            }
Пример #24
0
        public static Table CreateTable(ICollection <FixtureDetails> FixtureDetails, InsertPoint insertPoint)
        {
            Table t = new Table();

            //t.Layer = TableScheduleName.TableLayer;
            t.Width = TableScheduleName.Width;

            int rowsNum    = 2 + FixtureDetails.Count;
            int columnsNum = 8;

            // table already has 1 row, 1 column, that's why we insert - 1;
            t.InsertRows(0, 1.5, rowsNum - 1);
            t.InsertColumns(0, 1, columnsNum - 1);

            //Merge the Title ROWS
            CellRange crTitle = CellRange.Create(t, 0, 0, 0, columnsNum - 1);

            t.MergeCells(crTitle);

            //GENERAL SETTINGS
            t.Cells.TextHeight   = TableScheduleName.GeneralTextHeight;
            t.Cells.ContentColor = Color.FromColorIndex(ColorMethod.ByAci, 2);
            t.Cells.Alignment    = CellAlignment.MiddleCenter;


            //Column Description -- Align Left
            t.Columns[columnsNum - 1].Alignment = CellAlignment.MiddleLeft;

            t.Cells[1, 7].Alignment = CellAlignment.MiddleCenter;

            //Set WIDTH FOR EARCH COLUMN:
            t.Columns[0].Width = 0.67;
            t.Columns[1].Width = 2;
            t.Columns[2].Width = 0.5;
            t.Columns[3].Width = 0.5;
            t.Columns[4].Width = 0.5;
            t.Columns[5].Width = 0.5;
            t.Columns[6].Width = 0.5;
            t.Columns[7].Width = 4.25;

            //Set General ROWS HEIGHT;
            for (int index = 0; index < rowsNum; index++)
            {
                t.Rows[index].Height = TableScheduleName.GeneralRowHeight;
            }

            t.Rows[0].Height         = TableScheduleName.TitleRowHeight;
            t.Cells[0, 0].TextString = insertPoint.model.name;
            t.Cells[0, 0].TextHeight = TableScheduleName.TitleTextHeight;

            //SET UP SECOND ROW TITLES
            t.Rows[1].Height         = 0.75;
            t.Cells[1, 0].TextString = "ITEM";
            t.Cells[1, 1].TextString = "FIXTURE";

            t.Cells[1, 2].TextString           = "COLD WATER";
            t.Cells[1, 2].Contents[0].Rotation = Math.PI / 2;

            t.Cells[1, 3].TextString           = "HOT WATER";
            t.Cells[1, 3].Contents[0].Rotation = Math.PI / 2;

            t.Cells[1, 4].TextString           = "WASTE";
            t.Cells[1, 4].Contents[0].Rotation = Math.PI / 2;

            t.Cells[1, 5].TextString           = "VENT";
            t.Cells[1, 5].Contents[0].Rotation = Math.PI / 2;

            t.Cells[1, 6].TextString           = "STORM DRAIN";
            t.Cells[1, 6].Contents[0].Rotation = Math.PI / 2;

            t.Cells[1, 7].TextString = "DESCRIPTION";

            //Index starts at third orw;
            int i = 2;

            foreach (FixtureDetails FD in FixtureDetails)
            {
                t.Cells[i, 1].TextString = FD.model.FIXTURENAME;

                t.Cells[i, 2].TextString = returnTextStringFinalValue(NumberConverter.ConvertToFractionalNumber(FD.model.CW_DIA));
                t.Cells[i, 3].TextString = returnTextStringFinalValue(NumberConverter.ConvertToFractionalNumber(FD.model.HW_DIA));
                t.Cells[i, 4].TextString = returnTextStringFinalValue(NumberConverter.ConvertToFractionalNumber(FD.model.WASTE_DIA));
                t.Cells[i, 5].TextString = returnTextStringFinalValue(NumberConverter.ConvertToFractionalNumber(FD.model.VENT_DIA));
                t.Cells[i, 6].TextString = returnTextStringFinalValue(NumberConverter.ConvertToFractionalNumber(FD.model.STORM_DIA));
                t.Cells[i, 7].TextString = FD.model.DESCRIPTION;

                i++;
            }

            t.Position = new Point3d(insertPoint.model.position.X, insertPoint.model.position.Y, insertPoint.model.position.Z);

            return(t);
        }
Пример #25
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonExportTbl_Click(object sender, RoutedEventArgs e)
        {
            if (dataGridTdInfo.Items.Count == 0)
            {
                MessageBox.Show("表中没有数据!");
                return;
            }
            this.Hide();//对话框消失
            Document doc = AcadApp.DocumentManager.MdiActiveDocument;
            Database db  = doc.Database;
            Editor   ed  = doc.Editor;
            //1.提示用户输入插入点
            PromptPointResult ptRes = ed.GetPoint("\n选择表格插入点");

            if (ptRes.Status != PromptStatus.OK) //如果选择不正确
            {
                this.Show();                     //回到对话框
                return;
            }
            //2.先对钢束信息进行更新,类似于点击了更新并退出按钮,但显示更新成功对话框
            using (Transaction trans = db.TransactionManager.StartTransaction()) //开始事务处理
                using (DocumentLock loc = doc.LockDocument())
                {
                    //1.更新图形数据库总体信息
                    SyncData.SyncTdGenParasToDlg(this);
                    db.SyncDwgToTdGenParas();
                    //2.更新钢束Xrecord信息
                    SyncData.SyncTdsToDlg(ref tdsInTbl, this);
                    db.SyncDwgToTds(tdsInTbl);
                    trans.Commit();//执行事务处理
                }
            //3.输出表格
            using (Transaction trans1 = db.TransactionManager.StartTransaction()) //开始事务处理
                using (DocumentLock loc = doc.LockDocument())
                {
                    //3.1 将表格内容读入列表中便于操作
                    List <string> tdNames          = new List <string>();
                    List <string> tdStyles         = new List <string>();
                    List <int>    tdNums           = new List <int>();
                    List <double> pipeDias         = new List <double>();
                    List <int>    drawTypes        = new List <int>();
                    List <double> leftDrawAmounts  = new List <double>();
                    List <double> rightDrawAmounts = new List <double>();
                    List <double> clearLens        = new List <double>();
                    List <double> totalLens        = new List <double>();
                    for (int i = 0; i < dataGridTdInfo.Items.Count; i++)
                    {
                        tdNames.Add((dataGridTdInfo.Columns[0].GetCellContent(dataGridTdInfo.Items[i]) as TextBlock).Text);
                        tdStyles.Add((dataGridTdInfo.GetControl(i, 1, "comboBoxTdStyles") as ComboBox).Text);
                        tdNums.Add(int.Parse((dataGridTdInfo.Columns[2].GetCellContent(dataGridTdInfo.Items[i]) as TextBlock).Text));
                        pipeDias.Add(double.Parse((dataGridTdInfo.Columns[3].GetCellContent(dataGridTdInfo.Items[i]) as TextBlock).Text));
                        drawTypes.Add(
                            ((bool)((dataGridTdInfo.GetControl(i, 4, "checkBoxLeftDraw") as CheckBox).IsChecked) ? -1 : 0)
                            + ((bool)((dataGridTdInfo.GetControl(i, 5, "checkBoxRightDraw") as CheckBox).IsChecked) ? 1 : 0)
                            );
                        leftDrawAmounts.Add(double.Parse((dataGridTdInfo.Columns[6].GetCellContent(dataGridTdInfo.Items[i]) as TextBlock).Text));
                        rightDrawAmounts.Add(double.Parse((dataGridTdInfo.Columns[7].GetCellContent(dataGridTdInfo.Items[i]) as TextBlock).Text));
                        clearLens.Add(double.Parse((dataGridTdInfo.Columns[8].GetCellContent(dataGridTdInfo.Items[i]) as TextBlock).Text));
                        totalLens.Add(double.Parse((dataGridTdInfo.Columns[9].GetCellContent(dataGridTdInfo.Items[i]) as TextBlock).Text));
                    }
                    //3.2 设置表格规格
                    Autodesk.AutoCAD.DatabaseServices.Table tb = new Autodesk.AutoCAD.DatabaseServices.Table(); //初始化钢束表格
                    tb.SetSize(dataGridTdInfo.Items.Count + 3, 14);                                             //设置表格行数(表格行数、表头2行、合计1行)、列数
                    //设置列宽
                    tb.SetColumnWidth(12);                                                                      //全部设为12
                    tb.Columns[1].Width = 22;                                                                   //将钢束规格列设为22
                    //设置行高
                    tb.SetRowHeight(4);
                    tb.Position = ptRes.Value;//插入点
                    //根据所使用的波纹管直径种类增加新列
                    var pipeDiasDist = pipeDias.Select(c => c).Distinct().OrderBy(c => c).ToList();
                    //多一种管道直径增加一列
                    if (pipeDiasDist.Count > 1)
                    {
                        tb.InsertColumns(9, 12, pipeDiasDist.Count - 1);
                    }
                    //根据所使用的钢束规格增加新列
                    var tdStylesDist = tdStyles.Select(c => c).Distinct().OrderBy(c => int.Parse(c.Remove(0, 4))).ToList();
                    //多一种钢束规格增加两列,分别为固定和张拉锚具,表格成形后如果本列锚具合计为零,再进行删除
                    if (tdStylesDist.Count > 1)
                    {
                        tb.InsertColumns(10 + pipeDiasDist.Count, 12, (tdStylesDist.Count - 1) * 2);
                    }
                    //设置表格样式
                    tb.TableStyle        = db.Tablestyle;              //表格样式为当前表格样式
                    tb.Cells.TextStyleId = db.Textstyle;               //表格字体样式为当前样式
                    tb.Cells.TextHeight  = 3;                          //表格字高为3
                    tb.Cells.Alignment   = CellAlignment.MiddleCenter; //表格对其方式为对中
                    tb.SetMargin(-1, -1, CellMargins.Left, 0);         //左侧边距
                    tb.SetMargin(-1, -1, CellMargins.Right, 0);        //右侧边距
                    tb.SetMargin(-1, -1, CellMargins.Top, 0);          //上侧边距
                    tb.SetMargin(-1, -1, CellMargins.Bottom, 0);       //下侧边距
                    //3.3 表头合并并填写表头
                    //将标题行拆分
                    tb.UnmergeCells(tb.Cells[0, 0].GetMergeRange());
                    //名称
                    tb.Cells[0, 0].TextString = "名称";
                    tb.MergeCells(CellRange.Create(tb, 0, 0, 1, 0));
                    //规格
                    tb.Cells[0, 1].TextString = "规格";
                    tb.MergeCells(CellRange.Create(tb, 0, 1, 1, 1));
                    //钢束长度
                    tb.Cells[0, 2].TextString = "钢束长度\n(mm)";
                    tb.MergeCells(CellRange.Create(tb, 0, 2, 1, 2));
                    //根数
                    tb.Cells[0, 3].TextString = "根数";
                    tb.MergeCells(CellRange.Create(tb, 0, 3, 1, 3));
                    //钢束总长
                    tb.Cells[0, 4].TextString = "钢束总长\n(m)";
                    tb.MergeCells(CellRange.Create(tb, 0, 4, 1, 4));
                    //总重
                    tb.Cells[0, 5].TextString = "总重(kg)";
                    tb.MergeCells(CellRange.Create(tb, 0, 5, 1, 5));
                    //引伸量
                    tb.Cells[0, 6].TextString = "张拉端引伸量(mm)";
                    tb.MergeCells(CellRange.Create(tb, 0, 6, 0, 7));
                    tb.Cells[1, 6].TextString = "左端";
                    tb.Cells[1, 7].TextString = "右端";
                    //波纹管长
                    tb.Cells[0, 8].TextString = "波纹管长\n(mm)";
                    tb.MergeCells(CellRange.Create(tb, 0, 8, 1, 8));
                    //管道总长
                    tb.Cells[0, 9].TextString = "管道总长(m)";
                    if (pipeDiasDist.Count > 1)
                    {
                        tb.MergeCells(CellRange.Create(tb, 0, 9, 0, 8 + pipeDiasDist.Count));
                    }
                    for (int i = 0; i < pipeDiasDist.Count; i++)
                    {
                        tb.Cells[1, 9 + i].TextString = "Φ" + pipeDiasDist[i].ToString("F0");
                    }
                    //锚具
                    tb.Cells[0, 9 + pipeDiasDist.Count].TextString = "锚具套数";
                    tb.MergeCells(CellRange.Create(tb, 0, 9 + pipeDiasDist.Count, 0, 10 + pipeDiasDist.Count + (tdStylesDist.Count - 1) * 2));
                    for (int i = 0; i < tdStylesDist.Count; i++)
                    {
                        tb.Cells[1, 9 + pipeDiasDist.Count + 2 * i].TextString     = tdStylesDist[i].Remove(0, 1) + "张拉";
                        tb.Cells[1, 9 + pipeDiasDist.Count + 2 * i + 1].TextString = tdStylesDist[i].Remove(0, 1) + "固定";
                    }
                    //控制应力
                    tb.Cells[0, tb.Columns.Count - 2].TextString = "控制应力\n(MPa)";
                    tb.MergeCells(CellRange.Create(tb, 0, tb.Columns.Count - 2, 1, tb.Columns.Count - 2));
                    //备注
                    tb.Cells[0, tb.Columns.Count - 1].TextString = "备注";
                    tb.MergeCells(CellRange.Create(tb, 0, tb.Columns.Count - 1, 1, tb.Columns.Count - 1));
                    //3.4 填写表格内容
                    for (int i = 0; i < dataGridTdInfo.Items.Count; i++)                                  //行迭代
                    {
                        tb.Cells[2 + i, 0].TextString = tdNames[i];                                       //名称
                        tb.Cells[2 + i, 1].TextString = tdStyles[i];                                      //规格
                        tb.Cells[2 + i, 2].TextString = totalLens[i].ToString("F0");                      //钢束长度
                        tb.Cells[2 + i, 3].TextString = tdNums[i].ToString("F0");                         //钢束根数
                        tb.Cells[2 + i, 4].TextString = (totalLens[i] * tdNums[i] / 1000).ToString("F1"); //钢束总长
                        tb.Cells[2 + i, 5].TextString = (int.Parse(tdStyles[i].Remove(0, 4)) * 1.101      //总重
                                                         * (totalLens[i] * tdNums[i] / 1000)).ToString("F1");
                        tb.Cells[2 + i, 6].TextString = leftDrawAmounts[i].ToString("F0");                //左侧引伸量
                        tb.Cells[2 + i, 7].TextString = rightDrawAmounts[i].ToString("F0");               //右侧引伸量
                        tb.Cells[2 + i, 8].TextString = clearLens[i].ToString("F0");                      //波纹管长
                        for (int j = 0; j < pipeDiasDist.Count; j++)                                      //管道总长
                        {
                            if (pipeDias[i] == pipeDiasDist[j])                                           //找到对应直径列
                            {
                                tb.Cells[2 + i, 9 + j].TextString = (clearLens[i] * tdNums[i] / 1000).ToString("F1");
                                break;
                            }
                        }
                        for (int j = 0; j < tdStylesDist.Count; j++)                           //锚具套数
                        {
                            if (tdStyles[i] == tdStylesDist[j])                                //找到对应规格列
                            {
                                tb.Cells[2 + i, 9 + pipeDiasDist.Count + 2 * j].TextString     //张拉套数
                                    = (tdNums[i] * (2 - Math.Abs(drawTypes[i]))).ToString("F0");
                                tb.Cells[2 + i, 9 + pipeDiasDist.Count + 2 * j + 1].TextString //锚固套数
                                    = (tdNums[i] * Math.Abs(drawTypes[i])).ToString("F0");
                            }
                        }
                        tb.Cells[2 + i, tb.Columns.Count - 2].TextString = TendonGeneralParameters.CtrlStress.ToString("F0");//控制应力
                        tb.Cells[2 + i, tb.Columns.Count - 1].TextString = (drawTypes[i] == 0) ? "两端张拉" : "单端张拉";
                    }
                    //3.5 填写最后一行合计内容并删除合计为0的锚具列
                    tb.Cells[tb.Rows.Count - 1, 0].TextString = "合计";
                    //总重合计
                    tb.Cells[tb.Rows.Count - 1, 5].TextString = tb.Columns[5]
                                                                .Where(c => c.Row > 1 && c.Row < tb.Rows.Count - 1)
                                                                .Sum(c => double.Parse(tb.Cells[c.Row, c.Column].TextString)).ToString("F1");
                    //管道总长合计
                    for (int j = 0; j < pipeDiasDist.Count; j++)//管道总长
                    {
                        tb.Cells[tb.Rows.Count - 1, 9 + j].TextString = tb.Columns[9 + j]
                                                                        .Where(c => c.Row > 1 && c.Row < tb.Rows.Count - 1 && (bool)!tb.Cells[c.Row, c.Column].IsEmpty)
                                                                        .Sum(c => double.Parse(tb.Cells[c.Row, c.Column].TextString)).ToString("F1");
                    }
                    //锚具套数合计
                    for (int j = 0; j < 2 * tdStylesDist.Count; j++)
                    {
                        tb.Cells[tb.Rows.Count - 1, 9 + pipeDiasDist.Count + j].TextString = tb.Columns[9 + pipeDiasDist.Count + j]
                                                                                             .Where(c => c.Row > 1 && c.Row < tb.Rows.Count - 1 && (bool)!tb.Cells[c.Row, c.Column].IsEmpty)
                                                                                             .Sum(c => int.Parse(tb.Cells[c.Row, c.Column].TextString)).ToString("F0");
                    }
                    //删除锚具套数合计为0的列,减小表格规模
                    var voidCols = tb.Rows[tb.Rows.Count - 1]
                                   .Where(c => c.Column >= 9 + pipeDiasDist.Count && c.Column <= tb.Columns.Count - 3)
                                   .Where(c => int.Parse(tb.Cells[c.Row, c.Column].TextString) == 0)
                                   .Select(c => c.Column)
                                   .OrderByDescending(c => c);
                    foreach (int iCol in voidCols)
                    {
                        tb.DeleteColumns(iCol, 1);//依次删除套数为0的列
                    }
                    //3.6 将表格按照输入比例缩放
                    double   scale = double.Parse(textBoxScale.Text);
                    Matrix3d mt    = Matrix3d.Scaling(scale, ptRes.Value);
                    tb.TransformBy(mt);
                    tb.GenerateLayout();    //更新表格
                    db.AddToModelSpace(tb); //将表格加入数据库
                    trans1.Commit();        //执行事务处理
                }
            //4.输出表格并查看后重新返回对话框还是离开程序
            PromptKeywordOptions kwOpt = new PromptKeywordOptions("\n返回对话框还是退出程序[返回对话框(R)/退出程序(任意键)]");

            kwOpt.AllowArbitraryInput = true;
            kwOpt.AllowNone           = false;
            PromptResult keRes = ed.GetKeywords(kwOpt);

            if (keRes.Status == PromptStatus.OK && keRes.StringResult == "R")
            {
                this.Show();
            }
            else
            {
                this.Close();
            }
        }
Пример #26
0
        private bool EditOrCreateTable(JsonData data, Point3d point)
        {
            //TotalFacilitiesRequired total = data.minimumfixture;
            ac.Document doc = ac.Application.DocumentManager.MdiActiveDocument;
            Database    db  = doc.Database;

            Table tb = new Table();

            tb.TableStyle = db.Tablestyle;
            tb.Layer      = "TABLE";


            //Set Size First...
            tb.SetSize(data.minimumfixture.fixtureUnitArray.Count + 4, 9);
            tb.Cells.ContentColor = Color.FromColorIndex(ColorMethod.ByAci, 2);
            tb.Cells.TextHeight   = 0.09375;
            tb.Columns[0].Width   = 1.06;
            tb.Columns[1].Width   = 1.34 / 2;
            tb.Columns[2].Width   = 1.34 / 2;
            tb.Columns[3].Width   = 0.85;
            tb.Columns[4].Width   = 1.3 / 2;
            tb.Columns[5].Width   = 1.3 / 2;
            tb.Columns[6].Width   = 1.27;
            tb.Columns[7].Width   = 1.53;
            tb.Columns[8].Width   = 2.15;

            //Table Title
            CellRange titleRange = CellRange.Create(tb, 0, 0, 0, 8);

            tb.MergeCells(titleRange);
            tb.Cells[0, 0].Value      = "Minimum Number of Required Fixtures";
            tb.Cells[0, 0].TextHeight = 3.0 / 16;

            //Table Items

            tb.Cells[1, 0].Value = "TYPE OF OCCUPANCY";

            CellRange wcTitleRange = CellRange.Create(tb, 1, 1, 1, 2);

            tb.MergeCells(wcTitleRange);
            tb.Cells[1, 1].Value = "WATER CLOSETS";

            tb.Cells[1, 3].Value = "URINALS";

            CellRange lavatoriesTitle = CellRange.Create(tb, 1, 4, 1, 5);

            tb.MergeCells(lavatoriesTitle);
            tb.Cells[1, 4].Value = "LAVATORIES";

            tb.Cells[1, 6].Value = "BATHTUBS OR SHOWERS";

            tb.Cells[1, 7].Value = "DRINKINGFOUNTAINS/FACILITIES";


            tb.Cells[1, 8].Value = "OTHER";

            //Table Bottom:

            if (!data.minimumfixture.totalRequiredFixture.ContainsKey(Table422_1Categories.urinals) &&
                data.minimumfixture.sliderValue > 0)
            {
                data.minimumfixture.totalRequiredFixture.Add(Table422_1Categories.urinals, 0);
            }

            string bottomValue = "";

            if (data.minimumfixture.totalFixtureBasedOnGender.ContainsKey(data.minimumfixture.totalFemaleCloset) &&
                data.minimumfixture.femaleWaterClosetAddIn > 0)
            {
                if (data.minimumfixture.femaleWaterClosetAddIn > 0)
                {
                    bottomValue += string.Format("Female Water Closet: {0} + {1} (note 3)\n", data.minimumfixture.totalFixtureBasedOnGender[data.minimumfixture.totalFemaleCloset], data.minimumfixture.femaleWaterClosetAddIn);
                }
                else
                {
                    bottomValue += string.Format("Female Water Closet: {0}\n", data.minimumfixture.totalFixtureBasedOnGender[data.minimumfixture.totalFemaleCloset]);
                }
            }

            if (data.minimumfixture.totalFixtureBasedOnGender.ContainsKey(data.minimumfixture.totalMaleCloset) &&
                data.minimumfixture.totalRequiredFixture.ContainsKey(Table422_1Categories.urinals)
                )
            {
                if (data.minimumfixture.sliderValue > 0)
                {
                    bottomValue += string.Format("Male Water Closet: {0} - {1} (note 4)\n", data.minimumfixture.totalFixtureBasedOnGender[data.minimumfixture.totalMaleCloset], data.minimumfixture.sliderValue);
                }
                else
                {
                    bottomValue += string.Format("Male Water Closet: {0}\n", data.minimumfixture.totalFixtureBasedOnGender[data.minimumfixture.totalMaleCloset]);
                }
            }

            if (data.minimumfixture.totalFixtureBasedOnGender.ContainsKey(data.minimumfixture.totalMaleUrinals) &&
                data.minimumfixture.totalRequiredFixture.ContainsKey(Table422_1Categories.urinals)
                )
            {
                if (data.minimumfixture.sliderValue > 0)
                {
                    bottomValue += string.Format("** Male Urinal(s): {0} + {1} (note 4)\n", data.minimumfixture.totalFixtureBasedOnGender[data.minimumfixture.totalMaleUrinals], data.minimumfixture.sliderValue);
                }
            }

            if (data.minimumfixture.femaleWaterClosetAddIn > 0)
            {
                bottomValue += string.Format("* added {0} female lavatories -- satisfies note 3 requirement.\n", data.minimumfixture.femaleWaterClosetAddIn);
            }
            if (data.minimumfixture.sliderValue > 0)
            {
                bottomValue += string.Format("** based on Note 4, it's okay to added {0} male urinals and remove {0} male water closet\n", data.minimumfixture.sliderValue);
            }

            bottomValue += "\nCalifornia Plumbing Code 2019 - Table 422.1 - Note:\n";
            bottomValue += "(3) The total number of required water closets for females shall be not less than the total number of required water closets and urinals for males.\n";
            bottomValue += "(4) For each urinal added in excess of the minimum required, one water closet shall be permitted to be deducted. The number of water closets shall not be reduced to less than two-thirds of the minimum requirement.\n";
            bottomValue += "\n Created based on Table 422.1 California Plumbing Code 2019";
            int       bottomRowIndex = data.minimumfixture.fixtureUnitArray.Count + 4 - 1;
            CellRange bottomRange    = CellRange.Create(tb, bottomRowIndex, 0, bottomRowIndex, 8);

            tb.Cells[bottomRowIndex, 0].Value     = bottomValue;
            tb.Cells[bottomRowIndex, 0].Alignment = CellAlignment.BottomLeft;
            tb.MergeCells(bottomRange);
            tb.Cells[0, 0].TextHeight = 3.0 / 16;

            //Fill Data...
            int rIndex = 2;

            foreach (FixtureUnit unit in data.minimumfixture.fixtureUnitArray)
            {
                createRow(unit.outputUnits, tb, ref rIndex, data, unit.occupancy.type, false);
            }

            createRow(data.minimumfixture.totalRequiredFixture, tb, ref rIndex, data, "TOTAL", true);


            tb.Cells.DataFormat = "%lu2%pr0%";

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                BlockTableRecord btr  = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
                TableJig         tJig = new TableJig(tb);
                Editor           ed   = ac.Application.DocumentManager.MdiActiveDocument.Editor;

                PromptResult result;
                bool         cont = false;

                if (point == new Point3d(-1000, -1000, -1000))
                {
                    result = ed.Drag(tJig);
                    if (result.Status == PromptStatus.OK)
                    {
                        point = tJig.insertionPoint;
                        cont  = true;
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    cont = true;
                }
                if (cont)
                {
                    tb.Position = point;
                    btr.AppendEntity(tb);
                    tr.AddNewlyCreatedDBObject(tb, true);
                    AddTableRecord(data.id.ToString(), db, tr, tb);
                    ResultBuffer rb = new ResultBuffer(
                        new TypedValue(1001, uriInit),
                        new TypedValue(1000, data.id.ToString())
                        );
                    tb.XData = rb;
                    rb.Dispose();
                    tr.Commit();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Пример #27
0
        private void createRow(Dictionary <string, double> itemsCount, Table tb, ref int rIndex, JsonData data, string name, bool isTotal)
        {
            tb.Cells[rIndex, 0].Value = name;
            CellRange wcTitleRange1 = CellRange.Create(tb, rIndex, 1, rIndex, 2);

            tb.MergeCells(wcTitleRange1);

            CellRange lavatoriesTitle1 = CellRange.Create(tb, rIndex, 4, rIndex, 5);

            tb.MergeCells(lavatoriesTitle1);

            foreach (KeyValuePair <string, double> kv in itemsCount)
            {
                if (kv.Key == Table422_1Categories.waterClosets)
                {
                    if (isTotal)
                    {
                        tb.Cells[rIndex, 1].Value = (kv.Value - data.minimumfixture.sliderValue + data.minimumfixture.femaleWaterClosetAddIn).ToString();
                        if (data.minimumfixture.sliderValue > 0 || data.minimumfixture.femaleWaterClosetAddIn > 0)
                        {
                            tb.Cells[rIndex, 1].Value += "*";
                        }
                    }
                    else
                    {
                        tb.Cells[rIndex, 1].Value = kv.Value;
                    }
                    tb.Cells[rIndex, 1].Alignment = CellAlignment.MiddleRight;
                }
                else if (kv.Key == Table422_1Categories.urinals)
                {
                    if (isTotal)
                    {
                        tb.Cells[rIndex, 3].Value = (kv.Value + data.minimumfixture.sliderValue).ToString();
                        if (data.minimumfixture.sliderValue > 0)
                        {
                            tb.Cells[rIndex, 3].Value += "**";
                        }
                    }
                    else
                    {
                        tb.Cells[rIndex, 3].Value = kv.Value;
                    }
                    tb.Cells[rIndex, 3].Alignment = CellAlignment.MiddleRight;
                }
                else if (kv.Key == Table422_1Categories.lavatories)
                {
                    tb.Cells[rIndex, 4].Value     = kv.Value;
                    tb.Cells[rIndex, 4].Alignment = CellAlignment.MiddleRight;
                }
                else if (kv.Key == Table422_1Categories.bathtubsOrShowers)
                {
                    tb.Cells[rIndex, 6].Value     = kv.Value;
                    tb.Cells[rIndex, 6].Alignment = CellAlignment.MiddleRight;
                }
                else if (kv.Key == Table422_1Categories.drinkingFountains)
                {
                    tb.Cells[rIndex, 7].Value     = kv.Value;
                    tb.Cells[rIndex, 7].Alignment = CellAlignment.MiddleRight;
                }
            }
            tb.Cells[rIndex, 8].Value     = getOtherFixtures(itemsCount);
            tb.Cells[rIndex, 8].Alignment = CellAlignment.MiddleRight;
            rIndex++;
        }
Пример #28
0
        private Table getTable(Database db)
        {
            Table table = new Table();

            table.SetDatabaseDefaults(db);
            table.TableStyle = db.GetTableStylePIK(); //getTableStyle(db);

            bool hasColorName = Paint.HasColorName(_album.Colors);
            int  numColumns   = hasColorName? 6:5;

            table.SetSize(_album.Colors.Count + 3, numColumns);
            table.Columns[0].Width = 10; // Поз
            table.Columns[1].Width = 20; // Артикул
            table.Columns[2].Width = 20; // Образец
            table.Columns[3].Width = 20; // Расход шт
            table.Columns[4].Width = 20; // Расход м.кв.
            if (hasColorName)
            {
                table.Columns[5].Width       = 30; // Цвет
                table.Cells[1, 5].TextString = "Цвет";
            }

            table.Columns[0].Alignment = CellAlignment.MiddleCenter;
            table.Columns[3].Alignment = CellAlignment.MiddleCenter;
            table.Columns[4].Alignment = CellAlignment.MiddleCenter;

            table.Rows[1].Height = 15;

            table.Cells[0, 0].TextString = "Расход плитки на альбом " + _album.StartOptions.Abbr + " от " + _album.Date;
            table.Cells[1, 0].TextString = "Поз.";
            table.Cells[1, 1].TextString = "Артикул";
            table.Cells[1, 2].TextString = "Образец";
            table.Cells[1, 3].TextString = "Расход, шт.";
            table.Cells[1, 4].TextString = "Расход, м.кв.";

            int    row            = 2;
            int    i              = 1;
            int    totalCountTile = 0;
            double totalArea      = 0;

            foreach (var tileCalcSameColor in _album.TotalTilesCalc)
            {
                table.Cells[row, 0].TextString      = i++.ToString();                         //"Поз.";
                table.Cells[row, 1].TextString      = tileCalcSameColor.Paint.Article;        //"Артикул";
                table.Cells[row, 2].BackgroundColor = tileCalcSameColor.Paint.Color;          // "Образец";
                table.Cells[row, 3].TextString      = tileCalcSameColor.Count.ToString();     // "Расход, шт.";
                table.Cells[row, 4].TextString      = tileCalcSameColor.TotalArea.ToString(); // "Расход, м.кв.";
                if (hasColorName)
                {
                    table.Cells[row, 5].TextString = tileCalcSameColor.Paint.Name;  //"Цвет";
                }

                totalCountTile += tileCalcSameColor.Count;
                totalArea      += tileCalcSameColor.TotalArea;

                row++;
            }
            var mCells = CellRange.Create(table, row, 0, row, 2);

            table.MergeCells(mCells);
            table.Cells[row, 0].TextString = "Итого:";
            table.Cells[row, 3].TextString = totalCountTile.ToString();
            table.Cells[row, 4].TextString = totalArea.ToString();

            table.GenerateLayout();
            return(table);
        }
Пример #29
0
        public void PlineTable()
        {
            ///*
            Document doc = GetDocument();
            Database db  = doc.Database;
            Editor   ed  = doc.Editor;

            try
            {
                using (Transaction trans = db.TransactionManager.StartTransaction())
                {
                    PromptEntityOptions peo = new PromptEntityOptions(
                        "\nSelect a closed polyline: ")
                    {
                        AllowNone = false
                    };
                    peo.SetRejectMessage("\n>>>Select a closed polyline: ");
                    peo.AddAllowedClass(typeof(Polyline), true);
                    PromptEntityResult per;
                    Polyline           pline;
                    while (true)
                    {
                        per = ed.GetEntity(peo);
                        if (per.Status == PromptStatus.Cancel)
                        {
                            return;
                        }
                        pline = trans.GetObject(per.ObjectId, OpenMode.ForRead) as Polyline;
                        if (per.Status == PromptStatus.OK && pline != null && pline.Closed)
                        {
                            break;
                        }
                    }
                    ed.WriteMessage("\n Closed Polyline selected");

                    PromptPointOptions ppo = new PromptPointOptions("\nSelect a destination base point: ")
                    {
                        AllowNone = false,
                    };

                    PromptPointResult ppr;
                    while (true)
                    {
                        ppr = ed.GetPoint(ppo);
                        if (ppr.Status == PromptStatus.Cancel)
                        {
                            return;
                        }
                        if (ppr.Status == PromptStatus.OK)
                        {
                            break;
                        }
                    }
                    Point3d insertionPoint = ppr.Value;

                    BlockTable bt = trans.GetObject(db.BlockTableId
                                                    , OpenMode.ForRead) as BlockTable;

                    BlockTableRecord btr = trans.GetObject(
                        bt[BlockTableRecord.ModelSpace],
                        OpenMode.ForWrite) as BlockTableRecord;

                    // make sure pline is in clockwise direction
                    double area = pline.GetArea();
                    if (area < 0.0)
                    {
                        area = -area;
                        // I 'll do it later
                        //pline.ReverseCurve();
                    }

                    // get pline points
                    var list = pline.GetPolylinePoints(0);

                    var count = list.Count;

                    Table table = new Table();
                    table.SetDatabaseDefaults();
                    table.SetSize(count + 2, 4);

                    table.Cells.Alignment       = CellAlignment.MiddleCenter;
                    table.Rows[0].Alignment     = CellAlignment.MiddleLeft;
                    table.Cells[0, 2].Alignment = CellAlignment.MiddleCenter;

                    table.Cells.TextHeight = 3.0;

                    int    i, j;
                    string from, to, northing, easting, ds;

                    table.Columns[0].Width = 17.0;
                    table.Columns[1].Width = 36.0;
                    table.Columns[2].Width = 35.0;
                    table.Columns[3].Width = 19.0;


                    //table.Rows[0].Height = 5.0;
                    //table.Rows[1].Height = 5.0;

                    CellRange range1 = CellRange.Create(table, 0, 0, 0, 1);
                    CellRange range2 = CellRange.Create(table, 0, 2, 0, 3);

                    table.MergeCells(range2);
                    table.MergeCells(range1);

                    table.Cells[0, 0].TextString = "Coordinates:";
                    //table.Cells[0, 2].TextString = $"Area: {area:F0} m\xB2";

                    string textArea = $"{area:F0}";
                    string text     = "{\\fMonospac821 BT|b1|;\\L\\C1;" + textArea + "}";
                    table.Cells[0, 2].TextString = "Area: " + text + " m\xB2";
                    //"Coordinates , Area =  {0:0.00} SQ.M", area);
                    //table.VerticalCellMargin=

                    table.Rows[0].Height = 6.0;


                    table.Cells[1, 0].TextString = "LINE";
                    table.Cells[1, 1].TextString = "NORTHING";
                    table.Cells[1, 2].TextString = "EASTING";
                    table.Cells[1, 3].TextString = "DIST(m)";

                    string spaces = "";

                    for (i = 0, j = 1; i < count; i++, j++)
                    {
                        var p1 = pline.GetPoint2dAt(i);
                        var p2 = pline.GetPoint2dAt(j);
                        from     = (i + 1).ToString();
                        to       = (j + 1).ToString();
                        northing = p1.Y.ToString("0.00");
                        easting  = p1.X.ToString("0.00");
                        ds       = p1.GetDistanceTo(p2).ToString("0.00");

                        spaces = "  ";
                        if (i < 9)
                        {
                            spaces += " ";
                        }
                        if (j < 9)
                        {
                            spaces += " ";
                        }
                        //table.Rows[i + 2].Height = 5.0;

                        table.Cells[i + 2, 0].TextString = from + spaces + to;
                        table.Cells[i + 2, 1].TextString = northing;
                        table.Cells[i + 2, 2].TextString = easting;
                        table.Cells[i + 2, 3].TextString = ds;


                        // check if we are out of bounds, then make j -1 so after increment
                        // it will reset to 0 (the first point).
                        if (j == count - 1)
                        {
                            j = -1;
                        }


                        MText mt = new MText();
                        mt.SetDatabaseDefaults();
                        mt.Contents   = from;
                        mt.TextHeight = 2.0;

                        // location logic to be recalculated
                        mt.Location = p1.GetPoint3d();
                        btr.AppendEntity(mt);
                        trans.AddNewlyCreatedDBObject(mt, true);
                        //trans.Commit();
                    }
                    table.Rows[0].Height = 7.0;
                    table.Position       = insertionPoint;
                    table.GenerateLayout();



                    btr.AppendEntity(table);
                    trans.AddNewlyCreatedDBObject(table, true);
                    trans.Commit();


                    ed.WriteMessage($"\n{table.Rows[0].Height}");
                }
            }
            catch (Autodesk.AutoCAD.Runtime.Exception ex)
            {
                ed.WriteMessage(ex.Message);
            }
            //*/
        }
Пример #30
0
        private Table getTable(Database db)
        {
            Table table = new Table();

            table.SetDatabaseDefaults(db);
            table.TableStyle = db.GetTableStylePIK(); // если нет стиля ПИк в этом чертеже, то он скопируетс из шаблона, если он найдется

            var data = _service.DataSection;

            table.SetSize(10, 2);

            table.Columns[0].Width = 55;
            table.Columns[1].Width = 25;

            foreach (var item in table.Rows)
            {
                item.Height = 8;
            }

            //foreach (var column in table.Columns)
            //{
            //    column.Width = 30;
            //    column.Alignment = CellAlignment.MiddleCenter;
            //}

            table.Columns[0].Alignment = CellAlignment.MiddleLeft;
            table.Columns[1].Alignment = CellAlignment.MiddleCenter;
            //table.Rows[1].Height = 15;

            table.Cells[0, 0].TextString = "Московская область (РНГП №713/30)";
            table.Cells[0, 0].Alignment  = CellAlignment.MiddleCenter;

            //table.Cells[1, 0].TextString = "Наименование блок-секции";
            //table.Cells[1, 0].Alignment = CellAlignment.MiddleCenter;
            //table.Cells[2, 0].TextString = "Площадь квартир, м.кв.";
            //table.Cells[2, 0].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            //table.Cells[3, 0].TextString = "Площадь БКФН, м.кв.";
            //table.Cells[3, 0].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            //table.Cells[4, 0].TextString = "Количество секций";
            //table.Cells[4, 0].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            table.Cells[1, 0].TextString = "Всего площадь жилого фонда, м.кв.";
            table.Cells[1, 0].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            table.Cells[2, 0].TextString = "Всего площадь квартир, м.кв.";
            table.Cells[2, 0].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            table.Cells[3, 0].TextString = "Всего площадь БКФН, м.кв.";
            table.Cells[3, 0].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            table.Cells[4, 0].TextString = "Средняя этажность";
            table.Cells[4, 0].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            table.Cells[5, 0].TextString = "Жителей, чел (28м2/чел)";
            table.Cells[5, 0].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            table.Cells[6, 0].TextString = "ДОО, чел (65/1000)";
            table.Cells[6, 0].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            table.Cells[7, 0].TextString = "СОШ, чел (135/1000)";
            table.Cells[7, 0].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            table.Cells[8, 0].TextString = @"Машиноместа, м/м ((420/1000)х90%)"; // "\\A1;\\pxt8;Машиноместа, м/м\\P\\ptz;{\\H0.6x;420/1 000}"
            table.Cells[8, 0].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            table.Cells[9, 0].TextString = "Машиноместа гостевые, м/м (25%)";
            table.Cells[9, 0].Borders.Bottom.LineWeight = LineWeight.LineWeight030;

            var titleCells = CellRange.Create(table, 1, 0, 1, table.Columns.Count - 1);

            titleCells.Borders.Bottom.LineWeight = LineWeight.LineWeight030;

            // Параметры по типам секций
            //int col = 1;
            //foreach (var sectType in data.SectionTypes)
            //{
            //    table.Cells[1, col].TextString = sectType.Name; //Наименование
            //    table.Cells[2, col].TextString = sectType.AreaApartTotal.ToString("0.0");  //Площадь квартир
            //    table.Cells[3, col].TextString = sectType.AreaBKFN.ToString("0.0");  // Площадь БКФН
            //    table.Cells[4, col].TextString = sectType.Count.ToString();// Кол секций
            //    col++;
            //}
            //var mCells = CellRange.Create(table, 5, 1, 5, table.Columns.Count - 1);
            //table.MergeCells(mCells);
            //mCells = CellRange.Create(table, 6, 1, 6, table.Columns.Count - 1);
            //table.MergeCells(mCells);
            //mCells = CellRange.Create(table, 7, 1, 7, table.Columns.Count - 1);
            //table.MergeCells(mCells);
            //mCells = CellRange.Create(table, 8, 1, 8, table.Columns.Count - 1);
            //table.MergeCells(mCells);
            //mCells = CellRange.Create(table, 9, 1, 9, table.Columns.Count - 1);
            //table.MergeCells(mCells);
            //mCells = CellRange.Create(table, 10, 1, 10, table.Columns.Count - 1);
            //table.MergeCells(mCells);
            //mCells = CellRange.Create(table, 11, 1, 11, table.Columns.Count - 1);
            //table.MergeCells(mCells);
            //mCells = CellRange.Create(table, 12, 1, 12, table.Columns.Count - 1);
            //table.MergeCells(mCells);

            // Общие параметры по всем типам секций

            // Всего площадь жилого фонда
            table.Cells[1, 1].TextString = (data.TotalAreaApart + data.TotalAreaBKFN).ToString("0.0");
            table.Cells[1, 1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            // ВСЕГО ПЛОЩАДЬ КВАРТИР
            table.Cells[2, 1].TextString = data.TotalAreaApart.ToString("0.0");
            table.Cells[2, 1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            // ВСЕГО ПЛОЩАДЬ БКФН
            table.Cells[3, 1].TextString = data.TotalAreaBKFN.ToString("0.0");
            table.Cells[3, 1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            // Средняя этажность
            table.Cells[4, 1].TextString = data.AverageFloors.ToString("0.0");
            table.Cells[4, 1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            // Жителей
            double population = Math.Ceiling(data.TotalAreaApart * 0.035714); // Всего площадь квартир/28

            table.Cells[5, 1].TextString = population.ToString();
            table.Cells[5, 1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            //ДОО, чел
            table.Cells[6, 1].TextString = Math.Ceiling(population * 0.065).ToString(); //(("Всего площадь квартир"/28)/1000)*65
            table.Cells[6, 1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            //СОШ, чел
            table.Cells[7, 1].TextString = Math.Ceiling(population * 0.135).ToString();//  (("Всего площадь квартир"/28)/1000)*135
            table.Cells[7, 1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            //Машиноместа, м/м
            var mm = population * 0.42;

            table.Cells[8, 1].TextString = Math.Ceiling(mm * 0.9).ToString();//  (("Всего площадь квартир"/28)/1000)*420 90%
            table.Cells[8, 1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;
            //Машиноместа гостевые, м/м
            table.Cells[9, 1].TextString = Math.Ceiling(mm * 0.25).ToString();//  Машиноместа %25
            table.Cells[9, 1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;

            table.GenerateLayout();
            return(table);
        }