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;
using DevExpress;
using DevExpress.XtraBars.Ribbon;
using DevExpress.LookAndFeel;
using DevExpress.XtraBars.Docking;
using System.Xml;

namespace Mutation
{
    public partial class Settings : Form
    {
        public Settings()
        {
            InitializeComponent();
        }

        private void Settings_Load(object sender, EventArgs e)
        {
            try
            {
                XmlTextReader xr = new XmlTextReader(Application.StartupPath + "\\Settings.xml");
                while (xr.Read())
                {
                    switch (xr.Name)
                    {
                        case "MainMenu":
                            {
                                textEdit1.Text = xr.ReadElementString();
                                textEdit2.Text = xr.ReadElementString();
                                textEdit3.Text = xr.ReadElementString();
                                break;
                            }
                    }
                }
                xr.Close();
            }
            catch { }
        }

        private void Settings_FormClosing(object sender, FormClosingEventArgs e)
        {
            XmlTextWriter xw = new XmlTextWriter(Application.StartupPath + "\\Settings.xml", null);
            xw.WriteStartDocument();
            xw.WriteStartElement("Settings");
            xw.WriteElementString("MainMenu", textEdit1.Text);
            xw.WriteElementString("Shared", textEdit2.Text);
            xw.WriteElementString("SingleplayerShared", textEdit3.Text);
            xw.WriteEndElement();
            xw.Close();
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "mainmenu.map (mainmenu.map)|mainmenu.map";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                textEdit1.Text = ofd.FileName;
            }
        }

        private void simpleButton2_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "shared.map (shared.map)|shared.map";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                textEdit2.Text = ofd.FileName;
            }
        }

        private void simpleButton3_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "single_player_shared.map (single_player_shared.map)|single_player_shared.map";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                textEdit3.Text = ofd.FileName;
            }
        }
    }
}
