private void LoadChannels() { try { Cursor.Current = Cursors.WaitCursor; ChannelType channelType = (ChannelType)_channelTypeComboBox.SelectedIndex; List <Channel> channels = new List <Channel>(_tvSchedulerAgent.GetAllChannels(channelType, false)); ChannelLinks.RemoveObsoleteLinks(channelType, channels); List <LinkedChannelItem> channelItems = new List <LinkedChannelItem>(); foreach (Channel channel in channels) { string message; Color rowColor; GetLinkedMessageAndColor(channel, out message, out rowColor); channelItems.Add(new LinkedChannelItem(channel, message, rowColor)); } _channelItemsBindingSource.DataSource = channelItems; } catch (Exception ex) { MessageBox.Show(this, ex.Message, null, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { Cursor.Current = Cursors.Default; } }
private void GetLinkedMessageAndColor(Channel channel, out string message, out Color rowColor) { bool isAutoLinked; bool duplicateChannelsFound; LinkedMediaPortalChannel linkedChannel = ChannelLinks.GetLinkedMediaPortalChannel(channel, out isAutoLinked, out duplicateChannelsFound); if (duplicateChannelsFound) { message = "More than one channel found, change name or link manually"; rowColor = Color.Red; } else if (linkedChannel == null) { message = "Channel not linked, change name or link manually"; rowColor = Color.Red; } else if (isAutoLinked) { message = "Linked (auto)"; rowColor = Color.Black; } else { message = "Linked to " + linkedChannel.DisplayName; rowColor = Color.DarkGreen; } }
private static TvDatabase.Channel GetLinkedMediaPortalChannel(ChannelType channelType, Guid channelId, string displayName) { TvDatabase.Channel allocatedChannel = null; LinkedMediaPortalChannel linkedChannel = ChannelLinks.GetLinkedMediaPortalChannel(channelType, channelId, displayName); if (linkedChannel != null) { allocatedChannel = TvDatabase.Channel.Retrieve(linkedChannel.Id); } return(allocatedChannel); }
private void _okButton_Click(object sender, EventArgs e) { if (_channelsListView.SelectedItems.Count > 0) { ChannelItem channelItem = _channelsListView.SelectedItems[0].Tag as ChannelItem; ChannelLinks.SetLinkedMediaPortalChannel(this.Channel, channelItem.Channel); } else { ChannelLinks.ClearLinkedMediaPortalChannel(this.Channel); } this.DialogResult = DialogResult.OK; this.Close(); }
private static Channel EnsureChannelForDvbEpg(SchedulerServiceAgent tvSchedulerAgent, TvDatabase.Channel mpChannel, bool epgSyncAutoCreateChannels, bool epgSyncAutoCreateChannelsWithGroup) { ChannelLink channelLink = ChannelLinks.GetChannelLinkForMediaPortalChannel(mpChannel); ChannelType channelType = mpChannel.IsTv ? ChannelType.Television : ChannelType.Radio; Channel channel = null; if (channelLink != null) { channel = tvSchedulerAgent.GetChannelById(channelLink.ChannelId); if (channel == null) { channel = tvSchedulerAgent.GetChannelByDisplayName(channelType, channelLink.ChannelName); } } if (channel == null) { channel = tvSchedulerAgent.GetChannelByDisplayName(channelType, mpChannel.DisplayName); } if (channel == null && (epgSyncAutoCreateChannels || epgSyncAutoCreateChannelsWithGroup)) { string groupName = "DVB-EPG"; if (epgSyncAutoCreateChannelsWithGroup) { IList <TvDatabase.GroupMap> groupMaps = mpChannel.ReferringGroupMap(); foreach (TvDatabase.GroupMap groupMap in groupMaps) { TvDatabase.ChannelGroup channelGroup = TvDatabase.ChannelGroup.Retrieve(groupMap.IdGroup); if (channelGroup != null) { groupName = channelGroup.GroupName; break; } } } Guid channelId = tvSchedulerAgent.EnsureChannel(channelType, mpChannel.DisplayName, groupName); channel = tvSchedulerAgent.GetChannelById(channelId); if (!channel.LogicalChannelNumber.HasValue && mpChannel.ChannelNumber > 0) { channel.LogicalChannelNumber = mpChannel.ChannelNumber; tvSchedulerAgent.SaveChannel(channel); } } return(channel); }
private void CreateShareForm_Load(object sender, EventArgs e) { _channelNameLabel.Text = this.Channel.DisplayName; LoadGroups(); LinkedMediaPortalChannel linkedChannel = ChannelLinks.GetLinkedMediaPortalChannel(this.Channel); if (linkedChannel != null) { SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof(TvDatabase.GroupMap)); sb.AddConstraint(Operator.Equals, "idChannel", linkedChannel.Id); SqlResult result = Broker.Execute(sb.GetStatement()); List <TvDatabase.GroupMap> groupMaps = (List <TvDatabase.GroupMap>) ObjectFactory.GetCollection(typeof(TvDatabase.GroupMap), result, new List <TvDatabase.GroupMap>()); if (groupMaps.Count > 0) { foreach (ListViewItem item in _groupsListView.Items) { if (item.Tag is int && (int)item.Tag == groupMaps[0].IdGroup) { item.Selected = true; _groupsListView.EnsureVisible(item.Index); break; } else { item.Selected = false; } } foreach (ListViewItem item in _channelsListView.Items) { ChannelItem channelItem = item.Tag as ChannelItem; if (channelItem.Channel.IdChannel == linkedChannel.Id) { item.Selected = true; _channelsListView.EnsureVisible(item.Index); break; } else { item.Selected = false; } } } } }
private void EnsureChildren(TreeNode node) { try { if (node.Nodes.Count == 1 && String.IsNullOrEmpty(node.Nodes[0].Text)) { int groupId; string groupName; int groupSequence; TvDatabase.ChannelGroup group = node.Tag as TvDatabase.ChannelGroup; if (group == null) { TvDatabase.RadioChannelGroup radioGroup = node.Tag as TvDatabase.RadioChannelGroup; groupId = radioGroup.IdGroup; groupName = radioGroup.GroupName; groupSequence = 0; } else { groupId = group.IdGroup; groupName = group.GroupName; groupSequence = group.SortOrder; } List <TvDatabase.Channel> channels = Utility.GetAllChannelsInGroup(this.Context.ChannelType, groupId); node.Nodes.Clear(); foreach (TvDatabase.Channel channel in channels) { if (ChannelLinks.GetChannelLinkForMediaPortalChannel(channel) == null && !ChannelLinks.IsAutoLinked(channel)) { TreeNode channelNode = new TreeNode(channel.DisplayName); channelNode.Tag = new ImportChannelsContext.ImportChannel(channel, groupId < 0 ? null : groupName, groupSequence); node.Nodes.Add(channelNode); } } _recordingsTreeView.InitializeNodesState(node.Nodes); } } catch (Exception ex) { MessageBox.Show(this, ex.Message, null, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void _linkChannelButton_Click(object sender, EventArgs e) { if (_channelsDataGridView.SelectedRows.Count > 0) { LinkedChannelItem linkItem = _channelsDataGridView.SelectedRows[0].DataBoundItem as LinkedChannelItem; CreateChannelLinkForm form = new CreateChannelLinkForm(); form.Channel = linkItem.Channel; if (form.ShowDialog() == DialogResult.OK) { ChannelLinks.Save(); string message; Color rowColor; GetLinkedMessageAndColor(linkItem.Channel, out message, out rowColor); linkItem.Message = message; linkItem.RowColor = rowColor; _channelItemsBindingSource.ResetBindings(false); } } }
private void _clearLinkButton_Click(object sender, EventArgs e) { ChannelLinks.ClearLinkedMediaPortalChannel(this.Channel); this.DialogResult = DialogResult.OK; this.Close(); }