using DevExpress.Charts.Native; using DevExpress.ClipboardSource.SpreadsheetML; using DevExpress.Utils; using DevExpress.XtraCharts; using DevExpress.XtraEditors; using DevExpress.XtraRichEdit.Fields.Expression; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using IStation.Calc; namespace IStation.WinFrmUI.CalcErQu { public partial class ViewRealTimeRiverWaterLevelCtrl : DevExpress.XtraEditors.XtraUserControl { public ViewRealTimeRiverWaterLevelCtrl() { InitializeComponent(); } private Series _areaSeries; /// /// 初始化默认系列 /// /// 数据源 public void SetBindingData(List timeValues) { _areaSeries = this.chartControl1.Series[0]; if (timeValues == null || timeValues.Count() < 1) { // _defaultSeries.BindToData(timeValues, null); } else { timeValueBindingSource.DataSource = timeValues; // _defaultSeries.BindToData(timeValues, "Time", "Level"); } //GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce; //GC.Collect(2, GCCollectionMode.Forced); //GC.WaitForFullGCComplete(); } public List SetBindingData3Day(DateTime start, DateTime end,out string benchmark) { benchmark = null; DateTime toDay = start.Date; DateTime yesterDay = toDay.AddDays(-1); DateTime tomor = toDay.AddDays( 1); string benchmark1, benchmark2, benchmark3; string error; var waterLevels长江1 = IStation.WinFrmUI.CalcErQu.TideHelper.GetByTime(yesterDay, toDay, out benchmark1, out error); var waterLevels长江2 = IStation.WinFrmUI.CalcErQu.TideHelper.GetByTime(toDay, tomor, out benchmark2, out error); var waterLevels长江3 = IStation.WinFrmUI.CalcErQu.TideHelper.GetByTime(tomor, tomor.AddDays(1),out benchmark3, out error); List timeValues = new List(); if (waterLevels长江1 != null) { timeValues.AddRange(waterLevels长江1); } if (waterLevels长江2 != null) { benchmark = benchmark2; timeValues.AddRange(waterLevels长江2); } if (waterLevels长江3 != null) { timeValues.AddRange(waterLevels长江3); } _areaSeries = this.chartControl1.Series[0]; if (timeValues == null || timeValues.Count() < 1) { // _defaultSeries.BindToData(timeValues, null); } else { timeValueBindingSource.DataSource = timeValues; // _defaultSeries.BindToData(timeValues, "Time", "Level"); // this.chartControl1.AnnotationRepository[] DevExpress.XtraCharts.TextAnnotation textAnnotationMax = this.chartControl1.AnnotationRepository[0] as DevExpress.XtraCharts.TextAnnotation ; DevExpress.XtraCharts.PaneAnchorPoint paneAnchorPointMax = textAnnotationMax.AnchorPoint as DevExpress.XtraCharts.PaneAnchorPoint ; DevExpress.XtraCharts.TextAnnotation textAnnotationMin = this.chartControl1.AnnotationRepository[1] as DevExpress.XtraCharts.TextAnnotation; DevExpress.XtraCharts.PaneAnchorPoint paneAnchorPointMin = textAnnotationMin.AnchorPoint as DevExpress.XtraCharts.PaneAnchorPoint; var maxLevel = timeValues.Where(x => x.Time >= start && x.Time <= end).FindObjMaxBy(x => x.Level); paneAnchorPointMax.AxisXCoordinate.AxisValueSerializable = maxLevel.Time.ToString(); paneAnchorPointMax.AxisYCoordinate.AxisValueSerializable = maxLevel.Level.ToString(); textAnnotationMax.Text = string.Format("max:{0}", maxLevel.Level); var minLevel = timeValues.Where(x => x.Time >= start && x.Time <= end).FindObjMinBy(x => x.Level); paneAnchorPointMin.AxisXCoordinate.AxisValueSerializable = minLevel.Time.ToString(); paneAnchorPointMin.AxisYCoordinate.AxisValueSerializable = minLevel.Level.ToString(); textAnnotationMin.Text = string.Format("min:{0}", minLevel.Level); } SetStripRange(start, end); return timeValues; } private bool isInitialRange=false; public void SetStripRange(DateTime start, DateTime end) { var xyDiagram = this.chartControl1.Diagram as DevExpress.XtraCharts.XYDiagram; var strp = xyDiagram.AxisX.Strips[0]; if (!isInitialRange) { isInitialRange = true; strp.MaxLimit.AxisValueSerializable = end.ToString();// "01/01/0001 01:00:00.000"; strp.MinLimit.AxisValueSerializable = start.ToString();// "01/01/0001 00:00:00.000"; } else if (DateTime.Parse(strp.MinLimit.AxisValueSerializable) > end) { isInitialRange=true; strp.MinLimit.AxisValueSerializable = start.ToString();// "01/01/0001 00:00:00.000"; strp.MaxLimit.AxisValueSerializable = end.ToString();// "01/01/0001 01:00:00.000"; } else { isInitialRange = true; strp.MaxLimit.AxisValueSerializable = end.ToString();// "01/01/0001 01:00:00.000"; strp.MinLimit.AxisValueSerializable = start.ToString();// "01/01/0001 00:00:00.000"; } } } }