123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- using DevExpress.Charts.Native;
- using DevExpress.Map.Dashboard;
- using DevExpress.Map.Native;
- using DevExpress.XtraBars;
- using DevExpress.XtraCharts;
- using DevExpress.XtraEditors.Repository;
- using ExtensionsDev;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Forms;
- using System.Xml.Linq;
- using XdCxRhDW.Core;
- using XdCxRhDW.Core.Api;
- using static DevExpress.XtraEditors.Mask.Design.MaskSettingsForm.DesignInfo.MaskManagerInfo;
- using static System.Windows.Forms.VisualStyles.VisualStyleElement.TaskbarClock;
- using static System.Windows.Forms.VisualStyles.VisualStyleElement.ToolTip;
- namespace XdCxRhDW.App.CorTools
- {
- public partial class Test : DevExpress.XtraEditors.XtraForm
- {
- List<ImageResult> list;
- public Test()
- {
- InitializeComponent();
- int w = (this.chartControl1.AnnotationRepository[0] as ImageAnnotation).Width;
- int h = (this.chartControl1.AnnotationRepository[0] as ImageAnnotation).Height;
- Bitmap bmp = new Bitmap(w, h);
- for (int x = 0; x < w; x++)
- {
- for (int y = 0; y < h; y++)
- {
- var rgbb = ColorRGB.GetSpecColor(x / 1d / w);
- int r = rgbb.R;
- int g = rgbb.G;
- int b = rgbb.B;
- Color c = Color.FromArgb(r, g, b);
- bmp.SetPixel(x, y, c);
- }
- }
- var bgColor = ColorRGB.GetSpecColor(0.3);
- chartControl1.BackColor = bgColor;
- (this.chartControl1.Diagram as XYDiagram).DefaultPane.BackColor = bgColor;
- (this.chartControl1.AnnotationRepository[0] as ImageAnnotation).Image.DXImage = bmp;
- (this.chartControl1.AnnotationRepository[1] as TextAnnotation).BackColor = bgColor;
- (this.chartControl1.AnnotationRepository[1] as TextAnnotation).TextColor = Color.White;
- (this.chartControl1.AnnotationRepository[2] as TextAnnotation).BackColor = bgColor;
- (this.chartControl1.AnnotationRepository[2] as TextAnnotation).TextColor = Color.White;
- (this.chartControl1.Diagram as XYDiagram).AxisX.Color = Color.White;
- (this.chartControl1.Diagram as XYDiagram).AxisX.Label.TextColor = Color.White;
- (this.chartControl1.Diagram as XYDiagram).AxisY.Color = Color.White;
- (this.chartControl1.Diagram as XYDiagram).AxisY.Label.TextColor = Color.White;
- this.chartControl1.Series[0].ToolTipEnabled = DevExpress.Utils.DefaultBoolean.True;
- //ToolTipPointPattern可以参考以下网站说明
- //https://docs.devexpress.com/CoreLibraries/DevExpress.XtraCharts.SeriesBase.ToolTipPointPattern?utm_source=visualstudio&utm_medium=DXHelpAssistant&utm_campaign=onlinehelp
- this.chartControl1.Series[0].ToolTipPointPattern = "{A:f3}us\r\n{V:f3}Hz";
- }
- public Test(List<ImageResult> list)
- : this()
- {
- this.list = list;
- var maxY = list.First().YMax / 2;
- (this.chartControl1.AnnotationRepository[2] as TextAnnotation).Text = $"共{list.Count}个点";
- (this.chartControl1.Diagram as XYDiagram).AxisY.WholeRange.SetMinMaxValues(-maxY, maxY);
- (this.chartControl1.Diagram as XYDiagram).AxisY.VisualRange.SetMinMaxValues(-maxY, maxY);
- }
- private void Test_Load(object sender, EventArgs e)
- {
- foreach (var item in list)
- {
- double xValue = (item.XValue + item.XFlag)/1d/
- this.chartControl1.Series[0].Points.AddPoint(item.XValue, item.YValue);
- }
- }
- }
- }
|