GroupLmax.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace OTSExtremum
  11. {
  12. public partial class GroupLmax : Form
  13. {
  14. public List<Business.groupInfo> parameters { get; set; }
  15. public GroupLmax()
  16. {
  17. InitializeComponent();
  18. }
  19. private void GroupLmax_Load(object sender, EventArgs e)
  20. {
  21. //先设置一下头的高度,否则会太矮不好看
  22. dtgrid.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing;
  23. dtgrid.ColumnHeadersHeight = 40;
  24. dtgrid.ColumnHeadersDefaultCellStyle.Font = new Font("微软雅黑", 12, FontStyle.Regular);
  25. dtgrid.ColumnHeadersDefaultCellStyle.BackColor = Color.WhiteSmoke;
  26. for (int i = 0; i < parameters.Count; i++)
  27. {
  28. int add_rowindex = dtgrid.Rows.Add();
  29. dtgrid.Rows[add_rowindex].Cells[0].Value = parameters[i].groupTitle;
  30. dtgrid.Rows[add_rowindex].Cells[1].Value = Math.Round(parameters[i].values[0], 1);
  31. dtgrid.Rows[add_rowindex].Cells[2].Value = Math.Round(parameters[i].values[1], 1);
  32. if (i + 1 < parameters.Count)
  33. {
  34. double l1 = parameters[i].values[0];
  35. double l2 = parameters[i + 1].values[0];
  36. double se1 = parameters[i].values[1];
  37. double se2 = parameters[i + 1].values[1];
  38. double c1 = l1 - l2 + 2 * Math.Sqrt(se1 * se1 + se2 * se2);
  39. double c2 = l1 - l2 - 2 * Math.Sqrt(se1 * se1 + se2 * se2);
  40. dtgrid.Rows[add_rowindex].Cells[3].Value = Math.Round(c1, 1);
  41. dtgrid.Rows[add_rowindex].Cells[4].Value = Math.Round(c2, 1);
  42. }
  43. else
  44. {
  45. dtgrid.Rows[add_rowindex].Cells[3].Value ="";
  46. dtgrid.Rows[add_rowindex].Cells[4].Value = "";
  47. }
  48. }
  49. //画data
  50. for (int i = 0; i < parameters.Count; i++)
  51. {
  52. chart1.Series[0].Points.AddXY(parameters[i].groupTitle, Math.Round(parameters[i].values[0], 3));
  53. }
  54. }
  55. }
  56. }