private void tabPage4_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; int maxX = 0; int[] tempDiameter = new int[5]; double[] diameter = new double[5]; double maxDiameter; float x1 = 100, y1 = 10; for (int i = 0; i <= 500; i += 100) { if (MyCalculate.IsMxMyMzMore(i, maxX)) { maxX = i; } } int maxDiameterIndex; if ((maxX >= 0 && maxX <= 50) || (maxX >= 450 && maxX <= 500)) { maxDiameterIndex = 4; } else if (maxX > 50 && maxX <= 150) { maxDiameterIndex = 3; } else if (maxX > 150 && maxX <= 350) { maxDiameterIndex = 2; } else { maxDiameterIndex = 1; } g.DrawString("危险截面的横坐标: x=" + Math.Round(a * maxX / 100.0, 2) + "m 截面直径为Φ" + maxDiameterIndex + "\n\n设计直径:", font1, brush1, x1, y1); //设计直径1 maxX = 350; for (int i = 351; i <= 450; i++) { if (MyCalculate.IsMxMyMzMore(i, maxX)) { maxX = i; } } maxDiameter = Math.Pow((32 * Math.Sqrt(MyCalculate.SumOfSquaresMxyz(maxX))) / (pi * permissibleStress), 1 / 3.0); diameter[1] = maxDiameter * 1000; g.DrawString("Φ1≥" + Math.Round(maxDiameter * 1000, 2) + "mm 在 x=" + maxX * a / 100.0 + "m 处应力最大", font1, brush1, x1, y1 + 80); //设计直径2 maxX = 150; for (int i = 151; i <= 350; i++) { if (MyCalculate.IsMxMyMzMore(i, maxX)) { maxX = i; } } maxDiameter = Math.Pow((32 * Math.Sqrt(MyCalculate.SumOfSquaresMxyz(maxX))) / (pi * permissibleStress), 1 / 3.0); diameter[2] = maxDiameter * 1000; g.DrawString("Φ2≥" + Math.Round(maxDiameter * 1000, 2) + "mm 在 x=" + maxX * a / 100.0 + "m 处应力最大", font1, brush1, x1, y1 + 120); //设计直径3 maxX = 50; for (int i = 51; i <= 150; i++) { if (MyCalculate.IsMxMyMzMore(i, maxX)) { maxX = i; } } maxDiameter = Math.Pow((32 * Math.Sqrt(MyCalculate.SumOfSquaresMxyz(maxX))) / (pi * permissibleStress), 1 / 3.0); diameter[3] = maxDiameter * 1000; g.DrawString("Φ3≥" + Math.Round(maxDiameter * 1000, 2) + "mm 在 x=" + maxX * a / 100.0 + "m 处应力最大", font1, brush1, x1, y1 + 160); //设计直径4 maxX = 0; for (int i = 1; i <= 50; i++) { if (MyCalculate.IsMxMyMzMore(i, maxX)) { maxX = i; } } for (int i = 450; i <= 500; i++) { if (MyCalculate.IsMxMyMzMore(i, maxX)) { maxX = i; } } maxDiameter = Math.Pow((32 * Math.Sqrt(MyCalculate.SumOfSquaresMxyz(maxX))) / (pi * permissibleStress), 1 / 3.0); diameter[4] = maxDiameter * 1000; g.DrawString("Φ4≥" + Math.Round(maxDiameter * 1000, 2) + "mm 在 x=" + maxX * a / 100.0 + "m 处应力最大", font1, brush1, x1, y1 + 200); g.DrawString("之后根据比例关系得(这部分不同人有不同理解):", font2, brush1, x1, y1 + 240); int diameterStatus = 1; tempDiameter[1] = MyCalculate.NearestMoreEvenNumber(diameter[1]) - 2; while (diameterStatus != 4) { tempDiameter[1] += 2; if (tempDiameter[1] / 1.1 >= diameter[2]) { tempDiameter[2] = MyCalculate.NearestMoreEvenNumber(tempDiameter[1] / 1.1); diameterStatus = 2; } if (diameterStatus == 2 && tempDiameter[2] / 1.1 >= diameter[3]) { tempDiameter[3] = MyCalculate.NearestMoreEvenNumber(tempDiameter[2] / 1.1); diameterStatus = 3; } if (diameterStatus == 3 && tempDiameter[3] / 1.1 >= diameter[4]) { tempDiameter[4] = MyCalculate.NearestMoreEvenNumber(tempDiameter[3] / 1.1); diameterStatus = 4; } } g.DrawString("Φ1≥ " + tempDiameter[1] + " mm" + "\n\nΦ2≥ " + tempDiameter[2] + " mm" + "\n\nΦ3≥ " + tempDiameter[3] + " mm" + "\n\nΦ4≥ " + tempDiameter[4] + " mm", font2, brush1, x1, y1 + 270); textBox13.Text = "" + tempDiameter[1]; }
private void tabPage6_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; int x = 0; switch (comboBox1.SelectedIndex) { case 0: x = 0; break; case 1: x = 50; break; case 2: x = 150; break; case 3: x = 300; break; case 4: x = 350; break; case 5: x = 450; break; case 6: x = 500; break; } g.DrawString("Mx= " + Math.Round(mx[x], 2) + " N•m My= " + Math.Round(my[x], 2) + " N•m Mz= " + Math.Round(mz[x], 2) + " N•m", font1, brush1, 100, 100); if (status6 == 1) { double W = (pi * diameter2 * diameter2 * diameter2) / 32; double aMax = (Math.Sqrt(my[x] * my[x] + mz[x] * mz[x])) / W; double Wp = (pi * diameter2 * diameter2 * diameter2) / 16; double tMax = mx[x] / Wp; double tm = tMax / 2; double ta = tMax / 2; double na = (a_1 * Ea * B) / (Ka * aMax); double nt = t_1 / (Kt * ta / (Et * B) + sensitivity * tm); double nat = (na * nt) / Math.Sqrt(na * na + nt * nt); double a_r3 = Math.Sqrt(MyCalculate.SumOfSquaresMxyz(x)) / W; double nat1 = a_s / a_r3; string isOk = ""; if (double.IsNaN(nat) || double.IsNaN(nat1)) { if (nt > safeN) { isOk = "是"; } else { isOk = "否"; } } else { if (nat > safeN && nat1 > safeN) { isOk = "是"; } else { isOk = "否"; } } g.DrawString("σmax= " + Math.Round(aMax / 1000000, 2) + " Mpa" + " τmax= " + Math.Round(tMax / 1000000, 2) + " Mpa\n\n" + "Na= " + Math.Round(na, 2) + " Nt= " + Math.Round(nt, 2) + " Nat= " + Math.Round(nat, 2) + " Nat′= " + Math.Round(nat1, 2) + "\n\n该截面是否满足强度要求: " + isOk, font2, brush1, 100, 300); status6 = 0; } }