This repository was archived by the owner on Apr 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSideBar.cs
More file actions
181 lines (154 loc) · 4.85 KB
/
Copy pathSideBar.cs
File metadata and controls
181 lines (154 loc) · 4.85 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using Vectrons_Library;
namespace System_Info
{
public partial class SideBar : Form
{
private bool dragging = false;
private Point dragCursorPoint;
private Point dragFormPoint;
private Font font;
private Color backgroundColor;
private Color borderColor;
private Color textColor;
public SideBar()
{
font = Properties.Settings.Default.Font;
backgroundColor = ColorTranslator.FromHtml(Properties.Settings.Default.BackgroundColor);
borderColor = ColorTranslator.FromHtml(Properties.Settings.Default.BorderColor);
textColor = ColorTranslator.FromHtml(Properties.Settings.Default.TextColor);
InitializeComponent();
graphicalOverlay1.Owner = this;
}
protected override CreateParams CreateParams
{
get
{
var parameters = base.CreateParams;
parameters.ExStyle |= 0x80;
return parameters;
}
}
private GraphicsPath FormGraphic
{
get
{
GraphicsPath p = new GraphicsPath();
p.StartFigure();
p.AddArc(new Rectangle(0, 0, 40, 40), 180, 90);
p.AddLine(40, 0, Width - 40, 0);
p.AddArc(new Rectangle(Width - 40, 0, 40, 40), -90, 90);
p.AddLine(Width, 40, Width, Height - 40);
p.AddArc(new Rectangle(Width - 40, Height - 40, 40, 40), 0, 90);
p.AddLine(Width - 40, Height, 40, Height);
p.AddArc(new Rectangle(0, Height - 40, 40, 40), 90, 90);
p.CloseFigure();
return p;
}
}
private void SetControlEventHandlers(Control.ControlCollection coll)
{
foreach (Control ctr in coll)
{
ctr.MouseDown += new MouseEventHandler(CtrMouseDown);
ctr.MouseMove += new MouseEventHandler(CtrMouseMove);
ctr.MouseUp += new MouseEventHandler(CtrMouseUp);
SetControlEventHandlers(ctr.Controls);
}
}
private void SetControlFontAndBackground(Control.ControlCollection coll)
{
foreach (Control ctr in coll)
{
ctr.ForeColor = textColor;
ctr.Font = font;
ctr.BackColor = backgroundColor;
SetControlFontAndBackground(ctr.Controls);
}
}
private void SideBar_Load(object sender, EventArgs e)
{
FormGeometry.GeometryFromString(Properties.Settings.Default.WindowGeometry, this);
DrawForm();
}
private void SideBar_Paint(object sender, PaintEventArgs e)
{
using (Pen borderPen = new Pen(new SolidBrush(borderColor), 2))
{
e.Graphics.DrawPath(borderPen, FormGraphic);
}
using (Pen matrixPen = new Pen(new SolidBrush(borderColor), 1))
{
for (int i = 0; i < flowLayoutPanel1.Controls.Count - 1; i++)
{
if (flowLayoutPanel1.Controls[i].GetType() == typeof(Panel))
{
Panel item = (Panel)flowLayoutPanel1.Controls[i];
int y = item.Location.Y + item.Size.Height + 5;
e.Graphics.DrawLine(matrixPen, 0, y, Width, y);
}
}
}
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
ShowInTaskbar = false;
}
private void SideBar_FormClosing(object sender, FormClosingEventArgs e)
{
// persist our geometry string.
Properties.Settings.Default.WindowGeometry = FormGeometry.GeometryToString(this);
Properties.Settings.Default.Save();
}
private void CtrMouseDown(object sender, MouseEventArgs e)
{
if (Properties.Settings.Default.LockPlacement == false)
{
dragging = true;
dragCursorPoint = Cursor.Position;
dragFormPoint = Location;
}
}
private void CtrMouseMove(object sender, MouseEventArgs e)
{
if (dragging)
{
Point dif = Point.Subtract(Cursor.Position, new Size(dragCursorPoint));
Location = Point.Add(dragFormPoint, new Size(dif));
}
}
private void CtrMouseUp(object sender, MouseEventArgs e)
{
dragging = false;
}
private void DrawForm()
{
SuspendLayout();
flowLayoutPanel1.Controls.Clear();
flowLayoutPanel1.Padding = new Padding(10);
Panel panelCpu = SystemInfo.CPUController.GetPanel();
panelCpu.Margin = new Padding(0, 0, 0, 0);
flowLayoutPanel1.Controls.Add(panelCpu);
Panel panelMemory = SystemInfo.MemoryController.GetPanel();
panelMemory.Margin = new Padding(0, 10, 0, 0);
flowLayoutPanel1.Controls.Add(panelMemory);
Panel panelNetwork = SystemInfo.NetworkController.GetPanel();
panelNetwork.Margin = new Padding(0, 10, 0, 0);
flowLayoutPanel1.Controls.Add(panelNetwork);
Panel panelHdd = SystemInfo.DriveController.GetPanel();
panelHdd.Margin = new Padding(0, 10, 0, 0);
flowLayoutPanel1.Controls.Add(panelHdd);
SetControlEventHandlers(Controls);
SetControlFontAndBackground(Controls);
ResumeLayout();
}
private void SideBar_SizeChanged(object sender, EventArgs e)
{
SuspendLayout();
Region = new Region(FormGraphic);
SetControlFontAndBackground(Controls);
ResumeLayout();
}
}
}