* IsScaled属性设置为不可见

This commit is contained in:
Sunny 2021-10-20 22:38:37 +08:00
parent e3ad3afb5d
commit c9bb1b0faf
20 changed files with 83 additions and 16 deletions

Binary file not shown.

View File

@ -13,4 +13,13 @@ namespace Sunny.UI
{
Control ExToolTipControl();
}
public enum UILineCap
{
None,
Square,
Diamond,
Triangle,
Circle
}
}

View File

@ -33,6 +33,7 @@ namespace Sunny.UI
}
}
[Browsable(false)]
public bool IsScaled { get; private set; }
public void SetDPIScale()

View File

@ -11,6 +11,7 @@ namespace Sunny.UI
private ContentAlignment m_rotatePointAlignment = ContentAlignment.MiddleCenter;
private ContentAlignment m_textAlignment = ContentAlignment.MiddleLeft;
[Browsable(false)]
public bool IsScaled { get; private set; }
public void SetDPIScale()

View File

@ -49,6 +49,7 @@ namespace Sunny.UI
Width = 150;
}
[Browsable(false)]
public bool IsScaled { get; private set; }
public void SetDPIScale()

View File

@ -38,6 +38,7 @@ namespace Sunny.UI
Version = UIGlobal.Version;
}
[Browsable(false)]
public bool IsScaled { get; private set; }
public void SetDPIScale()

View File

@ -45,6 +45,7 @@ namespace Sunny.UI
base.MinimumSize = new Size(1, 1);
}
[Browsable(false)]
public bool IsScaled { get; private set; }
public void SetDPIScale()

View File

@ -98,6 +98,7 @@ namespace Sunny.UI
HorizontalScrollBar.VisibleChanged += HorizontalScrollBar_VisibleChanged;
}
[Browsable(false)]
public bool IsScaled { get; private set; }
public void SetDPIScale()

View File

@ -368,6 +368,7 @@ namespace Sunny.UI
}
}
[Browsable(false)]
public bool IsScaled { get; private set; }
public void SetDPIScale()

View File

@ -41,6 +41,7 @@ namespace Sunny.UI
ForeColorChanged += UILabel_ForeColorChanged;
}
[Browsable(false)]
public bool IsScaled { get; private set; }
public void SetDPIScale()
@ -138,6 +139,7 @@ namespace Sunny.UI
LinkColor = UIColor.Blue;
}
[Browsable(false)]
public bool IsScaled { get; private set; }
public void SetDPIScale()

View File

@ -99,10 +99,10 @@ namespace Sunny.UI
set => SetForeColor(value);
}
private LineCap startCap = LineCap.Flat;
private UILineCap startCap = UILineCap.None;
[DefaultValue(LineCap.Flat), Category("SunnyUI")]
public LineCap StartCap
[DefaultValue(UILineCap.None), Category("SunnyUI")]
public UILineCap StartCap
{
get => startCap;
set
@ -112,10 +112,10 @@ namespace Sunny.UI
}
}
private LineCap endCap = LineCap.Flat;
private UILineCap endCap = UILineCap.None;
[DefaultValue(LineCap.Flat), Category("SunnyUI")]
public LineCap EndCap
[DefaultValue(UILineCap.None), Category("SunnyUI")]
public UILineCap EndCap
{
get => endCap;
set
@ -125,26 +125,66 @@ namespace Sunny.UI
}
}
private int lineCapSize = 6;
[DefaultValue(6), Category("SunnyUI")]
public int LineCapSize
{
get => lineCapSize;
set
{
lineCapSize = value;
Invalidate();
}
}
protected override void OnPaintRect(Graphics g, GraphicsPath path)
{
Pen pen = new Pen(rectColor, lineSize);
pen.StartCap = StartCap;
pen.EndCap = EndCap;
g.Smooth();
g.SetDefaultQuality();
if (Direction == LineDirection.Horizontal)
{
int top = (Height - lineSize) / 2;
g.DrawLine(pen, Padding.Left, top, Width - Padding.Left - Padding.Right, top);
g.FillRectangle(rectColor, Padding.Left + 1, top, Width - 2 - Padding.Left - Padding.Right, lineSize);
switch (startCap)
{
case UILineCap.Square:
top = Height / 2 - LineCapSize - 1;
g.FillRectangle(rectColor, new RectangleF(0, top, LineCapSize * 2, LineCapSize * 2));
break;
case UILineCap.Diamond:
break;
case UILineCap.Triangle:
break;
case UILineCap.Circle:
top = Height / 2 - LineCapSize - 1;
g.FillEllipse(rectColor, new RectangleF(0, top, LineCapSize * 2, LineCapSize * 2));
break;
}
switch (endCap)
{
case UILineCap.Square:
top = Height / 2 - LineCapSize;
if (lineSize.Mod(2) == 1) top -= 1;
g.FillRectangle(rectColor, new RectangleF(Width - lineCapSize * 2 - 1, top, LineCapSize * 2, LineCapSize * 2));
break;
case UILineCap.Diamond:
break;
case UILineCap.Triangle:
break;
case UILineCap.Circle:
top = Height / 2 - LineCapSize - 1;
g.FillEllipse(rectColor, new RectangleF(Width - lineCapSize * 2 - 1, top, LineCapSize * 2, LineCapSize * 2));
break;
}
}
else
{
int left = (Width - lineSize) / 2;
g.DrawLine(pen, left, Padding.Top, left, Height - Padding.Top - Padding.Bottom);
g.FillRectangle(rectColor, left, Padding.Top, lineSize, Height - Padding.Top - Padding.Bottom);
}
g.Smooth(false);
pen.Dispose();
}
@ -169,7 +209,7 @@ namespace Sunny.UI
SizeF sf = g.MeasureString(Text, Font);
if (Direction == LineDirection.Horizontal)
if (Direction == LineDirection.Horizontal && Height > sf.Height)
{
switch (TextAlign)
{

View File

@ -605,6 +605,7 @@ namespace Sunny.UI
[Description("获取或设置包含有关控件的数据的对象字符串"), Category("SunnyUI")]
public string TagString { get; set; }
[Browsable(false)]
public bool IsScaled { get; private set; }
public void SetDPIScale()

View File

@ -60,6 +60,7 @@ namespace Sunny.UI
Version = UIGlobal.Version;
}
[Browsable(false)]
public bool IsScaled { get; private set; }
public void SetDPIScale()

View File

@ -80,6 +80,7 @@ namespace Sunny.UI
SetScrollInfo();
}
[Browsable(false)]
public bool IsScaled { get; private set; }
public void SetDPIScale()

View File

@ -52,6 +52,7 @@ namespace Sunny.UI
SetStyleFlags(true, false);
}
[Browsable(false)]
public bool IsScaled { get; private set; }
public void SetDPIScale()

View File

@ -62,6 +62,7 @@ namespace Sunny.UI
timer.Tick += Timer_Tick;
}
[Browsable(false)]
public bool IsScaled { get; private set; }
public void SetDPIScale()

View File

@ -46,6 +46,7 @@ namespace Sunny.UI
Version = UIGlobal.Version;
}
[Browsable(false)]
public bool IsScaled { get; private set; }
public void SetDPIScale()

View File

@ -32,6 +32,7 @@ namespace Sunny.UI
Version = UIGlobal.Version;
}
[Browsable(false)]
public bool IsScaled { get; private set; }
public void SetDPIScale()

View File

@ -70,6 +70,7 @@ namespace Sunny.UI
showTitleIcon = false;
}
[Browsable(false)]
public bool IsScaled { get; private set; }
public void SetDPIScale()

View File

@ -68,6 +68,7 @@ namespace Sunny.UI
SetDPIScale();
}
[Browsable(false)]
public bool IsScaled { get; private set; }
public void SetDPIScale()