Subversion Repositories spk

Rev

Rev 161 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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 PluginManager {
12
 
13
	/// <summary>
14
	/// Summary for DownloadPackageList
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 DownloadPackageList : public System::Windows::Forms::Form
23
	{
24
	public:
162 cycrow 25
		DownloadPackageList(CPackages *p, Utils::CStringList *servers);
1 cycrow 26
 
75 cycrow 27
		void NextServer();
28
		void Finished();
29
		void ExtractWebData(String ^data);
1 cycrow 30
 
31
	protected:
32
		/// <summary>
33
		/// Clean up any resources being used.
34
		/// </summary>
35
		~DownloadPackageList()
36
		{
37
			if (components)
38
			{
39
				delete components;
40
			}
41
		}
42
 
43
	private:
44
		int			  m_iServerPos;
45
		CPackages	 *m_pPackages;
162 cycrow 46
		Utils::CStringList *m_pServers;
47
		Utils::String *_pCurrentServer;
1 cycrow 48
	private: System::Windows::Forms::ProgressBar^  progressBar1;
49
	private: System::Windows::Forms::Label^  label1;
50
	private: System::Windows::Forms::Label^  label2;
51
	private: System::Windows::Forms::Panel^  panel1;
52
	private: System::Windows::Forms::Panel^  panel2;
53
	private: System::Windows::Forms::Label^  label3;
54
	private: System::Windows::Forms::Label^  label4;
55
private: System::ComponentModel::BackgroundWorker^  backgroundWorker1;
56
	private: System::Windows::Forms::Panel^  panel3;
57
	private: System::Windows::Forms::Label^  label5;
58
	private: System::Windows::Forms::Label^  label6;
59
 
60
		/// <summary>
61
		/// Required designer variable.
62
		/// </summary>
63
		System::ComponentModel::Container ^components;
64
 
65
#pragma region Windows Form Designer generated code
66
		/// <summary>
67
		/// Required method for Designer support - do not modify
68
		/// the contents of this method with the code editor.
69
		/// </summary>
70
		void InitializeComponent(void)
71
		{
72
			this->progressBar1 = (gcnew System::Windows::Forms::ProgressBar());
73
			this->label1 = (gcnew System::Windows::Forms::Label());
74
			this->label2 = (gcnew System::Windows::Forms::Label());
75
			this->panel1 = (gcnew System::Windows::Forms::Panel());
76
			this->panel2 = (gcnew System::Windows::Forms::Panel());
77
			this->label3 = (gcnew System::Windows::Forms::Label());
78
			this->label4 = (gcnew System::Windows::Forms::Label());
79
			this->backgroundWorker1 = (gcnew System::ComponentModel::BackgroundWorker());
80
			this->panel3 = (gcnew System::Windows::Forms::Panel());
81
			this->label5 = (gcnew System::Windows::Forms::Label());
82
			this->label6 = (gcnew System::Windows::Forms::Label());
83
			this->panel1->SuspendLayout();
84
			this->panel2->SuspendLayout();
85
			this->panel3->SuspendLayout();
86
			this->SuspendLayout();
87
			// 
88
			// progressBar1
89
			// 
90
			this->progressBar1->Dock = System::Windows::Forms::DockStyle::Bottom;
91
			this->progressBar1->Location = System::Drawing::Point(5, 109);
92
			this->progressBar1->Name = L"progressBar1";
93
			this->progressBar1->Size = System::Drawing::Size(475, 23);
94
			this->progressBar1->Style = System::Windows::Forms::ProgressBarStyle::Marquee;
95
			this->progressBar1->TabIndex = 0;
96
			// 
97
			// label1
98
			// 
99
			this->label1->Dock = System::Windows::Forms::DockStyle::Left;
100
			this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
101
				static_cast<System::Byte>(0)));
102
			this->label1->Location = System::Drawing::Point(5, 5);
103
			this->label1->Name = L"label1";
104
			this->label1->Size = System::Drawing::Size(125, 20);
105
			this->label1->TabIndex = 1;
106
			this->label1->Text = L"Server:";
107
			this->label1->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;
108
			// 
109
			// label2
110
			// 
111
			this->label2->Dock = System::Windows::Forms::DockStyle::Fill;
112
			this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Italic, System::Drawing::GraphicsUnit::Point, 
113
				static_cast<System::Byte>(0)));
114
			this->label2->Location = System::Drawing::Point(130, 5);
115
			this->label2->Name = L"label2";
116
			this->label2->Size = System::Drawing::Size(340, 20);
117
			this->label2->TabIndex = 2;
118
			this->label2->Text = L"1/1";
119
			this->label2->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;
120
			// 
121
			// panel1
122
			// 
123
			this->panel1->Controls->Add(this->label2);
124
			this->panel1->Controls->Add(this->label1);
125
			this->panel1->Dock = System::Windows::Forms::DockStyle::Top;
126
			this->panel1->Location = System::Drawing::Point(5, 5);
127
			this->panel1->Name = L"panel1";
128
			this->panel1->Padding = System::Windows::Forms::Padding(5);
129
			this->panel1->Size = System::Drawing::Size(475, 30);
130
			this->panel1->TabIndex = 3;
131
			// 
132
			// panel2
133
			// 
134
			this->panel2->Controls->Add(this->label3);
135
			this->panel2->Controls->Add(this->label4);
136
			this->panel2->Dock = System::Windows::Forms::DockStyle::Top;
137
			this->panel2->Location = System::Drawing::Point(5, 35);
138
			this->panel2->Name = L"panel2";
139
			this->panel2->Padding = System::Windows::Forms::Padding(5);
140
			this->panel2->Size = System::Drawing::Size(475, 30);
141
			this->panel2->TabIndex = 4;
142
			// 
143
			// label3
144
			// 
145
			this->label3->Dock = System::Windows::Forms::DockStyle::Fill;
146
			this->label3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Italic, System::Drawing::GraphicsUnit::Point, 
147
				static_cast<System::Byte>(0)));
148
			this->label3->Location = System::Drawing::Point(130, 5);
149
			this->label3->Name = L"label3";
150
			this->label3->Size = System::Drawing::Size(340, 20);
151
			this->label3->TabIndex = 2;
152
			this->label3->Text = L"http://";
153
			this->label3->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;
154
			// 
155
			// label4
156
			// 
157
			this->label4->Dock = System::Windows::Forms::DockStyle::Left;
158
			this->label4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
159
				static_cast<System::Byte>(0)));
160
			this->label4->Location = System::Drawing::Point(5, 5);
161
			this->label4->Name = L"label4";
162
			this->label4->Size = System::Drawing::Size(125, 20);
163
			this->label4->TabIndex = 1;
164
			this->label4->Text = L"Address:";
165
			this->label4->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;
166
			// 
167
			// backgroundWorker1
168
			// 
169
			this->backgroundWorker1->WorkerReportsProgress = true;
170
			this->backgroundWorker1->WorkerSupportsCancellation = true;
171
			this->backgroundWorker1->DoWork += gcnew System::ComponentModel::DoWorkEventHandler(this, &DownloadPackageList::backgroundWorker1_DoWork);
172
			this->backgroundWorker1->RunWorkerCompleted += gcnew System::ComponentModel::RunWorkerCompletedEventHandler(this, &DownloadPackageList::backgroundWorker1_RunWorkerCompleted);
173
			// 
174
			// panel3
175
			// 
176
			this->panel3->Controls->Add(this->label5);
177
			this->panel3->Controls->Add(this->label6);
178
			this->panel3->Dock = System::Windows::Forms::DockStyle::Top;
179
			this->panel3->Location = System::Drawing::Point(5, 65);
180
			this->panel3->Name = L"panel3";
181
			this->panel3->Padding = System::Windows::Forms::Padding(5);
182
			this->panel3->Size = System::Drawing::Size(475, 30);
183
			this->panel3->TabIndex = 5;
184
			// 
185
			// label5
186
			// 
187
			this->label5->Dock = System::Windows::Forms::DockStyle::Fill;
188
			this->label5->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Italic, System::Drawing::GraphicsUnit::Point, 
189
				static_cast<System::Byte>(0)));
190
			this->label5->Location = System::Drawing::Point(130, 5);
191
			this->label5->Name = L"label5";
192
			this->label5->Size = System::Drawing::Size(340, 20);
193
			this->label5->TabIndex = 2;
194
			this->label5->Text = L"0";
195
			this->label5->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;
196
			// 
197
			// label6
198
			// 
199
			this->label6->Dock = System::Windows::Forms::DockStyle::Left;
200
			this->label6->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
201
				static_cast<System::Byte>(0)));
202
			this->label6->Location = System::Drawing::Point(5, 5);
203
			this->label6->Name = L"label6";
204
			this->label6->Size = System::Drawing::Size(125, 20);
205
			this->label6->TabIndex = 1;
206
			this->label6->Text = L"Packages:";
207
			this->label6->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;
208
			// 
209
			// DownloadPackageList
210
			// 
211
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
212
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
213
			this->ClientSize = System::Drawing::Size(485, 137);
214
			this->Controls->Add(this->panel3);
215
			this->Controls->Add(this->panel2);
216
			this->Controls->Add(this->panel1);
217
			this->Controls->Add(this->progressBar1);
218
			this->MaximizeBox = false;
219
			this->MinimizeBox = false;
220
			this->Name = L"DownloadPackageList";
221
			this->Padding = System::Windows::Forms::Padding(5);
222
			this->ShowIcon = false;
223
			this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
224
			this->Text = L"Download Package List";
225
			this->Load += gcnew System::EventHandler(this, &DownloadPackageList::DownloadPackageList_Load);
226
			this->panel1->ResumeLayout(false);
227
			this->panel2->ResumeLayout(false);
228
			this->panel3->ResumeLayout(false);
229
			this->ResumeLayout(false);
230
 
231
		}
232
#pragma endregion
233
	private: System::Void DownloadPackageList_Load(System::Object^  sender, System::EventArgs^  e) {
234
				 this->NextServer();
235
			 }
236
private: System::Void backgroundWorker1_DoWork(System::Object^  sender, System::ComponentModel::DoWorkEventArgs^  e) {
162 cycrow 237
			 String ^url = _US(*_pCurrentServer) + "/xpackagedata.dat";
1 cycrow 238
			 int error = CheckWebFileExists(url);
239
 
240
			 if ( backgroundWorker1->CancellationPending )
241
				 return;
242
 
243
			 if ( error == CONNECTERROR_NONE )
244
			 {
245
				 String ^data = ReadDataFromWeb(url);
246
				 if ( data )
247
					 this->ExtractWebData(data);
248
			 }
249
		 }
250
private: System::Void backgroundWorker1_RunWorkerCompleted(System::Object^  sender, System::ComponentModel::RunWorkerCompletedEventArgs^  e) {
251
			 // update the package list
161 cycrow 252
			 this->label5->Text = Convert::ToString(m_pPackages->getAvailablePackageList()->size());
1 cycrow 253
 
254
			 // do next server
255
			 this->NextServer();
256
		 }
257
};
258
}