private void PPositionChanged(object sender, PositionChangedEventArgs args) { var xDatamodelCurrent = XforDb(args.Position.X); var draggablePoint = (DraggablePoint)sender; //add node to replace moving sidenode (left). if (Math.Abs(args.PreviousPosition.X - CompXdBStart) < 3 && _points.First().Equals(draggablePoint)) { AddPointToList(CompXdBStart, args.PreviousPosition.Y, false); } //add node to replace moving sidenode (right). if (Math.Abs(args.PreviousPosition.X - (CompXdBStart + 96)) < 3 && _points.Last().Equals(draggablePoint)) { AddPointToList(CompXdBStart + 96, args.PreviousPosition.Y, true); } //from previous to current if (LineData.Any(q => q.Position.X < args.Position.X)) { var xDatamodelPrevious = XforDb(LineData.Where(q => q.Position.X < args.Position.X).Max(q => q.Position.X)); double positions = Math.Abs(xDatamodelPrevious - xDatamodelCurrent); var previousdB = Compressor.CompressorValues[xDatamodelPrevious]; for (var position = 0; position <= positions; position++) { Compressor.CompressorValues[position + xDatamodelPrevious] = previousdB + (args.Position.Y - previousdB) * (position / positions); } } //from current to next if (LineData.Any(q => q.Position.X > args.Position.X)) { var xDatamodelNext = XforDb(LineData.Where(q => q.Position.X > args.Position.X).Min(q => q.Position.X)); double positions = Math.Abs(xDatamodelCurrent - xDatamodelNext); var addition = 1 / positions; var nextDb = Compressor.CompressorValues[xDatamodelNext]; for (var position = 0; position < positions; position++) { Compressor.CompressorValues[position + xDatamodelCurrent] = args.Position.Y + addition * (nextDb - args.Position.Y) * position; } } SendCompressor(Id, Compressor); }