2017-01-26 5 views
0

PlotModelにはLineSeriesが塗装されています。 私が探しているのは、MouseDownイベントで検出されたポイントが属するすべてのLineSeriesを選択するというトリックです。OxyPlotは、選択したLineSeriesを見つけます

​​

をしかし、この方法でモデルが全体LineSeriesがのほんの一部の厚さを変更します。

私はこれをやりました。 ご意見はありますか? ありがとう!

答えて

0

あなたはe.Position周りをランダムに検索し、シリーズを選択することができます:radiusは、あなたが検索しようとしているどのくらいを決定

private void PlotModel_MouseDown(object sender, OxyMouseDownEventArgs e) 
    { 
     int radius = 5; 
     List<LineSeries> ss = new List<LineSeries>(); 
     searchAndAdd(ref ss, e.Position); 
     Random rand = new Random(); 
     for (int i = 0; i < 100; i++) 
     { 
      double x = rand.Next(-radius, radius); 
      double y = rand.Next(-radius, radius); 
      ScreenPoint pos = new ScreenPoint(e.Position.X + x, e.Position.X); 
      searchAndAdd(ref ss, pos); 
     } 
     foreach (var s in ss) 
      s.StrokeThickness = 8; 
     plotModel.InvalidatePlot(false); 
    } 
    void searchAndAdd(ref List<LineSeries> series, ScreenPoint pos) 
    { 
     var s = plotModel.GetSeriesFromPoint(pos, 10) as LineSeries; 
     if (s != null && series.Contains(s) == false) 
      series.Add(s); 
    } 

注こと。また、最後にplotModel.InvalidatePlot(false);に電話する必要があります。

関連する問題