Blame | Last modification | View Log | RSS feed
#pragma once
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::IO;
namespace PluginManager {
/// <summary>
/// Summary for FileLog
///
/// WARNING: If you change the name of this class, you will need to change the
/// 'Resource File Name' property for the managed resource compiler tool
/// associated with all .resx files this class depends on. Otherwise,
/// the designers will not be able to interact properly with localized
/// resources associated with this form.
/// </summary>
public ref class FileLog : public System::Windows::Forms::Form
{
public:
FileLog(void)
{
InitializeComponent();
this->columnHeader3 = (gcnew System::Windows::Forms::ColumnHeader());
this->columnHeader3->Text = L"Status";
this->listView1->Columns->Add(columnHeader3);
}
void AddItem(String ^file, String ^status, String ^date)
{
ListViewItem ^item = gcnew ListViewItem((!date) ? "" : date);
item->SubItems->Add(file);
item->SubItems->Add(status);
this->listView1->Items->Add(item);
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~FileLog()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Panel^ panel1;
protected:
private: System::Windows::Forms::Button^ button3;
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::ListView^ listView1;
private: System::Windows::Forms::ColumnHeader^ columnHeader1;
private: System::Windows::Forms::ColumnHeader^ columnHeader2;
private: System::Windows::Forms::ColumnHeader^ columnHeader3;
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(FileLog::typeid));
this->panel1 = (gcnew System::Windows::Forms::Panel());
this->button2 = (gcnew System::Windows::Forms::Button());
this->button1 = (gcnew System::Windows::Forms::Button());
this->listView1 = (gcnew System::Windows::Forms::ListView());
this->columnHeader1 = (gcnew System::Windows::Forms::ColumnHeader());
this->columnHeader2 = (gcnew System::Windows::Forms::ColumnHeader());
this->button3 = (gcnew System::Windows::Forms::Button());
this->panel1->SuspendLayout();
this->SuspendLayout();
//
// panel1
//
this->panel1->Controls->Add(this->button3);
this->panel1->Controls->Add(this->button2);
this->panel1->Controls->Add(this->button1);
this->panel1->Dock = System::Windows::Forms::DockStyle::Bottom;
this->panel1->Location = System::Drawing::Point(5, 323);
this->panel1->Name = L"panel1";
this->panel1->Padding = System::Windows::Forms::Padding(5);
this->panel1->Size = System::Drawing::Size(437, 34);
this->panel1->TabIndex = 0;
//
// button2
//
this->button2->Dock = System::Windows::Forms::DockStyle::Left;
this->button2->Location = System::Drawing::Point(5, 5);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(75, 24);
this->button2->TabIndex = 1;
this->button2->Text = L"Export";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &FileLog::button2_Click);
//
// button1
//
this->button1->DialogResult = System::Windows::Forms::DialogResult::OK;
this->button1->Dock = System::Windows::Forms::DockStyle::Right;
this->button1->Location = System::Drawing::Point(343, 5);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(89, 24);
this->button1->TabIndex = 0;
this->button1->Text = L"Close";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &FileLog::button1_Click);
//
// listView1
//
this->listView1->Columns->AddRange(gcnew cli::array< System::Windows::Forms::ColumnHeader^ >(2) {this->columnHeader1, this->columnHeader2});
this->listView1->Dock = System::Windows::Forms::DockStyle::Fill;
this->listView1->FullRowSelect = true;
this->listView1->HeaderStyle = System::Windows::Forms::ColumnHeaderStyle::Nonclickable;
this->listView1->Location = System::Drawing::Point(5, 5);
this->listView1->MultiSelect = false;
this->listView1->Name = L"listView1";
this->listView1->Size = System::Drawing::Size(437, 318);
this->listView1->TabIndex = 1;
this->listView1->UseCompatibleStateImageBehavior = false;
this->listView1->View = System::Windows::Forms::View::Details;
//
// columnHeader1
//
this->columnHeader1->Text = L"Time";
//
// columnHeader2
//
this->columnHeader2->Text = L"File";
//
// button3
//
this->button3->DialogResult = System::Windows::Forms::DialogResult::Cancel;
this->button3->Dock = System::Windows::Forms::DockStyle::Right;
this->button3->Location = System::Drawing::Point(268, 5);
this->button3->Name = L"button3";
this->button3->Size = System::Drawing::Size(75, 24);
this->button3->TabIndex = 2;
this->button3->Text = L"Clear Log";
this->button3->UseVisualStyleBackColor = true;
//
// FileLog
//
this->AcceptButton = this->button1;
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->CancelButton = this->button3;
this->ClientSize = System::Drawing::Size(447, 362);
this->Controls->Add(this->listView1);
this->Controls->Add(this->panel1);
this->Icon = (cli::safe_cast<System::Drawing::Icon^ >(resources->GetObject(L"$this.Icon")));
this->MinimizeBox = false;
this->Name = L"FileLog";
this->Padding = System::Windows::Forms::Padding(5);
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
this->Text = L"View File Log";
this->Load += gcnew System::EventHandler(this, &FileLog::FileLog_Load);
this->panel1->ResumeLayout(false);
this->ResumeLayout(false);
}
#pragma endregion
private: System::Void FileLog_Load(System::Object^ sender, System::EventArgs^ e) {
this->listView1->AutoResizeColumns(ColumnHeaderAutoResizeStyle::HeaderSize);
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
Close();
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
SaveFileDialog ^ofd = gcnew SaveFileDialog();
ofd->Filter = "Log Files (*.log)|*.log";
ofd->FilterIndex = 1;
ofd->RestoreDirectory = true;
ofd->AddExtension = true;
ofd->Title = "Select the file to save file log to";
if ( ofd->ShowDialog(this) == Windows::Forms::DialogResult::OK )
{
if ( IO::File::Exists(ofd->FileName) )
IO::File::Delete(ofd->FileName);
StreamWriter ^sw = File::CreateText(ofd->FileName);
try
{
for ( int i = 0; i < this->listView1->Items->Count; i++ )
{
sw->WriteLine(this->listView1->Items[i]->Text + " - " + this->listView1->Items[i]->SubItems[1]->Text + " - " + this->listView1->Items[i]->SubItems[2]->Text);
}
}
finally
{
if ( sw )
delete (IDisposable ^)sw;
}
if ( IO::File::Exists(ofd->FileName) )
MessageBox::Show(this, "File log has been saved to:\n" + ofd->FileName, "File Log Saved", MessageBoxButtons::OK, MessageBoxIcon::Information);
else
MessageBox::Show(this, "There was an error writing file:\n" + ofd->FileName, "File Log Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
}
}
};
}