Subversion Repositories spk

Rev

Details | 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
using namespace System::IO;
10
 
11
namespace PluginManager {
12
 
13
	/// <summary>
14
	/// Summary for FileLog
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 FileLog : public System::Windows::Forms::Form
23
	{
24
	public:
25
		FileLog(void)
26
		{
27
			InitializeComponent();
28
 
29
			this->columnHeader3 = (gcnew System::Windows::Forms::ColumnHeader());
30
			this->columnHeader3->Text = L"Status";
31
			this->listView1->Columns->Add(columnHeader3);
32
		}
33
 
34
		void AddItem(String ^file, String ^status, String ^date)
35
		{
36
			ListViewItem ^item = gcnew ListViewItem((!date) ? "" : date);
37
			item->SubItems->Add(file);
38
			item->SubItems->Add(status);
39
			this->listView1->Items->Add(item);
40
		}
41
 
42
	protected:
43
		/// <summary>
44
		/// Clean up any resources being used.
45
		/// </summary>
46
		~FileLog()
47
		{
48
			if (components)
49
			{
50
				delete components;
51
			}
52
		}
53
	private: System::Windows::Forms::Panel^  panel1;
54
	protected: 
55
	private: System::Windows::Forms::Button^  button3;
56
	private: System::Windows::Forms::Button^  button2;
57
	private: System::Windows::Forms::Button^  button1;
58
	private: System::Windows::Forms::ListView^  listView1;
59
	private: System::Windows::Forms::ColumnHeader^  columnHeader1;
60
	private: System::Windows::Forms::ColumnHeader^  columnHeader2;
61
	private: System::Windows::Forms::ColumnHeader^  columnHeader3;
62
 
63
	private:
64
		/// <summary>
65
		/// Required designer variable.
66
		/// </summary>
67
		System::ComponentModel::Container ^components;
68
 
69
#pragma region Windows Form Designer generated code
70
		/// <summary>
71
		/// Required method for Designer support - do not modify
72
		/// the contents of this method with the code editor.
73
		/// </summary>
74
		void InitializeComponent(void)
75
		{
76
			System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(FileLog::typeid));
77
			this->panel1 = (gcnew System::Windows::Forms::Panel());
78
			this->button2 = (gcnew System::Windows::Forms::Button());
79
			this->button1 = (gcnew System::Windows::Forms::Button());
80
			this->listView1 = (gcnew System::Windows::Forms::ListView());
81
			this->columnHeader1 = (gcnew System::Windows::Forms::ColumnHeader());
82
			this->columnHeader2 = (gcnew System::Windows::Forms::ColumnHeader());
83
			this->button3 = (gcnew System::Windows::Forms::Button());
84
			this->panel1->SuspendLayout();
85
			this->SuspendLayout();
86
			// 
87
			// panel1
88
			// 
89
			this->panel1->Controls->Add(this->button3);
90
			this->panel1->Controls->Add(this->button2);
91
			this->panel1->Controls->Add(this->button1);
92
			this->panel1->Dock = System::Windows::Forms::DockStyle::Bottom;
93
			this->panel1->Location = System::Drawing::Point(5, 323);
94
			this->panel1->Name = L"panel1";
95
			this->panel1->Padding = System::Windows::Forms::Padding(5);
96
			this->panel1->Size = System::Drawing::Size(437, 34);
97
			this->panel1->TabIndex = 0;
98
			// 
99
			// button2
100
			// 
101
			this->button2->Dock = System::Windows::Forms::DockStyle::Left;
102
			this->button2->Location = System::Drawing::Point(5, 5);
103
			this->button2->Name = L"button2";
104
			this->button2->Size = System::Drawing::Size(75, 24);
105
			this->button2->TabIndex = 1;
106
			this->button2->Text = L"Export";
107
			this->button2->UseVisualStyleBackColor = true;
108
			this->button2->Click += gcnew System::EventHandler(this, &FileLog::button2_Click);
109
			// 
110
			// button1
111
			// 
112
			this->button1->DialogResult = System::Windows::Forms::DialogResult::OK;
113
			this->button1->Dock = System::Windows::Forms::DockStyle::Right;
114
			this->button1->Location = System::Drawing::Point(343, 5);
115
			this->button1->Name = L"button1";
116
			this->button1->Size = System::Drawing::Size(89, 24);
117
			this->button1->TabIndex = 0;
118
			this->button1->Text = L"Close";
119
			this->button1->UseVisualStyleBackColor = true;
120
			this->button1->Click += gcnew System::EventHandler(this, &FileLog::button1_Click);
121
			// 
122
			// listView1
123
			// 
124
			this->listView1->Columns->AddRange(gcnew cli::array< System::Windows::Forms::ColumnHeader^  >(2) {this->columnHeader1, this->columnHeader2});
125
			this->listView1->Dock = System::Windows::Forms::DockStyle::Fill;
126
			this->listView1->FullRowSelect = true;
127
			this->listView1->HeaderStyle = System::Windows::Forms::ColumnHeaderStyle::Nonclickable;
128
			this->listView1->Location = System::Drawing::Point(5, 5);
129
			this->listView1->MultiSelect = false;
130
			this->listView1->Name = L"listView1";
131
			this->listView1->Size = System::Drawing::Size(437, 318);
132
			this->listView1->TabIndex = 1;
133
			this->listView1->UseCompatibleStateImageBehavior = false;
134
			this->listView1->View = System::Windows::Forms::View::Details;
135
			// 
136
			// columnHeader1
137
			// 
138
			this->columnHeader1->Text = L"Time";
139
			// 
140
			// columnHeader2
141
			// 
142
			this->columnHeader2->Text = L"File";
143
			// 
144
			// button3
145
			// 
146
			this->button3->DialogResult = System::Windows::Forms::DialogResult::Cancel;
147
			this->button3->Dock = System::Windows::Forms::DockStyle::Right;
148
			this->button3->Location = System::Drawing::Point(268, 5);
149
			this->button3->Name = L"button3";
150
			this->button3->Size = System::Drawing::Size(75, 24);
151
			this->button3->TabIndex = 2;
152
			this->button3->Text = L"Clear Log";
153
			this->button3->UseVisualStyleBackColor = true;
154
			// 
155
			// FileLog
156
			// 
157
			this->AcceptButton = this->button1;
158
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
159
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
160
			this->CancelButton = this->button3;
161
			this->ClientSize = System::Drawing::Size(447, 362);
162
			this->Controls->Add(this->listView1);
163
			this->Controls->Add(this->panel1);
164
			this->Icon = (cli::safe_cast<System::Drawing::Icon^  >(resources->GetObject(L"$this.Icon")));
165
			this->MinimizeBox = false;
166
			this->Name = L"FileLog";
167
			this->Padding = System::Windows::Forms::Padding(5);
168
			this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
169
			this->Text = L"View File Log";
170
			this->Load += gcnew System::EventHandler(this, &FileLog::FileLog_Load);
171
			this->panel1->ResumeLayout(false);
172
			this->ResumeLayout(false);
173
 
174
		}
175
#pragma endregion
176
private: System::Void FileLog_Load(System::Object^  sender, System::EventArgs^  e) {
177
			this->listView1->AutoResizeColumns(ColumnHeaderAutoResizeStyle::HeaderSize);
178
		 }
179
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
180
			 Close();
181
		 }
182
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
183
			SaveFileDialog ^ofd = gcnew SaveFileDialog();
184
			ofd->Filter = "Log Files (*.log)|*.log";
185
			ofd->FilterIndex = 1;
186
			ofd->RestoreDirectory = true;
187
			ofd->AddExtension =  true;
188
			ofd->Title = "Select the file to save file log to";
189
			if ( ofd->ShowDialog(this) == Windows::Forms::DialogResult::OK )
190
			{
191
				if ( IO::File::Exists(ofd->FileName) )
192
					IO::File::Delete(ofd->FileName);
193
 
194
				StreamWriter ^sw = File::CreateText(ofd->FileName);
195
				try 
196
				{
197
					for ( int i = 0; i < this->listView1->Items->Count; i++ )
198
					{
199
						sw->WriteLine(this->listView1->Items[i]->Text + " - " + this->listView1->Items[i]->SubItems[1]->Text + " - " + this->listView1->Items[i]->SubItems[2]->Text);
200
					}
201
				}
202
				finally
203
				{
204
					if ( sw )
205
						delete (IDisposable ^)sw;
206
				}				
207
 
208
				if ( IO::File::Exists(ofd->FileName) )
209
					MessageBox::Show(this, "File log has been saved to:\n" + ofd->FileName, "File Log Saved", MessageBoxButtons::OK, MessageBoxIcon::Information);
210
				else
211
					MessageBox::Show(this, "There was an error writing file:\n" + ofd->FileName, "File Log Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
212
			}
213
		 }
214
};
215
}