public Statistic(string name, AmphibianSoftware.VisualSail.Data.Statistics.Calculator.Calculator <T> calculator, StatisticType type, StatisticUnit metricUnit, StatisticUnit standardUnit, string description, bool selectedByDefault) { _name = name; _calculator = calculator; _type = type; _metricUnit = metricUnit; _standardUnit = standardUnit; _description = description; _selectedByDefault = selectedByDefault; }
public override float ConvertToStandardUnits(float value, StatisticUnit from, StatisticUnit to) { if (from == StatisticUnit.kilometers) { return((float)UnitConversionHelper.KilometersToMiles((double)value)); } else if (from == StatisticUnit.meters) { return((float)UnitConversionHelper.MetersToYards((double)value)); } else if (from == StatisticUnit.kmh) { return((float)UnitConversionHelper.KmhToMph((double)value)); } else { return(value); } }
public Sum(string name, AmphibianSoftware.VisualSail.Data.Statistics.Calculator.Calculator <T> calculator, StatisticType type, StatisticUnit metricUnit, StatisticUnit standardUnit, string description, bool selectedByDefault) : base(name, calculator, type, metricUnit, standardUnit, description, selectedByDefault) { }
private void ConfigureGraph() { //make sure we only run one configure at a time. if (!_configuring) { _configuring = true; _curves = new List <CurveItem>(); zg.GraphPane.Title.Text = _statisticName + " by " + _type.ToString(); this.Text = zg.GraphPane.Title.Text; this.TabText = zg.GraphPane.Title.Text; zg.GraphPane.XAxis.Title.Text = "Time"; _unit = _replay.Boats[0].TotalStatistics.GetStatisticUnit(_statisticName, _unitType); zg.GraphPane.YAxis.Title.Text = _statisticName + " (" + _unit.ToString() + ")"; zg.GraphPane.CurveList.Clear(); foreach (SelectedStatisticCell ssc in _statistics) { SortedList <DateTime, double> data = new SortedList <DateTime, double>(); string curveName = GetSelectionLabel(ssc); if (_type == StatisticGroupType.Tack) { data = _replay.Boats[ssc.BoatIndex.Value].TackStatistics[ssc.TackIndex.Value].GetGraphableTimeline(_statisticName, _unitType); } else if (_type == StatisticGroupType.Leg) { data = _replay.Boats[ssc.BoatIndex.Value].LegStatistics[ssc.LegIndex.Value].GetGraphableTimeline(_statisticName, _unitType); } else { data = _replay.Boats[ssc.BoatIndex.Value].TotalStatistics.GetGraphableTimeline(_statisticName, _unitType); } PointPairList graphData = new PointPairList(); LineItem curve = zg.GraphPane.AddCurve(curveName, graphData, _replay.Boats[ssc.BoatIndex.Value].Color, SymbolType.Diamond); foreach (DateTime dt in data.Keys) { AddPoint(curve, dt, data[dt]); } curve.Symbol.Fill = new Fill(Color.White); curve.Symbol.IsVisible = true; curve.Symbol.Size = 3f; curve.Line.IsOptimizedDraw = true; _curves.Add(curve); } if (_enableOffset) { List <int> usedColors = new List <int>(); _offset = DateTime.MaxValue; //find the smallest date //also alter the colors so that they are different foreach (CurveItem ci in zg.GraphPane.CurveList) { if (ci.Points.Count > 0) { if (new XDate(ci[0].X).DateTime < _offset) { _offset = new XDate(ci[0].X).DateTime; } } } //now go through and apply the offset to all points foreach (CurveItem ci in zg.GraphPane.CurveList) { if (ci.Points.Count > 0) { //no point offsetting if we're on the minimum if (new XDate(ci[0].X).DateTime != _offset) { //determine the difference between this curve and the minimum curve TimeSpan difference = new XDate(ci[0].X).DateTime - _offset.Value; //now go through and offset each point for (int i = 0; i < ci.Points.Count; i++) { ci[i].X = new XDate(new XDate(ci[i].X).DateTime - difference); } } } } } else { _offset = null; } DateTime simTime = _replay.SimulationTime; //_nowLine = new LineObj(Color.Blue,new XDate(simTime), _minYValue, new XDate(simTime), _maxYValue); //_nowLine.IsClippedToChartRect = true; //_nowLine.ZOrder = ZOrder.A_InFront; //_nowLine.IsVisible = true; //zg.GraphPane.GraphObjList.Add(_nowLine); zg.GraphPane.Legend.IsVisible = false; zg.GraphPane.XAxis.MajorGrid.IsVisible = true; zg.GraphPane.XAxis.Type = AxisType.Date; zg.IsShowHScrollBar = true; zg.IsShowVScrollBar = true; zg.IsAutoScrollRange = true; zg.IsShowPointValues = true; zg.AxisChange(); zg.RestoreScale(zg.GraphPane); zg.Invalidate(); _autoScrollSize = _defaultAutoScrollSize; _configuring = false; } }
private void ConfigureGraph() { //make sure we only run one configure at a time. if (!_configuring) { _configuring = true; _curves = new List<CurveItem>(); zg.GraphPane.Title.Text = _statisticName + " by " + _type.ToString(); this.Text = zg.GraphPane.Title.Text; this.TabText = zg.GraphPane.Title.Text; zg.GraphPane.XAxis.Title.Text = "Time"; _unit = _replay.Boats[0].TotalStatistics.GetStatisticUnit(_statisticName, _unitType); zg.GraphPane.YAxis.Title.Text = _statisticName + " (" + _unit.ToString() + ")"; zg.GraphPane.CurveList.Clear(); foreach (SelectedStatisticCell ssc in _statistics) { SortedList<DateTime, double> data = new SortedList<DateTime, double>(); string curveName = GetSelectionLabel(ssc); if (_type == StatisticGroupType.Tack) { data = _replay.Boats[ssc.BoatIndex.Value].TackStatistics[ssc.TackIndex.Value].GetGraphableTimeline(_statisticName, _unitType); } else if (_type == StatisticGroupType.Leg) { data = _replay.Boats[ssc.BoatIndex.Value].LegStatistics[ssc.LegIndex.Value].GetGraphableTimeline(_statisticName, _unitType); } else { data = _replay.Boats[ssc.BoatIndex.Value].TotalStatistics.GetGraphableTimeline(_statisticName, _unitType); } PointPairList graphData = new PointPairList(); LineItem curve = zg.GraphPane.AddCurve(curveName, graphData, _replay.Boats[ssc.BoatIndex.Value].Color, SymbolType.Diamond); foreach (DateTime dt in data.Keys) { AddPoint(curve, dt, data[dt]); } curve.Symbol.Fill = new Fill(Color.White); curve.Symbol.IsVisible = true; curve.Symbol.Size = 3f; curve.Line.IsOptimizedDraw = true; _curves.Add(curve); } if (_enableOffset) { List<int> usedColors = new List<int>(); _offset = DateTime.MaxValue; //find the smallest date //also alter the colors so that they are different foreach (CurveItem ci in zg.GraphPane.CurveList) { if (ci.Points.Count > 0) { if (new XDate(ci[0].X).DateTime < _offset) { _offset = new XDate(ci[0].X).DateTime; } } } //now go through and apply the offset to all points foreach (CurveItem ci in zg.GraphPane.CurveList) { if (ci.Points.Count > 0) { //no point offsetting if we're on the minimum if (new XDate(ci[0].X).DateTime != _offset) { //determine the difference between this curve and the minimum curve TimeSpan difference = new XDate(ci[0].X).DateTime - _offset.Value; //now go through and offset each point for (int i = 0; i < ci.Points.Count; i++) { ci[i].X = new XDate(new XDate(ci[i].X).DateTime - difference); } } } } } else { _offset = null; } DateTime simTime = _replay.SimulationTime; //_nowLine = new LineObj(Color.Blue,new XDate(simTime), _minYValue, new XDate(simTime), _maxYValue); //_nowLine.IsClippedToChartRect = true; //_nowLine.ZOrder = ZOrder.A_InFront; //_nowLine.IsVisible = true; //zg.GraphPane.GraphObjList.Add(_nowLine); zg.GraphPane.Legend.IsVisible = false; zg.GraphPane.XAxis.MajorGrid.IsVisible = true; zg.GraphPane.XAxis.Type = AxisType.Date; zg.IsShowHScrollBar = true; zg.IsShowVScrollBar = true; zg.IsAutoScrollRange = true; zg.IsShowPointValues = true; zg.AxisChange(); zg.RestoreScale(zg.GraphPane); zg.Invalidate(); _autoScrollSize = _defaultAutoScrollSize; _configuring = false; } }
public SetTimeAverage(string name, TimeSpan span, AmphibianSoftware.VisualSail.Data.Statistics.Calculator.Calculator <T> calculator, T zero, StatisticType type, StatisticUnit metricUnit, StatisticUnit standardUnit, string description, bool selectedByDefault) : base(name, calculator, type, metricUnit, standardUnit, description, selectedByDefault) { _zero = zero; _timespan = span; _values = new SortedList <DateTime, T>(); }
public override System.TimeSpan ConvertToStandardUnits(System.TimeSpan value, StatisticUnit from, StatisticUnit to) { return(value); }
public override System.DateTime ConvertToStandardUnits(System.DateTime value, StatisticUnit from, StatisticUnit to) { return(value); }
public abstract T ConvertToStandardUnits(T value, StatisticUnit from, StatisticUnit to);