using FCOMMON;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Project
{
    public partial class fLog : fBase
    {
        public fLog()
        {
            InitializeComponent();
            FCOMMON.Pub.log.RaiseMsg += Log_RaiseMsg;
            this.FormClosed += FLog_FormClosed;
            this.KeyDown += (s1, e1) => {
                if (e1.KeyCode == Keys.Escape) this.Close();
            };
        }

        private void FLog_FormClosed(object sender, FormClosedEventArgs e)
        {
            FCOMMON.Pub.log.RaiseMsg -= Log_RaiseMsg;
        }


        private void __Load(object sender, EventArgs e)
        {
            EnsureVisibleAndUsableSize();
        }


        private void Log_RaiseMsg(DateTime LogTime, string TypeStr, string Message)
        {
            this.logTextBox1.AddMsg(TypeStr, Message);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.logTextBox1.LoadFile(FCOMMON.Pub.log.FileName, RichTextBoxStreamType.PlainText);
            this.logTextBox1.ForeColor = Color.White;
        }
    }
}
