private void InsertNewDataPoint(FatigueInfo fatigueInfo)
{
if (LenghtInSeconds == 0 || MaxValue == 0 || TotalTimeInSeconds == 0)
return;
if (fatigueInfo.SelectedArm == Arm.LeftArm)
ConsumeEndurance = fatigueInfo.LeftData.ConsumedEndurance;
else
ConsumeEndurance = fatigueInfo.RightData.ConsumedEndurance;
//Shrink the polyline if needed
double totalTimeFactor = 1;
if (TotalTimeInSeconds > LenghtInSeconds)
totalTimeFactor = 1.5;
double maxValueFactor = 1;
if (ConsumeEndurance > MaxValue)
maxValueFactor = 1.5;
for (int i = 0; i < plotGraphRight.Points.Count; i++)
{
plotGraphRight.Points[i] = new Point()
{
X = plotGraphRight.Points[i].X / totalTimeFactor,
Y = plotGraphRight.Points[i].Y / maxValueFactor
};
}
LenghtInSeconds *= totalTimeFactor;
MaxValue *= maxValueFactor;
TimePlotValue = TotalTimeInSeconds * (cGraphContent.Width) / LenghtInSeconds;
plotGraphRight.Points.Add(new Point(TimePlotValue, ConsumeEndurance * (cGraphContent.Height) / MaxValue));
FatigueInfo newFatigueInfo = new FatigueInfo()
{
DateTime = DateTime.Now,
FatigueFile = fatigueInfo.FatigueFile,
SelectedArm = fatigueInfo.SelectedArm,
TotalTimeInSeconds = fatigueInfo.TotalTimeInSeconds,
LeftData = new ArmData(fatigueInfo.LeftData),
RightData = new ArmData(fatigueInfo.RightData)
};
fatigueInfoList.Add(newFatigueInfo);
}