-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainForm.cpp
103 lines (85 loc) · 2.86 KB
/
MainForm.cpp
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
#include "Kernel.h"
#include "MainForm.h"
//#define gcdelete(arg) arg->~
[System::STAThreadAttribute]
int main()
{
#if !defined(DEBUG) & defined(XRCORE_API)
Core._initialize("XFont Cast", 0, 0);
//Debug._initializeAfterFS();
#else
ShowWindow(GetConsoleWindow(), SW_HIDE);
#endif
XFontForm::Application::EnableVisualStyles();
XFontForm::Application::SetCompatibleTextRenderingDefault(false);
XFontForm::Application::Run(gcnew XFontForm::MeshEdit);
return 0;
}
System::Void XFontForm::MeshEdit::MakeDraftBox()
{
if (this->TestText->Text == "" || this->openFileDialog1->FileName == "") return;
Bitmap^ pImage = gcnew Bitmap(TexFontBox->Width, TexFontBox->Height);
pImage->MakeTransparent(Color::White);
Graphics^ pGraphics = Graphics::FromImage(pImage);
System::Drawing::Text::PrivateFontCollection^ pLatestFont = gcnew System::Drawing::Text::PrivateFontCollection();
pLatestFont->AddFontFile(this->openFileDialog1->FileName);
pGraphics->DrawString
(
/* Text */ this->TestText->Text,
/* Stule */ gcnew System::Drawing::Font(pLatestFont->Families[0], (float)numericUpDown1->Value, FontStyle::Regular),
/* Color */ gcnew SolidBrush(Color::White),
/* Size */ 10, 10
);
TexFontBox->Image = pImage;
delete pGraphics;
}
System::Void XFontForm::MeshEdit::button1_Click(System::Object^ sender, System::EventArgs^ e)
{
if (this->openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK)
{
this->InputBox->Text = this->openFileDialog1->FileName;
this->MakeDraftBox();
this->TexFontBox->Visible = true;
this->Width = 618;
}
}
System::Void XFontForm::MeshEdit::button3_Click(System::Object ^ sender, System::EventArgs ^ e)
{
string128 InPathNameStr = { 0 };
ConvertDotNetStringToAscii(this->InputBox->Text, InPathNameStr);
string128 OutPathNameStr = { 0 };
ConvertDotNetStringToAscii(this->OutputBox->Text, OutPathNameStr);
XRay::CFontGen FrontSystem;
FrontSystem.InitFreeType();
FrontSystem.PathSystem.PathName = InPathNameStr;
FrontSystem.PathSystem.PathOutName = OutPathNameStr;
FrontSystem.PathSystem.PathOutName += "\\";
FrontSystem.PathSystem.FontSize = (unsigned int)this->numericUpDown1->Value;
FrontSystem.ManageCreationFile();
// @ Åñëè óñïåøíî çàãðóæåí ôàéë
if (XRay::CFontGen::bSucFile)
{
FrontSystem.CreateFolder();
FrontSystem.CheckTexConv();
// @ Åñëè óñïåøíî ñîçäàíà ïàïêà
if (XRay::CFontGen::bSucDir)
FrontSystem.InitFont();
}
FrontSystem.ReleaseFreeType();
System::String^ ImgPath = gcnew System::String((
FrontSystem.PathSystem.PathOutName +
FrontSystem.PathSystem.FileName + "_" +
std::to_string(FrontSystem.PathSystem.FontSize).c_str() + "_1600.png"
).c_str());
if (System::IO::File::Exists(ImgPath))
{
this->TexFontBox->Image = gcnew System::Drawing::Bitmap(ImgPath);
this->TexFontBox->Visible = true;
this->Width = 618;
}
else
{
this->TexFontBox->Visible = false;
this->Width = 357;
}
}