Subversion Repositories spk

Rev

Rev 197 | 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
#include <spk.h>
11
 
12
#define CLOSESIZE	120
13
#define OPENSIZE	300
14
 
15
namespace SpkExplorer {
16
 
17
	/// <summary>
18
	/// Summary for DropFileDialog
19
	///
20
	/// WARNING: If you change the name of this class, you will need to change the
21
	///          'Resource File Name' property for the managed resource compiler tool
22
	///          associated with all .resx files this class depends on.  Otherwise,
23
	///          the designers will not be able to interact properly with localized
24
	///          resources associated with this form.
25
	/// </summary>
26
	public ref class DropFileDialog : public System::Windows::Forms::Form
27
	{
28
	public:
197 cycrow 29
		DropFileDialog(Utils::WStringList *files)
1 cycrow 30
		{
31
			InitializeComponent();
32
 
33
			this->AddFileTypes();
34
 
35
			m_bOpen = false;
36
			m_lFiles = files;
37
			m_iOriginalSize = CLOSESIZE;
38
			this->Height = CLOSESIZE;
39
 
40
			this->UpdateFiles();
41
			this->UpdateDisplay();
42
		}
43
 
44
	protected:
45
		/// <summary>
46
		/// Clean up any resources being used.
47
		/// </summary>
48
		~DropFileDialog()
49
		{
50
			if (components)
51
			{
52
				delete components;
53
			}
54
		}
55
	private: System::Windows::Forms::Label^  label1;
56
	private: System::Windows::Forms::ComboBox^  ComboType;
57
	private: System::Windows::Forms::Label^  LabUnsure;
58
	protected: 
59
 
60
 
61
	private: System::Windows::Forms::ComboBox^  ComboUnsure;
62
	private: System::Windows::Forms::Button^  button1;
63
	private: System::Windows::Forms::Button^  button2;
64
	private: System::Windows::Forms::Button^  button3;
65
 
66
 
67
	private:
68
		int			m_iOriginalSize;
69
	private: System::Windows::Forms::GroupBox^  groupBox1;
70
	private: System::Windows::Forms::ListView^  listView1;
71
	private: System::Windows::Forms::ColumnHeader^  ColumnFile;
72
	private: System::Windows::Forms::ColumnHeader^  ColumnType;
73
			 bool			 m_bOpen;
74
	private: System::Windows::Forms::Panel^  panel1;
197 cycrow 75
			 Utils::WStringList	*m_lFiles;
1 cycrow 76
 
77
		void AddFileTypes()
78
		{
79
			this->ComboType->Items->Add("- Automatic -");
80
			this->ComboUnsure->Items->Add("- Dont Add -");
81
			for ( int i = 0; i < FILETYPE_MAX; i++ )
82
			{
191 cycrow 83
				this->ComboType->Items->Add(_US(GetFileTypeString(i)));
84
				this->ComboUnsure->Items->Add(_US(GetFileTypeString(i)));
1 cycrow 85
			}
86
 
87
			this->ComboType->SelectedIndex = 0;
88
			this->ComboUnsure->SelectedIndex = FILETYPE_EXTRA + 1;
89
		}
90
 
91
		void UpdateFiles()
92
		{
93
			this->listView1->Items->Clear();
180 cycrow 94
			for(auto itr = m_lFiles->begin(); itr != m_lFiles->end(); itr++)
1 cycrow 95
			{
180 cycrow 96
				ListViewItem ^item = gcnew ListViewItem(_US((*itr)->str));
197 cycrow 97
				int type = (*itr)->data.token(L" ", 1).toInt();
1 cycrow 98
				if ( type == -1 )
99
					item->SubItems->Add("Unsure");
100
				else
180 cycrow 101
					item->SubItems->Add(_US(GetFileTypeString(type)));
1 cycrow 102
				this->listView1->Items->Add(item);
103
				item->Checked = true;
104
			}
105
			this->listView1->AutoResizeColumns(ColumnHeaderAutoResizeStyle::HeaderSize);
106
		}
107
 
108
		void UpdateDisplay()
109
		{
110
			 if ( !m_bOpen )
111
			 {
112
				 this->button1->Text = "Details >>>";
113
				 this->groupBox1->Hide();
114
				 this->Height = CLOSESIZE;
115
			 }
116
			 else
117
			 {
118
				 this->button1->Text = "Details <<<";
119
				 this->groupBox1->Show();
120
				 this->Height = OPENSIZE;
121
			 }
122
		}
123
 
124
		void RemoveUncheckedFiles()
125
		{
126
			for ( int i = 0; i < this->listView1->Items->Count; i++ )
127
			{
128
				ListViewItem ^item = this->listView1->Items[i];
129
				if ( !item->Checked )
224 cycrow 130
					m_lFiles->remove(_WS(item->Text), false);
1 cycrow 131
			}
132
		}
133
 
134
		void ApplyTypes()
135
		{
136
			if ( this->ComboType->SelectedIndex == 0 )
137
			{
180 cycrow 138
				auto itr = m_lFiles->begin();
139
				while (itr != m_lFiles->end())
1 cycrow 140
				{
197 cycrow 141
					int type = (*itr)->data.token(L" ", 1).toInt();
180 cycrow 142
					if (type == -1) // unsure
1 cycrow 143
					{
180 cycrow 144
						if (this->ComboUnsure->SelectedIndex == 0)
145
						{
146
							itr = m_lFiles->remove(itr);
147
							continue;
148
						}
1 cycrow 149
						else
197 cycrow 150
							(*itr)->data = Utils::WString::Number(this->ComboUnsure->SelectedIndex - 1);
1 cycrow 151
					}
180 cycrow 152
 
153
					itr++;
154
 
1 cycrow 155
				}
156
			}
157
			else
158
			{
180 cycrow 159
				for(auto itr = m_lFiles->begin(); itr != m_lFiles->end(); itr++)
197 cycrow 160
					(*itr)->data = Utils::WString::Number(this->ComboType->SelectedIndex - 1);
1 cycrow 161
			}
162
		}
163
 
164
		/// <summary>
165
		/// Required designer variable.
166
		/// </summary>
167
		System::ComponentModel::Container ^components;
168
 
169
#pragma region Windows Form Designer generated code
170
		/// <summary>
171
		/// Required method for Designer support - do not modify
172
		/// the contents of this method with the code editor.
173
		/// </summary>
174
		void InitializeComponent(void)
175
		{
176
			this->label1 = (gcnew System::Windows::Forms::Label());
177
			this->ComboType = (gcnew System::Windows::Forms::ComboBox());
178
			this->LabUnsure = (gcnew System::Windows::Forms::Label());
179
			this->ComboUnsure = (gcnew System::Windows::Forms::ComboBox());
180
			this->button1 = (gcnew System::Windows::Forms::Button());
181
			this->button2 = (gcnew System::Windows::Forms::Button());
182
			this->button3 = (gcnew System::Windows::Forms::Button());
183
			this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
184
			this->listView1 = (gcnew System::Windows::Forms::ListView());
185
			this->ColumnFile = (gcnew System::Windows::Forms::ColumnHeader());
186
			this->ColumnType = (gcnew System::Windows::Forms::ColumnHeader());
187
			this->panel1 = (gcnew System::Windows::Forms::Panel());
188
			this->groupBox1->SuspendLayout();
189
			this->panel1->SuspendLayout();
190
			this->SuspendLayout();
191
			// 
192
			// label1
193
			// 
194
			this->label1->AutoSize = true;
195
			this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
196
				static_cast<System::Byte>(0)));
197
			this->label1->Location = System::Drawing::Point(12, 4);
198
			this->label1->Name = L"label1";
199
			this->label1->Size = System::Drawing::Size(78, 16);
200
			this->label1->TabIndex = 0;
201
			this->label1->Text = L"File Type:";
202
			// 
203
			// ComboType
204
			// 
205
			this->ComboType->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
206
			this->ComboType->FormattingEnabled = true;
207
			this->ComboType->Location = System::Drawing::Point(123, 3);
208
			this->ComboType->MaxDropDownItems = 20;
209
			this->ComboType->Name = L"ComboType";
210
			this->ComboType->Size = System::Drawing::Size(371, 21);
211
			this->ComboType->TabIndex = 1;
212
			this->ComboType->SelectedIndexChanged += gcnew System::EventHandler(this, &DropFileDialog::ComboType_SelectedIndexChanged);
213
			// 
214
			// LabUnsure
215
			// 
216
			this->LabUnsure->AutoSize = true;
217
			this->LabUnsure->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
218
				static_cast<System::Byte>(0)));
219
			this->LabUnsure->Location = System::Drawing::Point(12, 31);
220
			this->LabUnsure->Name = L"LabUnsure";
221
			this->LabUnsure->Size = System::Drawing::Size(103, 16);
222
			this->LabUnsure->TabIndex = 2;
223
			this->LabUnsure->Text = L"If unsure, use:";
224
			// 
225
			// ComboUnsure
226
			// 
227
			this->ComboUnsure->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
228
			this->ComboUnsure->FormattingEnabled = true;
229
			this->ComboUnsure->Location = System::Drawing::Point(123, 28);
230
			this->ComboUnsure->MaxDropDownItems = 20;
231
			this->ComboUnsure->Name = L"ComboUnsure";
232
			this->ComboUnsure->Size = System::Drawing::Size(371, 21);
233
			this->ComboUnsure->TabIndex = 3;
234
			// 
235
			// button1
236
			// 
237
			this->button1->Location = System::Drawing::Point(12, 59);
238
			this->button1->Name = L"button1";
239
			this->button1->Size = System::Drawing::Size(103, 23);
240
			this->button1->TabIndex = 4;
241
			this->button1->Text = L"Details >>>";
242
			this->button1->UseVisualStyleBackColor = true;
243
			this->button1->Click += gcnew System::EventHandler(this, &DropFileDialog::button1_Click);
244
			// 
245
			// button2
246
			// 
247
			this->button2->DialogResult = System::Windows::Forms::DialogResult::OK;
248
			this->button2->Location = System::Drawing::Point(405, 59);
249
			this->button2->Name = L"button2";
250
			this->button2->Size = System::Drawing::Size(89, 23);
251
			this->button2->TabIndex = 5;
252
			this->button2->Text = L"Add File(s)";
253
			this->button2->UseVisualStyleBackColor = true;
254
			// 
255
			// button3
256
			// 
257
			this->button3->DialogResult = System::Windows::Forms::DialogResult::Cancel;
258
			this->button3->Location = System::Drawing::Point(324, 59);
259
			this->button3->Name = L"button3";
260
			this->button3->Size = System::Drawing::Size(75, 23);
261
			this->button3->TabIndex = 6;
262
			this->button3->Text = L"Cancel";
263
			this->button3->UseVisualStyleBackColor = true;
264
			// 
265
			// groupBox1
266
			// 
267
			this->groupBox1->AutoSizeMode = System::Windows::Forms::AutoSizeMode::GrowAndShrink;
268
			this->groupBox1->Controls->Add(this->listView1);
269
			this->groupBox1->Dock = System::Windows::Forms::DockStyle::Fill;
270
			this->groupBox1->Location = System::Drawing::Point(0, 90);
271
			this->groupBox1->Name = L"groupBox1";
272
			this->groupBox1->Size = System::Drawing::Size(506, 150);
273
			this->groupBox1->TabIndex = 7;
274
			this->groupBox1->TabStop = false;
275
			this->groupBox1->Text = L"Files";
276
			// 
277
			// listView1
278
			// 
279
			this->listView1->CheckBoxes = true;
280
			this->listView1->Columns->AddRange(gcnew cli::array< System::Windows::Forms::ColumnHeader^  >(2) {this->ColumnFile, this->ColumnType});
281
			this->listView1->Dock = System::Windows::Forms::DockStyle::Fill;
282
			this->listView1->FullRowSelect = true;
283
			this->listView1->Location = System::Drawing::Point(3, 16);
284
			this->listView1->Name = L"listView1";
285
			this->listView1->Size = System::Drawing::Size(500, 131);
286
			this->listView1->TabIndex = 0;
287
			this->listView1->UseCompatibleStateImageBehavior = false;
288
			this->listView1->View = System::Windows::Forms::View::Details;
289
			// 
290
			// ColumnFile
291
			// 
292
			this->ColumnFile->Text = L"File";
293
			// 
294
			// ColumnType
295
			// 
296
			this->ColumnType->Text = L"Type";
297
			// 
298
			// panel1
299
			// 
300
			this->panel1->Controls->Add(this->button3);
301
			this->panel1->Controls->Add(this->button2);
302
			this->panel1->Controls->Add(this->button1);
303
			this->panel1->Controls->Add(this->ComboUnsure);
304
			this->panel1->Controls->Add(this->LabUnsure);
305
			this->panel1->Controls->Add(this->ComboType);
306
			this->panel1->Controls->Add(this->label1);
307
			this->panel1->Dock = System::Windows::Forms::DockStyle::Top;
308
			this->panel1->Location = System::Drawing::Point(0, 0);
309
			this->panel1->Name = L"panel1";
310
			this->panel1->Size = System::Drawing::Size(506, 90);
311
			this->panel1->TabIndex = 8;
312
			// 
313
			// DropFileDialog
314
			// 
315
			this->AcceptButton = this->button2;
316
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
317
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
318
			this->CancelButton = this->button3;
319
			this->ClientSize = System::Drawing::Size(506, 240);
320
			this->ControlBox = false;
321
			this->Controls->Add(this->groupBox1);
322
			this->Controls->Add(this->panel1);
323
			this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedDialog;
324
			this->Name = L"DropFileDialog";
325
			this->ShowIcon = false;
326
			this->ShowInTaskbar = false;
327
			this->SizeGripStyle = System::Windows::Forms::SizeGripStyle::Hide;
328
			this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
329
			this->Text = L"Add Dropped Files";
330
			this->FormClosing += gcnew System::Windows::Forms::FormClosingEventHandler(this, &DropFileDialog::DropFileDialog_FormClosing);
331
			this->groupBox1->ResumeLayout(false);
332
			this->panel1->ResumeLayout(false);
333
			this->panel1->PerformLayout();
334
			this->ResumeLayout(false);
335
 
336
		}
337
#pragma endregion
338
	private: System::Void ComboType_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
339
				 if ( this->ComboType->SelectedIndex == 0 )
340
					 this->ComboUnsure->Enabled = true;
341
				 else
342
					 this->ComboUnsure->Enabled = false;
343
			 }
344
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
345
			 m_bOpen = !m_bOpen;
346
			 this->UpdateDisplay();
347
		 }
348
private: System::Void DropFileDialog_FormClosing(System::Object^  sender, System::Windows::Forms::FormClosingEventArgs^  e) {
349
			 this->RemoveUncheckedFiles();
350
			 this->ApplyTypes();
351
		 }
352
};
353
}