SourceCode/PROMS/DataLoader/frmErrors.cs
Rich 508a86a8ac Added memory usage to output
Add separate counts for Errors, Warnings and Information
2012-05-21 13:27:44 +00:00

90 lines
1.8 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace DataLoader
{
public partial class frmErrors : Form
{
private Form _MyParent;
public frmErrors(Form myParent)
{
InitializeComponent();
_MyParent = myParent;
}
private List<string> _MyMessages = new List<string>();
private int _ErrorCount = 0;
public int ErrorCount
{
get { return _ErrorCount; }
set { _ErrorCount = value; }
}
private int _WarningCount = 0;
public int WarningCount
{
get { return _WarningCount; }
set { _WarningCount = value; }
}
private int _InfoCount = 0;
public int InfoCount
{
get { return _InfoCount; }
set { _InfoCount = value; }
}
string sep = "";
public void Add(string err, MessageType messageType)
{
switch (messageType)
{
case MessageType.Information:
_InfoCount++;
break;
case MessageType.Warning:
_WarningCount++;
break;
case MessageType.Error:
_ErrorCount++;
break;
default:
break;
}
_MyMessages.Add(err);
tbErrors.SelectionStart = tbErrors.TextLength;
tbErrors.SelectedText = sep + err;
sep = "\r\n";
Show();
Application.DoEvents();
}
public void Clear()
{
tbErrors.Text = "";
sep = "";
Hide();
}
private void frmErrors_Load(object sender, EventArgs e)
{
Rectangle rec = Screen.GetWorkingArea(this);
Top = _MyParent.Top;
Left = _MyParent.Right + Width > rec.Right ? rec.Right - Width : _MyParent.Right;
}
public void Save(string path)
{
StreamWriter fs = new StreamWriter(path,false);
foreach (string txt in _MyMessages)
fs.WriteLine(txt);
fs.Close();
}
}
public enum MessageType
{
Information,
Warning,
Error
}
}