C#鼠标在触发发面的问题 5C

private void diagram_MouseMove(object sender, MouseEventArgs e)
{
if (selectedPoint != null && movepoint != null && Gobal.MainWin.TraceSettingsViewModel.TracesSettings.MovePoint)
{
ChartControl chart = (ChartControl)sender;

            //XYDiagram2D diagram = (XYDiagram2D)chart.Diagram;
            DiagramCoordinates coord = diagram.PointToDiagram(e.GetPosition(chartControl1));

            selectedPoint.Value = coord.NumericalValue;

            Gobal.MainWin.ChartViewModel.Trace1[(int)movepoint].Y = coord.NumericalValue;

        }

        if (!Gobal.MainWin.TraceSettingsViewModel.TracesSettings.MarkEnable)
            return;


        if (Trace1.Points.Count <= 0)
            return;

        double fre;
        // ChartHitInfo hitInfo = chartControl1.CalcHitInfo(e.GetPosition(chartControl1));
        Point position = e.GetPosition(chartControl1);
        DiagramCoordinates diagramCoordinates = diagram.PointToDiagram(position);

        if (!diagramCoordinates.IsEmpty)
        {


            fre = Convert.ToDouble(diagramCoordinates.NumericalArgument);
            int count = GetSeriesValue(Trace1, fre);

            int min, max;

            if (count - Gobal.MainWin.TraceSettingsViewModel.TracesSettings.MarkSpan <= 0)
                min = 0;
            else
                min = count - Gobal.MainWin.TraceSettingsViewModel.TracesSettings.MarkSpan;

            if (count + Gobal.MainWin.TraceSettingsViewModel.TracesSettings.MarkSpan >= Trace1.Points.Count)
                max = Trace1.Points.Count - 1;
            else
                max = count + Gobal.MainWin.TraceSettingsViewModel.TracesSettings.MarkSpan;

            CCInstrument.Model.Point p0 = new CCInstrument.Model.Point();
            CCInstrument.Model.Point p1 = new CCInstrument.Model.Point();
            CCInstrument.Model.Point p2 = new CCInstrument.Model.Point();
            CCInstrument.Model.Point p3 = new CCInstrument.Model.Point();

            p0.X = Trace1.Points[min].NumericalArgument;
            p0.Y = Trace1.Points[min].Value - 300;

            p1.X = Trace1.Points[min].NumericalArgument;
            p1.Y = Trace1.Points[min].Value + 300;

            Gobal.MainWin.ChartViewModel.Markline1.Clear();              //清理Markline1线
            //string shubiaox =Cursor.Position.X.toSting();
            int i=1;
         ****   if()
            {
             Gobal.MainWin.ChartViewModel.Markline1.Add(p0);
             Gobal.MainWin.ChartViewModel.Markline1.Add(p1);
            }****



            p2.X = Trace1.Points[max].NumericalArgument;
            p2.Y = Trace1.Points[max].Value - 300;
            p3.X = Trace1.Points[max].NumericalArgument;
            p3.Y = Trace1.Points[max].Value + 300;

            Gobal.MainWin.ChartViewModel.Markline2.Clear();            //清理Markline2线
           **** if()
            {
              Gobal.MainWin.ChartViewModel.Markline2.Add(p2);            //添加Markline2线的坐标
              Gobal.MainWin.ChartViewModel.Markline2.Add(p3);
            }****


        }
        else
        {
            Gobal.MainWin.ChartViewModel.Markline1.Clear();
            Gobal.MainWin.ChartViewModel.Markline2.Clear();
        }   

    }




            这是在一个mousemove事件里触发滴我想限制一下有标记部分 if()里面的添加的方法是    
            Gobal.MainWin.ChartViewModel.Markline2.Add(p2);           
     Gobal.MainWin.ChartViewModel.Markline2.Add(p3);
            移动中不执行:
            Gobal.MainWin.ChartViewModel.Markline2.Add(p2);           
     Gobal.MainWin.ChartViewModel.Markline2.Add(p3);
            不移动执行:
            Gobal.MainWin.ChartViewModel.Markline2.Add(p2);           
     Gobal.MainWin.ChartViewModel.Markline2.Add(p3);
            求教好的方法

1个回答

我之前遇到这种,大多都采用 判断两个时间点的坐标是不是相同,如果相同,则是没有移动,不相同则在移动

qiuzhihzy123
qiuzhihzy123 回复qq_38353711: 用计时器即可,相当于另起一个线程
接近 2 年之前 回复
qq_38353711
Lonely King 那你写在那个事件里了
接近 2 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问