/// <summary> /// Constructor of the ScaleIcon Class /// </summary> /// <param name="camera"></param> public ScaleIcon(Camera2dv2 camera) { _camera = camera; color = new Color(Colors.White); font = new Font(FontFamilies.Fantasy, Scale); pen = new Pen(color, thickness); sizeAndLabel = new KeyValuePair <int, string>(ScaleMinLength, _camera.WorldDistance(ScaleMinLength).ToString() + " au"); }
/// <summary> /// Calculates the Size of the ScaleLabel and the Text indicating the Scale. /// Logarithmically and in 1, 2, 5 steps /// </summary> public void calcLabelAndSize() { string unit = " au"; double nearestWorldLength; double MinWorldLength = _camera.WorldDistance(ScaleMinLength); if (MinWorldLength > 0.001) { nearestWorldLength = Math.Pow(10, Math.Ceiling(Math.Log10(MinWorldLength))); if (nearestWorldLength / 5 > MinWorldLength) { sizeAndLabel = new KeyValuePair <int, string>((int)_camera.ViewDistance((float)nearestWorldLength / 5), nearestWorldLength / 5 + unit); return; } if (nearestWorldLength / 2 > MinWorldLength) { sizeAndLabel = new KeyValuePair <int, string>((int)_camera.ViewDistance((float)nearestWorldLength / 2), nearestWorldLength / 2 + unit); return; } sizeAndLabel = new KeyValuePair <int, string>((int)_camera.ViewDistance((float)nearestWorldLength), nearestWorldLength + unit); return; } else { MinWorldLength = _camera.WorldDistance(ScaleMinLength) * GameConstants.Units.KmPerAu; unit = " km"; nearestWorldLength = Math.Pow(10, Math.Ceiling(Math.Log10(MinWorldLength))); if (nearestWorldLength / 5 > MinWorldLength) { sizeAndLabel = new KeyValuePair <int, string>((int)_camera.ViewDistance((float)(nearestWorldLength / GameConstants.Units.KmPerAu / 5)), nearestWorldLength / 5 + unit); return; } if (nearestWorldLength / 2 > MinWorldLength) { sizeAndLabel = new KeyValuePair <int, string>((int)_camera.ViewDistance((float)(nearestWorldLength / GameConstants.Units.KmPerAu / 2)), nearestWorldLength / 2 + unit); return; } sizeAndLabel = new KeyValuePair <int, string>((int)_camera.ViewDistance((float)(nearestWorldLength / GameConstants.Units.KmPerAu)), nearestWorldLength + unit); return; } }