WPF鼠标移动触发事件怎么改写成鼠标悬停触发事件 10C

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; if (!diagramCoordinates.IsEmpty)
{
double 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;                  //绘制最小点的X轴坐标
            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清空
            Gobal.MainWin.ChartViewModel.Markline1.Add(p0);         //p0,p1为左边红线
            Gobal.MainWin.ChartViewModel.Markline1.Add(p1);
            p2.X = Trace1.Points[max].NumericalArgument;                      //绘制最大点的X轴坐标
            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清空
            Gobal.MainWin.ChartViewModel.Markline2.Add(p2);                 //p2,p3为右边红线
            Gobal.MainWin.ChartViewModel.Markline2.Add(p3);

        }
        else
        {
            Gobal.MainWin.ChartViewModel.Markline1.Clear();                      //Markline1清空
            Gobal.MainWin.ChartViewModel.Markline2.Clear();                      //Markline2清空
        }
        #endregion   
    }
            WPF里目前我有一个鼠标移动事件,由于数据量大,触发效果不好,有点卡顿,现在想把这个鼠标移动触发 变成 鼠标悬停触发 求解各位大神,如知道加我微信xiaoyi895860863必带红包答谢

1个回答

定义一个bool变量
在mouse_enter里设置为true
在mouse_move里判断,如果为true,那么调用你的代码,并且设置为false
在mouse_leave里设置为false

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问