using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing;

namespace Hex_2048
{
    public class formDebug_ExcitementLevel : Form
    {
        static formDebug_ExcitementLevel _instance = null;
        public static formDebug_ExcitementLevel instance
        {
            get { return _instance; }
        }
        //public static List<WaveOut_Mine> lstWOLoopTracks
        //{
        //    get
        //    {
        //        return formHex2048.lstWOLoopTracks;
        //    }
        //}
        //static classEventController.classEventTicket _cEventTicket_LbxResetColor = null;
        //static classEventController.classEventTicket cEventTicket_LbxResetColor
        //{
        //    get
        //    {
        //        if (_cEventTicket_LbxResetColor == null)
        //        {
        //            _cEventTicket_LbxResetColor = formHex2048.cEC.Ticket("formDebug_ExcitementLevel_LbxResetColor", 3000, tmrLbxResetColor_Tick);
        //            _cEventTicket_LbxResetColor.quit();
        //        }
        //        return _cEventTicket_LbxResetColor;
        //    }
        //}
        //static void tmrLbxResetColor_Tick(object sender, EventArgs e)
        //{
        //    //instance.lbxSongs.BackColor = System.Drawing.Color.White;

        //    instance.lbxSongs_SetColor();
        //}
        ListBox lbxSongs = new ListBox(); 
        public formDebug_ExcitementLevel()
        {
            _instance = this;

            //Controls.Add(lbxSongs);
            //lbxSongs.Dock = DockStyle.Fill;
            //lbxSongs.KeyDown += LbxSongs_KeyDown;
            //lbxSongs.MouseWheel += LbxSongs_MouseWheel;
            //lbxSongs.DoubleClick += LbxSongs_DoubleClick;


            //SizeChanged += FormDebug_ExcitementLevel_SizeChanged;
            //VisibleChanged += FormDebug_ExcitementLevel_VisibleChanged;
            //FormClosing += FormDebug_ExcitementLevel_FormClosing;

            //LocationChanged += FormDebug_ExcitementLevel_LocationChanged;

            //Activated += FormDebug_ExcitementLevel_Activated;

            Hide();

        }

        //bool bolInit = false;
        //private void FormDebug_ExcitementLevel_Activated(object sender, EventArgs e)
        //{
        //    if (!bolInit)
        //    {
        //        bolInit = true;
        //        StartUpInfo_Load();
        //    }

        //}

        //private void FormDebug_ExcitementLevel_LocationChanged(object sender, EventArgs e)
        //{
        //    ;
        //}

        //string strDebugMusicLoad_Filename
        //{
        //    get
        //    {
        //        string strPath = formHex2048.WorkingDirectory + "DebugMusicLoad.txt";
        //        return strPath;
        //    }
        //}

        //char[] chrSplitInfo = new char[] { '|' };
        //void StartUpInfo_Load()
        //{
        //    if (System.IO.File.Exists(strDebugMusicLoad_Filename))
        //    {
        //        string strLoadInfo = System.IO.File.ReadAllText(strDebugMusicLoad_Filename);
        //        string[] arrLoadInfo = strLoadInfo.Split(chrSplitInfo, StringSplitOptions.RemoveEmptyEntries);
        //        if (arrLoadInfo.Length == 4)
        //        {
        //            try
        //            {
        //                int intLocX = (int)Convert.ToInt16(arrLoadInfo[0]);
        //                int intLocY = (int)Convert.ToInt16(arrLoadInfo[1]);
        //                int intWidth = (int)Convert.ToInt16(arrLoadInfo[2]);
        //                int intHeight= (int)Convert.ToInt16(arrLoadInfo[3]);
        //                Location = new Point(intLocX, intLocY);
        //                Size = new Size(intWidth, intHeight);
        //            }
        //            catch (Exception)
        //            {

        //            }
        //        }


        //    }

        //}

        //public void StartUpInfo_Save()
        //{
        //    string strSaveInfo = Location.X.ToString() + "|" + Location.Y.ToString() + "|" + Size.Width.ToString() + "|" + Size.Height.ToString();
        //    System.IO.File.WriteAllText(strDebugMusicLoad_Filename, strSaveInfo);
        //}


        //private void FormDebug_ExcitementLevel_FormClosing(object sender, FormClosingEventArgs e)
        //{
        //    szSize_Load = Size;
        //    ptLocation_Load = Location;
        //}

        //private void LbxSongs_DoubleClick(object sender, EventArgs e)
        //{
        //formHex2048.instance.ExcitementLevel_Temp = lbxSongs.SelectedIndex - formHex2048.instance.ExcitementLevel_Base;
        //}


        //bool _bolLoop = false;
        //public bool bolLoop
        //{
        //    get { return _bolLoop; }
        //    set { _bolLoop = value; }
        //}

        //bool _bolTrack = true;
        //public bool bolTrack
        //{
        //    get { return _bolTrack; }
        //    set { _bolTrack = value; }
        //}

        //public void update()
        //{
        //    Text = (bolLoop ? "(loop)" : "")
        //             + " Base(" + formHex2048.instance.ExcitementLevel_Base + ")"
        //             + " Temp(" + formHex2048.instance.ExcitementLevel_Temp + ")"
        //             + " = [" + formHex2048.instance.ExcitementLevel + "]"
        //             + " Song:" + lstWOLoopTracks[formHex2048.instance.ExcitementLevel].Name
        //             + " current(" + formHex2048.instance.wo_Current.Name + ")"
        //             + DateTime.Now.ToUniversalTime();

        //    if (bolTrack)
        //    {
        //        int intIndexSelection = lstWOLoopTracks.IndexOf(formHex2048.instance.wo_Current);
        //        if (intIndexSelection >= 0 && intIndexSelection < lbxSongs.Items.Count)
        //            lbxSongs.SelectedIndex = intIndexSelection;
        //    }
        //}
        //private void LbxSongs_MouseWheel(object sender, MouseEventArgs e)
        //{
        //    if (e.Delta > 0)
        //        MoveSelection_Up();
        //    else
        //        MoveSelection_Down();

        //    lbxSongs_build();
        //}

        //private void LbxSongs_KeyDown(object sender, KeyEventArgs e)
        //{
        //    switch(e.KeyCode)
        //    {
        //        case Keys.Enter:
        //            {
        //                bolLoop = !bolLoop;
        //                update();
        //            }
        //            break;

        //        case Keys.Insert:
        //            {
        //                SongArray_WriteToClipboard();
        //            }
        //            break;

        //        case Keys.Down:
        //            {
        //                bolTrack = !bolTrack;
        //                lbxSongs_SetColor();
        //                cEventTicket_LbxResetColor.Reschedule();
        //            }
        //            break;
        //    }
        //}

        //static Point _ptLocation_Load = new Point(int.MinValue, int.MinValue);
        //static public Point ptLocation_Load
        //{
        //    get
        //    {
        //        if (_ptLocation_Load.X < -Screen.PrimaryScreen.Bounds.Width)
        //        {
        //            _ptLocation_Load = new Point(10, 10);
        //        }
        //        return _ptLocation_Load;
        //    }
        //    set { _ptLocation_Load = value; }
        //}

        //static Size _szSize_Load = new Size(1, 1);
        //static public Size szSize_Load

        //{
        //    get
        //    {
        //        if (_szSize_Load.Width < 10)
        //        {

        //            Size szScreen = Screen.PrimaryScreen.Bounds.Size;
        //            _szSize_Load = new Size(szScreen.Width / 4, szScreen.Height / 2);
        //        }
        //        return _szSize_Load;
        //    }
        //    set { _szSize_Load = value; }
        //}


        //void lbxSongs_SetColor()
        //{
        //    lbxSongs.BackColor = bolTrack ? System.Drawing.Color.LightBlue : System.Drawing.Color.White;
        //}

        //public static void SongArray_WriteToClipboard()
        //{
       
        //    string strCode = "\r\n\tstring[] arrSongTitles =\r\n\t\t{";

        //    for (int intSongCounter =0; intSongCounter < lstWOLoopTracks.Count; intSongCounter++)
        //    {
        //        strCode += "\r\n\t\t\t\"" + lstWOLoopTracks[intSongCounter].Name + "\"";
        //        if (intSongCounter < lstWOLoopTracks.Count - 1)
        //            strCode += ",";
        //    }

        //    strCode += "\r\n         };";
        //    Clipboard.SetText(strCode);

        //    instance.lbxSongs.BackColor = System.Drawing.Color.LightGreen;
        //    cEventTicket_LbxResetColor.Reschedule();
        //}

        //void MoveSelection_Up()
        //{
        //    if (lbxSongs.SelectedIndex >=1 && lbxSongs.SelectedIndex < lstWOLoopTracks.Count)
        //    {
        //        WaveOut_Mine woSelected = lstWOLoopTracks[lbxSongs.SelectedIndex];
        //        WaveOut_Mine woAbove = lstWOLoopTracks[lbxSongs.SelectedIndex - 1];

        //        lstWOLoopTracks[lbxSongs.SelectedIndex - 1] = woSelected;
        //        lstWOLoopTracks[lbxSongs.SelectedIndex] = woAbove;
        //        lbxSongs.SelectedIndex = lbxSongs.SelectedIndex - 1;
        //    }
        //}

        //void MoveSelection_Down()
        //{
        //    if (lbxSongs.SelectedIndex >=0 && lbxSongs.SelectedIndex < lstWOLoopTracks.Count-1)
        //    {

        //        WaveOut_Mine woSelected = lstWOLoopTracks[lbxSongs.SelectedIndex];
        //        WaveOut_Mine woBelow = lstWOLoopTracks[lbxSongs.SelectedIndex + 1];

        //        lstWOLoopTracks[lbxSongs.SelectedIndex + 1] = woSelected;
        //        lstWOLoopTracks[lbxSongs.SelectedIndex] = woBelow;
        //        lbxSongs.SelectedIndex = lbxSongs.SelectedIndex + 1;
        //    }
        //}
        //bool bolFirstAppearance = true;
        //private void FormDebug_ExcitementLevel_VisibleChanged(object sender, EventArgs e)
        //{
        //    //if (Visible && bolFirstAppearance)
        //    //{
        //    //    bolFirstAppearance = false;
        //    //    Location = ptLocation_Load;
        //    //    Size = szSize_Load;
        //    //}

        //    lbxSongs_build();
        //}

        //private void FormDebug_ExcitementLevel_SizeChanged(object sender, EventArgs e)
        //{
        //    lbxSongs_build();
        //}


        //void lbxSongs_build()
        //{
        //    int intSelected = lbxSongs.SelectedIndex;
        //    lbxSongs.Items.Clear();
        //    if (lstWOLoopTracks != null)
        //    foreach (WaveOut_Mine w in lstWOLoopTracks)
        //    {
        //        lbxSongs.Items.Add(w.Name);
        //    }
        //    lbxSongs.SelectedIndex = intSelected;
        //}

 
    }
}
