diff --git a/Dashboard.Common/Measure.cs b/Dashboard.Common/Measure.cs
new file mode 100644
index 0000000..61fbf8d
--- /dev/null
+++ b/Dashboard.Common/Measure.cs
@@ -0,0 +1,86 @@
+namespace Dashboard
+{
+ public enum MeasurementUnit
+ {
+ ///
+ /// The default unit. A size of a single picture element.
+ ///
+ Pixel,
+ ///
+ /// 1/72th of an inch traditional in graphics design.
+ ///
+ Point,
+ ///
+ /// The universal length unit for small distances.
+ ///
+ Millimeter,
+ ///
+ /// An inverse proportional unit with respect to the container size.
+ ///
+ Star,
+ ///
+ /// A directly proportional unit with respect to the container size.
+ ///
+ Percent,
+ }
+
+ public record struct AdvancedMetric(MeasurementUnit Unit, float Value)
+ {
+ public AdvancedMetric Convert(MeasurementUnit target, float dpi, float rel, int stars)
+ {
+ if (Unit == target)
+ return this;
+
+ float pixels = Unit switch {
+ MeasurementUnit.Pixel => Value,
+ MeasurementUnit.Point => Value * (72f / dpi),
+ MeasurementUnit.Millimeter => Value * (28.3464566929f / dpi),
+ MeasurementUnit.Star => Value * rel / stars,
+ MeasurementUnit.Percent => Value * rel / 100,
+ _ => throw new Exception(),
+ };
+
+ float value = target switch {
+ MeasurementUnit.Pixel => pixels,
+ MeasurementUnit.Point => Value * (dpi / 72f),
+ // MeasurementUnit.Millimeter =>
+ };
+
+ return new AdvancedMetric(target, value);
+ }
+
+ public override string ToString()
+ {
+ return $"{Value} {Unit.ToShortString()}";
+ }
+
+ public static bool TryParse(ReadOnlySpan str, out AdvancedMetric metric)
+ {
+ metric = default;
+ return false;
+ }
+
+ public static AdvancedMetric Parse(ReadOnlySpan str) =>
+ TryParse(str, out AdvancedMetric metric)
+ ? metric
+ : throw new Exception($"Could not parse the value '{str}'.");
+ }
+
+ public static class MeasurementExtensions
+ {
+ public static bool IsRelative(this MeasurementUnit unit) => unit switch {
+ MeasurementUnit.Star or MeasurementUnit.Percent => true,
+ _ => false,
+ };
+ public static bool IsAbsolute(this MeasurementUnit unit) => !IsRelative(unit);
+
+ public static string ToShortString(this MeasurementUnit unit) => unit switch {
+ MeasurementUnit.Pixel => "px",
+ MeasurementUnit.Point => "pt",
+ MeasurementUnit.Millimeter => "mm",
+ MeasurementUnit.Star => "*",
+ MeasurementUnit.Percent => "%",
+ _ => throw new Exception("Unknown unit."),
+ };
+ }
+}
diff --git a/Dashboard/Application.cs b/Dashboard/Application.cs
index c9c1bd0..62db7dc 100644
--- a/Dashboard/Application.cs
+++ b/Dashboard/Application.cs
@@ -67,6 +67,7 @@ namespace Dashboard
public virtual void Leave()
{
Backend.Leave();
+ Leaving?.Invoke(this, EventArgs.Empty);
}
public void Run() => Run(true, CancellationToken.None);
diff --git a/tests/Dashboard.TestApplication/Program.cs b/tests/Dashboard.TestApplication/Program.cs
index 17a80ea..1b174b9 100644
--- a/tests/Dashboard.TestApplication/Program.cs
+++ b/tests/Dashboard.TestApplication/Program.cs
@@ -4,7 +4,6 @@ using System.Text;
using Dashboard.Drawing.OpenGL;
using Dashboard.ImmediateUI;
using Dashboard.OpenTK.PAL2;
-using OpenTK.Graphics;
using OpenTK.Platform;
using OpenTK.Graphics.OpenGL;
using OpenTK.Mathematics;