| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067 | 
							- using System;
 
- using System.Collections;
 
- using System.Collections.Generic;
 
- using System.Drawing;
 
- using System.Drawing.Imaging;
 
- using System.Globalization;
 
- using System.IO;
 
- using System.Linq;
 
- using System.Reflection.Emit;
 
- using System.Windows;
 
- using System.Windows.Controls;
 
- using System.Windows.Input;
 
- using System.Windows.Media;
 
- using System.Windows.Media.Animation;
 
- using System.Windows.Media.Imaging;
 
- using Venus_Core;
 
- namespace Venus_Themes.UserControls
 
- {
 
-     /// <summary>
 
-     /// DrawGraphicsControl.xaml 的交互逻辑
 
-     /// </summary>
 
-     public partial class DrawGraphicsControl : UserControl
 
-     {
 
-         private double m_WavePlotX = 0;//x轴起始点
 
-         private double m_WavePlotY = 0;//y轴起始点
 
-         private double m_WavePlotWidth = 5000;//x轴长度
 
-         private double m_WavePlotHeight = 100;//y轴长度
 
-         private double m_WavePlotMinX = double.MaxValue;
 
-         private double m_WavePlotMaxX = double.MinValue;
 
-         private double m_WavePlotMinY = double.MaxValue;
 
-         private double m_WavePlotMaxY = double.MinValue;
 
-         private double m_StartDrawLineX = 0;
 
-         private System.Drawing.Brush m_BrushText = System.Drawing.Brushes.Black;
 
-         private System.Drawing.Brush m_BrushXYText = System.Drawing.Brushes.DarkRed;
 
-         private System.Drawing.Pen m_PenLine;
 
-         private System.Drawing.Pen m_PenLightGray;
 
-         private System.Drawing.Pen m_PenBlue;
 
-         private System.Drawing.Pen m_PenData;
 
-         private System.Drawing.Pen m_PenSData;
 
-         private System.Drawing.Pen m_PenASData;
 
-         public System.Drawing.Pen[] m_PenCollencteions;
 
-         public System.Drawing.Pen[] m_PenCollencteionsnew;
 
-         private bool m_StartMouseMove = false;
 
-         private bool m_MouseMove = false;
 
-         private bool m_MouseEnter = false;
 
-         private System.Windows.Point m_StartPoint;
 
-         private System.Windows.Point m_EndPoint;
 
-         private System.Windows.Point m_CurrentPoint;
 
-         private float LineThickness = 3.0f;
 
-         #region Property
 
-         public PointCollection PlotDataPoints
 
-         {
 
-             get { return (PointCollection)GetValue(PlotDataProperty); }
 
-             set { SetValue(PlotDataProperty, value); GraphicDraw(); }
 
-         }
 
-         /// <summary>
 
-         /// Identifies the DrawGraphicsControl.PlotDataPoints attached property. 
 
-         /// </summary>
 
-         public static readonly DependencyProperty PlotDataProperty =
 
-             DependencyProperty.RegisterAttached("PlotDataPoints", typeof(PointCollection), typeof(DrawGraphicsControl));
 
-         public PointCollection PlotSDataPoints
 
-         {
 
-             get { return (PointCollection)GetValue(PlotSDataProperty); }
 
-             set { SetValue(PlotSDataProperty, value); GraphicDraw(); }
 
-         }
 
-         /// <summary>
 
-         /// Identifies the DrawGraphicsControl.PlotSDataPoints attached property. 
 
-         /// </summary>
 
-         public static readonly DependencyProperty PlotSDataProperty =
 
-             DependencyProperty.RegisterAttached("PlotSDataPoints", typeof(PointCollection), typeof(DrawGraphicsControl));
 
-         public PointCollection PlotASDataPoints
 
-         {
 
-             get { return (PointCollection)GetValue(PlotASDataProperty); }
 
-             set { SetValue(PlotASDataProperty, value); GraphicDraw(); }
 
-         }
 
-         /// <summary>
 
-         /// Identifies the DrawGraphicsControl.PlotASDataPoints attached property. 
 
-         /// </summary>
 
-         public static readonly DependencyProperty PlotASDataProperty =
 
-             DependencyProperty.RegisterAttached("PlotASDataPoints", typeof(PointCollection), typeof(DrawGraphicsControl));
 
-         public List<PointCollection> PointCollections
 
-         {
 
-             get { return (List<PointCollection>)GetValue(PointCollectionsProperty); }
 
-             set { SetValue(PointCollectionsProperty, value); GraphicDraw(); }
 
-         }
 
-         /// <summary>
 
-         /// Identifies the DrawGraphicsControl.PointCollections attached property. 
 
-         /// </summary>
 
-         public static readonly DependencyProperty PointCollectionsProperty =
 
-             DependencyProperty.RegisterAttached("PointCollections", typeof(List<PointCollection>), typeof(DrawGraphicsControl));
 
-         public PointCollection Points
 
-         {
 
-             get { return (PointCollection)GetValue(PointsProperty); }
 
-             set { SetValue(PointsProperty, value); GraphicDraw(); }
 
-         }
 
-         /// <summary>
 
-         /// Identifies the DrawGraphicsControl.Points attached property. 
 
-         /// </summary>
 
-         public static readonly DependencyProperty PointsProperty =
 
-             DependencyProperty.RegisterAttached("Points", typeof(PointCollection), typeof(DrawGraphicsControl));
 
-         public List<StepItem> YPoints
 
-         {
 
-             get { return (List<StepItem>)GetValue(YPointsProperty); }
 
-             set { SetValue(YPointsProperty, value);  }
 
-         }
 
-         public static readonly DependencyProperty YPointsProperty =
 
-             DependencyProperty.RegisterAttached("YPoints", typeof(List<StepItem>), typeof(DrawGraphicsControl),new PropertyMetadata (new List<StepItem>()));
 
-         #region 起始坐标轴
 
-         public double WavePlotOriginX
 
-         {
 
-             get { return (double)GetValue(WavePlotOriginXProperty); }
 
-             set { SetValue(WavePlotOriginXProperty, value); }
 
-         }
 
-         public static readonly DependencyProperty WavePlotOriginXProperty =
 
-             DependencyProperty.Register("WavePlotOriginX", typeof(double), typeof(DrawGraphicsControl), new PropertyMetadata(0.0));
 
-         public double WavePlotOriginY
 
-         {
 
-             get { return (double)GetValue(WavePlotOriginYProperty); }
 
-             set { SetValue(WavePlotOriginYProperty, value); }
 
-         }
 
-         public static readonly DependencyProperty WavePlotOriginYProperty =
 
-             DependencyProperty.Register("WavePlotOriginY", typeof(double), typeof(DrawGraphicsControl), new PropertyMetadata(0.0));
 
-         public double WavePlotOriginWidth
 
-         {
 
-             get { return (double)GetValue(WavePlotOriginWidthProperty); }
 
-             set { SetValue(WavePlotOriginWidthProperty, value); }
 
-         }
 
-         public static readonly DependencyProperty WavePlotOriginWidthProperty =
 
-            DependencyProperty.Register("WavePlotOriginWidth", typeof(double), typeof(DrawGraphicsControl), new PropertyMetadata(1000.0));
 
-         public double WavePlotOriginHeight
 
-         {
 
-             get { return (double)GetValue(WavePlotOriginHeightProperty); }
 
-             set { SetValue(WavePlotOriginHeightProperty, value); }
 
-         }
 
-         public static readonly DependencyProperty WavePlotOriginHeightProperty =
 
-             DependencyProperty.Register("WavePlotOriginHeight", typeof(double), typeof(DrawGraphicsControl), new PropertyMetadata(1000.0));
 
-         #endregion
 
-         public bool IsHorizontalNavigationEnabled
 
-         {
 
-             get { return (bool)GetValue(IsHorizontalNavigationEnabledProperty); }
 
-             set { SetValue(IsHorizontalNavigationEnabledProperty, value); }
 
-         }
 
-         /// <summary>Identifies <see cref="IsHorizontalNavigationEnabled"/> property</summary>
 
-         public static readonly DependencyProperty IsHorizontalNavigationEnabledProperty =
 
-             DependencyProperty.Register("IsHorizontalNavigationEnabled", typeof(bool), typeof(DrawGraphicsControl), new PropertyMetadata(true));
 
-         public bool IsVerticalNavigationEnabled
 
-         {
 
-             get { return (bool)GetValue(IsVerticalNavigationEnabledProperty); }
 
-             set { SetValue(IsVerticalNavigationEnabledProperty, value); }
 
-         }
 
-         /// <summary>Identifies <see cref="IsVerticalNavigationEnabled"/> property</summary>
 
-         public static readonly DependencyProperty IsVerticalNavigationEnabledProperty =
 
-             DependencyProperty.Register("IsVerticalNavigationEnabled", typeof(bool), typeof(DrawGraphicsControl), new PropertyMetadata(true));
 
-         public bool IsHorizontalDateTimeAxis
 
-         {
 
-             get { return (bool)GetValue(IsHorizontalDateTimeAxisProperty); }
 
-             set { SetValue(IsHorizontalDateTimeAxisProperty, value); }
 
-         }
 
-         /// <summary>Identifies <see cref="IsVerticalNavigationEnabled"/> property</summary>
 
-         public static readonly DependencyProperty IsHorizontalDateTimeAxisProperty =
 
-             DependencyProperty.Register("IsHorizontalDateTimeAxis", typeof(bool), typeof(DrawGraphicsControl), new PropertyMetadata(false));
 
-         #endregion Property
 
-         public DrawGraphicsControl()
 
-         {
 
-             InitializeComponent();
 
-             m_PenLine = new System.Drawing.Pen(System.Drawing.Brushes.Black, 1);
 
-             m_PenLightGray = new System.Drawing.Pen(System.Drawing.Brushes.LightGray, 0.1F);
 
-             m_PenBlue = new System.Drawing.Pen(System.Drawing.Brushes.DarkBlue, 1);
 
-             m_PenData = new System.Drawing.Pen(System.Drawing.Brushes.Green, 1);
 
-             m_PenSData = new System.Drawing.Pen(System.Drawing.Brushes.Blue, 1);
 
-             m_PenASData = new System.Drawing.Pen(System.Drawing.Brushes.Red, 1);
 
-             InitPens();
 
-             IsHorizontalNavigationEnabled = false;
 
-             IsVerticalNavigationEnabled = false;
 
-         }
 
-         #region Public
 
-         public void InitPens()
 
-         {
 
-             m_PenCollencteions = new System.Drawing.Pen[]
 
-                {
 
-                 new System.Drawing.Pen(System.Drawing.Brushes.Green,LineThickness),
 
-                 new System.Drawing.Pen(System.Drawing.Brushes.Red,LineThickness),
 
-                 new System.Drawing.Pen(System.Drawing.Brushes.Blue,LineThickness),
 
-                 new System.Drawing.Pen(System.Drawing.Brushes.Orange,LineThickness),
 
-                 new System.Drawing.Pen(System.Drawing.Brushes.Yellow,LineThickness),
 
-                 new System.Drawing.Pen(System.Drawing.Brushes.YellowGreen,LineThickness),
 
-                 new System.Drawing.Pen(System.Drawing.Brushes.AliceBlue,LineThickness),
 
-                 new System.Drawing.Pen(System.Drawing.Brushes.Chocolate,LineThickness),
 
-                 new System.Drawing.Pen(System.Drawing.Brushes.Cyan,LineThickness),
 
-                 new System.Drawing.Pen(System.Drawing.Brushes.DarkGreen,LineThickness),
 
-                };
 
-         }
 
-         public void ResetCoordinate()
 
-         {
 
-             m_WavePlotX = WavePlotOriginX;
 
-             m_WavePlotY = WavePlotOriginY;
 
-             m_WavePlotWidth = WavePlotOriginWidth;
 
-             m_WavePlotHeight = WavePlotOriginHeight;
 
-             GraphicDraw();
 
-         }
 
-         public void ResetControl()
 
-         {
 
-             GraphicDraw();
 
-         }
 
-         public void FitControl()
 
-         {
 
-             if (!double.IsNaN(m_WavePlotMinX) && !double.IsNaN(m_WavePlotMaxX) && !double.IsNaN(m_WavePlotMinY) && !double.IsNaN(m_WavePlotMaxY)
 
-                 && m_WavePlotMinX != double.MaxValue && m_WavePlotMaxX != double.MinValue && m_WavePlotMinY != double.MaxValue && m_WavePlotMaxY != double.MinValue)
 
-             {
 
-                 m_WavePlotX = m_WavePlotMinX;
 
-                 m_WavePlotWidth = m_WavePlotMaxX - m_WavePlotMinX;
 
-                 m_WavePlotY = m_WavePlotMinY-1;
 
-                 m_WavePlotHeight = m_WavePlotMaxY - m_WavePlotMinY+2;
 
-                 GraphicDraw();
 
-             }
 
-         }
 
-         public void FitControlWithoutDrawing()
 
-         {
 
-             m_WavePlotX = m_WavePlotMinX;
 
-             m_WavePlotWidth = m_WavePlotMaxX - m_WavePlotMinX;
 
-             m_WavePlotY = m_WavePlotMinY - 1;
 
-             m_WavePlotHeight = m_WavePlotMaxY - m_WavePlotMinY + 2;
 
-         }
 
-         public void ClearPlot()
 
-         {
 
-             Points = new PointCollection();
 
-         }
 
-         public void ClearPlotPoints()
 
-         {
 
-             PointCollections = new List<PointCollection>();
 
-         }
 
-         public void Plot(IEnumerable x, IEnumerable y, int count = 0)
 
-         {
 
-             if (x == null || y == null) return;
 
-             if (Points == null || count == 0) Points = new PointCollection();
 
-             var enx = x.GetEnumerator();
 
-             var eny = y.GetEnumerator();
 
-             while (true)
 
-             {
 
-                 var nx = enx.MoveNext();
 
-                 var ny = eny.MoveNext();
 
-                 if (nx && ny)
 
-                     Points.Add(new System.Windows.Point(Convert.ToSingle(enx.Current, CultureInfo.InvariantCulture),
 
-                         Convert.ToSingle(eny.Current, CultureInfo.InvariantCulture)));
 
-                 else if (!nx && !ny)
 
-                     break;
 
-                 else
 
-                     throw new ArgumentException("x and y have different lengthes");
 
-                 if (count > 0 && Points.Count > count) Points.RemoveAt(0);
 
-             }
 
-         }
 
-         public void PlotY(IEnumerable y, int count = 0)
 
-         {
 
-             if (y == null) return;
 
-             if (Points == null || count == 0) Points = new PointCollection();
 
-             int x = 0;
 
-             var en = y.GetEnumerator();
 
-             while (en.MoveNext())
 
-             {
 
-                 Points.Add(new System.Windows.Point(x++, Convert.ToSingle(en.Current, CultureInfo.InvariantCulture)));
 
-                 if (count > 0 && Points.Count > count) Points.RemoveAt(0);
 
-             }
 
-         }
 
-         public void PlotPoints(IEnumerable x, IEnumerable y, int count = 0)
 
-         {
 
-             if (x == null || y == null)
 
-             {
 
-                 PointCollections = new List<PointCollection>();
 
-                 return;
 
-             }
 
-             if (PointCollections == null || count == 0) PointCollections = new List<PointCollection>();
 
-             var points = new PointCollection();
 
-             var enx = x.GetEnumerator();
 
-             var eny = y.GetEnumerator();
 
-             while (true)
 
-             {
 
-                 var nx = enx.MoveNext();
 
-                 var ny = eny.MoveNext();
 
-                 if (nx && ny)
 
-                     points.Add(new System.Windows.Point(Convert.ToSingle(enx.Current, CultureInfo.InvariantCulture),
 
-                         Convert.ToSingle(eny.Current, CultureInfo.InvariantCulture)));
 
-                 else if (!nx && !ny)
 
-                     break;
 
-                 else
 
-                     throw new ArgumentException("x and y have different lengthes");
 
-             }
 
-             PointCollections.Add(points);
 
-             if (count > 0 && PointCollections.Count > count) PointCollections.RemoveAt(0);
 
-             PointCollections = PointCollections;
 
-         }
 
-         public void PlotPointYs(IEnumerable y, int count = 0)
 
-         {
 
-             if (y == null) return;
 
-             if (PointCollections == null || count == 0) PointCollections = new List<PointCollection>();
 
-             var points = new PointCollection();
 
-             int x = 0;
 
-             var en = y.GetEnumerator();
 
-             while (en.MoveNext())
 
-             {
 
-                 points.Add(new System.Windows.Point(x++, Convert.ToSingle(en.Current, CultureInfo.InvariantCulture)));
 
-             }
 
-             PointCollections.Add(points);
 
-             if (count > 0 && PointCollections.Count > count) PointCollections.RemoveAt(0);
 
-         }
 
-         public void PlotData(IEnumerable x, IEnumerable y)
 
-         {
 
-             if (x == null || y == null)
 
-             {
 
-                 PlotDataPoints = new PointCollection();
 
-                 return;
 
-             }
 
-             var points = new PointCollection();
 
-             var enx = x.GetEnumerator();
 
-             var eny = y.GetEnumerator();
 
-             while (true)
 
-             {
 
-                 var nx = enx.MoveNext();
 
-                 var ny = eny.MoveNext();
 
-                 if (nx && ny)
 
-                     points.Add(new System.Windows.Point(Convert.ToDouble(enx.Current, CultureInfo.InvariantCulture),
 
-                         Convert.ToDouble(eny.Current, CultureInfo.InvariantCulture)));
 
-                 else if (!nx && !ny)
 
-                     break;
 
-                 else
 
-                     throw new ArgumentException("x and y have different lengthes");
 
-             }
 
-             PlotDataPoints = points;
 
-         }
 
-         public void PlotSData(IEnumerable x, IEnumerable y)
 
-         {
 
-             if (x == null || y == null)
 
-             {
 
-                 PlotSDataPoints = new PointCollection();
 
-                 return;
 
-             }
 
-             var points = new PointCollection();
 
-             var enx = x.GetEnumerator();
 
-             var eny = y.GetEnumerator();
 
-             while (true)
 
-             {
 
-                 var nx = enx.MoveNext();
 
-                 var ny = eny.MoveNext();
 
-                 if (nx && ny)
 
-                     points.Add(new System.Windows.Point(Convert.ToDouble(enx.Current, CultureInfo.InvariantCulture),
 
-                         Convert.ToDouble(eny.Current, CultureInfo.InvariantCulture)));
 
-                 else if (!nx && !ny)
 
-                     break;
 
-                 else
 
-                     throw new ArgumentException("x and y have different lengthes");
 
-             }
 
-             PlotSDataPoints = points;
 
-         }
 
-         public void PlotASData(IEnumerable x, IEnumerable y)
 
-         {
 
-             if (x == null || y == null)
 
-             {
 
-                 PlotASDataPoints = new PointCollection();
 
-                 return;
 
-             }
 
-             var points = new PointCollection();
 
-             var enx = x.GetEnumerator();
 
-             var eny = y.GetEnumerator();
 
-             while (true)
 
-             {
 
-                 var nx = enx.MoveNext();
 
-                 var ny = eny.MoveNext();
 
-                 if (nx && ny)
 
-                     points.Add(new System.Windows.Point(Convert.ToDouble(enx.Current, CultureInfo.InvariantCulture),
 
-                         Convert.ToDouble(eny.Current, CultureInfo.InvariantCulture)));
 
-                 else if (!nx && !ny)
 
-                     break;
 
-                 else
 
-                     throw new ArgumentException("x and y have different lengthes");
 
-             }
 
-             PlotASDataPoints = points;
 
-         }
 
-         /// <summary>
 
-         /// 获取小数位数
 
-         /// </summary>
 
-         /// <param name="decimalV">小数</param>
 
-         /// <returns></returns>
 
-         public int GetNumberOfDecimalPlaces(double decimalV)
 
-         {
 
-             string[] temp = decimalV.ToString().Split('.');
 
-             if (temp.Length == 2 && temp[1].Length > 0)
 
-             {
 
-                 int index = temp[1].Length - 1;
 
-                 while (temp[1][index] == '0' && index-- > 0) ;
 
-                 return index + 1;
 
-             }
 
-             return 0;
 
-         }
 
-         #endregion Public
 
-         #region Private Draw
 
-         //public void GraphicDrawplotsally()
 
-         //{
 
-         //    if (Canvas_Main.ActualWidth <= 0 || Canvas_Main.ActualHeight <= 0) return;
 
-         //    m_WavePlotMinX = double.MaxValue;
 
-         //    m_WavePlotMaxX = double.MinValue;
 
-         //    m_WavePlotMinY = double.MaxValue;
 
-         //    m_WavePlotMaxY = double.MinValue;
 
-         //    using (Bitmap bitmap = new Bitmap((int)Canvas_Main.ActualWidth, (int)Canvas_Main.ActualHeight))
 
-         //    {
 
-         //        Graphics graphics = Graphics.FromImage(bitmap);
 
-         //        if (m_WavePlotHeight < Math.Pow(10, -4))
 
-         //        {
 
-         //            double Min = m_WavePlotY;
 
-         //            double Max = m_WavePlotY + m_WavePlotHeight;
 
-         //            double delta = (Max - Min) / 2;
 
-         //            double center = (Max + Min) / 2;
 
-         //            Min = center - delta * 1.2;
 
-         //            Max = center + delta * 1.2;
 
-         //            m_WavePlotY = Min;
 
-         //            m_WavePlotHeight = Max - Min;
 
-         //        }
 
-         //    }
 
-         //}
 
-         private void GraphicDraw()
 
-         {
 
-             if (Canvas_Main.ActualWidth <= 0 || Canvas_Main.ActualHeight <= 0) return;
 
-             m_WavePlotMinX = double.MaxValue;
 
-             m_WavePlotMaxX = double.MinValue;
 
-             m_WavePlotMinY = double.MaxValue;
 
-             m_WavePlotMaxY = double.MinValue;
 
-             using (Bitmap bitmap = new Bitmap((int)Canvas_Main.ActualWidth, (int)Canvas_Main.ActualHeight))
 
-             {
 
-                 Graphics graphics = Graphics.FromImage(bitmap);
 
-                 //纵坐标 
 
-                 if (m_WavePlotHeight < Math.Pow(10, -4))
 
-                 {
 
-                     double Min = m_WavePlotY;
 
-                     double Max = m_WavePlotY + m_WavePlotHeight;
 
-                     double delta = (Max - Min) / 2;
 
-                     double center = (Max + Min) / 2;
 
-                     Min = center - delta * 1.2;
 
-                     Max = center + delta * 1.2;
 
-                     m_WavePlotY = Min;
 
-                     m_WavePlotHeight = Max - Min;
 
-                 }
 
-                 if (m_WavePlotHeight > Math.Pow(10, -4))
 
-                 {
 
-                     int IntervalTextY; int ExpCountY;
 
-                     GetIntervalValue(m_WavePlotY, m_WavePlotY + m_WavePlotHeight, out IntervalTextY, out ExpCountY);
 
-                     int StartIndexY = (int)(m_WavePlotY / (IntervalTextY * Math.Pow(10, ExpCountY)));
 
-                     int EndIndexY = (int)((m_WavePlotY + m_WavePlotHeight) / (IntervalTextY * Math.Pow(10, ExpCountY)));
 
-                     int DrawStringLength = 0;
 
-                     //寻找显示最长字符串
 
-                     for (int i = StartIndexY; i <= EndIndexY; i++)
 
-                     {
 
-                         if (DrawStringLength < ChangeDataToD((i * IntervalTextY * Math.Pow(10, ExpCountY)).ToString()).ToString().Length) DrawStringLength = ChangeDataToD((i * IntervalTextY * Math.Pow(10, ExpCountY)).ToString()).ToString().Length;
 
-                     }
 
-                     m_StartDrawLineX = (DrawStringLength + 5) * 5;
 
-                     for (int i = StartIndexY; i <= EndIndexY; i++)
 
-                     {
 
-                         if (i == StartIndexY && (i * IntervalTextY * Math.Pow(10, ExpCountY)) < m_WavePlotY) continue;
 
-                         if (i == EndIndexY && (i * IntervalTextY * Math.Pow(10, ExpCountY)) > m_WavePlotY + m_WavePlotHeight) continue;
 
-                         double Y = Canvas_Main.ActualHeight - 50 - ((Canvas_Main.ActualHeight - 50.0) / m_WavePlotHeight) * (i * IntervalTextY * Math.Pow(10, ExpCountY) - m_WavePlotY);
 
-                         if (Y < 0) Y = 0;
 
-                         if (Y > Canvas_Main.ActualHeight - 50) Y = Canvas_Main.ActualHeight - 50;
 
-                         graphics.DrawLine(m_PenLightGray, new PointF((float)m_StartDrawLineX, (float)Y), new PointF((float)(Canvas_Main.ActualWidth), (float)Y));
 
-                         graphics.DrawLine(m_PenLine, new PointF((float)m_StartDrawLineX, (float)Y), new PointF((float)m_StartDrawLineX - 10, (float)Y));
 
-                         graphics.DrawString(ChangeDataToD((i * IntervalTextY * Math.Pow(10, ExpCountY)).ToString()).ToString(), System.Drawing.SystemFonts.DefaultFont, m_BrushText, new PointF(0, (float)(Y - 5)));
 
-                     }
 
-                 }
 
-                 //横坐标
 
-                 if (m_WavePlotWidth < Math.Pow(10, -4))
 
-                 {
 
-                     double Min = m_WavePlotX;
 
-                     double Max = m_WavePlotX + m_WavePlotWidth;
 
-                     double delta = (Max - Min) / 2;
 
-                     double center = (Max + Min) / 2;
 
-                     Min = center - delta * 1.2;
 
-                     Max = center + delta * 1.2;
 
-                     m_WavePlotX = Min;
 
-                     m_WavePlotWidth = Max - Min;
 
-                 }
 
-                 if (m_WavePlotWidth > Math.Pow(10, -4))
 
-                 {
 
-                     int IntervalTextX; int ExpCountX;
 
-                     GetIntervalValue(m_WavePlotX, m_WavePlotX + m_WavePlotWidth, out IntervalTextX, out ExpCountX);
 
-                     int StartIndexX = (int)(m_WavePlotX / (IntervalTextX * Math.Pow(10, ExpCountX)));
 
-                     int EndIndexX = (int)((m_WavePlotX + m_WavePlotWidth) / (IntervalTextX * Math.Pow(10, ExpCountX)));
 
-                     for (int i = StartIndexX; i <= EndIndexX; i++)
 
-                     {
 
-                         if (i == StartIndexX && (i * IntervalTextX * Math.Pow(10, ExpCountX)) < m_WavePlotX) continue;
 
-                         if (i == EndIndexX && (i * IntervalTextX * Math.Pow(10, ExpCountX)) > m_WavePlotX + m_WavePlotWidth) continue;
 
-                         double X = m_StartDrawLineX + ((Canvas_Main.ActualWidth - m_StartDrawLineX) / m_WavePlotWidth) * (i * IntervalTextX * Math.Pow(10, ExpCountX) - m_WavePlotX);
 
-                         if (X < m_StartDrawLineX) X = m_StartDrawLineX;
 
-                         if (X > Canvas_Main.ActualWidth) X = Canvas_Main.ActualWidth;
 
-                         
 
-                         //graphics.DrawLine(m_PenLightGray, new PointF((float)X, 0), new PointF((float)X, (float)Canvas_Main.ActualHeight - 50));//画X轴横线
 
-                         graphics.DrawLine(m_PenLine, new PointF((float)X, (float)Canvas_Main.ActualHeight - 30), new PointF((float)X, (float)Canvas_Main.ActualHeight - 50));
 
-                         if (IsHorizontalDateTimeAxis)
 
-                         {
 
-                             graphics.DrawString(DateTime.FromOADate((double)ChangeDataToD((i * IntervalTextX * Math.Pow(10, ExpCountX)).ToString())).ToString("yyyy-MM-dd HH:mm:ss"), System.Drawing.SystemFonts.DefaultFont, m_BrushText, new PointF((float)X - 10, (float)Canvas_Main.ActualHeight - 30));
 
-                         }
 
-                         else
 
-                         {
 
-                             graphics.DrawString(ChangeDataToD((i * IntervalTextX * Math.Pow(10, ExpCountX)).ToString()).ToString(), System.Drawing.SystemFonts.DefaultFont, m_BrushText, new PointF((float)X - 10, (float)Canvas_Main.ActualHeight - 30));
 
-                         }
 
-                     }
 
-                 }
 
-                 //画边框
 
-                 graphics.DrawLine(m_PenLine, new PointF((float)m_StartDrawLineX, 0), new PointF((float)m_StartDrawLineX, (float)Canvas_Main.ActualHeight - 50));
 
-                 graphics.DrawLine(m_PenLine, new PointF((float)m_StartDrawLineX, 0), new PointF((float)(Canvas_Main.ActualWidth), 0));
 
-                 graphics.DrawLine(m_PenLine, new PointF((float)m_StartDrawLineX, (float)(Canvas_Main.ActualHeight - 50)), new PointF((float)Canvas_Main.ActualWidth, (float)(Canvas_Main.ActualHeight - 50)));
 
-                 graphics.DrawLine(m_PenLine, new PointF((float)Canvas_Main.ActualWidth - 1, 0), new PointF((float)Canvas_Main.ActualWidth - 1, (float)(Canvas_Main.ActualHeight - 50)));
 
-                
 
-                 if (this.PlotDataPoints != null && this.PlotDataPoints.Count > 0)
 
-                 {
 
-                     List<PointF> points = new List<PointF>();
 
-                     for (int i = 0; i < PlotDataPoints.Count; i++)
 
-                     {
 
-                         if (PlotDataPoints[i].X >= m_WavePlotX && PlotDataPoints[i].X <= m_WavePlotX + m_WavePlotWidth)
 
-                         {
 
-                             double StartX = m_StartDrawLineX + (Canvas_Main.ActualWidth - m_StartDrawLineX) / m_WavePlotWidth * (PlotDataPoints[i].X - m_WavePlotX);
 
-                             if (StartX < m_StartDrawLineX || PlotDataPoints[i].X < m_WavePlotX) StartX = m_StartDrawLineX;
 
-                             if (StartX > Canvas_Main.ActualWidth || PlotDataPoints[i].X > m_WavePlotX + m_WavePlotWidth) StartX = Canvas_Main.ActualWidth;
 
-                             double StartY = Canvas_Main.ActualHeight - 50 - (Canvas_Main.ActualHeight - 50.0) / m_WavePlotHeight * (PlotDataPoints[i].Y - m_WavePlotY);
 
-                             if (StartY < 0 || PlotDataPoints[i].Y > m_WavePlotY + m_WavePlotHeight) StartY = 0;
 
-                             if (StartY > Canvas_Main.ActualHeight - 50 || PlotDataPoints[i].Y < m_WavePlotY) StartY = Canvas_Main.ActualHeight - 50;
 
-                             points.Add(new PointF((float)StartX, (float)StartY));
 
-                         }
 
-                         if (m_WavePlotMinX == double.MaxValue || m_WavePlotMinX > PlotDataPoints[i].X) m_WavePlotMinX = PlotDataPoints[i].X;
 
-                         if (m_WavePlotMaxX == double.MinValue || m_WavePlotMaxX < PlotDataPoints[i].X) m_WavePlotMaxX = PlotDataPoints[i].X;
 
-                         if (m_WavePlotMinY == double.MaxValue || m_WavePlotMinY > PlotDataPoints[i].Y) m_WavePlotMinY = PlotDataPoints[i].Y;
 
-                         if (m_WavePlotMaxY == double.MinValue || m_WavePlotMaxY < PlotDataPoints[i].Y) m_WavePlotMaxY = PlotDataPoints[i].Y;
 
-                     }
 
-                     if (points.Count > 1 && points.Where(_ => float.IsNaN(_.X) || float.IsNaN(_.Y)).ToList<PointF>().Count == 0) graphics.DrawLines(m_PenData, points.ToArray());
 
-                 }
 
-                 if (this.PlotSDataPoints != null && this.PlotSDataPoints.Count > 0)
 
-                 {
 
-                     List<PointF> points = new List<PointF>();
 
-                     for (int i = 0; i < PlotSDataPoints.Count; i++)
 
-                     {
 
-                         if (PlotSDataPoints[i].X >= m_WavePlotX && PlotSDataPoints[i].X <= m_WavePlotX + m_WavePlotWidth)
 
-                         {
 
-                             double StartX = 50 + (Canvas_Main.ActualWidth - m_StartDrawLineX) / m_WavePlotWidth * (PlotSDataPoints[i].X - m_WavePlotX);
 
-                             if (StartX < m_StartDrawLineX || PlotSDataPoints[i].X < m_WavePlotX) StartX = m_StartDrawLineX;
 
-                             if (StartX > Canvas_Main.ActualWidth || PlotSDataPoints[i].X > m_WavePlotX + m_WavePlotWidth) StartX = Canvas_Main.ActualWidth;
 
-                             double StartY = Canvas_Main.ActualHeight - 50 - (Canvas_Main.ActualHeight - 50.0) / m_WavePlotHeight * (PlotSDataPoints[i].Y - m_WavePlotY);
 
-                             if (StartY < 0 || PlotSDataPoints[i].Y > m_WavePlotY + m_WavePlotHeight) StartY = 0;
 
-                             if (StartY > Canvas_Main.ActualHeight - 50 || PlotSDataPoints[i].Y < m_WavePlotY) StartY = Canvas_Main.ActualHeight - 50;
 
-                             points.Add(new PointF((float)StartX, (float)StartY));
 
-                         }
 
-                         if (double.IsNaN(m_WavePlotMinX) || m_WavePlotMinX > PlotSDataPoints[i].X) m_WavePlotMinX = PlotSDataPoints[i].X;
 
-                         if (double.IsNaN(m_WavePlotMaxX) || m_WavePlotMaxX < PlotSDataPoints[i].X) m_WavePlotMaxX = PlotSDataPoints[i].X;
 
-                         if (double.IsNaN(m_WavePlotMinY) || m_WavePlotMinY > PlotSDataPoints[i].Y) m_WavePlotMinY = PlotSDataPoints[i].Y;
 
-                         if (double.IsNaN(m_WavePlotMaxY) || m_WavePlotMaxY < PlotSDataPoints[i].Y) m_WavePlotMaxY = PlotSDataPoints[i].Y;
 
-                     }
 
-                     if (points.Count > 1 && points.Where(_ => float.IsNaN(_.X) || float.IsNaN(_.Y)).ToList<PointF>().Count == 0) graphics.DrawLines(m_PenSData, points.ToArray());
 
-                 }
 
-                 if (this.PlotASDataPoints != null && this.PlotASDataPoints.Count > 0)
 
-                 {
 
-                     List<PointF> points = new List<PointF>();
 
-                     for (int i = 0; i < PlotASDataPoints.Count; i++)
 
-                     {
 
-                         if (PlotASDataPoints[i].X >= m_WavePlotX && PlotASDataPoints[i].X <= m_WavePlotX + m_WavePlotWidth)
 
-                         {
 
-                             double StartX = m_StartDrawLineX + (Canvas_Main.ActualWidth - m_StartDrawLineX) / m_WavePlotWidth * (PlotASDataPoints[i].X - m_WavePlotX);
 
-                             if (StartX < m_StartDrawLineX || PlotASDataPoints[i].X < m_WavePlotX) StartX = m_StartDrawLineX;
 
-                             if (StartX > Canvas_Main.ActualWidth || PlotASDataPoints[i].X > m_WavePlotX + m_WavePlotWidth) StartX = Canvas_Main.ActualWidth;
 
-                             double StartY = Canvas_Main.ActualHeight - 50 - (Canvas_Main.ActualHeight - 50.0) / m_WavePlotHeight * (PlotASDataPoints[i].Y - m_WavePlotY);
 
-                             if (StartY < 0 || PlotASDataPoints[i].Y > m_WavePlotY + m_WavePlotHeight) StartY = 0;
 
-                             if (StartY > Canvas_Main.ActualHeight - 50 || PlotASDataPoints[i].Y < m_WavePlotY) StartY = Canvas_Main.ActualHeight - 50;
 
-                             points.Add(new PointF((float)StartX, (float)StartY));
 
-                         }
 
-                         if (m_WavePlotMinX == double.MaxValue || m_WavePlotMinX > PlotASDataPoints[i].X) m_WavePlotMinX = PlotASDataPoints[i].X;
 
-                         if (m_WavePlotMaxX == double.MinValue || m_WavePlotMaxX < PlotASDataPoints[i].X) m_WavePlotMaxX = PlotASDataPoints[i].X;
 
-                         if (m_WavePlotMinY == double.MaxValue || m_WavePlotMinY > PlotASDataPoints[i].Y) m_WavePlotMinY = PlotASDataPoints[i].Y;
 
-                         if (m_WavePlotMaxY == double.MinValue || m_WavePlotMaxY < PlotASDataPoints[i].Y) m_WavePlotMaxY = PlotASDataPoints[i].Y;
 
-                     }
 
-                     if (points.Count > 1 && points.Where(_ => float.IsNaN(_.X) || float.IsNaN(_.Y)).ToList<PointF>().Count == 0) graphics.DrawLines(m_PenASData, points.ToArray());
 
-                 }
 
-                 if (YPoints.Count > 0)
 
-                 {
 
-                     YPoints.ForEach(p =>
 
-                     {
 
-                         double StartX = m_StartDrawLineX + (Canvas_Main.ActualWidth - m_StartDrawLineX) / m_WavePlotWidth * (p.StartValue - m_WavePlotX);
 
-                         if (StartX < m_StartDrawLineX || p.StartValue < m_WavePlotX)
 
-                         {
 
-                             StartX = m_StartDrawLineX;
 
-                         }
 
-                         if (StartX > Canvas_Main.ActualWidth || p.StartValue > m_WavePlotX + m_WavePlotWidth)
 
-                         {
 
-                             StartX = Canvas_Main.ActualWidth;
 
-                         }
 
-                         graphics.DrawLine(new System.Drawing.Pen(System.Drawing.Color.Silver, 3), (float)StartX, (float)Canvas_Main.ActualHeight - 50, (float)StartX, 0);
 
-                         graphics.DrawString(p.Information, new System.Drawing.Font("Arial", 12), System.Drawing.Brushes.Black, (float)StartX, (float)Canvas_Main.ActualHeight / 15);
 
-                     });
 
-                 }
 
-                 if (this.Points != null && this.Points.Count > 0)
 
-                 {
 
-                     List<PointF> points = new List<PointF>();
 
-                     for (int i = 0; i < Points.Count; i++)
 
-                     {
 
-                         if (Points[i].X >= m_WavePlotX && Points[i].X <= m_WavePlotX + m_WavePlotWidth)
 
-                         {
 
-                             double StartX = m_StartDrawLineX + (Canvas_Main.ActualWidth - m_StartDrawLineX) / m_WavePlotWidth * (Points[i].X - m_WavePlotX);
 
-                             if (StartX < m_StartDrawLineX || Points[i].X < m_WavePlotX) StartX = m_StartDrawLineX;
 
-                             if (StartX > Canvas_Main.ActualWidth || Points[i].X > m_WavePlotX + m_WavePlotWidth) StartX = Canvas_Main.ActualWidth;
 
-                             double StartY = Canvas_Main.ActualHeight - 50 - (Canvas_Main.ActualHeight - 50.0) / m_WavePlotHeight * (Points[i].Y - m_WavePlotY);
 
-                             if (StartY < 0 || Points[i].Y > m_WavePlotY + m_WavePlotHeight) StartY = 0;
 
-                             if (StartY > Canvas_Main.ActualHeight - 50 || Points[i].Y < m_WavePlotY) StartY = Canvas_Main.ActualHeight - 50;
 
-                             points.Add(new PointF((float)StartX, (float)StartY));
 
-                         }
 
-                         if (m_WavePlotMinX == double.MaxValue || m_WavePlotMinX > Points[i].X) m_WavePlotMinX = Points[i].X;
 
-                         if (m_WavePlotMaxX == double.MinValue || m_WavePlotMaxX < Points[i].X) m_WavePlotMaxX = Points[i].X;
 
-                         if (m_WavePlotMinY == double.MaxValue || m_WavePlotMinY > Points[i].Y) m_WavePlotMinY = Points[i].Y;
 
-                         if (m_WavePlotMaxY == double.MinValue || m_WavePlotMaxY < Points[i].Y) m_WavePlotMaxY = Points[i].Y;
 
-                     }
 
-                     if (points.Count > 1 && points.Where(_ => float.IsNaN(_.X) || float.IsNaN(_.Y)).ToList<PointF>().Count == 0) graphics.DrawLines(m_PenData, points.ToArray());
 
-                 }
 
-                 if (this.PointCollections != null && this.PointCollections.Count > 0)
 
-                 {
 
-                     for (int i = 0; i < this.PointCollections.Count; i++)
 
-                     {
 
-                         List<PointF> points = new List<PointF>();
 
-                         for (int j = 0; j < this.PointCollections[i].Count; j++)
 
-                         {
 
-                             if (this.PointCollections[i][j].X >= m_WavePlotX && this.PointCollections[i][j].X <= m_WavePlotX + m_WavePlotWidth)
 
-                             {
 
-                                 double StartX = m_StartDrawLineX + (Canvas_Main.ActualWidth - m_StartDrawLineX) / m_WavePlotWidth * (this.PointCollections[i][j].X - m_WavePlotX);
 
-                                 if (StartX < m_StartDrawLineX || this.PointCollections[i][j].X < m_WavePlotX) StartX = m_StartDrawLineX;
 
-                                 if (StartX > Canvas_Main.ActualWidth || this.PointCollections[i][j].X > m_WavePlotX + m_WavePlotWidth) StartX = Canvas_Main.ActualWidth;
 
-                                 double StartY = Canvas_Main.ActualHeight - 50 - (Canvas_Main.ActualHeight - 50.0) / m_WavePlotHeight * (this.PointCollections[i][j].Y - m_WavePlotY);
 
-                                 if (StartY < 0 || this.PointCollections[i][j].Y > m_WavePlotY + m_WavePlotHeight) StartY = 0;
 
-                                 if (StartY > Canvas_Main.ActualHeight - 50 || this.PointCollections[i][j].Y < m_WavePlotY) StartY = Canvas_Main.ActualHeight - 50;
 
-                                 points.Add(new PointF((float)StartX, (float)StartY));
 
-                             }
 
-                             if (m_WavePlotMinX == double.MaxValue || m_WavePlotMinX > this.PointCollections[i][j].X) m_WavePlotMinX = this.PointCollections[i][j].X;
 
-                             if (m_WavePlotMaxX == double.MinValue || m_WavePlotMaxX < this.PointCollections[i][j].X) m_WavePlotMaxX = this.PointCollections[i][j].X;
 
-                             if (m_WavePlotMinY == double.MaxValue || m_WavePlotMinY > this.PointCollections[i][j].Y) m_WavePlotMinY = this.PointCollections[i][j].Y;
 
-                             if (m_WavePlotMaxY == double.MinValue || m_WavePlotMaxY < this.PointCollections[i][j].Y) m_WavePlotMaxY = this.PointCollections[i][j].Y;
 
-                         }
 
-                         if (points.Count > 1 && points.Where(_ => float.IsNaN(_.X) || float.IsNaN(_.Y)).ToList<PointF>().Count == 0)
 
-                         {
 
-                             graphics.DrawLines(m_PenCollencteions[i % 10], points.ToArray());
 
-                         }
 
-                     }
 
-                 }
 
-                 
 
-                 //框选
 
-                 if (m_StartMouseMove && m_MouseMove)
 
-                 {
 
-                     if (m_StartPoint != null && m_EndPoint != null)
 
-                     {
 
-                         int x = m_StartPoint.X > m_EndPoint.X ? (int)m_EndPoint.X : (int)m_StartPoint.X;
 
-                         int y = m_StartPoint.Y > m_EndPoint.Y ? (int)m_EndPoint.Y : (int)m_StartPoint.Y;
 
-                         int width = (int)Math.Abs(m_EndPoint.X - m_StartPoint.X);
 
-                         int height = (int)Math.Abs(m_EndPoint.Y - m_StartPoint.Y);
 
-                         System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(x, y, width, height);                    
 
-                         SolidBrush shadowBrush = new SolidBrush(System.Drawing.Color.FromArgb(100,100,100,100));
 
-                         graphics.FillRectangle(shadowBrush, rectangle);
 
-                         graphics.DrawRectangle(new System.Drawing.Pen (System.Drawing.Color.Transparent), rectangle);
 
-                     }
 
-                 }
 
-                 else
 
-                 {
 
-                     //拾取坐标
 
-                     if (m_MouseEnter && m_CurrentPoint != null)
 
-                     {
 
-                         double X = m_WavePlotX + (m_CurrentPoint.X - m_StartDrawLineX) / ((this.ActualWidth - m_StartDrawLineX) / m_WavePlotWidth);
 
-                         double Y = m_WavePlotY + (this.ActualHeight - 50 - m_CurrentPoint.Y) / ((this.ActualHeight - 50) / m_WavePlotHeight);
 
-                         if (this.PointCollections == null || this.PointCollections.Count <= 10)
 
-                         {
 
-                             graphics.DrawLine(m_PenBlue, new System.Drawing.PointF((float)m_StartDrawLineX, (float)m_CurrentPoint.Y), new PointF((float)Canvas_Main.ActualWidth, (float)m_CurrentPoint.Y));
 
-                             graphics.DrawLine(m_PenBlue, new System.Drawing.PointF((float)m_CurrentPoint.X, 0), new PointF((float)m_CurrentPoint.X, (float)Canvas_Main.ActualHeight - 50));
 
-                             //if (IsHorizontalDateTimeAxis)
 
-                             //{
 
-                             //    graphics.DrawString(string.Format("X={0};Y={1}", DateTime.FromOADate(X), Y.ToString("0.00")), System.Drawing.SystemFonts.DefaultFont, m_BrushXYText, new PointF((float)m_CurrentPoint.X + 10, (float)m_CurrentPoint.Y + 10));
 
-                             //}
 
-                             //else
 
-                             //{
 
-                             //    graphics.DrawString(string.Format("X={0};Y={1}", X.ToString("0.00"), Y.ToString("0.00")), System.Drawing.SystemFonts.DefaultFont, m_BrushXYText, new PointF((float)m_CurrentPoint.X + 10, (float)m_CurrentPoint.Y + 10));
 
-                             //}
 
-                         }
 
-                         //
 
-                         if (this.PlotDataPoints != null && this.PlotDataPoints.Count > 0)
 
-                         {
 
-                             if (X >= this.PlotDataPoints[0].X && X <= this.PlotDataPoints[this.PlotDataPoints.Count - 1].X)
 
-                             {
 
-                                 //int index = this.PlotDataX.IndexOf((int)Math.Round(X, 0));
 
-                                 var minDistance = this.PlotDataPoints.Min(x => Math.Abs(x.X - X));
 
-                                 var closest = this.PlotDataPoints.First(x => Math.Abs(Math.Abs(x.X - X) - minDistance) < 0.0001f);
 
-                                 int index = this.PlotDataPoints.IndexOf(closest);
 
-                                 if (index >= 0)
 
-                                 {
 
-                                     double StartX = m_StartDrawLineX + (Canvas_Main.ActualWidth - m_StartDrawLineX) / m_WavePlotWidth * (PlotDataPoints[index].X - m_WavePlotX);
 
-                                     if (StartX < m_StartDrawLineX || PlotDataPoints[index].X < m_WavePlotX) StartX = m_StartDrawLineX;
 
-                                     if (StartX > Canvas_Main.ActualWidth || PlotDataPoints[index].X > m_WavePlotX + m_WavePlotWidth) StartX = Canvas_Main.ActualWidth;
 
-                                     double StartY = Canvas_Main.ActualHeight - 50 - (Canvas_Main.ActualHeight - 50.0) / m_WavePlotHeight * (PlotDataPoints[index].Y - m_WavePlotY);
 
-                                     if (StartY < 0 || PlotDataPoints[index].Y > m_WavePlotY + m_WavePlotHeight) StartY = 0;
 
-                                     if (StartY > Canvas_Main.ActualHeight - 50 || PlotDataPoints[index].Y < m_WavePlotY) StartY = Canvas_Main.ActualHeight - 50;
 
-                                     if (!double.IsNaN(StartX) && !double.IsNaN(StartY))
 
-                                     {
 
-                                         System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle((int)StartX, (int)StartY, 5, 5);
 
-                                         graphics.FillRectangle(System.Drawing.Brushes.Blue, rectangle);
 
-                                         graphics.DrawEllipse(m_PenBlue, rectangle);
 
-                                         if (IsHorizontalDateTimeAxis)
 
-                                         {
 
-                                             graphics.DrawString(string.Format("X={0};Y={1}", DateTime.FromOADate(PlotDataPoints[index].X), PlotDataPoints[index].Y.ToString("0.00")), System.Drawing.SystemFonts.DefaultFont, m_BrushXYText, new PointF((float)StartX + 10, (float)StartY + 10));
 
-                                         }
 
-                                         else
 
-                                         {
 
-                                             graphics.DrawString(string.Format("X={0};Y={1}", PlotDataPoints[index].X.ToString("0.00"), PlotDataPoints[index].Y.ToString("0.00")), System.Drawing.SystemFonts.DefaultFont, m_BrushXYText, new PointF((float)StartX + 10, (float)StartY + 10));
 
-                                         }
 
-                                     }
 
-                                 }
 
-                             }
 
-                         }
 
-                         //
 
-                         if (this.PlotSDataPoints != null && this.PlotSDataPoints.Count > 0)
 
-                         {
 
-                             if (X >= this.PlotSDataPoints[0].X && X <= this.PlotSDataPoints[this.PlotSDataPoints.Count - 1].X)
 
-                             {
 
-                                 //int index = this.PlotSDataX.IndexOf((int)Math.Round(X, 0));
 
-                                 var minDistance = this.PlotSDataPoints.Min(x => Math.Abs(x.X - X));
 
-                                 var closest = this.PlotSDataPoints.First(x => Math.Abs(Math.Abs(x.X - X) - minDistance) < 0.0001f);
 
-                                 int index = this.PlotSDataPoints.IndexOf(closest);
 
-                                 if (index >= 0)
 
-                                 {
 
-                                     double StartX = m_StartDrawLineX + (Canvas_Main.ActualWidth - m_StartDrawLineX) / m_WavePlotWidth * (PlotSDataPoints[index].X - m_WavePlotX);
 
-                                     if (StartX < m_StartDrawLineX || PlotSDataPoints[index].X < m_WavePlotX) StartX = m_StartDrawLineX;
 
-                                     if (StartX > Canvas_Main.ActualWidth || PlotSDataPoints[index].X > m_WavePlotX + m_WavePlotWidth) StartX = Canvas_Main.ActualWidth;
 
-                                     double StartY = Canvas_Main.ActualHeight - 50 - (Canvas_Main.ActualHeight - 50.0) / m_WavePlotHeight * (PlotSDataPoints[index].Y - m_WavePlotY);
 
-                                     if (StartY < 0 || PlotSDataPoints[index].Y > m_WavePlotY + m_WavePlotHeight) StartY = 0;
 
-                                     if (StartY > Canvas_Main.ActualHeight - 50 || PlotSDataPoints[index].Y < m_WavePlotY) StartY = Canvas_Main.ActualHeight - 50;
 
-                                     if (!double.IsNaN(StartX) && !double.IsNaN(StartY))
 
-                                     {
 
-                                         System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle((int)StartX, (int)StartY, 5, 5);
 
-                                         graphics.FillRectangle(System.Drawing.Brushes.Blue, rectangle);
 
-                                         graphics.DrawEllipse(m_PenBlue, rectangle);
 
-                                         graphics.DrawString(string.Format("X={0};Y={1}", PlotSDataPoints[index].X.ToString("0.00"), PlotSDataPoints[index].Y.ToString("0.00")), System.Drawing.SystemFonts.DefaultFont, m_BrushXYText, new PointF((float)StartX + 10, (float)StartY + 10));
 
-                                     }
 
-                                 }
 
-                             }
 
-                         }
 
-                         //
 
-                         if (this.PlotASDataPoints != null && this.PlotASDataPoints.Count > 0)
 
-                         {
 
-                             if (X >= this.PlotASDataPoints[0].X && X <= this.PlotASDataPoints[this.PlotASDataPoints.Count - 1].X)
 
-                             {
 
-                                 //int index = this.PlotASDataX.IndexOf((int)Math.Round(X, 0));
 
-                                 var minDistance = this.PlotASDataPoints.Min(x => Math.Abs(x.X - X));
 
-                                 var closest = this.PlotASDataPoints.First(x => Math.Abs(x.X - X) == minDistance);
 
-                                 int index = this.PlotASDataPoints.IndexOf(closest);
 
-                                 if (index >= 0)
 
-                                 {
 
-                                     double StartX = m_StartDrawLineX + (Canvas_Main.ActualWidth - m_StartDrawLineX) / m_WavePlotWidth * (PlotASDataPoints[index].X - m_WavePlotX);
 
-                                     if (StartX < m_StartDrawLineX || PlotASDataPoints[index].X < m_WavePlotX) StartX = m_StartDrawLineX;
 
-                                     if (StartX > Canvas_Main.ActualWidth || PlotASDataPoints[index].X > m_WavePlotX + m_WavePlotWidth) StartX = Canvas_Main.ActualWidth;
 
-                                     double StartY = Canvas_Main.ActualHeight - 50 - (Canvas_Main.ActualHeight - 50.0) / m_WavePlotHeight * (PlotASDataPoints[index].Y - m_WavePlotY);
 
-                                     if (StartY < 0 || PlotASDataPoints[index].Y > m_WavePlotY + m_WavePlotHeight) StartY = 0;
 
-                                     if (StartY > Canvas_Main.ActualHeight - 50 || PlotASDataPoints[index].Y < m_WavePlotY) StartY = Canvas_Main.ActualHeight - 50;
 
-                                     if (!double.IsNaN(StartX) && !double.IsNaN(StartY))
 
-                                     {
 
-                                         System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle((int)StartX, (int)StartY, 5, 5);
 
-                                         graphics.FillRectangle(System.Drawing.Brushes.Blue, rectangle);
 
-                                         graphics.DrawEllipse(m_PenBlue, rectangle);
 
-                                         graphics.DrawString(string.Format("X={0};Y={1}", PlotASDataPoints[index].X.ToString("0.00"), PlotASDataPoints[index].Y.ToString("0.00")), System.Drawing.SystemFonts.DefaultFont, m_BrushXYText, new PointF((float)StartX + 10, (float)StartY + 10));
 
-                                     }
 
-                                 }
 
-                             }
 
-                         }
 
-                         //
 
-                         if (this.PointCollections != null && this.PointCollections.Count <= 10)
 
-                         {
 
-                             foreach (PointCollection point in this.PointCollections)
 
-                             {
 
-                                 //if (X >= point[0].X && X <= point[point.Count - 1].X)
 
-                                 {
 
-                                     //int index = this.PlotASDataX.IndexOf((int)Math.Round(X, 0));
 
-                                     var minDistance = point.Min(x => Math.Abs(x.X - X));
 
-                                     var closest = point.First(x => Math.Abs(x.X - X) == minDistance);
 
-                                     int index = point.IndexOf(closest);
 
-                                     if (index >= 0)
 
-                                     {
 
-                                         double StartX = m_StartDrawLineX + (Canvas_Main.ActualWidth - m_StartDrawLineX) / m_WavePlotWidth * (point[index].X - m_WavePlotX);
 
-                                         if (StartX < m_StartDrawLineX || point[index].X < m_WavePlotX) StartX = m_StartDrawLineX;
 
-                                         if (StartX > Canvas_Main.ActualWidth || point[index].X > m_WavePlotX + m_WavePlotWidth) StartX = Canvas_Main.ActualWidth;
 
-                                         double StartY = Canvas_Main.ActualHeight - 50 - (Canvas_Main.ActualHeight - 50.0) / m_WavePlotHeight * (point[index].Y - m_WavePlotY);
 
-                                         if (StartY < 0 || point[index].Y > m_WavePlotY + m_WavePlotHeight) StartY = 0;
 
-                                         if (StartY > Canvas_Main.ActualHeight - 50 || point[index].Y < m_WavePlotY) StartY = Canvas_Main.ActualHeight - 50;
 
-                                         if (!double.IsNaN(StartX) && !double.IsNaN(StartY))
 
-                                         {
 
-                                             System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle((int)StartX, (int)StartY, 5, 5);
 
-                                             graphics.FillRectangle(System.Drawing.Brushes.Blue, rectangle);
 
-                                             graphics.DrawEllipse(m_PenBlue, rectangle);
 
-                                             if (IsHorizontalDateTimeAxis)
 
-                                             {
 
-                                                 graphics.DrawString(string.Format("X={0};Y={1}", DateTime.FromOADate(point[index].X).ToString("yyyy/MM/dd HH:mm:ss:fff"), point[index].Y.ToString("0.00")), new Font("Times New Roman", 15.0F), m_BrushXYText, new PointF((float)StartX + 10, (float)StartY + 10));
 
-                                             }
 
-                                             else
 
-                                             {
 
-                                                 graphics.DrawString(string.Format("X={0};Y={1}", point[index].X.ToString("0.00"), point[index].Y.ToString("0.00")),     new Font("Times New Roman", 15.0F),   m_BrushXYText, new PointF((float)StartX + 10, (float)StartY + 10));
 
-                                             }
 
-                                         }
 
-                                     }
 
-                                 }
 
-                             }
 
-                         }
 
-                     }
 
-                 }
 
-                 ImageBrush_BK.ImageSource = BitmapToBitmapImage(bitmap);
 
-             }
 
-             this.InvalidateVisual();
 
-         }
 
-         #endregion Private Draw
 
-         #region Private
 
-         private void Canvas_Main_SizeChanged(object sender, SizeChangedEventArgs e)
 
-         {
 
-             GraphicDraw();
 
-         }
 
-         private void Canvas_Main_MouseWheel(object sender, MouseWheelEventArgs e)
 
-         {
 
-             double factor = e.Delta < 0 ? 1.2 : 1 / 1.2;
 
-             if (IsVerticalNavigationEnabled)
 
-             {
 
-                 double Min = m_WavePlotY;
 
-                 double Max = m_WavePlotY + m_WavePlotHeight;
 
-                 double delta = (Max - Min) / 2;
 
-                 double center = (Max + Min) / 2;
 
-                 Min = center - delta * factor;
 
-                 Max = center + delta * factor;
 
-                 m_WavePlotY = Min;
 
-                 m_WavePlotHeight = Max - Min;
 
-             }
 
-             if (IsHorizontalNavigationEnabled)
 
-             {
 
-                 double Min = m_WavePlotX;
 
-                 double Max = m_WavePlotX + m_WavePlotWidth;
 
-                 double delta = (Max - Min) / 2;
 
-                 double center = (Max + Min) / 2;
 
-                 Min = center - delta * factor;
 
-                 Max = center + delta * factor;
 
-                 m_WavePlotX = Min;
 
-                 m_WavePlotWidth = Max - Min;
 
-             }
 
-             GraphicDraw();
 
-         }
 
-         private void Canvas_Main_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 
-         {
 
-             this.Cursor = Cursors.Hand;
 
-             if (e.ClickCount == 2)
 
-             {
 
-                 FitControl();
 
-             }
 
-             else
 
-             {
 
-                 m_StartPoint = Mouse.GetPosition(e.Source as FrameworkElement);
 
-                 if (e.LeftButton == MouseButtonState.Pressed)
 
-                 {
 
-                     m_StartMouseMove = true;
 
-                 }//开始绘制矩形
 
-             }
 
-         }
 
-         private void Canvas_Main_MouseMove(object sender, MouseEventArgs e)
 
-         {
 
-             m_EndPoint = Mouse.GetPosition(e.Source as FrameworkElement);
 
-             m_CurrentPoint = Mouse.GetPosition(e.Source as FrameworkElement);
 
-             if ((Keyboard.Modifiers == ModifierKeys.Control || m_MouseMove) && m_StartMouseMove)
 
-             {
 
-                 m_MouseMove = true;
 
-                 GraphicDraw();
 
-             }//移动矩形位置
 
-             else if (m_StartMouseMove)
 
-             {
 
-                 m_WavePlotX = m_WavePlotX - (m_EndPoint.X - m_StartPoint.X) / (this.ActualWidth - 50) * m_WavePlotWidth;
 
-                 m_WavePlotY = m_WavePlotY + (m_EndPoint.Y - m_StartPoint.Y) / (this.ActualHeight - 50) * m_WavePlotHeight;
 
-                 m_StartPoint = m_EndPoint;
 
-                 GraphicDraw();
 
-             }
 
-             else if (this.PointCollections == null || this.PointCollections.Count <= 10)
 
-             {
 
-                 GraphicDraw();
 
-             }
 
-         }
 
-         private void Canvas_Main_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 
-         {
 
-             this.Cursor = Cursors.Arrow;
 
-             if (m_StartMouseMove && m_MouseMove && e.LeftButton == MouseButtonState.Released)
 
-             {
 
-                 m_StartMouseMove = false;
 
-                 m_MouseMove = false;
 
-                 if (m_StartPoint.X == m_EndPoint.X || m_StartPoint.Y == m_EndPoint.Y) return;
 
-                 double x = m_StartPoint.X > m_EndPoint.X ? m_EndPoint.X : m_StartPoint.X;
 
-                 double y = m_StartPoint.Y < m_EndPoint.Y ? m_EndPoint.Y : m_StartPoint.Y;
 
-                 double width = Math.Abs(m_EndPoint.X - m_StartPoint.X);
 
-                 double height = Math.Abs(m_EndPoint.Y - m_StartPoint.Y);
 
-                 //设置坐标轴起始位置
 
-                 this.m_WavePlotX = this.m_WavePlotX + (x - m_StartDrawLineX) / ((this.ActualWidth - m_StartDrawLineX) / this.m_WavePlotWidth);
 
-                 this.m_WavePlotY = this.m_WavePlotY + (this.ActualHeight - 50 - y) / ((this.ActualHeight - 50) / this.m_WavePlotHeight);
 
-                 this.m_WavePlotWidth = this.m_WavePlotWidth * (width / (this.ActualWidth - m_StartDrawLineX));
 
-                 this.m_WavePlotHeight = this.m_WavePlotHeight * (height / (this.ActualHeight - 50));
 
-                 GraphicDraw();
 
-             }//结束绘制矩形
 
-             m_StartMouseMove = false;
 
-             m_MouseMove = false;
 
-         }
 
-         private void Canvas_Main_MouseEnter(object sender, MouseEventArgs e)
 
-         {
 
-             if (this.PointCollections == null || this.PointCollections.Count <= 10)
 
-             {
 
-                 m_MouseEnter = true;
 
-             } 
 
-         }
 
-         private void Canvas_Main_MouseLeave(object sender, MouseEventArgs e)
 
-         {
 
-             if (this.PointCollections == null || this.PointCollections.Count <= 10) m_MouseEnter = false;
 
-             GraphicDraw();
 
-         }
 
-         private void Canvas_Main_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
 
-         {
 
-             m_WavePlotX = WavePlotOriginX;
 
-             m_WavePlotY = WavePlotOriginY;
 
-             m_WavePlotWidth = WavePlotOriginWidth;
 
-             m_WavePlotHeight = WavePlotOriginHeight;
 
-             ResetControl();
 
-         }
 
-         /// <summary>
 
-         /// 获取坐标间隔
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private void GetIntervalValue(double min, double max, out int IntervalValue, out int expCount)
 
-         {
 
-             IntervalValue = 0;
 
-             expCount = 0;
 
-             double ActualValue = Math.Abs(max - min);
 
-             if (ActualValue < 1)
 
-             {
 
-                 while (ActualValue < 1)
 
-                 {
 
-                     ActualValue *= 10;
 
-                     expCount -= 1;
 
-                 }
 
-             }
 
-             else
 
-             {
 
-                 while (ActualValue >= 10)
 
-                 {
 
-                     ActualValue /= 10;
 
-                     expCount += 1;
 
-                 }
 
-             }
 
-             if (ActualValue <= 1.2)
 
-             {
 
-                 IntervalValue = 1;
 
-                 expCount -= 1;
 
-             }
 
-             else if (ActualValue <= 3)
 
-             {
 
-                 IntervalValue = 2;
 
-                 expCount -= 1;
 
-             }
 
-             else if (ActualValue <= 5)
 
-             {
 
-                 IntervalValue = 5;
 
-                 expCount -= 1;
 
-             }
 
-             else
 
-             {
 
-                 IntervalValue = 1;
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// 字符串值中包含E等科学计数法
 
-         /// </summary>
 
-         /// <param name="strData"></param>
 
-         /// <returns></returns>
 
-         private Decimal ChangeDataToD(string strData)
 
-         {
 
-             Decimal dData = 0.0M;
 
-             if (strData.ToString().Contains("E"))
 
-             {
 
-                 dData = Decimal.Parse(strData, System.Globalization.NumberStyles.Float);
 
-             }
 
-             else
 
-             {
 
-                 dData = Decimal.Parse(strData);
 
-             }
 
-             return dData;
 
-         }
 
-         /// <summary>
 
-         /// Bitmap --> BitmapImage
 
-         /// </summary>
 
-         /// <param name="bitmap"></param>
 
-         /// <returns></returns>
 
-         private BitmapImage BitmapToBitmapImage(Bitmap bitmap)
 
-         {
 
-             using (MemoryStream stream = new MemoryStream())
 
-             {
 
-                 bitmap.Save(stream, ImageFormat.Png); // 坑点:格式选Bmp时,不带透明度
 
-                 stream.Position = 0;
 
-                 BitmapImage result = new BitmapImage();
 
-                 result.BeginInit();
 
-                 // According to MSDN, "The default OnDemand cache option retains access to the stream until the image is needed."
 
-                 // Force the bitmap to load right now so we can dispose the stream.
 
-                 result.CacheOption = BitmapCacheOption.OnLoad;
 
-                 result.StreamSource = stream;
 
-                 result.EndInit();
 
-                 result.Freeze();
 
-                 return result;
 
-             }
 
-         }
 
-         #endregion Private
 
-     }
 
- }
 
 
  |