-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebugClassForm.cs
More file actions
127 lines (106 loc) · 4.36 KB
/
Copy pathDebugClassForm.cs
File metadata and controls
127 lines (106 loc) · 4.36 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
// SHIFT+STRG+ALT+D = Debug Mode in Settings Window
using System;
using System.Drawing;
using System.Windows.Forms;
namespace c2flux
{
public sealed class DebugClassForm : Form
{
private readonly AppLayout _layout;
private SymbolPreviewPanel symbolPreviewPanel;
public DebugClassForm(AppLayout layout)
{
_layout = layout;
InitializeComponent();
AntdThemeService.Apply(this, _layout);
}
private void InitializeComponent()
{
Text = "DebugClassForm";
StartPosition = FormStartPosition.CenterParent;
ClientSize = new Size(520, 280);
MinimumSize = new Size(520, 280);
MaximizeBox = false;
MinimizeBox = false;
ShowInTaskbar = false;
symbolPreviewPanel = new SymbolPreviewPanel
{
Name = "symbolPreviewPanel",
Dock = DockStyle.Fill,
BackColor = SystemColors.Window,
ForeColor = SystemColors.WindowText
};
Controls.Add(symbolPreviewPanel);
}
private sealed class SymbolPreviewPanel : Panel
{
private const int RowHeight = 48;
private const int IconCellLeft = 24;
private const int IconCellWidth = 24;
private const int SymbolBoxSize = StatusSymbolRenderer.DefaultSymbolSize;
public SymbolPreviewPanel()
{
SetStyle(
ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint |
ControlStyles.OptimizedDoubleBuffer |
ControlStyles.ResizeRedraw,
true);
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.Clear(BackColor);
DrawHeader(e.Graphics);
DrawSymbolRow(e.Graphics, 0, "Information", StatusSymbolKind.Information);
DrawSymbolRow(e.Graphics, 1, "Warnung", StatusSymbolKind.Warning);
DrawSymbolRow(e.Graphics, 2, "Fehler", StatusSymbolKind.Error);
DrawSymbolRow(e.Graphics, 3, "Systemordner-Hinweis", StatusSymbolKind.SystemDirectory);
}
private void DrawHeader(Graphics graphics)
{
Rectangle textBounds = new Rectangle(16, 12, Width - 32, 24);
TextRenderer.DrawText(
graphics,
"Symbol-Preview",
Font,
textBounds,
ForeColor,
TextFormatFlags.Left | TextFormatFlags.VerticalCenter | TextFormatFlags.EndEllipsis);
}
private void DrawSymbolRow(Graphics graphics, int index, string label, StatusSymbolKind symbolKind)
{
int y = 48 + index * RowHeight;
RectangleF iconCellBounds = new RectangleF(
IconCellLeft,
y,
IconCellWidth,
RowHeight);
RectangleF symbolBox = GetCenteredSymbolBox(iconCellBounds);
Rectangle textBounds = new Rectangle(72, y, Width - 88, RowHeight);
using (Pen separatorPen = new Pen(SystemColors.ControlLight))
{
graphics.DrawLine(separatorPen, 16, y + RowHeight - 1, Width - 16, y + RowHeight - 1);
}
StatusSymbolRenderer.DrawSymbol(graphics, symbolBox, symbolKind);
TextRenderer.DrawText(
graphics,
label,
Font,
textBounds,
ForeColor,
TextFormatFlags.Left | TextFormatFlags.VerticalCenter | TextFormatFlags.EndEllipsis);
}
private RectangleF GetCenteredSymbolBox(RectangleF containerBounds)
{
float left = containerBounds.Left + (containerBounds.Width - SymbolBoxSize) / 2F;
float top = containerBounds.Top + (containerBounds.Height - SymbolBoxSize) / 2F;
return new RectangleF(
(float)Math.Round(left),
(float)Math.Round(top),
SymbolBoxSize,
SymbolBoxSize);
}
}
}
}