/// <summary> /// Make sure the scaling and grid lines are nice (either in meters or feet, depending on user settings) /// </summary> private void CleanScaling() { if (Properties.Settings.Default.useMilesNotMeters) { niceScale = new NiceScaling(zoomedMinY, zoomedMaxY, Me.FromFt(1.0f), "ft"); } else { niceScale = new NiceScaling(zoomedMinY, zoomedMaxY, 1.0, "m"); } minY = (double)niceScale.ValueMin; maxY = (double)niceScale.ValueMax; }
/// <summary> /// Print the x-axes labels /// </summary> /// <param name="drawingCanvas">The canvas to draw upon</param> private void PrintHorizontalScaleLabels(Canvas drawingCanvas) { NiceScaling niceScale; int minNumberOfTicks = Math.Max(4, (int)(this.canvasWidth / 100)); if (Properties.Settings.Default.useMilesNotMeters) { niceScale = new NiceScaling(this.zoomedMinX, this.zoomedMaxX, Me.FromMi(1.0f), "M", minNumberOfTicks, true); } else { niceScale = new NiceScaling(this.zoomedMinX, this.zoomedMaxX, Me.FromKiloM(1.0f), "km", minNumberOfTicks, true); } foreach (decimal niceValue in niceScale.NiceValues) { string textToDraw = String.Format("{0}{1}", niceValue / niceScale.Scale, niceScale.Unit); DrawText(drawingCanvas, ScaledX((double)niceValue), 5, textToDraw, Colors.Black); } }