private void DrawGraphic() { DivePoint previous = _dive.DivePoints[0]; for (int i = 1; i < _dive.DivePoints.Count; i++) { DrawLine(previous, _dive.DivePoints[i]); previous = _dive.DivePoints[i]; } DrawDivePoints(); }
public void GetAscentByIndex(int index) { List <DivePoint> myDivePoint = new List <DivePoint>(); CompartmentParams compartmentParams = new CompartmentParams(DivePoints[0].Gas.Helium); double FGas = 1 - DivePoints[0].Gas.Oxygen; PointParams truePointParams = new PointParams(); PointParamsAscent truePointParamsAscent = new PointParamsAscent(); truePointParams.pCurrent = new double[17]; for (int i = 0; i < truePointParams.pCurrent.Length; i++) { truePointParams.pCurrent[i] = pressureAmbient(FGas, 0, pressureSeaLevel); } int count = index; int j = 0; double airConsumption = 0; double vConsumption = 30; while (count > 0) { compartmentParams = new CompartmentParams(DivePoints[j].Gas.Helium); FGas = 1 - DivePoints[j].Gas.Oxygen; double vRate = (DivePoints[j + 1].Depth - DivePoints[j].Depth) / (DivePoints[j + 1].Time - DivePoints[j].Time); airConsumption += findAirConsumption(vConsumption, DivePoints[j + 1].Time - DivePoints[j].Time, DivePoints[j].Depth, DivePoints[j + 1].Depth); for (int i = 0; i < truePointParams.pCurrent.Length; i++) { truePointParams.pCurrent[i] = pressureAtoB(pressureAmbient(FGas, DivePoints[j].Depth, pressureSeaLevel), FGas, vRate, DivePoints[j + 1].Time - DivePoints[j].Time, Kf(compartmentParams.compartment.paramT[i]), truePointParams.pCurrent[i]); } j += 1; count -= 1; } compartmentParams = new CompartmentParams(DivePoints[j].Gas.Helium); FGas = 1 - DivePoints[j].Gas.Oxygen; double depthTo3 = maxDepthTo3(truePointParams.pCurrent, compartmentParams.compartment.paramM0, compartmentParams.compartment.paramdM, pressureSeaLevel); truePointParams.airConsumption = airConsumption; truePointParams.Gas = DivePoints[j].Gas; double lastDepth = DivePoints[j].Depth; double lastTime = DivePoints[j].Time; truePointParamsAscent = ascentUp(truePointParams, pressureSeaLevel, depthTo3, lastTime, lastDepth); for (int i = 0; i < truePointParamsAscent.depth.Count; i++) { DivePoint dv = new DivePoint(truePointParamsAscent.time[i], truePointParamsAscent.depth[i]); myDivePoint.Add(dv); } DivePoints.RemoveRange(index + 1, DivePoints.Count - 1 - index); DivePoints.AddRange(myDivePoint); }
private void DrawLine(DivePoint p1, DivePoint p2) { Line twoPointLine = new Line(); twoPointLine.X1 = DepthAxisIndent() + p1.Time / (_dive.TimeLength / 10) * TimeBeadLength; twoPointLine.Y1 = TimeAxisIndent() + p1.Depth / (_dive.MaxDepth / 10) * DepthBeadLength; twoPointLine.X2 = DepthAxisIndent() + p2.Time / (_dive.TimeLength / 10) * TimeBeadLength; twoPointLine.Y2 = TimeAxisIndent() + p2.Depth / (_dive.MaxDepth / 10) * DepthBeadLength; twoPointLine.Stroke = Brushes.Red; twoPointLine.StrokeThickness = 1; int index = _dive.GetListNumber(p2.Time, p2.Depth); if (!_dive.PointAvailable(index)) { twoPointLine.StrokeDashArray = new DoubleCollection() { 5, 5 } } ; GraphGrid.Children.Add(twoPointLine); }