* 重构一些笔刷和画笔的资源释放
This commit is contained in:
parent
50fe88ee07
commit
bcbab4f4eb
@ -226,7 +226,7 @@ namespace Sunny.UI
|
||||
|
||||
protected void DrawSelector(Graphics dc, RectangleF r, Orientation orientation, float percentSet)
|
||||
{
|
||||
Pen pen = new Pen(Color.CadetBlue);
|
||||
using Pen pen = new Pen(Color.CadetBlue);
|
||||
percentSet = Math.Max(0, percentSet);
|
||||
percentSet = Math.Min(1, percentSet);
|
||||
if (orientation == Orientation.Vertical)
|
||||
|
@ -20,6 +20,12 @@ namespace Sunny.UI
|
||||
private readonly List<Color> m_colors = new List<Color>();
|
||||
private double m_wheelLightness = 0.5;
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
m_brush?.Dispose();
|
||||
}
|
||||
|
||||
public HSLColor SelectedHSLColor
|
||||
{
|
||||
get { return m_selectedColor; }
|
||||
|
@ -623,7 +623,7 @@ namespace Sunny.UI
|
||||
// Set antialias effect on
|
||||
gOffScreen.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
// Draw border of knob
|
||||
gOffScreen.DrawEllipse(new Pen(this.BackColor), rKnob);
|
||||
gOffScreen.DrawEllipse(this.BackColor, rKnob);
|
||||
|
||||
//if control is focused
|
||||
if (this.isFocused)
|
||||
@ -846,7 +846,8 @@ namespace Sunny.UI
|
||||
int w = l / 4;
|
||||
Point[] pt = GetKnobLine(Gr, l);
|
||||
|
||||
Gr.DrawLine(new Pen(_PointerColor, w), pt[0], pt[1]);
|
||||
using Pen pen = new Pen(_PointerColor, w);
|
||||
Gr.DrawLine(pen, pt[0], pt[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -891,8 +892,8 @@ namespace Sunny.UI
|
||||
Rectangle rPointer = new Rectangle(Arrow.X - w / 2, Arrow.Y - w / 2, w, h);
|
||||
|
||||
//Utility.DrawInsetCircle(ref Gr, rPointer, new Pen(_PointerColor));
|
||||
DrawInsetCircle(ref Gr, rPointer, new Pen(GetLightColor(_PointerColor, 55)));
|
||||
|
||||
using Pen pen = new Pen(GetLightColor(_PointerColor, 55));
|
||||
DrawInsetCircle(ref Gr, rPointer, pen);
|
||||
Gr.FillEllipse(brushKnobPointer, rPointer);
|
||||
}
|
||||
}
|
||||
@ -1467,8 +1468,8 @@ namespace Sunny.UI
|
||||
}
|
||||
public static void DrawInsetCircle(ref Graphics g, Rectangle r, Pen p)
|
||||
{
|
||||
Pen p1 = new Pen(GetDarkColor(p.Color, 50));
|
||||
Pen p2 = new Pen(GetLightColor(p.Color, 50));
|
||||
using Pen p1 = new Pen(GetDarkColor(p.Color, 50));
|
||||
using Pen p2 = new Pen(GetLightColor(p.Color, 50));
|
||||
for (int i = 0; i < p.Width; i++)
|
||||
{
|
||||
Rectangle r1 = new Rectangle(r.X + i, r.Y + i, r.Width - i * 2, r.Height - i * 2);
|
||||
|
@ -34,6 +34,12 @@ namespace Sunny.UI
|
||||
[DefaultProperty("Text")]
|
||||
public sealed class UISmoothLabel : Label, IStyleInterface, IZoomScale
|
||||
{
|
||||
private PointF point;
|
||||
private SizeF drawSize;
|
||||
private Pen drawPen;
|
||||
private GraphicsPath drawPath;
|
||||
private SolidBrush forecolorBrush;
|
||||
|
||||
public UISmoothLabel()
|
||||
{
|
||||
base.Font = UIStyles.Font();
|
||||
@ -43,11 +49,23 @@ namespace Sunny.UI
|
||||
rectColor = UIStyles.Blue.SmoothLabelRectColor;
|
||||
|
||||
drawPath = new GraphicsPath();
|
||||
drawPen = new Pen(new SolidBrush(rectColor), rectSize);
|
||||
drawPen = new Pen(rectColor, rectSize);
|
||||
forecolorBrush = new SolidBrush(ForeColor);
|
||||
Size = new Size(300, 60);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
forecolorBrush?.Dispose();
|
||||
drawPath?.Dispose();
|
||||
drawPen?.Dispose();
|
||||
}
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 禁止控件跟随窗体缩放
|
||||
/// </summary>
|
||||
@ -69,24 +87,6 @@ namespace Sunny.UI
|
||||
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
forecolorBrush?.Dispose();
|
||||
drawPath?.Dispose();
|
||||
drawPen?.Dispose();
|
||||
}
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private PointF point;
|
||||
private SizeF drawSize;
|
||||
private Pen drawPen;
|
||||
private GraphicsPath drawPath;
|
||||
private SolidBrush forecolorBrush;
|
||||
|
||||
[Browsable(false), DefaultValue(false)]
|
||||
public bool IsScaled { get; set; }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user