1 |
cycrow |
1 |
#pragma once
|
|
|
2 |
|
|
|
3 |
using namespace System;
|
|
|
4 |
using namespace System::ComponentModel;
|
|
|
5 |
using namespace System::Collections;
|
|
|
6 |
using namespace System::Windows::Forms;
|
|
|
7 |
using namespace System::Data;
|
|
|
8 |
using namespace System::Drawing;
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
namespace Creator {
|
|
|
12 |
|
|
|
13 |
/// <summary>
|
|
|
14 |
/// Summary for SaveDialog
|
|
|
15 |
///
|
|
|
16 |
/// WARNING: If you change the name of this class, you will need to change the
|
|
|
17 |
/// 'Resource File Name' property for the managed resource compiler tool
|
|
|
18 |
/// associated with all .resx files this class depends on. Otherwise,
|
|
|
19 |
/// the designers will not be able to interact properly with localized
|
|
|
20 |
/// resources associated with this form.
|
|
|
21 |
/// </summary>
|
|
|
22 |
public ref class SaveDialog : public System::Windows::Forms::Form
|
|
|
23 |
{
|
|
|
24 |
public:
|
|
|
25 |
SaveDialog(CBaseFile *package, String ^saveFile)
|
|
|
26 |
{
|
|
|
27 |
InitializeComponent();
|
|
|
28 |
|
|
|
29 |
m_iStatus = 0;
|
|
|
30 |
m_pMultiPackage = NULL;
|
|
|
31 |
m_pPackage = package;
|
|
|
32 |
m_sSaveFile = saveFile;
|
|
|
33 |
m_pInfo = new CProgressInfoDone;
|
47 |
cycrow |
34 |
m_pInfo2 = new CProgressInfoDone;
|
1 |
cycrow |
35 |
}
|
|
|
36 |
|
|
|
37 |
SaveDialog(CMultiSpkFile *package, String ^saveFile)
|
|
|
38 |
{
|
|
|
39 |
InitializeComponent();
|
|
|
40 |
|
|
|
41 |
m_iStatus = 0;
|
|
|
42 |
m_pMultiPackage = package;
|
|
|
43 |
m_pPackage = NULL;
|
|
|
44 |
m_sSaveFile = saveFile;
|
|
|
45 |
m_pInfo = new CProgressInfoDone;
|
47 |
cycrow |
46 |
m_pInfo2 = new CProgressInfoDone;
|
1 |
cycrow |
47 |
}
|
|
|
48 |
|
|
|
49 |
protected:
|
|
|
50 |
/// <summary>
|
|
|
51 |
/// Clean up any resources being used.
|
|
|
52 |
/// </summary>
|
|
|
53 |
~SaveDialog()
|
|
|
54 |
{
|
|
|
55 |
if (components)
|
|
|
56 |
{
|
|
|
57 |
delete components;
|
|
|
58 |
}
|
|
|
59 |
delete m_pInfo;
|
47 |
cycrow |
60 |
delete m_pInfo2;
|
1 |
cycrow |
61 |
}
|
|
|
62 |
|
|
|
63 |
int m_iStatus;
|
|
|
64 |
CBaseFile *m_pPackage;
|
|
|
65 |
CMultiSpkFile *m_pMultiPackage;
|
|
|
66 |
CProgressInfoDone *m_pInfo;
|
47 |
cycrow |
67 |
CProgressInfoDone *m_pInfo2;
|
1 |
cycrow |
68 |
String ^m_sSaveFile;
|
|
|
69 |
private: System::Windows::Forms::Timer^ timer1;
|
|
|
70 |
protected:
|
|
|
71 |
private: System::Windows::Forms::Label^ label1;
|
|
|
72 |
private: System::Windows::Forms::Panel^ panel1;
|
|
|
73 |
private: System::Windows::Forms::Label^ label2;
|
|
|
74 |
private: System::Windows::Forms::Panel^ PanelCompress;
|
|
|
75 |
private: System::Windows::Forms::Label^ LabelCompress;
|
|
|
76 |
private: System::Windows::Forms::Label^ LabelStatus;
|
|
|
77 |
private: System::ComponentModel::BackgroundWorker^ backgroundWorker1;
|
|
|
78 |
private: System::Windows::Forms::ProgressBar^ progressBar1;
|
|
|
79 |
private: System::Windows::Forms::Panel^ panel2;
|
47 |
cycrow |
80 |
private: System::Windows::Forms::Panel^ panel3;
|
|
|
81 |
private: System::Windows::Forms::ProgressBar^ progressBar2;
|
1 |
cycrow |
82 |
private: System::ComponentModel::IContainer^ components;
|
|
|
83 |
|
|
|
84 |
private:
|
|
|
85 |
/// <summary>
|
|
|
86 |
/// Required designer variable.
|
|
|
87 |
/// </summary>
|
|
|
88 |
|
|
|
89 |
|
|
|
90 |
#pragma region Windows Form Designer generated code
|
|
|
91 |
/// <summary>
|
|
|
92 |
/// Required method for Designer support - do not modify
|
|
|
93 |
/// the contents of this method with the code editor.
|
|
|
94 |
/// </summary>
|
|
|
95 |
void InitializeComponent(void)
|
|
|
96 |
{
|
|
|
97 |
this->components = (gcnew System::ComponentModel::Container());
|
|
|
98 |
this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));
|
|
|
99 |
this->label1 = (gcnew System::Windows::Forms::Label());
|
|
|
100 |
this->panel1 = (gcnew System::Windows::Forms::Panel());
|
|
|
101 |
this->label2 = (gcnew System::Windows::Forms::Label());
|
|
|
102 |
this->PanelCompress = (gcnew System::Windows::Forms::Panel());
|
|
|
103 |
this->LabelCompress = (gcnew System::Windows::Forms::Label());
|
|
|
104 |
this->LabelStatus = (gcnew System::Windows::Forms::Label());
|
|
|
105 |
this->backgroundWorker1 = (gcnew System::ComponentModel::BackgroundWorker());
|
|
|
106 |
this->progressBar1 = (gcnew System::Windows::Forms::ProgressBar());
|
|
|
107 |
this->panel2 = (gcnew System::Windows::Forms::Panel());
|
47 |
cycrow |
108 |
this->panel3 = (gcnew System::Windows::Forms::Panel());
|
|
|
109 |
this->progressBar2 = (gcnew System::Windows::Forms::ProgressBar());
|
1 |
cycrow |
110 |
this->panel1->SuspendLayout();
|
|
|
111 |
this->PanelCompress->SuspendLayout();
|
|
|
112 |
this->panel2->SuspendLayout();
|
47 |
cycrow |
113 |
this->panel3->SuspendLayout();
|
1 |
cycrow |
114 |
this->SuspendLayout();
|
|
|
115 |
//
|
|
|
116 |
// timer1
|
|
|
117 |
//
|
|
|
118 |
this->timer1->Enabled = true;
|
|
|
119 |
this->timer1->Interval = 1000;
|
|
|
120 |
this->timer1->Tick += gcnew System::EventHandler(this, &SaveDialog::timer1_Tick);
|
|
|
121 |
//
|
|
|
122 |
// label1
|
|
|
123 |
//
|
|
|
124 |
this->label1->Dock = System::Windows::Forms::DockStyle::Left;
|
|
|
125 |
this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
|
|
|
126 |
static_cast<System::Byte>(0)));
|
|
|
127 |
this->label1->Location = System::Drawing::Point(0, 0);
|
|
|
128 |
this->label1->Name = L"label1";
|
|
|
129 |
this->label1->Size = System::Drawing::Size(163, 28);
|
|
|
130 |
this->label1->TabIndex = 0;
|
|
|
131 |
this->label1->Text = L"Saving:";
|
|
|
132 |
this->label1->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;
|
|
|
133 |
this->label1->UseWaitCursor = true;
|
|
|
134 |
//
|
|
|
135 |
// panel1
|
|
|
136 |
//
|
|
|
137 |
this->panel1->Controls->Add(this->label2);
|
|
|
138 |
this->panel1->Controls->Add(this->label1);
|
|
|
139 |
this->panel1->Dock = System::Windows::Forms::DockStyle::Top;
|
|
|
140 |
this->panel1->Location = System::Drawing::Point(0, 0);
|
|
|
141 |
this->panel1->Name = L"panel1";
|
47 |
cycrow |
142 |
this->panel1->Size = System::Drawing::Size(636, 28);
|
1 |
cycrow |
143 |
this->panel1->TabIndex = 1;
|
|
|
144 |
this->panel1->UseWaitCursor = true;
|
|
|
145 |
//
|
|
|
146 |
// label2
|
|
|
147 |
//
|
|
|
148 |
this->label2->Dock = System::Windows::Forms::DockStyle::Fill;
|
|
|
149 |
this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Italic, System::Drawing::GraphicsUnit::Point,
|
|
|
150 |
static_cast<System::Byte>(0)));
|
|
|
151 |
this->label2->Location = System::Drawing::Point(163, 0);
|
|
|
152 |
this->label2->Name = L"label2";
|
47 |
cycrow |
153 |
this->label2->Size = System::Drawing::Size(473, 28);
|
1 |
cycrow |
154 |
this->label2->TabIndex = 1;
|
|
|
155 |
this->label2->Text = L"filename";
|
|
|
156 |
this->label2->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;
|
|
|
157 |
this->label2->UseWaitCursor = true;
|
|
|
158 |
//
|
|
|
159 |
// PanelCompress
|
|
|
160 |
//
|
|
|
161 |
this->PanelCompress->Controls->Add(this->LabelCompress);
|
|
|
162 |
this->PanelCompress->Controls->Add(this->LabelStatus);
|
|
|
163 |
this->PanelCompress->Dock = System::Windows::Forms::DockStyle::Top;
|
|
|
164 |
this->PanelCompress->Location = System::Drawing::Point(0, 28);
|
|
|
165 |
this->PanelCompress->Name = L"PanelCompress";
|
47 |
cycrow |
166 |
this->PanelCompress->Size = System::Drawing::Size(636, 28);
|
1 |
cycrow |
167 |
this->PanelCompress->TabIndex = 2;
|
|
|
168 |
this->PanelCompress->UseWaitCursor = true;
|
|
|
169 |
//
|
|
|
170 |
// LabelCompress
|
|
|
171 |
//
|
|
|
172 |
this->LabelCompress->Dock = System::Windows::Forms::DockStyle::Fill;
|
|
|
173 |
this->LabelCompress->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Italic, System::Drawing::GraphicsUnit::Point,
|
|
|
174 |
static_cast<System::Byte>(0)));
|
|
|
175 |
this->LabelCompress->Location = System::Drawing::Point(163, 0);
|
|
|
176 |
this->LabelCompress->Name = L"LabelCompress";
|
47 |
cycrow |
177 |
this->LabelCompress->Size = System::Drawing::Size(473, 28);
|
1 |
cycrow |
178 |
this->LabelCompress->TabIndex = 1;
|
|
|
179 |
this->LabelCompress->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;
|
|
|
180 |
this->LabelCompress->UseWaitCursor = true;
|
|
|
181 |
//
|
|
|
182 |
// LabelStatus
|
|
|
183 |
//
|
|
|
184 |
this->LabelStatus->Dock = System::Windows::Forms::DockStyle::Left;
|
|
|
185 |
this->LabelStatus->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
|
|
|
186 |
static_cast<System::Byte>(0)));
|
|
|
187 |
this->LabelStatus->Location = System::Drawing::Point(0, 0);
|
|
|
188 |
this->LabelStatus->Name = L"LabelStatus";
|
|
|
189 |
this->LabelStatus->Size = System::Drawing::Size(163, 28);
|
|
|
190 |
this->LabelStatus->TabIndex = 0;
|
|
|
191 |
this->LabelStatus->Text = L"Compressing";
|
|
|
192 |
this->LabelStatus->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;
|
|
|
193 |
this->LabelStatus->UseWaitCursor = true;
|
|
|
194 |
//
|
|
|
195 |
// backgroundWorker1
|
|
|
196 |
//
|
|
|
197 |
this->backgroundWorker1->DoWork += gcnew System::ComponentModel::DoWorkEventHandler(this, &SaveDialog::backgroundWorker1_DoWork);
|
|
|
198 |
this->backgroundWorker1->RunWorkerCompleted += gcnew System::ComponentModel::RunWorkerCompletedEventHandler(this, &SaveDialog::backgroundWorker1_RunWorkerCompleted);
|
|
|
199 |
//
|
|
|
200 |
// progressBar1
|
|
|
201 |
//
|
|
|
202 |
this->progressBar1->Dock = System::Windows::Forms::DockStyle::Fill;
|
|
|
203 |
this->progressBar1->Location = System::Drawing::Point(10, 10);
|
|
|
204 |
this->progressBar1->Maximum = 1000;
|
|
|
205 |
this->progressBar1->Name = L"progressBar1";
|
47 |
cycrow |
206 |
this->progressBar1->Size = System::Drawing::Size(616, 25);
|
1 |
cycrow |
207 |
this->progressBar1->TabIndex = 5;
|
|
|
208 |
this->progressBar1->UseWaitCursor = true;
|
|
|
209 |
//
|
|
|
210 |
// panel2
|
|
|
211 |
//
|
|
|
212 |
this->panel2->Controls->Add(this->progressBar1);
|
|
|
213 |
this->panel2->Dock = System::Windows::Forms::DockStyle::Top;
|
|
|
214 |
this->panel2->Location = System::Drawing::Point(0, 56);
|
|
|
215 |
this->panel2->Name = L"panel2";
|
|
|
216 |
this->panel2->Padding = System::Windows::Forms::Padding(10);
|
47 |
cycrow |
217 |
this->panel2->Size = System::Drawing::Size(636, 45);
|
1 |
cycrow |
218 |
this->panel2->TabIndex = 6;
|
|
|
219 |
this->panel2->UseWaitCursor = true;
|
|
|
220 |
//
|
47 |
cycrow |
221 |
// panel3
|
|
|
222 |
//
|
|
|
223 |
this->panel3->Controls->Add(this->progressBar2);
|
|
|
224 |
this->panel3->Dock = System::Windows::Forms::DockStyle::Top;
|
|
|
225 |
this->panel3->Location = System::Drawing::Point(0, 101);
|
|
|
226 |
this->panel3->Name = L"panel3";
|
|
|
227 |
this->panel3->Padding = System::Windows::Forms::Padding(10);
|
|
|
228 |
this->panel3->Size = System::Drawing::Size(636, 45);
|
|
|
229 |
this->panel3->TabIndex = 7;
|
|
|
230 |
this->panel3->UseWaitCursor = true;
|
|
|
231 |
//
|
|
|
232 |
// progressBar2
|
|
|
233 |
//
|
|
|
234 |
this->progressBar2->Dock = System::Windows::Forms::DockStyle::Fill;
|
|
|
235 |
this->progressBar2->Location = System::Drawing::Point(10, 10);
|
|
|
236 |
this->progressBar2->Maximum = 1000;
|
|
|
237 |
this->progressBar2->Name = L"progressBar2";
|
|
|
238 |
this->progressBar2->Size = System::Drawing::Size(616, 25);
|
|
|
239 |
this->progressBar2->TabIndex = 5;
|
|
|
240 |
this->progressBar2->UseWaitCursor = true;
|
|
|
241 |
//
|
1 |
cycrow |
242 |
// SaveDialog
|
|
|
243 |
//
|
|
|
244 |
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
|
|
|
245 |
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
|
47 |
cycrow |
246 |
this->ClientSize = System::Drawing::Size(636, 147);
|
1 |
cycrow |
247 |
this->ControlBox = false;
|
47 |
cycrow |
248 |
this->Controls->Add(this->panel3);
|
1 |
cycrow |
249 |
this->Controls->Add(this->panel2);
|
|
|
250 |
this->Controls->Add(this->PanelCompress);
|
|
|
251 |
this->Controls->Add(this->panel1);
|
|
|
252 |
this->Name = L"SaveDialog";
|
|
|
253 |
this->ShowInTaskbar = false;
|
|
|
254 |
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
|
|
|
255 |
this->Text = L"Saving Package";
|
|
|
256 |
this->UseWaitCursor = true;
|
|
|
257 |
this->Load += gcnew System::EventHandler(this, &SaveDialog::SaveDialog_Load);
|
|
|
258 |
this->panel1->ResumeLayout(false);
|
|
|
259 |
this->PanelCompress->ResumeLayout(false);
|
|
|
260 |
this->panel2->ResumeLayout(false);
|
47 |
cycrow |
261 |
this->panel3->ResumeLayout(false);
|
1 |
cycrow |
262 |
this->ResumeLayout(false);
|
|
|
263 |
|
|
|
264 |
}
|
|
|
265 |
#pragma endregion
|
|
|
266 |
private: System::Void SaveDialog_Load(System::Object^ sender, System::EventArgs^ e) {
|
|
|
267 |
this->label2->Text = m_sSaveFile;
|
|
|
268 |
m_pInfo->SetDone(0);
|
47 |
cycrow |
269 |
m_pInfo2->SetDone(0);
|
1 |
cycrow |
270 |
this->backgroundWorker1->RunWorkerAsync();
|
|
|
271 |
}
|
|
|
272 |
private: System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e) {
|
|
|
273 |
if ( m_iStatus == 0 )
|
|
|
274 |
{
|
|
|
275 |
if ( (m_pPackage && m_pInfo->GetFile()) || (m_pMultiPackage && m_pInfo->GetPackage()) )
|
|
|
276 |
{
|
|
|
277 |
if ( m_pPackage )
|
197 |
cycrow |
278 |
LabelCompress->Text = _US(m_pInfo->GetFile()->getNameDirectory(m_pPackage) + L" (" + SPK::GetSizeString(m_pInfo->GetDone()) + L"/" + SPK::GetSizeString(m_pInfo->GetMax()) + L")");
|
1 |
cycrow |
279 |
else if ( m_pMultiPackage )
|
219 |
cycrow |
280 |
LabelCompress->Text = _US(m_pInfo->GetPackage()->sName + L" (" + SPK::GetSizeString(m_pInfo->GetDone()) + L"/" + SPK::GetSizeString(m_pInfo->GetMax()) + L")");
|
1 |
cycrow |
281 |
this->progressBar1->Maximum = m_pInfo->GetMax();
|
|
|
282 |
if ( (int)m_pInfo->GetDone() >= this->progressBar1->Minimum )
|
|
|
283 |
{
|
|
|
284 |
if ( (int)m_pInfo->GetDone() > this->progressBar1->Maximum )
|
|
|
285 |
this->progressBar1->Value = this->progressBar1->Maximum;
|
|
|
286 |
else
|
|
|
287 |
this->progressBar1->Value = m_pInfo->GetDone();
|
|
|
288 |
}
|
|
|
289 |
}
|
|
|
290 |
else
|
|
|
291 |
LabelCompress->Text = "";
|
47 |
cycrow |
292 |
|
|
|
293 |
this->progressBar2->Maximum = m_pInfo2->GetMax();
|
|
|
294 |
if ( (int)m_pInfo2->GetDone() >= this->progressBar2->Minimum )
|
|
|
295 |
{
|
|
|
296 |
if ( (int)m_pInfo2->GetDone() > this->progressBar2->Maximum )
|
|
|
297 |
this->progressBar2->Value = this->progressBar2->Maximum;
|
|
|
298 |
else
|
|
|
299 |
this->progressBar2->Value = m_pInfo2->GetDone();
|
|
|
300 |
}
|
1 |
cycrow |
301 |
}
|
|
|
302 |
else if ( m_iStatus == 3 )
|
|
|
303 |
{
|
|
|
304 |
this->progressBar1->Style = Windows::Forms::ProgressBarStyle::Marquee;
|
|
|
305 |
LabelStatus->Text = "Writing..";
|
|
|
306 |
LabelCompress->Text = "";
|
|
|
307 |
}
|
|
|
308 |
}
|
|
|
309 |
private: System::Void backgroundWorker1_DoWork(System::Object^ sender, System::ComponentModel::DoWorkEventArgs^ e) {
|
|
|
310 |
m_iStatus = 0;
|
|
|
311 |
if ( m_pPackage )
|
|
|
312 |
{
|
175 |
cycrow |
313 |
m_pPackage->updateSigned(true);
|
47 |
cycrow |
314 |
m_pPackage->CompressAllFiles(SPKCOMPRESS_LZMA, m_pInfo, m_pInfo2);
|
1 |
cycrow |
315 |
m_iStatus = 3;
|
|
|
316 |
|
224 |
cycrow |
317 |
if ( !m_pPackage->writeFile(_WS(m_sSaveFile), m_pInfo) )
|
1 |
cycrow |
318 |
m_iStatus = 1;
|
|
|
319 |
else
|
|
|
320 |
m_iStatus = 2;
|
|
|
321 |
}
|
|
|
322 |
else if ( m_pMultiPackage )
|
|
|
323 |
{
|
|
|
324 |
m_pMultiPackage->ReadAllFilesToMemory(m_pInfo);
|
|
|
325 |
m_iStatus = 3;
|
|
|
326 |
|
224 |
cycrow |
327 |
if ( !m_pMultiPackage->writeFile(_WS(m_sSaveFile), m_pInfo) )
|
1 |
cycrow |
328 |
m_iStatus = 1;
|
|
|
329 |
else
|
|
|
330 |
m_iStatus = 2;
|
|
|
331 |
}
|
|
|
332 |
}
|
|
|
333 |
private: System::Void backgroundWorker1_RunWorkerCompleted(System::Object^ sender, System::ComponentModel::RunWorkerCompletedEventArgs^ e) {
|
|
|
334 |
this->timer1->Stop();
|
|
|
335 |
if ( m_iStatus == 1 )
|
|
|
336 |
{
|
|
|
337 |
MessageBox::Show(this, "Unable to save package\n" + m_sSaveFile, "Save Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
|
|
|
338 |
this->DialogResult = Windows::Forms::DialogResult::Cancel;
|
|
|
339 |
}
|
|
|
340 |
else
|
|
|
341 |
this->DialogResult = Windows::Forms::DialogResult::OK;
|
|
|
342 |
this->Close();
|
|
|
343 |
}
|
|
|
344 |
};
|
|
|
345 |
}
|