0

我在我的 ios 项目中使用 oxyplot 来绘制一些图表。我需要处理图表上的触摸以在其上添加注释。我正在使用触摸事件,但它不起作用。实际上它有时有效,有时则无效。它在开始时有效,现在不再有效。有谁知道可能是什么错误。

这是代码

myLineChart.series1.TouchStarted += (sender, e) =>
        {
            myLineChart.xCoordinate = e.Position.X;
            myLineChart.yCoordinate = e.Position.Y;
            if(myLineChart.series1.Points != null){
                timer = new System.Timers.Timer ();
                timer.Interval = 400;
                timer.Elapsed += (senderr, er) => {
                    InvokeOnMainThread ( () => {
                        dialog = new DialogView(View,Language.AddNoteLabel,Language.NotesQuestionLabel,Language.YesButton,Language.NoButton); 
                        dialog.Show(); 

                        dialog.firstButton.TouchUpInside += (sender1, e1) => CreateNote ();

                        dialog.secondButton.TouchUpInside += (sender1, e1) => dialog.Dispose ();
                    });
                    timer.Dispose();
                };
                timer.Enabled = true;
            }
            e.Handled = true;
        };
4

1 回答 1

0

您可以考虑处理OxyPlot.Model.TouchCompleted事件。

private void HookEvents()
{
    this.UnhookEvents();

    if (this.plot != null && this.plot.Model != null)
    {
        this.plot.Model.TouchCompleted += this.PlotModelTouchCompletedHandler;
    }
}

private void UnhookEvents()
{
    if (this.plot != null && this.plot.Model != null)
    {
        this.plot.Model.TouchCompleted -= this.PlotModelTouchCompletedHandler;
    }
}

private void PlotModelTouchCompletedHandler (object sender, OxyTouchEventArgs e)
{
    // Put your logic to add custom node here.
}
于 2015-06-11T01:47:56.863 回答