当前位置: 代码迷 >> C# >> 单例模式的应用_网络电视玲珑
  详细解决方案

单例模式的应用_网络电视玲珑

热度:78   发布时间:2016-05-05 03:11:24.0
单例模式的应用___网络电视精灵

网络电视精灵

 

 

首先创建几个基本类

 

 

 

编写节目类 属性:播出时间、时段、名称、视频路径

编写频道基类 属性:频道名称、频道节目单位置、节目列表 抽象方法:Fetch()

编写频道子类 继承“频道基类”,实现Fetch()【只写方法声明】

编写频道工厂类 方法:实现创建频道子类

 

 

 

 

 

 

 

private void tsmAddToFavor_Click(object sender, EventArgs e)
{
    //如何将电台从所有电台加载到我的电台
    TreeNode tn = tvChannel.SelectedNode;
      if (tn == null)
    {
      return;
    }
  //02.判断我的电台下是否已经存在你要加入的电台
   foreach (TreeNode child in tvChannel.Nodes[0].Nodes)
  {
    if (child.Text == tn.Text)
    {
      return;
    }
  }
    //03.真正加入节点到我的电台下
    //把当前选中的节点的Tag属性取出来,转换成ChannelBase
    ChannelBase channel = (ChannelBase)tn.Tag;
    //04.将channel对象添加到我的电台下成为我的电台的一个节点
    TreeNode node = new TreeNode();
    node.Text = channel.channelName;
    node.Tag = channel;
    tvChannel.Nodes[0].Nodes.Add(node);
    //04.将channel加入到集合中
    myManage.MyChannelList.Channellist.Add(channel);

}

private void TMenuItemDel_Click(object sender, EventArgs e)
{
    TreeNode node = tvChannel.SelectedNode;
    node.Remove();

}

 

  相关解决方案