#region Copyright (C) 2007-2011 Team MediaPortal

/*
    Copyright (C) 2007-2011 Team MediaPortal
    http://www.team-mediaportal.com

    This file is part of MediaPortal 2

    MediaPortal 2 is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    MediaPortal 2 is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with MediaPortal 2. If not, see <http://www.gnu.org/licenses/>.
*/

#endregion

using MediaPortal.Common.Configuration.ConfigurationClasses;
using  MediaPortal.Plugins.MyTestPlugin.Settings;
using MyTestPlugin.Models;
using MediaPortal.Common;
using MediaPortal.Common.General;
using MediaPortal.Common.Logging;

using System;


namespace  MediaPortal.Plugins.MyTestPlugin.Settings.Configuration
{

    public class MySetting_BoolClass : YesNo
    {
        public override void Load()
        {
            _yes = SettingsManager.Load<MyTestPluginSettings>().MySetting_Bool;
        }

        public override void Save()
        {
            base.Save();
            MyTestPluginSettings settings = SettingsManager.Load<MyTestPluginSettings>();
            settings.MySetting_Bool = _yes;
            SettingsManager.Save(settings);
        }


    }


    public class MySetting_IntClass : NumberSelect
    {
        public override void Load()
        {
            _value = SettingsManager.Load<MyTestPluginSettings>().MySetting_Int;
        }

        public override void Save()
        {
            base.Save();
            MyTestPluginSettings settings = SettingsManager.Load<MyTestPluginSettings>();
            settings.MySetting_Int = (int)_value;
            SettingsManager.Save(settings);
        }
    }
    
    
    
    public class MySetting_StringClass : Entry
    {
      string myvalue = string.Empty;

      public override void Load()
      {
          _value = SettingsManager.Load<MyTestPluginSettings>().MySetting_String;
    
      }

      public override void Save()
      {
          base.Save();
          MyTestPluginSettings settings = SettingsManager.Load<MyTestPluginSettings>();
          settings.MySetting_String = _value;
          SettingsManager.Save(settings);

          if (_value != myvalue) //setting did change -> send a message
          {
              MyTestPluginMessaging.SendMyTestPluginMessage(MyTestPluginMessaging.MessageType.ConfigurationChanged);
              ServiceRegistration.Get<ILogger>().Debug("MySetting_StringClass:Load() Sending message at " + DateTime.Now.ToString());
          }
      }

      public override int DisplayLength
      {
          get { return 50; }
      }
    }

    public class MySetting_KeyClass : Entry
    {
        public override void Load()
        {
            _value = SettingsManager.Load<MyTestPluginSettings>().MyButton_Key;
        }

        public override void Save()
        {
            base.Save();
            MyTestPluginSettings settings = SettingsManager.Load<MyTestPluginSettings>();
            settings.MyButton_Key = _value;
            SettingsManager.Save(settings);
        }

        public override int DisplayLength
        {
            get { return 50; }
        }
    }
 
}