* UIChart: 修改可能显示出错的问题
This commit is contained in:
parent
560a6f00f6
commit
f53b3a56a0
Binary file not shown.
@ -485,20 +485,18 @@ namespace Sunny.UI
|
||||
}
|
||||
}
|
||||
|
||||
using Font tmp = this.DPIScaleFont(Font,SubTextFontSize);
|
||||
|
||||
if (Option.XAxis.AxisLabel.Show)
|
||||
{
|
||||
float start = DrawOrigin.X + DrawBarWidth / 2.0f;
|
||||
foreach (var data in Option.XAxis.Data)
|
||||
{
|
||||
SizeF sf = g.MeasureString(data, tmp);
|
||||
g.DrawString(data, tmp, ForeColor, start - sf.Width / 2.0f, DrawOrigin.Y + Option.XAxis.AxisTick.Length);
|
||||
SizeF sf = g.MeasureString(data, TempFont);
|
||||
g.DrawString(data, TempFont, ForeColor, start - sf.Width / 2.0f, DrawOrigin.Y + Option.XAxis.AxisTick.Length);
|
||||
start += DrawBarWidth;
|
||||
}
|
||||
|
||||
SizeF sfname = g.MeasureString(Option.XAxis.Name, tmp);
|
||||
g.DrawString(Option.XAxis.Name, tmp, ForeColor, DrawOrigin.X + (DrawSize.Width - sfname.Width) / 2.0f, DrawOrigin.Y + Option.XAxis.AxisTick.Length + sfname.Height);
|
||||
SizeF sfname = g.MeasureString(Option.XAxis.Name, TempFont);
|
||||
g.DrawString(Option.XAxis.Name, TempFont, ForeColor, DrawOrigin.X + (DrawSize.Width - sfname.Width) / 2.0f, DrawOrigin.Y + Option.XAxis.AxisTick.Length + sfname.Height);
|
||||
}
|
||||
|
||||
if (Option.YAxis.AxisTick.Show)
|
||||
@ -547,16 +545,16 @@ namespace Sunny.UI
|
||||
for (int i = YAxisStart; i <= YAxisEnd; i++)
|
||||
{
|
||||
string label = Option.YAxis.AxisLabel.GetLabel(i * YAxisInterval, idx);
|
||||
SizeF sf = g.MeasureString(label, tmp);
|
||||
SizeF sf = g.MeasureString(label, TempFont);
|
||||
wmax = Math.Max(wmax, sf.Width);
|
||||
g.DrawString(label, tmp, ForeColor, DrawOrigin.X - Option.YAxis.AxisTick.Length - sf.Width, start - sf.Height / 2.0f);
|
||||
g.DrawString(label, TempFont, ForeColor, DrawOrigin.X - Option.YAxis.AxisTick.Length - sf.Width, start - sf.Height / 2.0f);
|
||||
start -= DrawBarHeight;
|
||||
}
|
||||
|
||||
SizeF sfname = g.MeasureString(Option.YAxis.Name, tmp);
|
||||
SizeF sfname = g.MeasureString(Option.YAxis.Name, TempFont);
|
||||
int x = (int)(DrawOrigin.X - Option.YAxis.AxisTick.Length - wmax - sfname.Height);
|
||||
int y = (int)(Option.Grid.Top + (DrawSize.Height - sfname.Width) / 2);
|
||||
g.DrawString(Option.YAxis.Name, tmp, ForeColor, new Point(x, y),
|
||||
g.DrawString(Option.YAxis.Name, TempFont, ForeColor, new Point(x, y),
|
||||
new StringFormat() { Alignment = StringAlignment.Center }, 270);
|
||||
}
|
||||
}
|
||||
@ -575,15 +573,14 @@ namespace Sunny.UI
|
||||
g.DrawLine(pn, DrawOrigin.X, pos, Width - Option.Grid.Right, pos);
|
||||
}
|
||||
|
||||
using Font tmp = this.DPIScaleFont(Font, SubTextFontSize);
|
||||
SizeF sf = g.MeasureString(line.Name, tmp);
|
||||
SizeF sf = g.MeasureString(line.Name, TempFont);
|
||||
|
||||
if (line.Left == UILeftAlignment.Left)
|
||||
g.DrawString(line.Name, tmp, line.Color, DrawOrigin.X + 4, pos - 2 - sf.Height);
|
||||
g.DrawString(line.Name, TempFont, line.Color, DrawOrigin.X + 4, pos - 2 - sf.Height);
|
||||
if (line.Left == UILeftAlignment.Center)
|
||||
g.DrawString(line.Name, tmp, line.Color, DrawOrigin.X + (Width - Option.Grid.Left - Option.Grid.Right - sf.Width) / 2, pos - 2 - sf.Height);
|
||||
g.DrawString(line.Name, TempFont, line.Color, DrawOrigin.X + (Width - Option.Grid.Left - Option.Grid.Right - sf.Width) / 2, pos - 2 - sf.Height);
|
||||
if (line.Left == UILeftAlignment.Right)
|
||||
g.DrawString(line.Name, tmp, line.Color, Width - sf.Width - 4 - Option.Grid.Right, pos - 2 - sf.Height);
|
||||
g.DrawString(line.Name, TempFont, line.Color, Width - sf.Width - 4 - Option.Grid.Right, pos - 2 - sf.Height);
|
||||
}
|
||||
}
|
||||
|
||||
@ -602,8 +599,7 @@ namespace Sunny.UI
|
||||
|
||||
for (int i = 0; i < Option.XAxis.Data.Count; i++)
|
||||
{
|
||||
using Font tmp = this.DPIScaleFont(Font, SubTextFontSize);
|
||||
Bars[0][i].Size = g.MeasureString(Bars[0][i].Tips, tmp);
|
||||
Bars[0][i].Size = g.MeasureString(Bars[0][i].Tips, TempFont);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -453,7 +453,6 @@ namespace Sunny.UI
|
||||
protected override void DrawSeries(Graphics g, List<UIBarSeries> series)
|
||||
{
|
||||
if (series == null || series.Count == 0) return;
|
||||
using Font tmp = this.DPIScaleFont(Font, SubTextFontSize);
|
||||
|
||||
for (int i = 0; i < Bars.Count; i++)
|
||||
{
|
||||
@ -466,13 +465,13 @@ namespace Sunny.UI
|
||||
{
|
||||
if (s.BarName.Count > 0 && j < s.BarName.Count)
|
||||
{
|
||||
SizeF sf = g.MeasureString(s.BarName[j], tmp);
|
||||
SizeF sf = g.MeasureString(s.BarName[j], TempFont);
|
||||
if (s.Data[j] >= 0)
|
||||
g.DrawString(s.BarName[j], tmp, ChartStyle.ForeColor,
|
||||
g.DrawString(s.BarName[j], TempFont, ChartStyle.ForeColor,
|
||||
bars[j].Rect.Left + bars[j].Rect.Width / 2 - sf.Width / 2,
|
||||
bars[j].Rect.Bottom + 1);
|
||||
else
|
||||
g.DrawString(s.BarName[j], tmp, ChartStyle.ForeColor,
|
||||
g.DrawString(s.BarName[j], TempFont, ChartStyle.ForeColor,
|
||||
bars[j].Rect.Left + bars[j].Rect.Width / 2 - sf.Width / 2,
|
||||
bars[j].Rect.Top - sf.Height);
|
||||
}
|
||||
@ -480,28 +479,23 @@ namespace Sunny.UI
|
||||
|
||||
if (s.ShowValue)
|
||||
{
|
||||
Font fontShow = null;
|
||||
if (s.ShowValueFontSize > 0) fontShow = new Font(tmp.Name, s.ShowValueFontSize);
|
||||
|
||||
string value = s.Data[j].ToString("F" + Option.YAxis.AxisLabel.DecimalCount);
|
||||
SizeF sf = g.MeasureString(value, fontShow ?? tmp);
|
||||
SizeF sf = g.MeasureString(value, TempFont);
|
||||
if (s.Data[j] < 0)
|
||||
g.DrawString(value, fontShow ?? tmp, bars[j].Color,
|
||||
g.DrawString(value, TempFont, bars[j].Color,
|
||||
bars[j].Rect.Left + bars[j].Rect.Width / 2 - sf.Width / 2,
|
||||
bars[j].Rect.Bottom + 1);
|
||||
else
|
||||
g.DrawString(value, fontShow ?? tmp, bars[j].Color,
|
||||
g.DrawString(value, TempFont, bars[j].Color,
|
||||
bars[j].Rect.Left + bars[j].Rect.Width / 2 - sf.Width / 2,
|
||||
bars[j].Rect.Top - sf.Height);
|
||||
|
||||
fontShow?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < Option.Series.Count; i++)
|
||||
{
|
||||
Bars[i][0].Size = g.MeasureString(Bars[i][0].Tips, tmp);
|
||||
Bars[i][0].Size = g.MeasureString(Bars[i][0].Tips, TempFont);
|
||||
}
|
||||
}
|
||||
|
||||
@ -579,7 +573,6 @@ namespace Sunny.UI
|
||||
}
|
||||
}
|
||||
|
||||
using Font tmp = this.DPIScaleFont(Font, SubTextFontSize);
|
||||
//绘制X轴标签
|
||||
if (Option.XAxis.AxisLabel.Show)
|
||||
{
|
||||
@ -589,12 +582,12 @@ namespace Sunny.UI
|
||||
foreach (var data in Option.Series)
|
||||
{
|
||||
float w = DrawSize.Width * data.Data.Count * 1.0f / DataCount;
|
||||
SizeF sf = g.MeasureString(data.Name, tmp);
|
||||
SizeF sf = g.MeasureString(data.Name, TempFont);
|
||||
if (Option.XAxis.AxisLabel.Angle != 0)
|
||||
g.DrawString(data.Name, tmp, ChartStyle.ForeColor, new PointF(start + w / 2.0f - 10, DrawOrigin.Y + Option.Grid.Bottom / 2.0f),
|
||||
g.DrawString(data.Name, TempFont, ChartStyle.ForeColor, new PointF(start + w / 2.0f - 10, DrawOrigin.Y + Option.Grid.Bottom / 2.0f),
|
||||
new StringFormat() { Alignment = StringAlignment.Center }, (3600 - Option.XAxis.AxisLabel.Angle) % 360);
|
||||
else
|
||||
g.DrawString(data.Name, tmp, ChartStyle.ForeColor, start + w / 2.0f - sf.Width / 2.0f, DrawOrigin.Y + Option.XAxis.AxisTick.Length + Option.XAxis.AxisTick.Distance);
|
||||
g.DrawString(data.Name, TempFont, ChartStyle.ForeColor, start + w / 2.0f - sf.Width / 2.0f, DrawOrigin.Y + Option.XAxis.AxisTick.Length + Option.XAxis.AxisTick.Distance);
|
||||
start += w;
|
||||
}
|
||||
}
|
||||
@ -603,18 +596,18 @@ namespace Sunny.UI
|
||||
float start = DrawOrigin.X + DrawBarWidth / 2.0f;
|
||||
foreach (var data in Option.Series)
|
||||
{
|
||||
SizeF sf = g.MeasureString(data.Name, tmp);
|
||||
SizeF sf = g.MeasureString(data.Name, TempFont);
|
||||
if (Option.XAxis.AxisLabel.Angle != 0)
|
||||
g.DrawString(data.Name, tmp, ChartStyle.ForeColor, new PointF(start - 10, DrawOrigin.Y + Option.Grid.Bottom / 2.0f),
|
||||
g.DrawString(data.Name, TempFont, ChartStyle.ForeColor, new PointF(start - 10, DrawOrigin.Y + Option.Grid.Bottom / 2.0f),
|
||||
new StringFormat() { Alignment = StringAlignment.Center }, (3600 - Option.XAxis.AxisLabel.Angle) % 360);
|
||||
else
|
||||
g.DrawString(data.Name, tmp, ChartStyle.ForeColor, start - sf.Width / 2.0f, DrawOrigin.Y + Option.XAxis.AxisTick.Length + Option.XAxis.AxisTick.Distance);
|
||||
g.DrawString(data.Name, TempFont, ChartStyle.ForeColor, start - sf.Width / 2.0f, DrawOrigin.Y + Option.XAxis.AxisTick.Length + Option.XAxis.AxisTick.Distance);
|
||||
start += DrawBarWidth;
|
||||
}
|
||||
}
|
||||
|
||||
SizeF sfName = g.MeasureString(Option.XAxis.Name, tmp);
|
||||
g.DrawString(Option.XAxis.Name, tmp, ChartStyle.ForeColor, DrawOrigin.X + (DrawSize.Width - sfName.Width) / 2.0f, DrawOrigin.Y + Option.XAxis.AxisTick.Length + Option.XAxis.AxisTick.Distance + sfName.Height);
|
||||
SizeF sfName = g.MeasureString(Option.XAxis.Name, TempFont);
|
||||
g.DrawString(Option.XAxis.Name, TempFont, ChartStyle.ForeColor, DrawOrigin.X + (DrawSize.Width - sfName.Width) / 2.0f, DrawOrigin.Y + Option.XAxis.AxisTick.Length + Option.XAxis.AxisTick.Distance + sfName.Height);
|
||||
}
|
||||
|
||||
//绘制Y轴刻度
|
||||
@ -661,20 +654,20 @@ namespace Sunny.UI
|
||||
|
||||
if (Option.YAxis.AxisLabel.AutoFormat)
|
||||
Option.YAxis.AxisLabel.DecimalCount = YAxisDecimalCount;
|
||||
|
||||
|
||||
for (int i = YAxisStart; i <= YAxisEnd; i++)
|
||||
{
|
||||
string label = Option.YAxis.AxisLabel.GetLabel(i * YAxisInterval, idx);
|
||||
SizeF sf = g.MeasureString(label, tmp);
|
||||
SizeF sf = g.MeasureString(label, TempFont);
|
||||
wmax = Math.Max(wmax, sf.Width);
|
||||
g.DrawString(label, tmp, ChartStyle.ForeColor, DrawOrigin.X - Option.YAxis.AxisTick.Length - sf.Width, start - sf.Height / 2.0f);
|
||||
g.DrawString(label, TempFont, ChartStyle.ForeColor, DrawOrigin.X - Option.YAxis.AxisTick.Length - sf.Width, start - sf.Height / 2.0f);
|
||||
start -= DrawBarHeight;
|
||||
}
|
||||
|
||||
SizeF sfname = g.MeasureString(Option.YAxis.Name, tmp);
|
||||
SizeF sfname = g.MeasureString(Option.YAxis.Name, TempFont);
|
||||
int x = (int)(DrawOrigin.X - Option.YAxis.AxisTick.Length - wmax - sfname.Height);
|
||||
int y = (int)(Option.Grid.Top + (DrawSize.Height - sfname.Width) / 2);
|
||||
g.DrawString(Option.YAxis.Name, tmp, ChartStyle.ForeColor, new Point(x, y),
|
||||
g.DrawString(Option.YAxis.Name, TempFont, ChartStyle.ForeColor, new Point(x, y),
|
||||
new StringFormat() { Alignment = StringAlignment.Center }, 270);
|
||||
}
|
||||
}
|
||||
|
@ -57,6 +57,13 @@ namespace Sunny.UI
|
||||
tip.MouseEnter += Tip_MouseEnter;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
tmpFont?.Dispose();
|
||||
tmpLegendFont?.Dispose();
|
||||
}
|
||||
|
||||
private void Tip_MouseEnter(object sender, EventArgs e)
|
||||
{
|
||||
tip.Visible = false;
|
||||
@ -195,6 +202,38 @@ namespace Sunny.UI
|
||||
}
|
||||
}
|
||||
|
||||
Font tmpFont;
|
||||
|
||||
protected Font TempFont
|
||||
{
|
||||
get
|
||||
{
|
||||
if (tmpFont == null || !tmpFont.Size.EqualsFloat(SubTextFontSize / this.DPIScale()))
|
||||
{
|
||||
tmpFont?.Dispose();
|
||||
tmpFont = this.DPIScaleFont(Font, SubTextFontSize);
|
||||
}
|
||||
|
||||
return tmpFont;
|
||||
}
|
||||
}
|
||||
|
||||
Font tmpLegendFont;
|
||||
|
||||
protected Font TempLegendFont
|
||||
{
|
||||
get
|
||||
{
|
||||
if (tmpLegendFont == null || !tmpLegendFont.Size.EqualsFloat(LegendFontSize / this.DPIScale()))
|
||||
{
|
||||
tmpLegendFont?.Dispose();
|
||||
tmpLegendFont = this.DPIScaleFont(Font, SubTextFontSize);
|
||||
}
|
||||
|
||||
return tmpLegendFont;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void DrawOption(Graphics g)
|
||||
{
|
||||
}
|
||||
@ -242,8 +281,7 @@ namespace Sunny.UI
|
||||
|
||||
g.DrawString(title.Text, Font, ChartStyle.ForeColor, left, top);
|
||||
|
||||
using Font tmp = this.DPIScaleFont(Font, SubTextFontSize);
|
||||
SizeF sfs = g.MeasureString(title.SubText, tmp);
|
||||
SizeF sfs = g.MeasureString(title.SubText, TempFont);
|
||||
switch (title.Left)
|
||||
{
|
||||
case UILeftAlignment.Left: left = TextInterval; break;
|
||||
@ -257,7 +295,7 @@ namespace Sunny.UI
|
||||
case UITopAlignment.Bottom: top = top - sf.Height; break;
|
||||
}
|
||||
|
||||
g.DrawString(title.SubText, tmp, ChartStyle.ForeColor, left, top);
|
||||
g.DrawString(title.SubText, TempFont, ChartStyle.ForeColor, left, top);
|
||||
}
|
||||
|
||||
protected void DrawLegend(Graphics g, UILegend legend)
|
||||
@ -269,10 +307,9 @@ namespace Sunny.UI
|
||||
float maxWidth = 0;
|
||||
float oneHeight = 0;
|
||||
|
||||
using Font tmp = this.DPIScaleFont(Font, LegendFontSize);
|
||||
foreach (var data in legend.Data)
|
||||
{
|
||||
SizeF sf = g.MeasureString(data, tmp);
|
||||
SizeF sf = g.MeasureString(data, TempLegendFont);
|
||||
totalHeight += sf.Height;
|
||||
totalWidth += sf.Width;
|
||||
totalWidth += 20;
|
||||
@ -311,7 +348,7 @@ namespace Sunny.UI
|
||||
for (int i = 0; i < legend.DataCount; i++)
|
||||
{
|
||||
var data = legend.Data[i];
|
||||
SizeF sf = g.MeasureString(data, tmp);
|
||||
SizeF sf = g.MeasureString(data, TempLegendFont);
|
||||
Color color = ChartStyle.GetColor(i);
|
||||
|
||||
if (legend.Colors.Count > 0 && i >= 0 && i < legend.Colors.Count)
|
||||
@ -320,7 +357,7 @@ namespace Sunny.UI
|
||||
if (legend.Orient == UIOrient.Horizontal)
|
||||
{
|
||||
g.FillRoundRectangle(color, (int)startLeft, (int)top + 1, 18, (int)oneHeight - 2, 5);
|
||||
g.DrawString(data, tmp, color, startLeft + 20, top);
|
||||
g.DrawString(data, TempLegendFont, color, startLeft + 20, top);
|
||||
startLeft += 22;
|
||||
startLeft += sf.Width;
|
||||
}
|
||||
@ -328,7 +365,7 @@ namespace Sunny.UI
|
||||
if (legend.Orient == UIOrient.Vertical)
|
||||
{
|
||||
g.FillRoundRectangle(color, (int)left, (int)startTop + 1, 18, (int)oneHeight - 2, 5);
|
||||
g.DrawString(data, tmp, color, left + 20, startTop);
|
||||
g.DrawString(data, TempLegendFont, color, left + 20, startTop);
|
||||
startTop += oneHeight;
|
||||
}
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ namespace Sunny.UI
|
||||
private void DrawSeries(Graphics g, List<UIDoughnutSeries> series)
|
||||
{
|
||||
if (series == null || series.Count == 0) return;
|
||||
using Font tmp = this. DPIScaleFont(Font, LegendFontSize);
|
||||
|
||||
for (int pieIndex = 0; pieIndex < series.Count; pieIndex++)
|
||||
{
|
||||
var pie = series[pieIndex];
|
||||
@ -159,7 +159,7 @@ namespace Sunny.UI
|
||||
else
|
||||
g.FillFan(color, angle.Center, angle.Inner, angle.Outer, angle.Start - 90, angle.Sweep);
|
||||
|
||||
Angles[pieIndex][azIndex].TextSize = g.MeasureString(Angles[pieIndex][azIndex].Text, tmp);
|
||||
Angles[pieIndex][azIndex].TextSize = g.MeasureString(Angles[pieIndex][azIndex].Text, TempFont);
|
||||
|
||||
if (pie.Label.Show && ActiveAzIndex == azIndex)
|
||||
{
|
||||
|
@ -217,7 +217,7 @@ namespace Sunny.UI
|
||||
}
|
||||
|
||||
if (XScale == null || YScale == null) return;
|
||||
using Font tmp = this.DPIScaleFont(Font, SubTextFontSize);
|
||||
|
||||
//X Tick
|
||||
if (Option.XAxis.AxisTick.Show)
|
||||
{
|
||||
@ -245,8 +245,8 @@ namespace Sunny.UI
|
||||
label = XLabels[i].ToString("F" + Option.XAxis.AxisLabel.DecimalCount);
|
||||
}
|
||||
|
||||
SizeF sf = g.MeasureString(label, tmp);
|
||||
g.DrawString(label, tmp, ForeColor, x - sf.Width / 2.0f, DrawOrigin.Y + Option.XAxis.AxisTick.Length);
|
||||
SizeF sf = g.MeasureString(label, TempFont);
|
||||
g.DrawString(label, TempFont, ForeColor, x - sf.Width / 2.0f, DrawOrigin.Y + Option.XAxis.AxisTick.Length);
|
||||
}
|
||||
|
||||
if (x.Equals(DrawOrigin.X)) continue;
|
||||
@ -260,8 +260,8 @@ namespace Sunny.UI
|
||||
}
|
||||
}
|
||||
|
||||
SizeF sfName = g.MeasureString(Option.XAxis.Name, tmp);
|
||||
g.DrawString(Option.XAxis.Name, tmp, ForeColor,
|
||||
SizeF sfName = g.MeasureString(Option.XAxis.Name, TempFont);
|
||||
g.DrawString(Option.XAxis.Name, TempFont, ForeColor,
|
||||
DrawOrigin.X + (DrawSize.Width - sfName.Width) / 2.0f,
|
||||
DrawOrigin.Y + Option.XAxis.AxisTick.Length + sfName.Height);
|
||||
}
|
||||
@ -279,9 +279,9 @@ namespace Sunny.UI
|
||||
if (Option.YAxis.AxisLabel.Show)
|
||||
{
|
||||
string label = YLabels[i].ToString(YScale.Format);
|
||||
SizeF sf = g.MeasureString(label, tmp);
|
||||
SizeF sf = g.MeasureString(label, TempFont);
|
||||
widthMax = Math.Max(widthMax, sf.Width);
|
||||
g.DrawString(label, tmp, ForeColor, DrawOrigin.X - Option.YAxis.AxisTick.Length - sf.Width, y - sf.Height / 2.0f);
|
||||
g.DrawString(label, TempFont, ForeColor, DrawOrigin.X - Option.YAxis.AxisTick.Length - sf.Width, y - sf.Height / 2.0f);
|
||||
}
|
||||
|
||||
if (y.Equals(DrawOrigin.Y)) continue;
|
||||
@ -295,10 +295,10 @@ namespace Sunny.UI
|
||||
}
|
||||
}
|
||||
|
||||
SizeF sfName = g.MeasureString(Option.YAxis.Name, tmp);
|
||||
SizeF sfName = g.MeasureString(Option.YAxis.Name, TempFont);
|
||||
float xx = DrawOrigin.X - Option.YAxis.AxisTick.Length - widthMax - sfName.Height / 2.0f;
|
||||
float yy = Option.Grid.Top + DrawSize.Height / 2.0f;
|
||||
g.DrawStringRotateAtCenter(Option.YAxis.Name, tmp, ForeColor, new PointF(xx, yy), 270);
|
||||
g.DrawStringRotateAtCenter(Option.YAxis.Name, TempFont, ForeColor, new PointF(xx, yy), 270);
|
||||
}
|
||||
}
|
||||
|
||||
@ -534,7 +534,7 @@ namespace Sunny.UI
|
||||
private void DrawAxisScales(Graphics g)
|
||||
{
|
||||
if (YScale == null) return;
|
||||
using Font tmp = this.DPIScaleFont(Font, SubTextFontSize);
|
||||
|
||||
foreach (var line in Option.YAxisScaleLines)
|
||||
{
|
||||
float pos = YScale.CalcYPixel(line.Value, DrawOrigin.Y, DrawSize.Height);
|
||||
@ -546,14 +546,14 @@ namespace Sunny.UI
|
||||
}
|
||||
|
||||
|
||||
SizeF sf = g.MeasureString(line.Name, tmp);
|
||||
SizeF sf = g.MeasureString(line.Name, TempFont);
|
||||
|
||||
if (line.Left == UILeftAlignment.Left)
|
||||
g.DrawString(line.Name, tmp, line.Color, DrawOrigin.X + 4, pos - 2 - sf.Height);
|
||||
g.DrawString(line.Name, TempFont, line.Color, DrawOrigin.X + 4, pos - 2 - sf.Height);
|
||||
if (line.Left == UILeftAlignment.Center)
|
||||
g.DrawString(line.Name, tmp, line.Color, DrawOrigin.X + (Width - Option.Grid.Left - Option.Grid.Right - sf.Width) / 2, pos - 2 - sf.Height);
|
||||
g.DrawString(line.Name, TempFont, line.Color, DrawOrigin.X + (Width - Option.Grid.Left - Option.Grid.Right - sf.Width) / 2, pos - 2 - sf.Height);
|
||||
if (line.Left == UILeftAlignment.Right)
|
||||
g.DrawString(line.Name, tmp, line.Color, Width - sf.Width - 4 - Option.Grid.Right, pos - 2 - sf.Height);
|
||||
g.DrawString(line.Name, TempFont, line.Color, Width - sf.Width - 4 - Option.Grid.Right, pos - 2 - sf.Height);
|
||||
}
|
||||
|
||||
int idx = 0;
|
||||
@ -567,7 +567,7 @@ namespace Sunny.UI
|
||||
g.DrawLine(pn, pos, DrawOrigin.Y - 1, pos, Option.Grid.Top + 1);
|
||||
}
|
||||
|
||||
SizeF sf = g.MeasureString(line.Name, tmp);
|
||||
SizeF sf = g.MeasureString(line.Name, TempFont);
|
||||
float x = pos - sf.Width;
|
||||
if (x < Option.Grid.Left) x = pos + 2;
|
||||
float y = Option.Grid.Top + 4 + sf.Height * idx;
|
||||
@ -578,7 +578,7 @@ namespace Sunny.UI
|
||||
}
|
||||
|
||||
idx++;
|
||||
g.DrawString(line.Name, tmp, line.Color, x, y);
|
||||
g.DrawString(line.Name, TempFont, line.Color, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
@ -669,8 +669,7 @@ namespace Sunny.UI
|
||||
{
|
||||
using (Graphics g = this.CreateGraphics())
|
||||
{
|
||||
using Font tmp = this.DPIScaleFont(Font, SubTextFontSize);
|
||||
SizeF sf = g.MeasureString(sb.ToString(), tmp);
|
||||
SizeF sf = g.MeasureString(sb.ToString(), TempFont);
|
||||
tip.Size = new Size((int)sf.Width + 4, (int)sf.Height + 4);
|
||||
}
|
||||
|
||||
|
@ -158,7 +158,7 @@ namespace Sunny.UI
|
||||
{
|
||||
var pie = series[pieIndex];
|
||||
RectangleF rect = GetSeriesRect(pie);
|
||||
using Font tmp = this.DPIScaleFont(Font, LegendFontSize);
|
||||
|
||||
for (int azIndex = 0; azIndex < pie.Data.Count; azIndex++)
|
||||
{
|
||||
Color color = ChartStyle.GetColor(azIndex);
|
||||
@ -166,7 +166,7 @@ namespace Sunny.UI
|
||||
if (data.StyleCustomMode) color = data.Color;
|
||||
RectangleF rectx = new RectangleF(rect.X - 10, rect.Y - 10, rect.Width + 20, rect.Width + 20);
|
||||
g.FillPie(color, (ActivePieIndex == pieIndex && ActiveAzIndex == azIndex) ? rectx : rect, Angles[pieIndex][azIndex].Start - 90, Angles[pieIndex][azIndex].Sweep);
|
||||
Angles[pieIndex][azIndex].TextSize = g.MeasureString(Angles[pieIndex][azIndex].Text, tmp);
|
||||
Angles[pieIndex][azIndex].TextSize = g.MeasureString(Angles[pieIndex][azIndex].Text, TempFont);
|
||||
|
||||
if (pie.Label.Show)
|
||||
{
|
||||
@ -177,8 +177,8 @@ namespace Sunny.UI
|
||||
string name = Option.Legend != null ? Option.Legend.Data[azIndex] + " : " : "";
|
||||
if (pie.Data[azIndex].Value > 0)
|
||||
{
|
||||
string text = name + pie.Data[azIndex].Value.ToString("F0");
|
||||
SizeF sf = g.MeasureString(text, tmp);
|
||||
string text = name + pie.Data[azIndex].Value.ToString("F0");
|
||||
SizeF sf = g.MeasureString(text, TempFont);
|
||||
PointF pf;
|
||||
int added = 9;
|
||||
if (az >= 0 && az < 90)
|
||||
@ -191,7 +191,7 @@ namespace Sunny.UI
|
||||
pf = new PointF((float)(DrawCenter(pie).X - RadiusSize(pie) * x - added) - sf.Width, (float)(DrawCenter(pie).Y - RadiusSize(pie) * y) - sf.Height - added);
|
||||
|
||||
if (pie.Data[azIndex].Value > 0)
|
||||
g.DrawString(text, tmp, color, pf.X, pf.Y);
|
||||
g.DrawString(text, TempFont, color, pf.X, pf.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,8 +52,8 @@ namespace Sunny.UI
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
TempTitleFont?.Dispose();
|
||||
TempFont?.Dispose();
|
||||
tmpTitleFont?.Dispose();
|
||||
tmpFont?.Dispose();
|
||||
}
|
||||
|
||||
[DefaultValue(typeof(Font), "微软雅黑, 9pt"), Description("字体"), Category("SunnyUI")]
|
||||
|
Loading…
x
Reference in New Issue
Block a user