Пример #1
0
        public void PlayerClosed()
        {
            PlayerSaveObject tmp = new PlayerSaveObject();

            if (LastChatSong != null)
            {
                tmp.LastChatSong = LastChatSong;
            }
            else if (ChatPlayList.Count != 0)
            {
                tmp.LastChatSong = ChatPlayList[ChatPlayList.Count - 1];
            }

            if (LastStreamerSong != null)
            {
                tmp.LastStreamerSong = LastStreamerSong;
            }
            else if (StreamerPlaylist.Count != 0)
            {
                tmp.LastStreamerSong = StreamerPlaylist[0];
            }

            tmp.ChatPlayList     = ChatPlayList;
            tmp.StreamerPlayList = StreamerPlaylist;
            string stringConfig = JsonConvert.SerializeObject(tmp);

            using (BinaryWriter writer = new BinaryWriter(File.Create(ConfigSet.PlayerSaveFilePath)))
            {
                writer.Write(stringConfig);
            }
        }
Пример #2
0
        public void PlayerLoaded()
        {
            string stringConfig = "";

            if (!File.Exists(ConfigSet.PlayerSaveFilePath))
            {
                PlayerClosed();
            }
            using (BinaryReader reader = new BinaryReader(File.Open(ConfigSet.PlayerSaveFilePath, FileMode.OpenOrCreate)))
            {
                stringConfig = reader.ReadString();
            }
            PlayerSaveObject tmp = JsonConvert.DeserializeObject <PlayerSaveObject>(stringConfig);


            foreach (var item in tmp.StreamerPlayList)
            {
                StreamerPlaylist.Add(item);
            }
            if (StreamerPlaylist.Count != 0)
            {
                StreamerPlaylist[tmp.LastStreamerSong.Index - 1].IsSelected = true;
                LastStreamerSong = StreamerPlaylist[tmp.LastStreamerSong.Index - 1];
            }

            CurrentSong = null;
            foreach (var item in tmp.ChatPlayList)
            {
                ChatPlayList.Add(item);
            }
            if (ChatPlayList.Count != 0)
            {
                ChatPlayList[tmp.LastChatSong.Index - 1].IsSelected = true;
                LastChatSong = ChatPlayList[tmp.LastChatSong.Index - 1];
                if (LastChatSong.Index < ChatPlayList.Count)
                {
                    CurrentSong = LastChatSong;
                }
            }
            if (CurrentSong == null)
            {
                CurrentSong = LastStreamerSong;
            }
        }