コード例 #1
0
        /// <summary>
        /// 读取xml文件
        /// 加载歌曲信息
        /// </summary>
        async private void Ini()
        {
            try
            {
                const int numOfSingle = 22;
                for (int i = numOfSingle; i > 14; i--)
                {
                    string      filename = "Assets/Song/S" + i + ".xml";
                    XmlDocument document = new XmlDocument();
                    document.LoadXml(System.IO.File.ReadAllText(filename));
                    XmlNodeList        number = document.GetElementsByTagName("number");
                    XmlNodeList        title  = document.GetElementsByTagName("title");
                    XmlNodeList        image  = document.GetElementsByTagName("image");
                    XmlNodeList        song   = document.GetElementsByTagName("song");
                    XmlNodeList        link   = document.GetElementsByTagName("link");
                    List <Models.song> songs  = new List <Models.song>();
                    for (int j = 0; j < song.Count; j++)
                    {
                        Models.song temp = new Models.song(song[j].InnerText, link[j].InnerText, image[0].InnerText);
                        songs.Add(temp);
                    }
                    Models.Album temp2 = new Models.Album(number[0].InnerText, title[0].InnerText, image[0].InnerText, songs);
                    allItems.Add(temp2);
                }
            }

            catch (Exception e)
            {
                var dialog = new MessageDialog(e.Message, "Error");

                dialog.Commands.Add(new UICommand("Yes", cmd => { }, commandId: 0));

                await dialog.ShowAsync();
            }
        }
コード例 #2
0
 /// <summary>
 /// 宽屏右侧显示歌曲列表
 /// 窄屏跳转新页面显示
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void List_ItemClick(object sender, ItemClickEventArgs e)
 {
     Models.Album item = e.ClickedItem as Models.Album;
     if (Window.Current.Bounds.Width < 800)
     {
         (Application.Current as App).navi = true;
         this.Frame.Navigate(typeof(SongListPage), item.songs);
     }
     else
     {
         (Application.Current as App).navi = false;
         Songs.Navigate(typeof(SongListPage), item.songs);
     }
 }