using System;
using System.Windows.Forms;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using System.Drawing;

namespace Bil_LD
{
    public class Settings
    {
        public string MediaPath;

        #region Singleton
        private static Settings Singleton = null;

        public static Settings GetSingleton()
        {
            if (Singleton == null)
                Singleton = new Settings();

            return Singleton;
        }
        #endregion

        private Settings()
        {
            MediaPath = Application.StartupPath + @"\models\";
        }

        public static void Reset()
        {
            Singleton = new Settings();
        }


        public static void LoadSettings()
        {
            if (File.Exists("settings.xml"))
            {
                XmlSerializer s = new XmlSerializer(typeof(Settings));
                XmlTextReader reader = new XmlTextReader("settings.xml");

                Singleton = (Settings)s.Deserialize(reader);
                reader.Close();
            }
            else
                Singleton = new Settings();
        }

        public static void SaveSettings()
        {
            XmlSerializer s = new XmlSerializer(typeof(Settings));
            XmlTextWriter writer = new XmlTextWriter("settings.xml", System.Text.Encoding.UTF8);
            writer.Formatting = Formatting.Indented;
            s.Serialize(writer, Singleton);
            writer.Close();
        }
    }
}
