Exemplo n.º 1
0
    /// <summary>
    /// Add a radio channel to radio group by name
    /// </summary>
    /// <param name="channel">channel to add</param>
    /// <param name="groupName">target group name</param>
    public void AddChannelToRadioGroup(Channel channel, string groupName)
    {
      RadioChannelGroup currentRadioGroup = null;
      IList<RadioChannelGroup> allRadioGroups = RadioChannelGroup.ListAll();

      // check for existing group
      foreach (RadioChannelGroup radioGroup in allRadioGroups)
      {
        if (radioGroup.GroupName == groupName)
        {
          currentRadioGroup = radioGroup;
          break;
        }
      }
      // no group found yet? then create new one
      if (currentRadioGroup == null)
      {
        currentRadioGroup = new RadioChannelGroup(groupName, allRadioGroups.Count);
        currentRadioGroup.Persist();
      }
      // add channel to group
      AddChannelToRadioGroup(channel, currentRadioGroup);
    }
    private void addToFavoritesToolStripMenuItem_Click(object sender, EventArgs e)
    {
      RadioChannelGroup group;
      ToolStripMenuItem menuItem = (ToolStripMenuItem)sender;

      if (menuItem.Tag == null)
      {
        GroupNameForm dlg = new GroupNameForm();
        dlg.IsRadio = true;

        if (dlg.ShowDialog(this) != DialogResult.OK)
        {
          return;
        }

        group = new RadioChannelGroup(dlg.GroupName, 9999);
        group.Persist();

        UpdateMenuAndTabs();
      }
      else
      {
        group = (RadioChannelGroup)menuItem.Tag;
      }

      ListView.SelectedIndexCollection indexes = listView1.SelectedIndices;
      if (indexes.Count == 0)
        return;

      TvBusinessLayer layer = new TvBusinessLayer();

      for (int i = 0; i < indexes.Count; ++i)
      {
        ListViewItem item = listView1.Items[indexes[i]];
        RadioGroupMap map = (RadioGroupMap)item.Tag;
        Channel channel = map.ReferencedChannel();
        layer.AddChannelToRadioGroup(channel, group.GroupName);
      }
    }
Exemplo n.º 3
0
    private void OnAddToFavoritesMenuItem_Click(object sender, EventArgs e)
    {
      RadioChannelGroup group;
      ToolStripMenuItem menuItem = (ToolStripMenuItem)sender;
      if (menuItem.Tag == null)
      {
        GroupNameForm dlg = new GroupNameForm();
        dlg.IsRadio = true;
        if (dlg.ShowDialog(this) != DialogResult.OK)
        {
          return;
        }
        group = new RadioChannelGroup(dlg.GroupName, 9999);
        group.Persist();

        this.RefreshContextMenu();
        this.RefreshTabs();
      }
      else
      {
        group = (RadioChannelGroup)menuItem.Tag;
      }

      ListView.SelectedIndexCollection indexes = mpListView1.SelectedIndices;
      if (indexes.Count == 0)
        return;
      TvBusinessLayer layer = new TvBusinessLayer();
      for (int i = 0; i < indexes.Count; ++i)
      {
        ListViewItem item = mpListView1.Items[indexes[i]];

        Channel channel = (Channel)item.Tag;
        layer.AddChannelToRadioGroup(channel, group);

        string groupString = item.SubItems[1].Text;
        if (groupString == string.Empty)
        {
          groupString = group.GroupName;
        }
        else
        {
          groupString += ", " + group.GroupName;
        }

        item.SubItems[1].Text = groupString;
      }

      mpListView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
    }
Exemplo n.º 4
0
    private void mpButtonAddGroup_Click(object sender, EventArgs e)
    {
      GroupNameForm dlg = new GroupNameForm();
      dlg.IsRadio = true;

      if (dlg.ShowDialog(this) != DialogResult.OK)
      {
        return;
      }

      RadioChannelGroup group = new RadioChannelGroup(dlg.GroupName, 9999);
      group.Persist();

      this.RefreshContextMenu();
      this.RefreshTabs();
    }
Exemplo n.º 5
0
    private void OnAddToFavoritesMenuItem_Click(object sender, EventArgs e)
    {
      RadioChannelGroup group;
      ToolStripMenuItem menuItem = (ToolStripMenuItem)sender;
      if (menuItem.Tag == null)
      {
        GroupNameForm dlg = new GroupNameForm();
        dlg.IsRadio = true;
        if (dlg.ShowDialog(this) != DialogResult.OK)
        {
          return;
        }
        group = new RadioChannelGroup(dlg.GroupName, 9999);
        group.Persist();

        this.RefreshContextMenu();
        this.RefreshTabs();
      }
      else
      {
        group = (RadioChannelGroup)menuItem.Tag;
      }

      ListView.SelectedIndexCollection indexes = mpListView1.SelectedIndices;
      if (indexes.Count == 0)
        return;
      TvBusinessLayer layer = new TvBusinessLayer();
      for (int i = 0; i < indexes.Count; ++i)
      {
        ListViewItem item = mpListView1.Items[indexes[i]];

        Channel channel = (Channel)item.Tag;
        layer.AddChannelToRadioGroup(channel, group);

        IList<string> groups = channel.GroupNames;
        List<string> groupNames = new List<string>();
        foreach (string groupName in groups)
        {
          if (groupName != TvConstants.TvGroupNames.AllChannels &&
              groupName != TvConstants.RadioGroupNames.AllChannels)
          {
            //Don't add "All Channels"
            groupNames.Add(groupName);
          }
        }
        item.SubItems[2].Text = String.Join(", ", groupNames.ToArray());
      }

      mpListView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
    }