c#Windwosmedia控件使用探索(3)

来源:互联网 发布:厦门大学软件学院分数 编辑:程序博客网 时间:2024/04/29 12:15
 播放列表类:
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections;
  4. using System.Text;
  5. using System.IO;
  6. using System.Runtime.Serialization;
  7. using System.Runtime.Serialization.Formatters.Binary;
  8. namespace 谢飞的专属播放器
  9. {
  10.     /// <summary>
  11.     /// 播放列表
  12.     /// </summary>
  13.     [Serializable]
  14.    public class MyDocument
  15.     {
  16.         public Hashtable mylist = new Hashtable();
  17.         /// <summary>
  18.         /// 得到所有列表的标题
  19.         /// </summary>
  20.         /// <returns></returns>
  21.         public List<string> getListTitle()
  22.         {
  23.             if (mylist == null)
  24.             {
  25.                 return null;
  26.             }
  27.             List<string> title = new List<string>();
  28.             foreach (DictionaryEntry de in mylist)
  29.             {
  30.                 title.Add((string)de.Key);
  31.             }
  32.             return title;
  33.         }
  34.         /// <summary>
  35.         /// 得到制定标题下的详细内容
  36.         /// </summary>
  37.         /// <param name="title"></param>
  38.         /// <returns></returns>
  39.         public List<string> getDetailsByTitle(string title)
  40.         {
  41.             if (mylist == null)
  42.             {
  43.                 return null;
  44.             }
  45.             if (mylist.ContainsKey(title))
  46.             {
  47.                 foreach (DictionaryEntry de in mylist)
  48.                 {
  49.                     if (((string)de.Key).Equals(title))
  50.                     {
  51.                         return (List<string>)de.Value;
  52.                     }
  53.                 }
  54.             }
  55.             return null;
  56.         }
  57.         /// <summary>
  58.         /// 删除播放列表
  59.         /// </summary>
  60.         /// <param name="title"></param>
  61.         /// <returns></returns>
  62.        public bool deleteTitle(string title)
  63.        {
  64.            try
  65.            {
  66.                mylist.Remove(title);
  67.                return true;
  68.            }
  69.            catch (Exception ex)
  70.            {
  71.                return false;
  72.            }
  73.        }
  74.         /// <summary>
  75.         /// 删除制定列表的指定内容
  76.         /// </summary>
  77.         /// <param name="title"></param>
  78.         /// <param name="value"></param>
  79.         /// <returns></returns>
  80.        public bool deleteDetails(string title, string value)
  81.        {
  82.            foreach (DictionaryEntry de in mylist)
  83.            {
  84.                if (((string)de.Key).Equals(title))
  85.                {
  86.                    List<string> list = (List<string>)de.Value;
  87.                    list.Remove(value);
  88.                    mylist.Remove(title);
  89.                    mylist.Add(title, list);
  90.                    return true;
  91.                }
  92.            }
  93.            return false;
  94.        }
  95.     }
  96.     /// <summary>
  97.     /// 播放列表
  98.     /// </summary>
  99.     public class playlist
  100.     {
  101.         private string name;
  102.         private List<string> details;
  103.         public string getName()
  104.         {
  105.             return this.name;
  106.         }
  107.         public List<string> getDetails()
  108.         {
  109.             return this.details;
  110.         }
  111.         public void setName(string name)
  112.         {
  113.             this.name = name;
  114.         }
  115.         public void setDetails(List<string> details)
  116.         {
  117.             this.details = details;
  118.         }
  119.     }
  120. }

原创粉丝点击