using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Runtime.InteropServices;

namespace Foo.Settings
{

    /// <summary>
    /// Use this to specificy the names of each themed button
    /// </summary>
    [ComVisible(false)]
    public static class ButtonNames
    {
        public const string BUTTON_UP = "ButtonUp.ico";
        public const string BUTTON_DOWN = "ButtonDown.ico";
        public const string TOGGLE_UP = "ToggleUp.ico";
    }
    /// <summary>
    /// Button Location Interface for COM
    /// </summary>
    [Guid("CFE7FDB8-E3F0-45aa-9935-C9A8502FF7DF")]
    [InterfaceType(ComInterfaceType.InterfaceIsDual)]
    [ComVisible(true)]
    public interface IButtonIconLocation
    {
        string GetBUTTON_UP();
        string GetBUTTON_DOWN();
        string GetTOGGLE_UP();
    }
    /// <summary> 
    /// Button Theme Settings COM
    /// </summary>
    [Guid("F82358CD-8521-4d03-AFF9-352491E9A10E")]
    [InterfaceType(ComInterfaceType.InterfaceIsDual)]
    [ComVisible(true)]
    public interface IButtonThemeSetting
    {
        int Top();
        int Right();
        int Height();
        int Width();
    }
    /// <summary>
    /// Parent Class for all the Button Shared Code - *MAIN class for everthing basically*
    /// </summary>
    [ComVisible(false)]
    public class ButtonSharedCode : IButtonThemeSetting, IButtonIconLocation
    {
        private string m_RelativePath = "";
        private string m_AssemblyPath = "";
        private int m_nTop = 0;
        private int m_nRight = 0;
        private int m_nHeight = 0;
        private int m_nWidth = 0;

        /// <summary>
        /// Constructor for SharedButtonCode
        /// </summary>
        /// <param name="strRelativeLoc">relative location (folder) inside running application directory</param>
        /// <param name="nTop">Theme specific Top location for Button</param>
        /// <param name="nRight">Theme specific Right location for Button</param>
        /// <param name="nHeight">Theme specific Height of Button</param>
        /// <param name="nWidth">Theme specific Width of Button</param>
        public ButtonSharedCode(string strRelativeLoc, int nTop, int nRight, int nHeight, int nWidth)
        {
            // Theme settings are stored in the Platform Path            
            //m_AssemblyPath = Platform.InstallationSpec.PlatformPath;
            m_AssemblyPath = Platform.InstallationSpec.InstallPath;

            // Debug path 
            //m_AssemblyPath = @"C:\_ROOT_\Ooganizer\Ooganizer_1.0\Target\debug\Platform";

            m_RelativePath = strRelativeLoc;

            m_nTop = nTop;
            m_nRight = nRight;
            m_nHeight = nHeight;
            m_nWidth = nWidth;
        }

        ////
        // IButtonThemeSetting        
        ////                    
        public int Top() { return m_nTop; }
        public int Right() { return m_nRight; }
        public int Height() { return m_nHeight; }
        public int Width() { return m_nWidth; }

        ////
        // IButtonLocation        
        ////                    
        public string GetBUTTON_UP() { return (m_AssemblyPath + "\\" + m_RelativePath + "\\" + ButtonNames.BUTTON_UP); }
        public string GetBUTTON_DOWN() { return (m_AssemblyPath + "\\" + m_RelativePath + "\\" + ButtonNames.BUTTON_DOWN); }
        public string GetTOGGLE_UP() { return (m_AssemblyPath + "\\" + m_RelativePath + "\\" + ButtonNames.TOGGLE_UP); }
    }
    /// <summary>
    /// Classic Button Theme Setting
    /// </summary>
    [ComVisible(false)]
    public class ButtonClassicTheme : ButtonSharedCode
    {
        public ButtonClassicTheme() : base("Resources\\Themes\\ClassicTheme", 0, 0, 0, 0) { }
    }
    /// <summary>
    /// XP Button Theme Setting
    /// </summary>
    [ComVisible(false)]
    public class ButtonXPTheme : ButtonSharedCode
    {
        public ButtonXPTheme() : base("Resources\\Themes\\XPTheme", 1, 126, 16, 26) { }
    }
    /// <summary>
    /// Aero Button Theme Setting
    /// </summary>
    [ComVisible(false)]
    public class ButtonAeroTheme : ButtonSharedCode
    {
        //public ButtonAeroTheme() : base("Resources\\AeroTheme", 0, 129, 18, 26) { }
        public ButtonAeroTheme() : base("Resources\\Themes\\AeroTheme", 1, 126, 16, 26) { }
    }
    /// <summary>
    /// Vista No Aero Theme Setting
    /// </summary>
    [ComVisible(false)]
    public class ButtonVistaNoAeroTheme : ButtonSharedCode
    {
        public ButtonVistaNoAeroTheme() : base("Resources\\Themes\\VistaNoAeroTheme", 0, 0, 15, 28) { }
    }
    /// <summary>
    /// This class abstracts away all the settings we need for 
    /// ButtonHook to deal with themes and Buttons. (we may consider in the future
    /// to use this class to retrieve custom settings)
    /// ~this class is accessible via COM for the W32Button to work
    /// </summary>
    [Guid("9EEC54A0-77F3-4dcf-8C74-B6720437C59E")]
    [ClassInterface(ClassInterfaceType.AutoDual)]
    [ProgId("Ooganizer.ButtonThemeNIconSettingsCCW")]
    [ComVisible(true)]
    public class ButtonThemeNIconSettingsCCW
    {                
        private object m_oButtonThemeObject = null;

        public ButtonThemeNIconSettingsCCW()
        {
            switch (Foo.Platform.Env.Theme)
            {
                case Foo.Platform.Env.Themes.Classic:
                    m_oButtonThemeObject = new ButtonClassicTheme();
                    break;
                case Foo.Platform.Env.Themes.AeroTheme:
                    m_oButtonThemeObject = new ButtonAeroTheme();
                    break;
                case Foo.Platform.Env.Themes.VistaNoAero:
                    m_oButtonThemeObject = new ButtonVistaNoAeroTheme();
                    break;
                case Foo.Platform.Env.Themes.XPtheme:
                    m_oButtonThemeObject = new ButtonXPTheme();
                    break;
            }
        }
        public IButtonThemeSetting GetIButtonThemeInterface() { return (IButtonThemeSetting)m_oButtonThemeObject; }
        public IButtonIconLocation GetIButtonIconLocation() { return (IButtonIconLocation)m_oButtonThemeObject; }
    }
}
