-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSlidingPanel.cs
51 lines (45 loc) · 1.2 KB
/
SlidingPanel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Windows.Forms;
namespace TelefonRehberi
{
class SlidingPanel
{
private Panel span;
private readonly Button button;
private Timer tmr;
private bool hidden;
private readonly int size;
public SlidingPanel(ref Panel pnl,ref Button btn, int with)
{
pnl.Width = 0;
this.span = pnl;
this.button = btn;
hidden = true;
size = with;
btn.Click += new EventHandler(button_clicked);
tmr = new Timer
{
Interval = 1
};
tmr.Tick += new EventHandler(t_tick);
}
private void button_clicked(object sender, EventArgs e)
{
tmr.Start();
}
private void t_tick(object sender, EventArgs e)
{
if (hidden) ChangeSize(+6);
else ChangeSize(-6);
}
private void ChangeSize(int val)
{
span.Width += val;
if(span.Width >= size || span.Width <= 0)
{
tmr.Stop();
hidden = !hidden;
}
}
}
}