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 System.IO;

namespace Grovewood
{
    public partial class IRC_Options : Form
    {
        public IRC_Options()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (File.Exists("./xml/Master.xml") == false)
            {
                Form1.MakeMaster();
            }

            UpdateMaster();
        }

        private void IRC_Options_Load(object sender, EventArgs e)
        {
            if ((File.Exists("./xml/Master.xml") == true) && (xml.GetXML("./xml/Master.xml", "IRC_Server") != "null"))
            {
                //load the details
                string CampaignFile = "./xml/Master.xml";
                txtSvr.Text = xml.GetXML(CampaignFile, "IRC_Server");
                txtPort.Text = xml.GetXML(CampaignFile, "IRC_Port");
                txtChan.Text = xml.GetXML(CampaignFile, "IRC_Channel");
            }
        }

        private void UpdateMaster()
        {
            xml.UpdateXML("./xml/Master.xml", "IRC_Server", txtSvr.Text);
            xml.UpdateXML("./xml/Master.xml", "IRC_Port", txtPort.Text);
            xml.UpdateXML("./xml/Master.xml", "IRC_Channel", txtChan.Text);
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
