//Подобрать длину из условия общей толщины (или проверить длину, если не авто) private void SetBoltLength() { if (AutoLength) { DataTable dt = gost_base.Tables["Длина резьбы"]; double length; string result = ""; BoltLength = 0; ThreadLength = 0; for (int i = 0; i < dt.Rows.Count; i++) { length = TableReader.GetDoubleCell(dt.Rows[i], 0); if (length >= left_washers_count * WasherHeight + Package + right_washers_count * WasherHeight + grover_count * GroverWashersHeight + CountNuts * NutHeight + min_protrusion) { BoltLength = length; ThreadLength = TableReader.GetDoubleCell(dt.Rows[i], BoltName); index_length = i; result = BoltLength.ToString(System.Globalization.CultureInfo.InvariantCulture); break; } } if (ResultChangedEvent != null) { ResultChangedEvent(result); } } else { BoltLength = TableReader.GetDoubleCell(gost_base.Tables["Длина резьбы"].Rows[index_length], 0); ThreadLength = TableReader.GetDoubleCell(gost_base.Tables["Длина резьбы"].Rows[index_length], BoltName); CheckBoltLengths(); } }
public void DownLengthManually() { if (AutoLength) { return; } if (index_length == 0) { return; } index_length--; BoltLength = TableReader.GetDoubleCell(gost_base.Tables["Длина резьбы"].Rows[index_length], 0); ThreadLength = TableReader.GetDoubleCell(gost_base.Tables["Длина резьбы"].Rows[index_length], BoltName); if (ResultChangedEvent != null) { ResultChangedEvent(BoltLength.ToString(System.Globalization.CultureInfo.InvariantCulture)); } CheckBoltLengths(); }
private void InsertThreeRows( List <TableCell> trCells, OpenXmlElement clonedFirstTr, Table t, int num, ConstructionBolt bolt, BoltLength boltLength) { // Болт OpenXmlElement newTr = null; if (num != 1) { newTr = clonedFirstTr.CloneNode(true); trCells = newTr.Descendants <TableCell>().ToList(); } trCells[0].GetFirstChild <Paragraph>().Append( Word.GetTextElement(num.ToString(), 24)); trCells[1].GetFirstChild <Paragraph>().Append( Word.GetTextElement($"Высокопрочные болты по {bolt.Diameter.BoltTechSpec}", 24)); trCells[2].GetFirstChild <Paragraph>().Append( Word.GetTextElement(bolt.Diameter.Diameter.ToString(), 24)); trCells[3].GetFirstChild <Paragraph>().Append( Word.GetTextElement(bolt.Diameter.StrengthClass.ToStringWithComma(), 24)); trCells[4].GetFirstChild <Paragraph>().Append( Word.GetTextElement(bolt.Packet.ToString(), 24)); trCells[5].GetFirstChild <Paragraph>().Append( Word.GetTextElement(boltLength.Length.ToString(), 24)); trCells[6].GetFirstChild <Paragraph>().Append( Word.GetTextElement(bolt.Num.ToString(), 24)); trCells[7].GetFirstChild <Paragraph>().Append( Word.GetTextElement( (Math.Ceiling(bolt.Num * boltLength.Weight * 10) / 10).ToStringWithComma(), 24)); Word.MakeBordersThin(trCells, true, false); if (num != 1) { t.Append(newTr); } // Гайка newTr = clonedFirstTr.CloneNode(true); trCells = newTr.Descendants <TableCell>().ToList(); trCells[1].GetFirstChild <Paragraph>().Append( Word.GetTextElement($"Гайки по {bolt.Diameter.NutTechSpec}", 24)); trCells[3].GetFirstChild <Paragraph>().Append( Word.GetTextElement("?", 24)); trCells[6].GetFirstChild <Paragraph>().Append( Word.GetTextElement(bolt.NutNum.ToString(), 24)); trCells[8].GetFirstChild <Paragraph>().Append( Word.GetTextElement( (Math.Ceiling(bolt.NutNum * bolt.Diameter.NutWeight * 10) / 10).ToStringWithComma(), 24)); Word.MakeBordersThin(trCells); t.Append(newTr); // Шайба newTr = clonedFirstTr.CloneNode(true); trCells = newTr.Descendants <TableCell>().ToList(); trCells[1].GetFirstChild <Paragraph>().Append( Word.GetTextElement($"Шайбы по {bolt.Diameter.WasherTechSpec}", 24)); trCells[3].GetFirstChild <Paragraph>().Append( Word.GetTextElement(bolt.Diameter.WasherSteel, 24)); trCells[6].GetFirstChild <Paragraph>().Append( Word.GetTextElement(bolt.WasherNum.ToString(), 24)); trCells[9].GetFirstChild <Paragraph>().Append( Word.GetTextElement( (Math.Ceiling(bolt.WasherNum * bolt.Diameter.WasherWeight * 10) / 10).ToStringWithComma(), 24)); Word.MakeBordersThin(trCells, false); t.Append(newTr); }