using System;
using System.Windows.Forms;
using System.IO;
using GoodLuck.Properties;

namespace GoodLuck
{
    public partial class Options : Form
    {
        private Main m_main = null;
        public Options(Main main)
        {
            InitializeComponent();
            m_main = main;
        }
       

        private void win_Load(object sender, EventArgs e)
        {  
            System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(Application.StartupPath + "\\Luck\\");
            FileInfo[] ff = di.GetFiles("*.jpg");
            for (int i = 0; i < ff.Length; i++)//数组循环
            {
                string str = ff[i].ToString();
                string[] s = str.Split('.');//去掉扩展名
                listBoxOutput.Items.Add(s[0]);
            }
            comboBoxItems.Items.Clear();
            string strPrizes = Settings.Default.Prize;
            string[] strPs = strPrizes.Split('/');
            foreach (string s in strPs)
                comboBoxItems.Items.Add(s);     
        }

        private void comboBoxItems_SelectedIndexChanged(object sender, EventArgs e)
        {
            string msg = comboBoxItems.SelectedItem as string;
            this.m_main.UpdateTitle(msg);
        }

        private void listBoxOutput_DoubleClick(object sender, EventArgs e)
        {
            listBoxOutput.Items.Clear();
            System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(Application.StartupPath + "\\Luck\\");
            FileInfo[] ff = di.GetFiles("*.jpg");
            for (int i = 0; i < ff.Length; i++) 
            {
                string str = ff[i].ToString();
                string[] s = str.Split('.');//去掉扩展名
                listBoxOutput.Items.Add(s[0]);
            }
        }

        private void buttonHideTitle_Click(object sender, EventArgs e)
        {
            if (m_main.FormBorderStyle == FormBorderStyle.None)
                m_main.FormBorderStyle = FormBorderStyle.Sizable;
            else
                m_main.FormBorderStyle = FormBorderStyle.None;
        }

        private void clearToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(Application.StartupPath + "\\Luck\\");
            FileInfo[] ff = di.GetFiles("*.jpg");
            foreach (FileInfo fi in ff)
                fi.Delete();
            listBoxOutput.Items.Clear();
            m_main.ReloadUsers();
        }
    }
}
