|
@@ -36,12 +36,12 @@ public class GaugeControl : Control
|
|
|
var radius = Math.Min(bounds.Width, bounds.Height) / 2 - 20;
|
|
var radius = Math.Min(bounds.Width, bounds.Height) / 2 - 20;
|
|
|
var typeface = new Typeface("Microsoft YaHei", FontStyle.Normal, FontWeight.Bold);
|
|
var typeface = new Typeface("Microsoft YaHei", FontStyle.Normal, FontWeight.Bold);
|
|
|
|
|
|
|
|
- context.DrawEllipse(ThemeHelper.PanelBg(), null, new Rect(cx - radius - 5, cy - radius - 5, (radius + 5) * 2, (radius + 5) * 2));
|
|
|
|
|
- DrawArc(context, new Pen(ThemeHelper.Border(), 8), cx, cy, radius, 135, 270);
|
|
|
|
|
|
|
+ context.DrawEllipse(ThemeHelper.PanelBg, null, new Rect(cx - radius - 5, cy - radius - 5, (radius + 5) * 2, (radius + 5) * 2));
|
|
|
|
|
+ DrawArc(context, new Pen(ThemeHelper.Border, 8), cx, cy, radius, 135, 270);
|
|
|
|
|
|
|
|
var normalized = Math.Max(0, Math.Min(1, (Value - MinValue) / (MaxValue - MinValue)));
|
|
var normalized = Math.Max(0, Math.Min(1, (Value - MinValue) / (MaxValue - MinValue)));
|
|
|
var valueAngle = 135 + normalized * 270;
|
|
var valueAngle = 135 + normalized * 270;
|
|
|
- var valueColor = ValueColor ?? ThemeHelper.Success();
|
|
|
|
|
|
|
+ var valueColor = ValueColor ?? ThemeHelper.Success;
|
|
|
DrawArc(context, new Pen(valueColor, 8), cx, cy, radius, 135, valueAngle - 135);
|
|
DrawArc(context, new Pen(valueColor, 8), cx, cy, radius, 135, valueAngle - 135);
|
|
|
|
|
|
|
|
for (int i = 0; i <= 10; i++)
|
|
for (int i = 0; i <= 10; i++)
|
|
@@ -50,7 +50,7 @@ public class GaugeControl : Control
|
|
|
var rad = angle * Math.PI / 180;
|
|
var rad = angle * Math.PI / 180;
|
|
|
var isMajor = i % 5 == 0;
|
|
var isMajor = i % 5 == 0;
|
|
|
var tickLen = isMajor ? 12 : 6;
|
|
var tickLen = isMajor ? 12 : 6;
|
|
|
- context.DrawLine(new Pen(isMajor ? ThemeHelper.TextPrimary() : ThemeHelper.TextDisabled(), isMajor ? 2 : 1),
|
|
|
|
|
|
|
+ context.DrawLine(new Pen(isMajor ? ThemeHelper.TextPrimary : ThemeHelper.TextDisabled, isMajor ? 2 : 1),
|
|
|
new Point(cx + Math.Cos(rad) * (radius - tickLen), cy + Math.Sin(rad) * (radius - tickLen)),
|
|
new Point(cx + Math.Cos(rad) * (radius - tickLen), cy + Math.Sin(rad) * (radius - tickLen)),
|
|
|
new Point(cx + Math.Cos(rad) * radius, cy + Math.Sin(rad) * radius));
|
|
new Point(cx + Math.Cos(rad) * radius, cy + Math.Sin(rad) * radius));
|
|
|
}
|
|
}
|
|
@@ -60,13 +60,13 @@ public class GaugeControl : Control
|
|
|
context.DrawLine(new Pen(valueColor, 3), new Point(cx, cy), new Point(cx + Math.Cos(pAngle) * pLen, cy + Math.Sin(pAngle) * pLen));
|
|
context.DrawLine(new Pen(valueColor, 3), new Point(cx, cy), new Point(cx + Math.Cos(pAngle) * pLen, cy + Math.Sin(pAngle) * pLen));
|
|
|
context.DrawEllipse(valueColor, null, new Rect(cx - 6, cy - 6, 12, 12));
|
|
context.DrawEllipse(valueColor, null, new Rect(cx - 6, cy - 6, 12, 12));
|
|
|
|
|
|
|
|
- var titleText = new FormattedText(Title, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, typeface, 12, ThemeHelper.TextPrimary());
|
|
|
|
|
|
|
+ var titleText = new FormattedText(Title, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, typeface, 12, ThemeHelper.TextPrimary);
|
|
|
context.DrawText(titleText, new Point(cx - titleText.Width / 2, bounds.Y + 5));
|
|
context.DrawText(titleText, new Point(cx - titleText.Width / 2, bounds.Y + 5));
|
|
|
|
|
|
|
|
- var valText = new FormattedText($"{Value:F1}", CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Microsoft YaHei", FontStyle.Normal, FontWeight.Bold), 20, ThemeHelper.TextPrimary());
|
|
|
|
|
|
|
+ var valText = new FormattedText($"{Value:F1}", CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Microsoft YaHei", FontStyle.Normal, FontWeight.Bold), 20, ThemeHelper.TextPrimary);
|
|
|
context.DrawText(valText, new Point(cx - valText.Width / 2, cy + radius * 0.3));
|
|
context.DrawText(valText, new Point(cx - valText.Width / 2, cy + radius * 0.3));
|
|
|
|
|
|
|
|
- var unitText = new FormattedText(Unit, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Microsoft YaHei"), 10, ThemeHelper.TextDisabled());
|
|
|
|
|
|
|
+ var unitText = new FormattedText(Unit, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Microsoft YaHei"), 10, ThemeHelper.TextDisabled);
|
|
|
context.DrawText(unitText, new Point(cx - unitText.Width / 2, cy + radius * 0.3 + valText.Height + 2));
|
|
context.DrawText(unitText, new Point(cx - unitText.Width / 2, cy + radius * 0.3 + valText.Height + 2));
|
|
|
}
|
|
}
|
|
|
|
|
|