added files
This commit is contained in:
commit
b502964c9a
25 files changed
+1769
No files matched your search
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
internal class Toggle : Ctl
|
||||
{
|
||||
public bool On;
|
||||
|
||||
private float t;
|
||||
|
||||
private Timer tm = new Timer();
|
||||
|
||||
public event Action Changed;
|
||||
|
||||
public Toggle()
|
||||
{
|
||||
Size = new Size(44, 24);
|
||||
tm.Interval = 15;
|
||||
Timer timer = tm;
|
||||
EventHandler value = (object param0, EventArgs param1) =>
|
||||
{
|
||||
float num = (On ? 1f : 0f);
|
||||
t += (num - t) * 0.35f;
|
||||
if (Math.Abs(num - t) < 0.02f)
|
||||
{
|
||||
t = num;
|
||||
tm.Stop();
|
||||
}
|
||||
Invalidate();
|
||||
};
|
||||
timer.Tick += value;
|
||||
}
|
||||
|
||||
public void Set(bool v)
|
||||
{
|
||||
On = v;
|
||||
t = (v ? 1f : 0f);
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
protected override void OnClick(EventArgs e)
|
||||
{
|
||||
On = !On;
|
||||
tm.Start();
|
||||
if (Changed != null)
|
||||
{
|
||||
Changed();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
Graphics graphics = e.Graphics;
|
||||
Prep(graphics);
|
||||
graphics.Clear(BackColor);
|
||||
G.Fill(graphics, new RectangleF(0f, 0f, Width - 1, Height - 1), Height, G.Mix(G.Line, G.Acc, t));
|
||||
using SolidBrush brush = new SolidBrush(Color.White);
|
||||
graphics.FillEllipse(brush, 3f + t * (float)(Width - Height), 3f, Height - 7, Height - 7);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user