コード例 #1
0
        public Form1()
        {
            InitializeComponent();
            wmp.PlayStateChange += new AxWMPLib._WMPOCXEvents_PlayStateChangeEventHandler(player_PlayStateChange);
            wmp.Visible          = false;

            rootDir  = System.Environment.GetFolderPath(System.Environment.SpecialFolder.UserProfile);
            rootDir += "\\PlayerForSleep";
            System.IO.Directory.CreateDirectory(rootDir);
            rootDir += "\\ListPlayLists.lpl";

            lpl = new ListPlayList();

            if (!loadSetting())
            {
                nudHour.Value = h = 1;
                nudMin.Value  = m = 30;
                nudSec.Value  = s = 0;

                cbWillStop.Checked = true;
                cbEndMusic.Checked = true;
                cbRandom.Checked   = true;
                cbExit.Checked     = true;
                lpl.lPlayList.Add(new PlayList("Новй плейлист"));
            }
            else
            {
                while (tcListsMusic.TabPages.Count != 0)
                {
                    tcListsMusic.TabPages.RemoveAt(0);                                     // удаляем существующие табы
                }
                for (int intList = 0; intList < lpl.lPlayList.Count; intList++)
                {
                    resetTab(intList);
                }
                nowPlayIndex       = lpl.iMusic;
                nowPlayList        = lpl.iPlayList;
                nudHour.Value      = h = lpl.lPlayList[nowPlayList].h;
                nudMin.Value       = m = lpl.lPlayList[nowPlayList].m;
                nudSec.Value       = s = lpl.lPlayList[nowPlayList].s;
                nudVolume.Value    = lpl.lPlayList[nowPlayList].volume;
                cbWillStop.Checked = lpl.lPlayList[nowPlayList].pauseAfter;
                cbEndMusic.Checked = lpl.lPlayList[nowPlayList].pauseAfterEndMusic;
                cbRandom.Checked   = lpl.lPlayList[nowPlayList].randomPlay;
                cbExit.Checked     = lpl.lPlayList[nowPlayList].exitAfter;

                playCurrentMusic();
            }
            this.WindowState = FormWindowState.Minimized;
        }
コード例 #2
0
// .. изменение текста таба

        private bool loadSetting()
        {
            FileInfo fi1 = new FileInfo(rootDir);

            if (!fi1.Exists)
            {
                return(false);
            }

            BinaryFormatter formatter = new BinaryFormatter();

            using (FileStream fs = new FileStream(rootDir, FileMode.OpenOrCreate))
            {
                lpl = (ListPlayList)formatter.Deserialize(fs);
            }

            return(true);
        }