forked from jaysonragasa/MultiRDPClient.NET
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLine.cs
More file actions
64 lines (63 loc) · 1.81 KB
/
Line.cs
File metadata and controls
64 lines (63 loc) · 1.81 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace CommonTools
{
class Line : Control
{
AnchorStyles m_linePositions = AnchorStyles.Bottom;
public AnchorStyles LinePositions
{
get { return m_linePositions; }
set
{
m_linePositions = value;
Invalidate();
}
}
public Line()
{
TabStop = false;
SetStyle(ControlStyles.Selectable, false);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
}
protected override void OnPaintBackground(PaintEventArgs pevent)
{
base.OnPaintBackground(pevent);
}
protected override void OnPaint(PaintEventArgs e)
{
//base.OnPaint(e);
Rectangle r = ClientRectangle;
r.Inflate(-2,-2);
Pen p = new Pen(ForeColor, 1);
if ((int)(LinePositions & AnchorStyles.Left) > 0)
{
e.Graphics.DrawLine(p, r.Left-1, r.Top, r.Left-1, r.Bottom-1);
e.Graphics.DrawLine(Pens.WhiteSmoke, r.Left, r.Top, r.Left, r.Bottom-1);
}
if ((int)(LinePositions & AnchorStyles.Right) > 0)
{
e.Graphics.DrawLine(p, r.Right, r.Top, r.Right, r.Bottom-1);
e.Graphics.DrawLine(Pens.WhiteSmoke, r.Right+1, r.Top, r.Right+1, r.Bottom-1);
}
if ((int)(LinePositions & AnchorStyles.Top) > 0)
{
e.Graphics.DrawLine(p, r.Left, r.Top-1, r.Right-1, r.Top-1);
e.Graphics.DrawLine(Pens.WhiteSmoke, r.Left, r.Top, r.Right-1, r.Top);
}
if ((int)(LinePositions & AnchorStyles.Bottom) > 0)
{
e.Graphics.DrawLine(p, r.Left, r.Bottom, r.Right-1, r.Bottom);
e.Graphics.DrawLine(Pens.WhiteSmoke, r.Left, r.Bottom+1, r.Right-1, r.Bottom+1);
}
p.Dispose();
}
}
}