Test.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. using DevExpress.Charts.Native;
  2. using DevExpress.Map.Dashboard;
  3. using DevExpress.Map.Native;
  4. using DevExpress.XtraBars;
  5. using DevExpress.XtraCharts;
  6. using DevExpress.XtraEditors.Repository;
  7. using ExtensionsDev;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.ComponentModel;
  11. using System.Data;
  12. using System.Drawing;
  13. using System.Linq;
  14. using System.Text;
  15. using System.Threading.Tasks;
  16. using System.Windows;
  17. using System.Windows.Forms;
  18. using System.Xml.Linq;
  19. using XdCxRhDW.Core;
  20. using XdCxRhDW.Core.Api;
  21. using static DevExpress.XtraEditors.Mask.Design.MaskSettingsForm.DesignInfo.MaskManagerInfo;
  22. using static System.Windows.Forms.VisualStyles.VisualStyleElement.TaskbarClock;
  23. using static System.Windows.Forms.VisualStyles.VisualStyleElement.ToolTip;
  24. namespace XdCxRhDW.App.CorTools
  25. {
  26. public partial class Test : DevExpress.XtraEditors.XtraForm
  27. {
  28. List<ImageResult> list;
  29. public Test()
  30. {
  31. InitializeComponent();
  32. int w = (this.chartControl1.AnnotationRepository[0] as ImageAnnotation).Width;
  33. int h = (this.chartControl1.AnnotationRepository[0] as ImageAnnotation).Height;
  34. Bitmap bmp = new Bitmap(w, h);
  35. for (int x = 0; x < w; x++)
  36. {
  37. for (int y = 0; y < h; y++)
  38. {
  39. var rgbb = ColorRGB.GetSpecColor(x / 1d / w);
  40. int r = rgbb.R;
  41. int g = rgbb.G;
  42. int b = rgbb.B;
  43. Color c = Color.FromArgb(r, g, b);
  44. bmp.SetPixel(x, y, c);
  45. }
  46. }
  47. var bgColor = ColorRGB.GetSpecColor(0.3);
  48. chartControl1.BackColor = bgColor;
  49. (this.chartControl1.Diagram as XYDiagram).DefaultPane.BackColor = bgColor;
  50. (this.chartControl1.AnnotationRepository[0] as ImageAnnotation).Image.DXImage = bmp;
  51. (this.chartControl1.AnnotationRepository[1] as TextAnnotation).BackColor = bgColor;
  52. (this.chartControl1.AnnotationRepository[1] as TextAnnotation).TextColor = Color.White;
  53. (this.chartControl1.AnnotationRepository[2] as TextAnnotation).BackColor = bgColor;
  54. (this.chartControl1.AnnotationRepository[2] as TextAnnotation).TextColor = Color.White;
  55. (this.chartControl1.Diagram as XYDiagram).AxisX.Color = Color.White;
  56. (this.chartControl1.Diagram as XYDiagram).AxisX.Label.TextColor = Color.White;
  57. (this.chartControl1.Diagram as XYDiagram).AxisY.Color = Color.White;
  58. (this.chartControl1.Diagram as XYDiagram).AxisY.Label.TextColor = Color.White;
  59. this.chartControl1.Series[0].ToolTipEnabled = DevExpress.Utils.DefaultBoolean.True;
  60. //ToolTipPointPattern可以参考以下网站说明
  61. //https://docs.devexpress.com/CoreLibraries/DevExpress.XtraCharts.SeriesBase.ToolTipPointPattern?utm_source=visualstudio&utm_medium=DXHelpAssistant&utm_campaign=onlinehelp
  62. this.chartControl1.Series[0].ToolTipPointPattern = "{A:f3}us\r\n{V:f3}Hz";
  63. }
  64. public Test(List<ImageResult> list)
  65. : this()
  66. {
  67. this.list = list;
  68. var maxY = list.First().YMax / 2;
  69. (this.chartControl1.AnnotationRepository[2] as TextAnnotation).Text = $"共{list.Count}个点";
  70. (this.chartControl1.Diagram as XYDiagram).AxisY.WholeRange.SetMinMaxValues(-maxY, maxY);
  71. (this.chartControl1.Diagram as XYDiagram).AxisY.VisualRange.SetMinMaxValues(-maxY, maxY);
  72. }
  73. private void Test_Load(object sender, EventArgs e)
  74. {
  75. foreach (var item in list)
  76. {
  77. double xValue = (item.XValue + item.XFlag)/1d/
  78. this.chartControl1.Series[0].Points.AddPoint(item.XValue, item.YValue);
  79. }
  80. }
  81. }
  82. }