using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Maxim.Utility;

namespace FileLogExample
{
    public partial class Form1 : Form
    {
        FileLog fileLog = new FileLog();
        bool fileSelected = false;
        int count = 0;
        
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                fileSelected = fileLog.SelectCSVFile("fileLogExample");
                if (fileSelected)
                    MessageBox.Show("File Select successful");
                else
                    MessageBox.Show("File Select failed");
            }
            catch(System.IO.IOException ex)
            {
                MessageBox.Show(ex.Message, "File Select Failed");
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (fileSelected == true)
            {
                fileLog.WriteLine("Writing Line " + count++);
            }
        }
    }
}
