-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdataPanel.cpp
More file actions
98 lines (70 loc) · 1.9 KB
/
dataPanel.cpp
File metadata and controls
98 lines (70 loc) · 1.9 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
#include "dataPanel.h"
wxBEGIN_EVENT_TABLE(dataPanel, wxPanel)
// EVT_BUTTON(30001, SendSpeedUp)
wxEND_EVENT_TABLE()
dataPanel::dataPanel(wxFrame* parent) : wxPanel(parent, wxID_ANY, wxPoint(0, 0), wxSize(550, 200))
{
this->SetBackgroundColour(wxColor(39, 39, 39));
// ------------------------ Raw panel layout ------------------------ //
t_DataText = new wxTextCtrl(this, wxID_ANY, "", wxPoint(0, 0), wxSize(550, 200), wxTE_READONLY | wxTE_MULTILINE);
t_DataText->SetBackgroundColour(wxColor(59, 59, 59));
t_DataText->SetForegroundColour(wxColor(245, 247, 250));
wxFont dataFont = t_DataText->GetFont();
dataFont.SetPointSize(dataFont.GetPointSize() + 2);
t_DataText->SetFont(dataFont);
dataSizer = new wxBoxSizer(wxVERTICAL);
dataSizer->Add(t_DataText, 1, wxEXPAND | wxALIGN_TOP);
this->SetSizer(dataSizer);
}
dataPanel::~dataPanel()
{
}
void dataPanel::AddTextToBox(wxString textToAdd)
{
t_DataText->AppendText(textToAdd);
}
void dataPanel::ClearTextBox()
{
t_DataText->Clear();
}
void dataPanel::SaveRawOutput()
{
std::ofstream stream;
stream.open(get_desktop_path(1) + "\\output.txt");
if (!stream)
{
t_DataText->AppendText("Error saving the file!");
}
else
{
t_DataText->AppendText("File saved to: " + get_desktop_path(2) + "\\output.txt");
stream << static_cast<std::string>(t_DataText->GetValue());
}
stream.close();
}
std::string dataPanel::get_desktop_path(int slash)
{
TCHAR desktopPath[MAX_PATH];
if (SHGetFolderPath(NULL, CSIDL_DESKTOP, NULL, 0, desktopPath) != S_OK) {
t_DataText->AppendText("Error in getting desktop path");
}
std::wstring desktopPathW(desktopPath);
std::string desktopPathA(desktopPathW.begin(), desktopPathW.end());
std::string cleanDesktop;
for (char c : desktopPathA) {
if (c == '\\') {
cleanDesktop += "\\\\";
}
else {
cleanDesktop += c;
}
}
if (slash == 1)
{
return cleanDesktop;
}
else
{
return desktopPathA;
}
}