Subversion Repositories spk

Rev

Rev 1 | 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:
29
		DropFileDialog(CyStringList *files)
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;
75
			 CyStringList	*m_lFiles;
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
			{
83
				this->ComboType->Items->Add(SystemStringFromCyString(GetFileTypeString(i)));
84
				this->ComboUnsure->Items->Add(SystemStringFromCyString(GetFileTypeString(i)));
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();
94
			for ( SStringList *str = m_lFiles->Head(); str; str = str->next )
95
			{
96
				ListViewItem ^item = gcnew ListViewItem(SystemStringFromCyString(str->str));
97
				int type = str->data.GetToken(" ", 1, 1).ToInt();
98
				if ( type == -1 )
99
					item->SubItems->Add("Unsure");
100
				else
101
					item->SubItems->Add(SystemStringFromCyString(GetFileTypeString(type)));
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 )
130
					m_lFiles->Remove(CyStringFromSystemString(item->Text), false);
131
			}
132
		}
133
 
134
		void ApplyTypes()
135
		{
136
			if ( this->ComboType->SelectedIndex == 0 )
137
			{
138
				SStringList *str = m_lFiles->Head();
139
				while ( str )
140
				{
141
					SStringList *next = str->next;
142
 
143
					int type = str->data.GetToken(" ", 1, 1).ToInt();
144
					if ( type == -1 ) // unsure
145
					{
146
						if ( this->ComboUnsure->SelectedIndex == 0 )
147
							str->remove = true;
148
						else
149
							str->data = CyString::Number(this->ComboUnsure->SelectedIndex - 1);
150
					}
151
					str = next;
152
				}
153
 
154
				m_lFiles->RemoveMarked();
155
			}
156
			else
157
			{
158
				for ( SStringList *str = m_lFiles->Head(); str; str = str->next )
159
					str->data = CyString::Number(this->ComboType->SelectedIndex - 1);
160
			}
161
		}
162
 
163
		/// <summary>
164
		/// Required designer variable.
165
		/// </summary>
166
		System::ComponentModel::Container ^components;
167
 
168
#pragma region Windows Form Designer generated code
169
		/// <summary>
170
		/// Required method for Designer support - do not modify
171
		/// the contents of this method with the code editor.
172
		/// </summary>
173
		void InitializeComponent(void)
174
		{
175
			this->label1 = (gcnew System::Windows::Forms::Label());
176
			this->ComboType = (gcnew System::Windows::Forms::ComboBox());
177
			this->LabUnsure = (gcnew System::Windows::Forms::Label());
178
			this->ComboUnsure = (gcnew System::Windows::Forms::ComboBox());
179
			this->button1 = (gcnew System::Windows::Forms::Button());
180
			this->button2 = (gcnew System::Windows::Forms::Button());
181
			this->button3 = (gcnew System::Windows::Forms::Button());
182
			this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
183
			this->listView1 = (gcnew System::Windows::Forms::ListView());
184
			this->ColumnFile = (gcnew System::Windows::Forms::ColumnHeader());
185
			this->ColumnType = (gcnew System::Windows::Forms::ColumnHeader());
186
			this->panel1 = (gcnew System::Windows::Forms::Panel());
187
			this->groupBox1->SuspendLayout();
188
			this->panel1->SuspendLayout();
189
			this->SuspendLayout();
190
			// 
191
			// label1
192
			// 
193
			this->label1->AutoSize = true;
194
			this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
195
				static_cast<System::Byte>(0)));
196
			this->label1->Location = System::Drawing::Point(12, 4);
197
			this->label1->Name = L"label1";
198
			this->label1->Size = System::Drawing::Size(78, 16);
199
			this->label1->TabIndex = 0;
200
			this->label1->Text = L"File Type:";
201
			// 
202
			// ComboType
203
			// 
204
			this->ComboType->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
205
			this->ComboType->FormattingEnabled = true;
206
			this->ComboType->Location = System::Drawing::Point(123, 3);
207
			this->ComboType->MaxDropDownItems = 20;
208
			this->ComboType->Name = L"ComboType";
209
			this->ComboType->Size = System::Drawing::Size(371, 21);
210
			this->ComboType->TabIndex = 1;
211
			this->ComboType->SelectedIndexChanged += gcnew System::EventHandler(this, &DropFileDialog::ComboType_SelectedIndexChanged);
212
			// 
213
			// LabUnsure
214
			// 
215
			this->LabUnsure->AutoSize = true;
216
			this->LabUnsure->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
217
				static_cast<System::Byte>(0)));
218
			this->LabUnsure->Location = System::Drawing::Point(12, 31);
219
			this->LabUnsure->Name = L"LabUnsure";
220
			this->LabUnsure->Size = System::Drawing::Size(103, 16);
221
			this->LabUnsure->TabIndex = 2;
222
			this->LabUnsure->Text = L"If unsure, use:";
223
			// 
224
			// ComboUnsure
225
			// 
226
			this->ComboUnsure->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
227
			this->ComboUnsure->FormattingEnabled = true;
228
			this->ComboUnsure->Location = System::Drawing::Point(123, 28);
229
			this->ComboUnsure->MaxDropDownItems = 20;
230
			this->ComboUnsure->Name = L"ComboUnsure";
231
			this->ComboUnsure->Size = System::Drawing::Size(371, 21);
232
			this->ComboUnsure->TabIndex = 3;
233
			// 
234
			// button1
235
			// 
236
			this->button1->Location = System::Drawing::Point(12, 59);
237
			this->button1->Name = L"button1";
238
			this->button1->Size = System::Drawing::Size(103, 23);
239
			this->button1->TabIndex = 4;
240
			this->button1->Text = L"Details >>>";
241
			this->button1->UseVisualStyleBackColor = true;
242
			this->button1->Click += gcnew System::EventHandler(this, &DropFileDialog::button1_Click);
243
			// 
244
			// button2
245
			// 
246
			this->button2->DialogResult = System::Windows::Forms::DialogResult::OK;
247
			this->button2->Location = System::Drawing::Point(405, 59);
248
			this->button2->Name = L"button2";
249
			this->button2->Size = System::Drawing::Size(89, 23);
250
			this->button2->TabIndex = 5;
251
			this->button2->Text = L"Add File(s)";
252
			this->button2->UseVisualStyleBackColor = true;
253
			// 
254
			// button3
255
			// 
256
			this->button3->DialogResult = System::Windows::Forms::DialogResult::Cancel;
257
			this->button3->Location = System::Drawing::Point(324, 59);
258
			this->button3->Name = L"button3";
259
			this->button3->Size = System::Drawing::Size(75, 23);
260
			this->button3->TabIndex = 6;
261
			this->button3->Text = L"Cancel";
262
			this->button3->UseVisualStyleBackColor = true;
263
			// 
264
			// groupBox1
265
			// 
266
			this->groupBox1->AutoSizeMode = System::Windows::Forms::AutoSizeMode::GrowAndShrink;
267
			this->groupBox1->Controls->Add(this->listView1);
268
			this->groupBox1->Dock = System::Windows::Forms::DockStyle::Fill;
269
			this->groupBox1->Location = System::Drawing::Point(0, 90);
270
			this->groupBox1->Name = L"groupBox1";
271
			this->groupBox1->Size = System::Drawing::Size(506, 150);
272
			this->groupBox1->TabIndex = 7;
273
			this->groupBox1->TabStop = false;
274
			this->groupBox1->Text = L"Files";
275
			// 
276
			// listView1
277
			// 
278
			this->listView1->CheckBoxes = true;
279
			this->listView1->Columns->AddRange(gcnew cli::array< System::Windows::Forms::ColumnHeader^  >(2) {this->ColumnFile, this->ColumnType});
280
			this->listView1->Dock = System::Windows::Forms::DockStyle::Fill;
281
			this->listView1->FullRowSelect = true;
282
			this->listView1->Location = System::Drawing::Point(3, 16);
283
			this->listView1->Name = L"listView1";
284
			this->listView1->Size = System::Drawing::Size(500, 131);
285
			this->listView1->TabIndex = 0;
286
			this->listView1->UseCompatibleStateImageBehavior = false;
287
			this->listView1->View = System::Windows::Forms::View::Details;
288
			// 
289
			// ColumnFile
290
			// 
291
			this->ColumnFile->Text = L"File";
292
			// 
293
			// ColumnType
294
			// 
295
			this->ColumnType->Text = L"Type";
296
			// 
297
			// panel1
298
			// 
299
			this->panel1->Controls->Add(this->button3);
300
			this->panel1->Controls->Add(this->button2);
301
			this->panel1->Controls->Add(this->button1);
302
			this->panel1->Controls->Add(this->ComboUnsure);
303
			this->panel1->Controls->Add(this->LabUnsure);
304
			this->panel1->Controls->Add(this->ComboType);
305
			this->panel1->Controls->Add(this->label1);
306
			this->panel1->Dock = System::Windows::Forms::DockStyle::Top;
307
			this->panel1->Location = System::Drawing::Point(0, 0);
308
			this->panel1->Name = L"panel1";
309
			this->panel1->Size = System::Drawing::Size(506, 90);
310
			this->panel1->TabIndex = 8;
311
			// 
312
			// DropFileDialog
313
			// 
314
			this->AcceptButton = this->button2;
315
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
316
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
317
			this->CancelButton = this->button3;
318
			this->ClientSize = System::Drawing::Size(506, 240);
319
			this->ControlBox = false;
320
			this->Controls->Add(this->groupBox1);
321
			this->Controls->Add(this->panel1);
322
			this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedDialog;
323
			this->Name = L"DropFileDialog";
324
			this->ShowIcon = false;
325
			this->ShowInTaskbar = false;
326
			this->SizeGripStyle = System::Windows::Forms::SizeGripStyle::Hide;
327
			this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
328
			this->Text = L"Add Dropped Files";
329
			this->FormClosing += gcnew System::Windows::Forms::FormClosingEventHandler(this, &DropFileDialog::DropFileDialog_FormClosing);
330
			this->groupBox1->ResumeLayout(false);
331
			this->panel1->ResumeLayout(false);
332
			this->panel1->PerformLayout();
333
			this->ResumeLayout(false);
334
 
335
		}
336
#pragma endregion
337
	private: System::Void ComboType_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
338
				 if ( this->ComboType->SelectedIndex == 0 )
339
					 this->ComboUnsure->Enabled = true;
340
				 else
341
					 this->ComboUnsure->Enabled = false;
342
			 }
343
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
344
			 m_bOpen = !m_bOpen;
345
			 this->UpdateDisplay();
346
		 }
347
private: System::Void DropFileDialog_FormClosing(System::Object^  sender, System::Windows::Forms::FormClosingEventArgs^  e) {
348
			 this->RemoveUncheckedFiles();
349
			 this->ApplyTypes();
350
		 }
351
};
352
}