public ChannelGroup CreateGroup(string groupName) { SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (ChannelGroup)); sb.AddConstraint(Operator.Like, "groupName", "%" + groupName + "%"); SqlStatement stmt = sb.GetStatement(true); IList<ChannelGroup> groups = ObjectFactory.GetCollection<ChannelGroup>(stmt.Execute()); ChannelGroup group; int GroupSelected = 0; if (groups.Count == 0) { group = new ChannelGroup(groupName, 9999); group.Persist(); } else { for (int i = 0; i < groups.Count; ++i) { if (groups[i].GroupName == groupName) { GroupSelected = i; } } group = groups[GroupSelected]; } return group; }
private void addToFavoritesToolStripMenuItem_Click(object sender, EventArgs e) { ChannelGroup group; ToolStripMenuItem menuItem = (ToolStripMenuItem)sender; if (menuItem.Tag == null) { GroupNameForm dlg = new GroupNameForm(); if (dlg.ShowDialog(this) != DialogResult.OK) { return; } group = new ChannelGroup(dlg.GroupName, 9999); group.Persist(); UpdateMenuAndTabs(); } else { group = (ChannelGroup)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]]; GroupMap map = (GroupMap)item.Tag; Channel channel = map.ReferencedChannel(); layer.AddChannelToGroup(channel, group.GroupName); } }
private void OnAddToFavoritesMenuItem_Click(object sender, EventArgs e) { ChannelGroup group; ToolStripMenuItem menuItem = (ToolStripMenuItem)sender; if (menuItem.Tag == null) { GroupNameForm dlg = new GroupNameForm(); if (dlg.ShowDialog(this) != DialogResult.OK) { return; } group = new ChannelGroup(dlg.GroupName, 9999); group.Persist(); this.RefreshContextMenu(); this.RefreshTabs(); } else { group = (ChannelGroup)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.AddChannelToGroup(channel, group.GroupName); 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); }
private void mpButtonAddGroup_Click(object sender, EventArgs e) { GroupNameForm dlg = new GroupNameForm(); if (dlg.ShowDialog(this) != DialogResult.OK) { return; } ChannelGroup group = new ChannelGroup(dlg.GroupName, 9999); group.Persist(); this.RefreshContextMenu(); this.RefreshTabs(); }
private void OnAddToFavoritesMenuItem_Click(object sender, EventArgs e) { ChannelGroup group; ToolStripMenuItem menuItem = (ToolStripMenuItem)sender; if (menuItem.Tag == null) { GroupNameForm dlg = new GroupNameForm(); if (dlg.ShowDialog(this) != DialogResult.OK) { return; } group = new ChannelGroup(dlg.GroupName, 9999); group.Persist(); this.RefreshContextMenu(); this.RefreshTabs(); } else { group = (ChannelGroup)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.AddChannelToGroup(channel, group.GroupName); 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); }