This repository has been archived by the owner on Dec 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVpanel.h
75 lines (67 loc) · 2.1 KB
/
Vpanel.h
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
#pragma once
#include "Volume.h"
#include "Chapter.h"
ref struct VPanel : System::Windows::Forms::Panel {
public:
Volume^ Vol;
Chapter^ Chp;
BOOLEAN VolChp = FALSE;
BOOLEAN OpenClose = FALSE;
INT Index;
System::Drawing::SizeF TextSize;
System::Drawing::Font^ PFont;
void GenerateGraphics() {
switch (this->VolChp) {
case 0: {
System::Windows::Forms::Label^ headerTitle;
headerTitle = gcnew System::Windows::Forms::Label;
headerTitle->Visible = TRUE;
headerTitle->Text = this->Vol->Name;
headerTitle->Width = this->Width;
headerTitle->Height = this->Height;
System::Drawing::Graphics^ graphics = headerTitle->CreateGraphics();
System::Drawing::Font^ tFont;
System::Drawing::SizeF Size;
int tw, th;
tw = headerTitle->DisplayRectangle.Width - 3;
th = headerTitle->DisplayRectangle.Height - 3;
for (int idx = 1; idx <= 100; idx++) {
tFont = gcnew System::Drawing::Font("Arial", (idx));
Size = graphics->MeasureString(this->Vol->Name, tFont);
if ((Size.Width > tw) || (Size.Height > th)) {
headerTitle->Font = gcnew System::Drawing::Font("Arial", idx - 1);
break;
}
}
delete graphics;
delete headerTitle;
this->PFont = tFont;
this->TextSize = Size;
break;
}
case 1: {
System::Windows::Forms::Label^ chapterTitle;
chapterTitle = gcnew System::Windows::Forms::Label;
chapterTitle->Visible = TRUE;
chapterTitle->Text = this->Chp->Name;
chapterTitle->Width = this->Width;
chapterTitle->Height = this->Height;
System::Drawing::Graphics^ graphics = chapterTitle->CreateGraphics();
System::Drawing::Font^ cFont;
System::Drawing::SizeF Size;
for (int idx = 1; idx <= 100; idx++) {
cFont = gcnew System::Drawing::Font("Arial", idx);
Size = graphics->MeasureString(this->Chp->Name, cFont);
if ((Size.Width > (chapterTitle->DisplayRectangle.Width - 3) || Size.Height > (chapterTitle->DisplayRectangle.Height - 3))) {
chapterTitle->Font = gcnew System::Drawing::Font("Arial", idx--);
break;
}
}
delete graphics;
delete chapterTitle;
this->PFont = cFont;
this->TextSize = Size;
}
}
}
};