* UIDatePicker: 修复文字格式化显示问题
This commit is contained in:
parent
1d478a9117
commit
b84e0c1a3b
@ -29,6 +29,7 @@
|
|||||||
* 2022-09-07: V3.2.3 Option.YAxis.ShowGridLine为false时,不显示水平表格虚线
|
* 2022-09-07: V3.2.3 Option.YAxis.ShowGridLine为false时,不显示水平表格虚线
|
||||||
* 2022-05-10: V3.3.6 Option.ShowFullRect为true时,绘制右侧和上侧的边框实线
|
* 2022-05-10: V3.3.6 Option.ShowFullRect为true时,绘制右侧和上侧的边框实线
|
||||||
* 2022-05-13: V3.3.6 Option.BarInterval,设置Bar之间间隔,默认-1,自动计算间隔
|
* 2022-05-13: V3.3.6 Option.BarInterval,设置Bar之间间隔,默认-1,自动计算间隔
|
||||||
|
* 2022-05-14: V3.3.6 重构DrawString函数
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
@ -501,22 +502,22 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
if (Option.XAxis.AxisLabel.Show)
|
if (Option.XAxis.AxisLabel.Show)
|
||||||
{
|
{
|
||||||
float start = DrawOrigin.X + DrawBarWidth / 2.0f;
|
float start = DrawOrigin.X;
|
||||||
foreach (var data in Option.XAxis.Data)
|
foreach (var data in Option.XAxis.Data)
|
||||||
{
|
{
|
||||||
SizeF sf = g.MeasureString(data, TempFont);
|
|
||||||
int angle = (Option.XAxis.AxisLabel.Angle + 36000) % 360;
|
int angle = (Option.XAxis.AxisLabel.Angle + 36000) % 360;
|
||||||
if (angle > 0 && angle <= 90)
|
if (angle > 0 && angle <= 90)
|
||||||
g.DrawRotateString(data, TempFont, ForeColor, new PointF(start, DrawOrigin.Y + Option.XAxis.AxisTick.Length),
|
g.DrawRotateString(data, TempFont, ForeColor, new PointF(start, DrawOrigin.Y + Option.XAxis.AxisTick.Length),
|
||||||
new StringFormat() { Alignment = StringAlignment.Far }, (3600 - Option.XAxis.AxisLabel.Angle) % 360);
|
new StringFormat() { Alignment = StringAlignment.Far }, (3600 - Option.XAxis.AxisLabel.Angle) % 360);
|
||||||
else
|
else
|
||||||
g.DrawString(data, TempFont, ForeColor, start - sf.Width / 2.0f, DrawOrigin.Y + Option.XAxis.AxisTick.Length); start += DrawBarWidth;
|
g.DrawString(data, TempFont, ForeColor, new Rectangle((int)start, DrawOrigin.Y + Option.XAxis.AxisTick.Length, (int)DrawBarWidth, Height), ContentAlignment.TopCenter);
|
||||||
|
|
||||||
|
start += DrawBarWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Option.XAxis.Name.IsValid())
|
if (Option.XAxis.Name.IsValid())
|
||||||
{
|
{
|
||||||
SizeF sfname = g.MeasureString(Option.XAxis.Name, TempFont);
|
g.DrawString(Option.XAxis.Name, TempFont, ForeColor, new Rectangle(DrawOrigin.X, 0, DrawSize.Width, Height - 10), ContentAlignment.BottomCenter);
|
||||||
g.DrawString(Option.XAxis.Name, TempFont, ForeColor, DrawOrigin.X + (DrawSize.Width - sfname.Width) / 2.0f, DrawOrigin.Y + Option.XAxis.AxisTick.Length + sfname.Height);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -556,15 +557,15 @@ namespace Sunny.UI
|
|||||||
if (Option.YAxis.AxisLabel.Show)
|
if (Option.YAxis.AxisLabel.Show)
|
||||||
{
|
{
|
||||||
string label = YLabels[i].ToString(Option.YAxis.AxisLabel.DecimalPlaces >= 0 ? "F" + Option.YAxis.AxisLabel.DecimalPlaces : YScale.Format);
|
string label = YLabels[i].ToString(Option.YAxis.AxisLabel.DecimalPlaces >= 0 ? "F" + Option.YAxis.AxisLabel.DecimalPlaces : YScale.Format);
|
||||||
SizeF sf = g.MeasureString(label, TempFont);
|
Size sf = TextRenderer.MeasureText(label, TempFont);
|
||||||
wmax = Math.Max(wmax, sf.Width);
|
wmax = Math.Max(wmax, sf.Width);
|
||||||
g.DrawString(label, TempFont, ForeColor, DrawOrigin.X - Option.YAxis.AxisTick.Length - sf.Width, labels[i] - sf.Height / 2.0f);
|
g.DrawString(label, TempFont, ForeColor, new Rectangle(DrawOrigin.X - Option.YAxis.AxisTick.Length - Width, (int)labels[i] - Height, Width, Height * 2), ContentAlignment.MiddleRight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Option.YAxis.AxisLabel.Show && Option.YAxis.Name.IsValid())
|
if (Option.YAxis.AxisLabel.Show && Option.YAxis.Name.IsValid())
|
||||||
{
|
{
|
||||||
SizeF sfname = g.MeasureString(Option.YAxis.Name, TempFont);
|
Size sfname = TextRenderer.MeasureText(Option.YAxis.Name, TempFont);
|
||||||
int x = (int)(DrawOrigin.X - Option.YAxis.AxisTick.Length - wmax - sfname.Height);
|
int x = (int)(DrawOrigin.X - Option.YAxis.AxisTick.Length - wmax - sfname.Height);
|
||||||
int y = (int)(Option.Grid.Top + (DrawSize.Height - sfname.Width) / 2);
|
int y = (int)(Option.Grid.Top + (DrawSize.Height - sfname.Width) / 2);
|
||||||
g.DrawRotateString(Option.YAxis.Name, TempFont, ForeColor, new Point(x, y), new StringFormat() { Alignment = StringAlignment.Center }, 270);
|
g.DrawRotateString(Option.YAxis.Name, TempFont, ForeColor, new Point(x, y), new StringFormat() { Alignment = StringAlignment.Center }, 270);
|
||||||
@ -579,18 +580,9 @@ namespace Sunny.UI
|
|||||||
double ymax = YAxisEnd * YAxisInterval;
|
double ymax = YAxisEnd * YAxisInterval;
|
||||||
float pos = YScale.CalcYPixel(line.Value, DrawOrigin.Y, DrawSize.Height);
|
float pos = YScale.CalcYPixel(line.Value, DrawOrigin.Y, DrawSize.Height);
|
||||||
if (pos <= Option.Grid.Top || pos >= Height - Option.Grid.Bottom) continue;
|
if (pos <= Option.Grid.Top || pos >= Height - Option.Grid.Bottom) continue;
|
||||||
using (Pen pn = new Pen(line.Color, line.Size))
|
using Pen pn = new Pen(line.Color, line.Size);
|
||||||
{
|
|
||||||
g.DrawLine(pn, DrawOrigin.X, pos, Width - Option.Grid.Right, pos);
|
g.DrawLine(pn, DrawOrigin.X, pos, Width - Option.Grid.Right, pos);
|
||||||
}
|
g.DrawString(line.Name, TempFont, line.Color, new Rectangle(DrawOrigin.X + 4, (int)pos - 2 - Height, DrawSize.Width - 8, Height), (StringAlignment)((int)line.Left), StringAlignment.Far);
|
||||||
|
|
||||||
SizeF sf = g.MeasureString(line.Name, TempFont);
|
|
||||||
if (line.Left == UILeftAlignment.Left)
|
|
||||||
g.DrawString(line.Name, TempFont, line.Color, DrawOrigin.X + 4, pos - 2 - sf.Height);
|
|
||||||
if (line.Left == UILeftAlignment.Center)
|
|
||||||
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, TempFont, line.Color, Width - sf.Width - 4 - Option.Grid.Right, pos - 2 - sf.Height);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -613,21 +605,13 @@ namespace Sunny.UI
|
|||||||
if (Option.ShowValue)
|
if (Option.ShowValue)
|
||||||
{
|
{
|
||||||
string value = info.Value.ToString("F" + info.Series.DecimalPlaces);
|
string value = info.Value.ToString("F" + info.Series.DecimalPlaces);
|
||||||
SizeF sf = g.MeasureString(value, TempFont);
|
|
||||||
if (info.Top)
|
if (info.Top)
|
||||||
{
|
{
|
||||||
float top = info.Rect.Top - sf.Height;
|
g.DrawString(value, TempFont, info.Color, new Rectangle((int)info.Rect.Center().X - Width, (int)info.Rect.Top - Height, Width * 2, Height), ContentAlignment.BottomCenter);
|
||||||
if (top > Option.Grid.Top)
|
|
||||||
{
|
|
||||||
g.DrawString(value, TempFont, info.Color, info.Rect.Center().X - sf.Width / 2, top);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (info.Rect.Bottom + sf.Height + Option.Grid.Bottom < Height)
|
g.DrawString(value, TempFont, info.Color, new Rectangle((int)info.Rect.Center().X - Width, (int)info.Rect.Bottom, Width * 2, Height), ContentAlignment.TopCenter);
|
||||||
{
|
|
||||||
g.DrawString(value, TempFont, info.Color, info.Rect.Center().X - sf.Width / 2, info.Rect.Bottom);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,21 +107,6 @@ namespace Sunny.UI
|
|||||||
return series;
|
return series;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UILineSeries AddSwitchLineSeries(string seriesName, float Offset = 0, bool isY2 = false)
|
|
||||||
{
|
|
||||||
if (seriesName.IsNullOrEmpty())
|
|
||||||
{
|
|
||||||
throw new NullReferenceException("seriesName 不能为空");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ExistsSeries(seriesName)) return Series[seriesName];
|
|
||||||
|
|
||||||
UISwitchLineSeries series = new UISwitchLineSeries(seriesName, isY2);
|
|
||||||
series.YOffset = Offset;
|
|
||||||
AddSeries(series);
|
|
||||||
return series;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool ExistsSeries(string seriesName)
|
public bool ExistsSeries(string seriesName)
|
||||||
{
|
{
|
||||||
return seriesName.IsValid() && Series.ContainsKey(seriesName);
|
return seriesName.IsValid() && Series.ContainsKey(seriesName);
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
* 2021-08-14: V3.0.6 增加可选择年、年月、年月日
|
* 2021-08-14: V3.0.6 增加可选择年、年月、年月日
|
||||||
* 2022-11-08: V3.2.8 增加MaxDate,MinDate
|
* 2022-11-08: V3.2.8 增加MaxDate,MinDate
|
||||||
* 2023-05-14: V3.3.6 年、年月、年月日可单独设置格式化掩码
|
* 2023-05-14: V3.3.6 年、年月、年月日可单独设置格式化掩码
|
||||||
|
* 2023-05-14: V3.3.6 修复文字格式化显示问题
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
@ -235,8 +236,21 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DateTime dt = Text.ToDateTime(DateFormat);
|
switch (ShowType)
|
||||||
if (Value != dt) Value = dt;
|
{
|
||||||
|
case UIDateType.YearMonthDay:
|
||||||
|
DateTime dt1 = Text.ToDateTime(DateFormat);
|
||||||
|
if (Value != dt1) Value = dt1;
|
||||||
|
break;
|
||||||
|
case UIDateType.YearMonth:
|
||||||
|
DateTime dt2 = Text.ToDateTime(DateYearMonthFormat);
|
||||||
|
if (Value != dt2) Value = dt2;
|
||||||
|
break;
|
||||||
|
case UIDateType.Year:
|
||||||
|
DateTime dt3 = Text.ToDateTime(DateYearFormat);
|
||||||
|
if (Value != dt3) Value = dt3;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@ -254,8 +268,21 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DateTime dt = Text.ToDateTime(DateFormat);
|
switch (ShowType)
|
||||||
if (Value != dt) Value = dt;
|
{
|
||||||
|
case UIDateType.YearMonthDay:
|
||||||
|
DateTime dt1 = Text.ToDateTime(DateFormat);
|
||||||
|
if (Value != dt1) Value = dt1;
|
||||||
|
break;
|
||||||
|
case UIDateType.YearMonth:
|
||||||
|
DateTime dt2 = Text.ToDateTime(DateYearMonthFormat);
|
||||||
|
if (Value != dt2) Value = dt2;
|
||||||
|
break;
|
||||||
|
case UIDateType.Year:
|
||||||
|
DateTime dt3 = Text.ToDateTime(DateYearFormat);
|
||||||
|
if (Value != dt3) Value = dt3;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
* 2020-07-25: V2.2.6 更新绘制
|
* 2020-07-25: V2.2.6 更新绘制
|
||||||
* 2021-08-16: V3.0.6 增加ToolTip接口,解决类似UITextBox这类的组合控件无法显示ToolTip的问题
|
* 2021-08-16: V3.0.6 增加ToolTip接口,解决类似UITextBox这类的组合控件无法显示ToolTip的问题
|
||||||
* 2021-12-09: V3.0.9 修复默认显示
|
* 2021-12-09: V3.0.9 修复默认显示
|
||||||
|
* 2022-05-14: V3.3.6 重构DrawString函数
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
@ -262,24 +263,20 @@ namespace Sunny.UI
|
|||||||
titleSize = e.Graphics.MeasureString(tooltip.Title, TempTitleFont);
|
titleSize = e.Graphics.MeasureString(tooltip.Title, TempTitleFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
e.Graphics.DrawString(tooltip.Title, TempTitleFont, ForeColor,
|
e.Graphics.DrawString(tooltip.Title, TempTitleFont, ForeColor, new Rectangle(tooltip.Symbol > 0 ? tooltip.SymbolSize + 5 : 5, 5, bounds.Width, bounds.Height), ContentAlignment.TopLeft);
|
||||||
tooltip.Symbol > 0 ? tooltip.SymbolSize + 5 : 5, 5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (titleSize.Height > 0)
|
if (titleSize.Height > 0)
|
||||||
{
|
{
|
||||||
e.Graphics.DrawLine(ForeColor,
|
e.Graphics.DrawLine(ForeColor, symbolWidth == 0 ? 5 : symbolWidth + 5, 5 + titleSize.Height + 3,
|
||||||
symbolWidth == 0 ? 5 : symbolWidth + 5, 5 + titleSize.Height + 3,
|
|
||||||
e.Bounds.Width - 5, 5 + titleSize.Height + 3);
|
e.Bounds.Width - 5, 5 + titleSize.Height + 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
e.Graphics.DrawString(e.ToolTipText, TempFont, ForeColor,
|
e.Graphics.DrawString(e.ToolTipText, TempFont, ForeColor, new Rectangle(tooltip.Symbol > 0 ? tooltip.SymbolSize + 5 : 5, titleSize.Height > 0 ? 10 + (int)titleSize.Height : 5, bounds.Width, bounds.Height), ContentAlignment.TopLeft);
|
||||||
tooltip.Symbol > 0 ? tooltip.SymbolSize + 5 : 5,
|
|
||||||
titleSize.Height > 0 ? 10 + titleSize.Height : 5);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
e.Graphics.DrawString(e.ToolTipText, TempFont, ForeColor, 5, 5);
|
e.Graphics.DrawString(e.ToolTipText, TempFont, ForeColor, new Rectangle(5, 5, bounds.Width, bounds.Height), ContentAlignment.TopLeft);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user