示例#1
0
文件: Form1.cs 项目: N-SPC700/AMPoo
        public static SongList parseSongs(string str, string labelname)
        {
            string[] lines     = str.Split('\n');
            bool     foundList = false;
            SongList ret       = new SongList();

            foreach (string l in lines)
            {
                if (l.StartsWith(labelname + ":"))
                {
                    foundList = true;
                    continue;
                }
                else if (l.Contains(":"))
                {
                    foundList = false;
                }

                if (foundList && l.Length > 2)
                {
                    int    number   = Convert.ToInt32(l.Substring(0, 2), 16);
                    string filePath = l.Substring(2).Trim();

                    if (ret.fileNames.Count() <= number)
                    {
                        ret.fileNames.Resize(number + 1, "");
                    }

                    ret.fileNames[number] = filePath;
                }
            }
            ret.name = labelname;
            return(ret);
        }
示例#2
0
文件: Form1.cs 项目: N-SPC700/AMPoo
        private void parseListFiles()
        {
            try
            {
                string file     = "";
                string filePath = "";
                if (listFolderPath != "")
                {
                    file = System.IO.File.ReadAllText(filePath = listFolderPath + "Addmusic_list.txt");
                }
                else if (System.IO.File.Exists(System.IO.Path.GetFullPath("Addmusic_list.txt")) == false)
                {
                    if (openListOpenFileDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                    {
                        MessageBox.Show("Quitting.");
                        Close();
                        return;
                    }
                    file = System.IO.File.ReadAllText(filePath = openListOpenFileDialog.FileName);
                }
                else
                {
                    file = System.IO.File.ReadAllText(filePath = System.IO.Path.GetFullPath("Addmusic_list.txt"));
                }

                filePath = filePath.Replace('\\', '/');

                if (filePath.LastIndexOf("/") >= 0)
                {
                    listFolderPath = filePath.Substring(0, filePath.LastIndexOf("/")) + "/";
                }

                globalSongs = SongList.parseSongs(file, "Globals");
                localSongs  = SongList.parseSongs(file, "Locals");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Quitting due to an error.\r\nHere is the message:\r\n\r\n----------------------------------------\r\n\r\n" + ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
                return;
            }

            refreshListBoxes();
        }