* 控件中用到的Timer在控件销毁时释放

This commit is contained in:
Sunny 2020-11-21 11:46:59 +08:00
parent 325a384b4f
commit 359586ab7a
12 changed files with 51 additions and 5 deletions

Binary file not shown.

View File

@ -51,8 +51,9 @@ namespace Sunny.UI
public UIDatetimePicker() public UIDatetimePicker()
{ {
InitializeComponent(); InitializeComponent();
Width = 200;
Value = DateTime.Now; Value = DateTime.Now;
Text = Value.ToString(DateFormat);
Width = 200;
EditorLostFocus += UIDatePicker_LostFocus; EditorLostFocus += UIDatePicker_LostFocus;
TextChanged += UIDatePicker_TextChanged; TextChanged += UIDatePicker_TextChanged;
MaxLength = 19; MaxLength = 19;

View File

@ -47,6 +47,12 @@ namespace Sunny.UI
fillPressColor = Color.FromArgb(74, 131, 229); fillPressColor = Color.FromArgb(74, 131, 229);
} }
~UIHorScrollBar()
{
timer.Stop();
timer.Dispose();
}
private int scrollValue; private int scrollValue;
private int SmallChange = 1; private int SmallChange = 1;
private int LargeChange = 10; private int LargeChange = 10;

View File

@ -44,6 +44,12 @@ namespace Sunny.UI
private readonly Color[] _surroundColor = new Color[] { Color.FromArgb(0, 255, 255, 255) }; private readonly Color[] _surroundColor = new Color[] { Color.FromArgb(0, 255, 255, 255) };
private readonly Timer _timer = new Timer(); private readonly Timer _timer = new Timer();
~UILedBulb()
{
_timer.Stop();
_timer.Dispose();
}
/// <summary> /// <summary>
/// Gets or Sets the color of the LED light /// Gets or Sets the color of the LED light
/// </summary> /// </summary>
@ -129,7 +135,7 @@ namespace Sunny.UI
/// </summary> /// </summary>
private void drawControl(Graphics g, bool on) private void drawControl(Graphics g, bool on)
{ {
// Is the bulb on or off // Is the bulb on or off
Color lightColor = (on) ? Color : Color.FromArgb(150, DarkColor); Color lightColor = (on) ? Color : Color.FromArgb(150, DarkColor);
Color darkColor = (on) ? DarkColor : DarkDarkColor; Color darkColor = (on) ? DarkColor : DarkDarkColor;
@ -143,7 +149,7 @@ namespace Sunny.UI
// Draw the background ellipse // Draw the background ellipse
var rectangle = new Rectangle(Padding.Left, Padding.Top, diameter, diameter); var rectangle = new Rectangle(Padding.Left, Padding.Top, diameter, diameter);
g.FillEllipse(darkColor, rectangle,true); g.FillEllipse(darkColor, rectangle, true);
// Draw the glow gradient // Draw the glow gradient
var path = new GraphicsPath(); var path = new GraphicsPath();

View File

@ -47,6 +47,12 @@ namespace Sunny.UI
timer.Tick += Timer_Tick; timer.Tick += Timer_Tick;
} }
~UILedStopwatch()
{
timer.Stop();
timer.Dispose();
}
public enum TimeShowType public enum TimeShowType
{ {
mmss, mmss,

View File

@ -97,6 +97,7 @@ namespace Sunny.UI
~UIListBox() ~UIListBox()
{ {
timer.Stop(); timer.Stop();
timer.Dispose();
} }
private void Timer_Tick(object sender, EventArgs e) private void Timer_Tick(object sender, EventArgs e)

View File

@ -50,6 +50,7 @@ namespace Sunny.UI
~UIProgressIndicator() ~UIProgressIndicator()
{ {
timer.Stop(); timer.Stop();
timer.Dispose();
} }
public override void SetStyleColor(UIBaseStyle uiColor) public override void SetStyleColor(UIBaseStyle uiColor)

View File

@ -64,6 +64,12 @@ namespace Sunny.UI
public event EventHandler ValueChanged; public event EventHandler ValueChanged;
~UIScrollBar()
{
timer.Stop();
timer.Dispose();
}
[DefaultValue(0)] [DefaultValue(0)]
[Description("当前值"), Category("SunnyUI")] [Description("当前值"), Category("SunnyUI")]
public int Value public int Value

View File

@ -56,6 +56,7 @@ namespace Sunny.UI
~UIScrollingText() ~UIScrollingText()
{ {
timer.Stop(); timer.Stop();
timer.Dispose();
} }
[DefaultValue(200), Description("刷新间隔"), Category("SunnyUI")] [DefaultValue(200), Description("刷新间隔"), Category("SunnyUI")]

View File

@ -53,6 +53,12 @@ namespace Sunny.UI
timer.Tick += Timer_Tick; timer.Tick += Timer_Tick;
} }
~UITabControl()
{
timer.Stop();
timer.Dispose();
}
private void Timer_Tick(object sender, EventArgs e) private void Timer_Tick(object sender, EventArgs e)
{ {
timer.Stop(); timer.Stop();

View File

@ -46,6 +46,12 @@ namespace Sunny.UI
timer.Start(); timer.Start();
} }
~UIWaitingBar()
{
timer.Stop();
timer.Dispose();
}
private void UIWaitingBar_PaintOther(object sender, PaintEventArgs e) private void UIWaitingBar_PaintOther(object sender, PaintEventArgs e)
{ {
e.Graphics.FillRoundRectangle(rectColor, (int)dz + 1, 1, sliderWidth, Height - 3, Radius); e.Graphics.FillRoundRectangle(rectColor, (int)dz + 1, 1, sliderWidth, Height - 3, Radius);

View File

@ -58,6 +58,12 @@ namespace Sunny.UI
timer.Start(); timer.Start();
} }
~Thunder()
{
timer.Stop();
timer.Dispose();
}
private void Timer_Tick(object sender, EventArgs e) private void Timer_Tick(object sender, EventArgs e)
{ {
timer.Stop(); timer.Stop();
@ -320,7 +326,7 @@ namespace Sunny.UI
private static extern bool XL_UnInit(); private static extern bool XL_UnInit();
[DllImport("xldl.dll", CallingConvention = CallingConvention.Cdecl)] [DllImport("xldl.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr XL_CreateTask([In]DownTaskParam stParam); private static extern IntPtr XL_CreateTask([In] DownTaskParam stParam);
[DllImport("xldl.dll", CallingConvention = CallingConvention.Cdecl)] [DllImport("xldl.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern bool XL_StartTask(IntPtr hTask); private static extern bool XL_StartTask(IntPtr hTask);
@ -358,7 +364,7 @@ namespace Sunny.UI
[DllImport("xldl.dll", EntryPoint = "XL_QueryTaskInfoEx", CallingConvention = CallingConvention.Cdecl)] [DllImport("xldl.dll", EntryPoint = "XL_QueryTaskInfoEx", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.Bool)] [return: MarshalAs(UnmanagedType.Bool)]
private static extern bool XL_QueryTaskInfoEx(IntPtr hTask, [Out]DownTaskInfo stTaskInfo); private static extern bool XL_QueryTaskInfoEx(IntPtr hTask, [Out] DownTaskInfo stTaskInfo);
[DllImport("xldl.dll", EntryPoint = "XL_QueryTaskInfoEx", CallingConvention = CallingConvention.Cdecl)] [DllImport("xldl.dll", EntryPoint = "XL_QueryTaskInfoEx", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr XL_CreateBTTask(DownBTTaskParam stParam); private static extern IntPtr XL_CreateBTTask(DownBTTaskParam stParam);