/// <summary> /// /// </summary> /// <param name="mergedChannel"></param> /// <returns></returns> public static HashSet <long> GetAllScannedSourcesForChannel(MergedChannel mergedChannel) { var ret = new HashSet <long>(); try { if (mergedChannel.PrimaryChannel.Lineup.Name.StartsWith("Scanned")) { ret.Add(mergedChannel.PrimaryChannel.Lineup.Id); } foreach (Channel channel in mergedChannel.SecondaryChannels) { if (!(channel.Lineup?.Name ?? "").StartsWith("Scanned")) { continue; } if (channel.Lineup != null) { ret.Add(channel.Lineup.Id); } } } catch (Exception ex) { Logger.WriteError($"Exception thrown during GetAllScannedSourcesForChannel() for merged channel {mergedChannel}. {ex.Message}\n{ex.StackTrace}"); } return(ret); }
private void SelectMergedChannel(MergedChannel merged_channel) { int merged_channel_index = -1; for (int index = 0; index < merged_channels_.Count; ++index) { if (merged_channels_[index].StoredObjectGuid == merged_channel.StoredObjectGuid) { merged_channel_index = index; break; } } if (merged_channel_index >= 0) { MergedLineupGridView.ClearSelection(); MergedLineupGridView.CurrentCell = MergedLineupGridView.Rows[merged_channel_index].Cells[0]; foreach (DataGridViewCell cell in MergedLineupGridView.Rows[merged_channel_index].Cells) { cell.Selected = true; } if (MergedLineupGridView.FirstDisplayedScrollingRowIndex > merged_channel_index) { MergedLineupGridView.FirstDisplayedScrollingRowIndex = merged_channel_index; } else { if (MergedLineupGridView.DisplayedRowCount(false) + MergedLineupGridView.FirstDisplayedScrollingRowIndex <= merged_channel_index) { MergedLineupGridView.FirstDisplayedScrollingRowIndex = merged_channel_index - MergedLineupGridView.DisplayedRowCount(false) + 1; } } } }
public static void SetSubChannels(MergedChannel mc, List <Channel> subchannels, bool update_tuning_infos) { if (mc.PrimaryChannel != subchannels[0]) { mc.PrimaryChannel = subchannels[0]; } foreach (Channel ch in mc.SecondaryChannels) { mc.SecondaryChannels.RemoveAllMatching(ch); } for (int index = 1; index < subchannels.Count; ++index) { mc.SecondaryChannels.Add(subchannels[index]); } if (update_tuning_infos) { mc.TuningInfos.Clear(); foreach (Channel ch in subchannels) { foreach (TuningInfo ti in ch.TuningInfos) { if (ti.Device != null) { mc.TuningInfos.Add(ti); } } } } mc.Update(); }
public static void AddScannedChannelToMergedChannel(Channel scanned_channel, MergedChannel merged_channel, bool add_as_primary) { if (add_as_primary) { List <TuningInfo> tuning_infos = merged_channel.TuningInfos.ToList(); Channel old_primary_channel = merged_channel.PrimaryChannel; merged_channel.PrimaryChannel = scanned_channel; merged_channel.SecondaryChannels.Add(old_primary_channel); tuning_infos.InsertRange(0, scanned_channel.TuningInfos); merged_channel.TuningInfos.Clear(); foreach (TuningInfo ti in tuning_infos) { merged_channel.TuningInfos.Add(ti); } } else { merged_channel.SecondaryChannels.Add(scanned_channel); foreach (TuningInfo ti in scanned_channel.TuningInfos) { merged_channel.TuningInfos.Add(ti); } } merged_channel.Update(); }
public void AddChannel(MergedChannel mergedChannel, bool includeEncrypted) { foreach (TuningInfo tuningInfo in mergedChannel.TuningInfos) { // make sure it is DVBS if (!(tuningInfo is DvbTuningInfo dvbTuningInfo) || !dvbTuningInfo.TuningSpace.Equals("DVB-S")) { continue; } var locator = dvbTuningInfo.TuneRequest.Locator as DVBSLocator; // filter on options if ((dvbTuningInfo.IsEncrypted || dvbTuningInfo.IsSuggestedBlocked) && !includeEncrypted) { continue; } // determine satellite, transponder, and service for channel var satellite = GetOrCreateSatellite(locator.OrbitalPosition); var transponder = satellite.GetOrCreateTransponder(dvbTuningInfo.Frequency / 1000, (int)locator.SignalPolarisation - 1, locator.SymbolRate / 1000, dvbTuningInfo.Onid, dvbTuningInfo.Tsid); var service = transponder.GetOrCreateService(mergedChannel.CallSign, dvbTuningInfo.Sid, mergedChannel.Service.ServiceType == 2 ? 1 : mergedChannel.Service.ServiceType == 3 ? 2 : 0, dvbTuningInfo.IsEncrypted || dvbTuningInfo.IsSuggestedBlocked); // add channel with callsign and channel number var keyValues = new KeyValues(WmcStore.WmcObjectStore); var region = GetOrCreateRegion(keyValues.Single(arg => arg.Key == "ClientCountryCode").Value); var footprint = region.GetOrCreateFootprint(satellite); var headend = footprint.GetOrCreateHeadend(satellite.PositionEast); headend.AddChannel(service, int.Parse(mergedChannel.ChannelNumber.ToString())); AddReferenceHeadend(headend); } }
public SourceChannelManagementForm(MergedChannel merged_channel) { InitializeComponent(); merged_channel_ = merged_channel; RefreshSubchannelsGrid(); InitLineupCombos(); SortAvailChannels(); }
public myChannelLvi(MergedChannel channel) : base(new string[7]) { MergedChannel = channel; MergedChannel.Updated += Channel_Updated; ChannelId = MergedChannel.Id; UseItemStyleForSubItems = false; PopulateMergedChannelItems(); }
public static List <Channel> GetSubChannels(MergedChannel mc) { List <Channel> subchannels = new List <Channel>(); if (mc.PrimaryChannel != null) { subchannels.Add(mc.PrimaryChannel); } subchannels.AddRange(mc.SecondaryChannels.AsEnumerable()); return(subchannels); }
public void PopulateMergedChannelItems() { MergedChannel.Refresh(); SetServiceTypeFlags(); var scanned = MergedChannel.PrimaryChannel.Lineup?.Name?.StartsWith("Scanned") ?? false; // set callsign and backcolor Callsign = MergedChannel.PrimaryChannel.CallSign; CustomCallsign = MergedChannel.HasUserSpecifiedCallSign ? MergedChannel.CallSign : null; SubItems[0].Text = Custom ? CustomCallsign ?? Callsign : Callsign; SubItems[0].BackColor = MergedChannel.HasUserSpecifiedCallSign ? Color.Pink : SystemColors.Window; // set number and backcolor Number = $"{MergedChannel.OriginalNumber}{(MergedChannel.OriginalSubNumber > 0 ? $".{MergedChannel.OriginalSubNumber}" : "")}"; CustomNumber = MergedChannel.HasUserSpecifiedNumber || MergedChannel.HasUserSpecifiedSubNumber ? $"{MergedChannel.Number}{(MergedChannel.SubNumber > 0 ? $".{MergedChannel.SubNumber}" : "")}" : null; SubItems[1].Text = Custom ? CustomNumber ?? Number : Number; SubItems[1].BackColor = MergedChannel.HasUserSpecifiedNumber || MergedChannel.HasUserSpecifiedSubNumber ? Color.Pink : SystemColors.Window; // set service name, lineup name, and guide end time SubItems[2].Text = !scanned ? MergedChannel.Service?.Name : ""; SubItems[3].Text = !scanned ? MergedChannel.PrimaryChannel.Lineup?.Name : ""; SubItems[6].Text = !scanned?MergedChannel.Service?.ScheduleEndTime.ToLocalTime().ToString() : ""; // set scanned sources and tuning info ScannedLineupIds = WmcStore.GetAllScannedSourcesForChannel(MergedChannel); if (ScannedLineupIds.Count > 0) { var names = new HashSet <string>(); foreach (var name in ScannedLineupIds.Select(id => ((Lineup)WmcStore.WmcObjectStore.Fetch(id)).Name.Remove(0, 9))) { names.Add(name.Remove(name.Length - 1)); } var text = string.Empty; foreach (var name in names) { if (!string.IsNullOrEmpty(text)) { text += " + "; } text += name; } SubItems[4].Text = text; } SubItems[5].Text = WmcStore.GetAllTuningInfos((Channel)MergedChannel); // set checkbox Checked = Enabled = (!MergedChannel.IsSuggestedBlocked || MergedChannel.UserBlockedState != UserBlockedState.Unknown) && MergedChannel.UserBlockedState <= UserBlockedState.Enabled; }
public static void CombineMergedChannels(MergedChannel dest_channel, MergedChannel src_channel, bool src_is_primary, bool remove_src_channel) { List <TuningInfo> tuning_infos = new List <TuningInfo>(); tuning_infos.AddRange(dest_channel.TuningInfos.AsEnumerable()); Channel old_primary = dest_channel.PrimaryChannel; foreach (Channel secondary in src_channel.SecondaryChannels) { dest_channel.SecondaryChannels.Add(secondary); } if (src_is_primary) { tuning_infos.InsertRange(0, src_channel.TuningInfos.AsEnumerable()); dest_channel.PrimaryChannel = src_channel.PrimaryChannel; if (old_primary != null) { dest_channel.SecondaryChannels.Add(old_primary); } } else { tuning_infos.AddRange(src_channel.TuningInfos.AsEnumerable()); if (src_channel.PrimaryChannel != null) { dest_channel.SecondaryChannels.Add(src_channel.PrimaryChannel); } } dest_channel.TuningInfos.Clear(); foreach (TuningInfo ti in tuning_infos) { dest_channel.TuningInfos.Add(ti); } dest_channel.Update(); if (remove_src_channel) { src_channel.TuningInfos.Clear(); foreach (Channel ch in src_channel.SecondaryChannels) { src_channel.SecondaryChannels.RemoveAllMatching(ch); } src_channel.PrimaryChannel = null; src_channel.Lineup.RemoveChannel(src_channel); } }
private string SerializeSourceChannelList(MergedChannel mc) { StringBuilder sb = new StringBuilder(); if (mc.PrimaryChannel != null) { AppendSourceChannel(mc.PrimaryChannel, sb); } foreach (Channel ch in mc.SecondaryChannels) { sb.Append(", "); AppendSourceChannel(ch, sb); } return(sb.ToString()); }
//private TreeNode _tGrabbers; public MergedChannelDetails(MergedChannel channel, GetGrabberSelectorCallback getGrabberSelectorCallback, EventHandler ok_click) { InitializeComponent(); _getGrabberSelector = getGrabberSelectorCallback; if (channel != null) { tbChannelName.Text = channel.id; tbGrabSite.Text = channel.grabber; tbStart.Text = channel.start; tbEnd.Text = channel.end; } bOk.Click += ok_click; }
private int GetMergedChannelServiceType(MergedChannel mergedChannel) { var channel = mergedChannel.ChannelType == ChannelType.Scanned || mergedChannel.ChannelType == ChannelType.CalculatedScanned ? mergedChannel as Channel : mergedChannel.SecondaryChannels.FirstOrDefault(arg => arg.ChannelType == ChannelType.Scanned || arg.ChannelType == ChannelType.CalculatedScanned); if (channel == null) { return(0); } switch (channel.Service.ServiceType) { case 0: return(channel.ChannelType == ChannelType.Scanned ? 0 : 3); default: return(channel.Service.ServiceType); } }
private void RemoveChannelsButton_Click(object sender, EventArgs e) { IEnumerable <int> row_indices = GetSelectedRowIndices(); foreach (int row_index in row_indices) { MergedChannel ch = merged_channels_[row_index]; try { ch.Lineup.RemoveChannel(ch); } catch (Exception exc) { new ErrorReporter.ErrorReportingForm("Error occurred while attempting to remove a channel.", exc); } } SelectAndLoadLineup(merged_lineup_); // force a refresh. }
private void MergeButton_Click(object sender, EventArgs e) { MergedChannel dest_channel = ((MergedChannelComboBoxWrapper)DestinationChannelComboBox.SelectedItem).channel; List <MergedChannel> merge_order = new List <MergedChannel>(); foreach (object item in ChannelSortingListBox.Items) { merge_order.Add(((MergedChannelComboBoxWrapper)item).channel); } bool past_dest_channel = false; foreach (MergedChannel mc in merge_order) { if (mc == dest_channel) { past_dest_channel = true; continue; } ChannelEditing.CombineMergedChannels(dest_channel, mc, !past_dest_channel, RemoveChannelsCheckbox.Checked); } }
private void MergedLineupGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0 || e.RowIndex >= merged_channels_.Count) { return; } MergedChannel ch = merged_channels_[e.RowIndex]; MergedChannelGridColumn column = MergedChannelColumnToEnum(e.ColumnIndex); switch (column) { case MergedChannelGridColumn.Listing: new ListingSelectionForm(ch).ShowDialog(); MergedLineupGridView.InvalidateCell(e.ColumnIndex, e.RowIndex); break; case MergedChannelGridColumn.SourceChannels: new SourceChannelManagementForm(ch).ShowDialog(); MergedLineupGridView.InvalidateRow(e.RowIndex); break; case MergedChannelGridColumn.HD: if (ch.Service != null) { ch.Service.IsHDCapable = !ch.Service.IsHDCapable; ch.Service.Update(); MergedLineupGridView.InvalidateColumn(e.ColumnIndex); } break; case MergedChannelGridColumn.InBand: ch.IgnoreInbandSchedule = !ch.IgnoreInbandSchedule; ch.Update(); MergedLineupGridView.InvalidateCell(e.ColumnIndex, e.RowIndex); break; } }
public static void RemoveSubChannel(MergedChannel merged, Channel subchannel, bool delete_if_last_reference) { foreach (TuningInfo ti in subchannel.TuningInfos) { merged.TuningInfos.RemoveAllMatching(ti); } if (merged.PrimaryChannel == subchannel) { if (!merged.SecondaryChannels.Empty) { merged.PrimaryChannel = merged.SecondaryChannels.First; merged.SecondaryChannels.RemoveAllMatching(merged.PrimaryChannel); } } else { merged.SecondaryChannels.RemoveAllMatching(subchannel); } merged.Update(); if (delete_if_last_reference && GetReferencingMergedChannels(subchannel).Count == 0) { DeleteChannel(subchannel); } }
public static void AddUserChannelInLineup(Lineup lineup, string callsign, int channel_number, int subchannel, ModulationType modulation_type) { List <ChannelTuningInfo> tuning_infos = new List <ChannelTuningInfo>(); foreach (Device device in lineup.ScanDevices) { string old_tuningspace_name = device.DeviceType.TuningSpaceName; if (string.IsNullOrEmpty(old_tuningspace_name)) { // hacky. For now I'm just trying to get it to work with ClearQAM. Ultimately I guess this would be a case // statement picking a value based on modulation_type. Why is it null for all my devices currently? string temp_tuningspace_name = GetTuningSpaceNameForModulation(modulation_type); // What really seems to matter looking at // ChannelTuningInfo(Device device, SerializationFormat format, byte[] serializedTuneRequest, TuneRequest tr) : base(device, format, serializedTuneRequest, tr) // in .NET Reflector is whether the tuning space has subnumbers or not. So if we can't figure out // what TuningSpace makes sense, pick one based on if subchannel is 0. if (string.IsNullOrEmpty(temp_tuningspace_name)) { temp_tuningspace_name = ((subchannel != 0) ? "ClearQAM" : "Cable"); } device.DeviceType.TuningSpaceName = temp_tuningspace_name; } try { ChannelTuningInfo channel_tuning_info = new ChannelTuningInfo(device, channel_number, subchannel, modulation_type); tuning_infos.Add(channel_tuning_info); } finally { device.DeviceType.TuningSpaceName = old_tuningspace_name; } } Channel ch = new Channel(); ch.CallSign = callsign; ch.ChannelType = ChannelType.UserAdded; ch.Number = channel_number; ch.SubNumber = subchannel; lineup.AddChannel(ch); foreach (ChannelTuningInfo channel_tuning_info in tuning_infos) { ch.TuningInfos.Add(channel_tuning_info); } ch.Update(); MergedChannel merged_channel = new MergedChannel(); merged_channel.Number = channel_number; merged_channel.SubNumber = subchannel; merged_channel.CallSign = callsign; merged_channel.ChannelType = ChannelType.UserAdded; merged_channel.FullMerge(ch); MergedLineup merged_lineup = (lineup.PrimaryProvider != null) ? lineup.PrimaryProvider : lineup.SecondaryProvider; if (merged_lineup == null) { merged_lineup = new MergedLineups(lineup.ObjectStore).First; } List <Channel> new_channels_list = new List <Channel>(); new_channels_list.Add(ch); bool old_keepAllPrimary = merged_lineup.LineupMergeRule.KeepAllPrimary; bool old_keepAllSecondary = merged_lineup.LineupMergeRule.KeepAllSecondary; merged_lineup.LineupMergeRule.KeepAllPrimary = true; merged_lineup.LineupMergeRule.KeepAllSecondary = true; try { lineup.NotifyChannelAdded(ch); // merged_lineup.OnChannelsAdded(lineup, new_channels_list); } finally { merged_lineup.LineupMergeRule.KeepAllPrimary = old_keepAllPrimary; merged_lineup.LineupMergeRule.KeepAllSecondary = old_keepAllSecondary; } }
private void MergedLineupGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) { if (e.RowIndex < 0 || e.RowIndex >= merged_channels_.Count) { return; } MergedChannel ch = merged_channels_[e.RowIndex]; MergedChannelGridColumn column = MergedChannelColumnToEnum(e.ColumnIndex); switch (column) { case MergedChannelGridColumn.Logo: try { e.Value = GetChannelLogo(ch); } catch { e.Value = new Bitmap(5, 5); } break; case MergedChannelGridColumn.Number: e.Value = ch.Number; break; case MergedChannelGridColumn.SubNumber: if (ch.SubNumber != 0) { e.Value = ch.SubNumber; } else { e.Value = null; } break; case MergedChannelGridColumn.Listing: e.Value = ch.Service; break; case MergedChannelGridColumn.ListingProvider: e.Value = ch.Service?.Provider?.Name; break; case MergedChannelGridColumn.Type: e.Value = ch.ChannelType.ToString(); break; case MergedChannelGridColumn.TunerCount: e.Value = ChannelEditing.GetTunerCount(ch); break; case MergedChannelGridColumn.Visibility: e.Value = ch.Visibility.ToString(); break; case MergedChannelGridColumn.UserBlockedState: e.Value = ch.UserBlockedState.ToString(); break; case MergedChannelGridColumn.SourceChannels: e.Value = SerializeSourceChannelList(ch); break; case MergedChannelGridColumn.Encrypted: e.Value = ch.IsEncrypted; break; case MergedChannelGridColumn.HD: e.Value = IsChannelHD(ch); break; case MergedChannelGridColumn.InBand: e.Value = !ch.IgnoreInbandSchedule; break; } }
internal static int CompareInBand(MergedChannel ch1, MergedChannel ch2) { return(ch2.IgnoreInbandSchedule.CompareTo(ch1.IgnoreInbandSchedule)); }
public MergedChannelComboBoxWrapper(MergedChannel channel) { channel_ = channel; }
public void RemoveDelegate() { MergedChannel.Refresh(); MergedChannel.Updated -= Channel_Updated; MergedChannel = null; }
private void CreateChannelButton_Click(object sender, EventArgs e) { if (CallsignInput.Text.Length == 0) { MessageBox.Show("Callsign is required."); return; } Service new_channel_service = null; if (destination_merged_channel_ != null) { new_channel_service = destination_merged_channel_.Service; } else { if (ListingSelectionCombo.SelectedItem is Service) { new_channel_service = ListingSelectionCombo.SelectedItem as Service; } else if (ListingSelectionCombo.SelectedItem is ChannelService) { new_channel_service = (ListingSelectionCombo.SelectedItem as ChannelService).Service; } } Channel new_channel = null; if (ChannelTypeTabControl.SelectedTab == ChannelTuningInfoPage) { ModulationType mod_type = ((ModulationTypeWrapper)ModulationCombo.SelectedItem).modulation_type; try { new_channel = ChannelEditing.AddUserChannelToLineupWithoutMerge( SelectedLineup, CallsignInput.Text, (int)ChannelNumberInput.Value, (int)SubchannelInput.Value, mod_type, new_channel_service, GetCheckedDevices()); } catch (Exception exc) { AddInputsToException(exc); new ErrorReporter.ErrorReportingForm("Exception occured when trying to add the scanned channel.", exc); return; } } else if (ChannelTypeTabControl.SelectedTab == DVBTuningInfoPage) { try { new_channel = ChannelEditing.AddDvbUserChannelToLineupWithoutMerge( SelectedLineup, CallsignInput.Text, (int)ChannelNumberInput.Value, (int)SubchannelInput.Value, int.Parse(DvbONIDCombo.Text), int.Parse(DvbTSIDCombo.Text), int.Parse(DvbSIDCombo.Text), int.Parse(DvbNIDCombo.Text), int.Parse(DvbFrequencyCombo.Text), (int)DvbLCNInput.Value, new_channel_service, GetCheckedDevices()); } catch (Exception exc) { AddInputsToException(exc); new ErrorReporter.ErrorReportingForm("Exception occured when trying to add the DVB scanned channel.", exc); return; } } else if (ChannelTypeTabControl.SelectedTab == DVBLinkPage) { try { int dvblink_channel_key = (int)DVBLinkChannelNumInput.Value; int frequency = dvblink_channel_key * 10000; new_channel = ChannelEditing.AddDvbUserChannelToLineupWithoutMerge( SelectedLineup, CallsignInput.Text, (int)ChannelNumberInput.Value, (int)SubchannelInput.Value, dvblink_channel_key, dvblink_channel_key, dvblink_channel_key, dvblink_channel_key, frequency, (int)DVBLinkLCNInput.Value, new_channel_service, GetCheckedDevices()); } catch (Exception exc) { AddInputsToException(exc); new ErrorReporter.ErrorReportingForm("Exception occured when trying to add the DVBLink scanned channel.", exc); return; } } try { MergedChannel updated_merged_channel = null; if (destination_merged_channel_ != null) { ChannelEditing.AddScannedChannelToMergedChannel(new_channel, destination_merged_channel_, AddAsFirstRadio.Checked); updated_merged_channel = destination_merged_channel_; } else if (CreateNewChannelCheckbox.Checked) { updated_merged_channel = ChannelEditing.CreateMergedChannelFromChannels(new List <Channel>(new Channel[] { new_channel }), (int)GuideNumberInput.Value, (int)GuideSubNumberInput.Value); } /* if (ChannelAdded != null) * { * ChannelAddedEventArgs args = new ChannelAddedEventArgs(e, updated_merged_channel, new_channel); * ChannelAdded(sender, args); * } */ guide_channel_entered_ = false; } catch (Exception exc) { if (new_channel != null) { exc.Data.Add("new_channel number", new_channel.Number); exc.Data.Add("new_channel subnumber", new_channel.SubNumber); if (new_channel.TuningInfos != null) { exc.Data.Add("new_channel tuninginfo count", new_channel.TuningInfos.Count()); } else { exc.Data.Add("new_channel tuning infos", "NULL"); } } else { exc.Data.Add("new_channel", "NULL"); } AddInputsToException(exc); new ErrorReporter.ErrorReportingForm("Exception occured when trying to put the newly created scanned channel in a merged channel.", exc); return; } }
public ChannelAddedEventArgs(EventArgs inner_args, MergedChannel merged_channel, Channel scanned_channel) { merged_channel_ = merged_channel; scanned_channel_ = scanned_channel; inner_args_ = inner_args; }
private void MergedLineupGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { if (e.RowIndex < 0 || e.RowIndex >= merged_channels_.Count) { return; } MergedChannel ch = merged_channels_[e.RowIndex]; MergedChannelGridColumn column = MergedChannelColumnToEnum(e.ColumnIndex); switch (column) { case MergedChannelGridColumn.Number: try { int num = int.Parse(e.FormattedValue.ToString()); if (ch.Number == num) { return; } ch.Number = num; ch.Update(); } catch { e.Cancel = true; } break; case MergedChannelGridColumn.SubNumber: try { string formatted_value = e.FormattedValue.ToString(); int num = (formatted_value.Length != 0) ? int.Parse(formatted_value) : 0; if (ch.SubNumber == num) { return; } ch.SubNumber = num; ch.Update(); } catch { e.Cancel = true; } break; case MergedChannelGridColumn.Type: try { ChannelType channel_type = (ChannelType)Enum.Parse(typeof(ChannelType), e.FormattedValue.ToString()); if (ch.ChannelType == channel_type) { return; } ch.ChannelType = channel_type; ch.Update(); } catch { e.Cancel = true; } break; case MergedChannelGridColumn.UserBlockedState: try { UserBlockedState user_blocked_state = (UserBlockedState)Enum.Parse(typeof(UserBlockedState), e.FormattedValue.ToString()); if (ch.UserBlockedState == user_blocked_state) { return; } ch.UserBlockedState = user_blocked_state; ch.Update(); } catch { e.Cancel = true; } break; case MergedChannelGridColumn.Visibility: try { ChannelVisibility visibility = (ChannelVisibility)Enum.Parse(typeof(ChannelVisibility), e.FormattedValue.ToString()); if (ch.Visibility == visibility) { return; } ch.Visibility = visibility; ch.Update(); } catch { e.Cancel = true; } break; } }
public static MergedChannel CreateMergedChannelFromChannels( List <Channel> channels, int guide_channel_number, int guide_subchannel, ChannelType channel_type = ChannelType.UserAdded) { try { Channel primary_channel = channels[0]; List <Channel> secondary_channels = channels.GetRange(1, channels.Count - 1); MergedLineup merged_lineup = GetMergedLineupFromScannedLineup(primary_channel.Lineup); MergedChannel merged_channel = new MergedChannel(); merged_channel.CallSign = primary_channel.CallSign; merged_channel.Number = guide_channel_number; merged_channel.OriginalNumber = guide_channel_number; merged_channel.SubNumber = guide_subchannel; merged_channel.OriginalSubNumber = guide_subchannel; merged_channel.ChannelType = channel_type; merged_channel.PrimaryChannel = primary_channel; merged_channel.Service = primary_channel.Service; merged_channel.Lineup = merged_lineup; new MergedChannels(object_store).Add(merged_channel); foreach (TuningInfo tuning_info in primary_channel.TuningInfos) { merged_channel.TuningInfos.Add(tuning_info); } foreach (Channel secondary_channel in secondary_channels) { merged_channel.SecondaryChannels.Add(secondary_channel); foreach (TuningInfo tuning_info in secondary_channel.TuningInfos) { merged_channel.TuningInfos.Add(tuning_info); } } merged_channel.GetUIdValue(true); merged_channel.Update(); try { merged_lineup.AddChannel(merged_channel); } catch (Exception exc) { Console.WriteLine("Caught exception thrown by MergedLineup.AddChannel {0} Message: {1}", exc.ToString(), exc.Message); } return(merged_channel); } catch (Exception exc) { if (channels != null) { exc.Data.Add("CreateMergedChannelFromChannels_channels.Count", channels.Count); for (int index = 0; index < channels.Count; ++index) { string key_start = string.Format("CreateMergedChannelFromChannels_channels[{0}]", index); Channel channel = channels[index]; if (channel != null) { exc.Data.Add(key_start + ".Number", channel.Number); exc.Data.Add(key_start + ".SubNumber", channel.SubNumber); } else { exc.Data.Add(key_start, "NULL"); } } if (channels.Count > 0 && channels[0] != null) { if (channels[0].Lineup != null) { exc.Data.Add("CreateMergedChannelFromChannels_channels[0].Lineup", channels[0].Lineup); if (channels[0].Lineup.PrimaryProvider != null) { exc.Data.Add("CreateMergedChannelFromChannels_channels[0].Lineup.PrimaryProvider", channels[0].Lineup.PrimaryProvider); } else { exc.Data.Add("CreateMergedChannelFromChannels_channels[0].Lineup.PrimaryProvider", "NULL"); } } else { exc.Data.Add("CreateMergedChannelFromChannels_channels[0].Lineup", "NULL"); } } } else { exc.Data.Add("CreateMergedChannelFromChannels_channels", "NULL"); } throw; } }
//private void bMergedAdd_Click(object sender, EventArgs e) //{ // lvMerged.SelectedItems.Clear(); // //_mergeConfig = new MergedChannelDetails(tGrabbers, null, this.bMergedOk_Click); // //_mergeConfig.MinimizeBox = false; // //_mergeConfig.Show(); //} //private void bMergedOk_Click(object sender, EventArgs e) //{ // if (lvMapping.SelectedItems.Count == 1) // { // ChannelMap channelMap = _channelMapping[lvMapping.SelectedItems[0].Text]; // if (lvMerged.SelectedItems.Count == 1) // { // MergedChannel channelDetails = (MergedChannel) lvMerged.SelectedItems[0].Tag; // channelDetails.id = _mergeConfig.ChannelDetails.id; // channelDetails.grabber = _mergeConfig.ChannelDetails.grabber; // channelDetails.start = _mergeConfig.ChannelDetails.start; // channelDetails.end = _mergeConfig.ChannelDetails.end; // } // else // { // channelMap.merged.Add(_mergeConfig.ChannelDetails); // } // UpdateMergedList(channelMap); // } // _mergeConfig.Close(); //} //private void bMergedRemove_Click(object sender, EventArgs e) //{ // if (lvMerged.SelectedItems.Count == 1 && lvMapping.SelectedItems.Count == 1) // { // ChannelMap channelMap = _channelMapping[lvMapping.SelectedItems[0].Text]; // channelMap.merged.Remove((MergedChannel) lvMerged.SelectedItems[0].Tag); // UpdateMergedList(channelMap); // } //} //private void bMergedEdit_Click(object sender, EventArgs e) //{ // if (lvMerged.SelectedItems.Count == 1 && lvMapping.SelectedItems.Count == 1) // { // //MergedChannel channel = (MergedChannel) lvMerged.SelectedItems[0].Tag; // //_mergeConfig = new MergedChannelDetails(tGrabbers, channel, this.bMergedOk_Click); // //_mergeConfig.MinimizeBox = false; // //_mergeConfig.Show(); // } //} private void tcMappingDetails_Selecting(object sender, TabControlCancelEventArgs e) { if (tcMappingDetails.SelectedIndex == 1) { if (lvMapping.SelectedItems.Count == 1) { if (_channelMapping.ContainsKey(lvMapping.SelectedItems[0].Text)) { ChannelMap channelMap = _channelMapping[lvMapping.SelectedItems[0].Text]; if (channelMap.merged == null || channelMap.merged.Count == 0) { channelMap.merged = new List <MergedChannel>(); if (channelMap.id != null) { MergedChannel channel = new MergedChannel(); channel.id = channelMap.id; channelMap.id = null; channel.grabber = channelMap.grabber; channelMap.grabber = null; channelMap.merged.Add(channel); } //_channelMapping.Remove(channel.Text); //_channelMapping.Add(channel.Text, channelMap); } UpdateMergedList(channelMap); UpdateList(); } } else { e.Cancel = true; MessageBox.Show("Only one channel can be mapped to multiple channels at a time.", "Multiple Selection Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { if (lvMapping.SelectedItems.Count == 1) { if (_channelMapping.ContainsKey(lvMapping.SelectedItems[0].Text)) { if (_channelMapping[lvMapping.SelectedItems[0].Text].merged == null || _channelMapping[lvMapping.SelectedItems[0].Text].merged.Count <= 1) { ChannelMap channelMap = _channelMapping[lvMapping.SelectedItems[0].Text]; if (channelMap.merged != null) { if (channelMap.merged.Count > 0) { channelMap.id = channelMap.merged[0].id; channelMap.grabber = channelMap.merged[0].grabber; } channelMap.merged = null; } UpdateMergedList(channelMap); UpdateList(); } else { e.Cancel = true; MessageBox.Show("Cannot convert multiple channels to single channel. Please remove one.", "Multiple Channel Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } } }
private void LoadOldConfigFile() { Log.Info("Trying to load old config file format"); _configFile = new WebepgConfigFile(); Xml xmlreader = new Xml(_configFileDir + "\\WebEPG.xml"); _configFile.Info = new WebepgInfo(); _configFile.Info.GrabDays = xmlreader.GetValueAsInt("General", "MaxDays", 2); _configFile.Info.GrabberDir = xmlreader.GetValueAsString("General", "GrabberDir", null); int AuthCount = xmlreader.GetValueAsInt("AuthSites", "Count", 0); if (AuthCount > 0) { _configFile.Sites = new List <SiteAuth>(); for (int i = 1; i <= AuthCount; i++) { SiteAuth site = new SiteAuth(); site.id = xmlreader.GetValueAsString("Auth" + i.ToString(), "Site", ""); site.username = xmlreader.GetValueAsString("Auth" + i.ToString(), "Login", ""); site.password = xmlreader.GetValueAsString("Auth" + i.ToString(), "Password", ""); _configFile.Sites.Add(site); } } _configFile.Channels = new List <ChannelMap>(); int channelCount = xmlreader.GetValueAsInt("ChannelMap", "Count", 0); for (int i = 1; i <= channelCount; i++) { ChannelMap channel = new ChannelMap(); channel.displayName = xmlreader.GetValueAsString(i.ToString(), "DisplayName", ""); string grabber = xmlreader.GetValueAsString(i.ToString(), "Grabber1", ""); ; //if (mergedList.ContainsKey(channel.displayName)) //{ // channel.merged = mergedList[channel.displayName]; // foreach (MergedChannel mergedChannel in channel.merged) // mergedChannel.grabber = grabber; //} //else //{ channel.id = xmlreader.GetValueAsString(i.ToString(), "ChannelID", ""); channel.grabber = grabber; //} _configFile.Channels.Add(channel); } int mergeCount = xmlreader.GetValueAsInt("MergeChannels", "Count", 0); Dictionary <string, List <MergedChannel> > mergedList = new Dictionary <string, List <MergedChannel> >(); if (mergeCount > 0) { for (int i = 1; i <= mergeCount; i++) { int channelcount = xmlreader.GetValueAsInt("Merge" + i.ToString(), "Channels", 0); if (channelcount > 0) { List <MergedChannel> mergedChannels = new List <MergedChannel>(); ChannelMap channel = new ChannelMap(); channel.displayName = xmlreader.GetValueAsString("Merge" + i.ToString(), "DisplayName", ""); channel.merged = new List <MergedChannel>(); for (int c = 1; c <= channelcount; c++) { MergedChannel mergedChannel = new MergedChannel(); mergedChannel.id = xmlreader.GetValueAsString("Merge" + i.ToString(), "Channel" + c.ToString(), ""); mergedChannel.start = xmlreader.GetValueAsString("Merge" + i.ToString(), "Start" + c.ToString(), "0:0"); mergedChannel.end = xmlreader.GetValueAsString("Merge" + i.ToString(), "End" + c.ToString(), "0:0"); channel.merged.Add(mergedChannel); } _configFile.Channels.Add(channel); } } } xmlreader.Clear(); xmlreader.Dispose(); }
public static void RemoveSubChannel(MergedChannel merged, Channel subchannel) { RemoveSubChannel(merged, subchannel, true); }
private void SelectMergedChannel(MergedChannel merged_channel) { int merged_channel_index = -1; for (int index = 0; index < merged_channels_.Count; ++index) { if (merged_channels_[index].StoredObjectGuid == merged_channel.StoredObjectGuid) { merged_channel_index = index; break; } } if (merged_channel_index >= 0) { MergedLineupGridView.ClearSelection(); MergedLineupGridView.CurrentCell = MergedLineupGridView.Rows[merged_channel_index].Cells[0]; foreach (DataGridViewCell cell in MergedLineupGridView.Rows[merged_channel_index].Cells) cell.Selected = true; if (MergedLineupGridView.FirstDisplayedScrollingRowIndex > merged_channel_index) { MergedLineupGridView.FirstDisplayedScrollingRowIndex = merged_channel_index; } else { if (MergedLineupGridView.DisplayedRowCount(false) + MergedLineupGridView.FirstDisplayedScrollingRowIndex <= merged_channel_index) MergedLineupGridView.FirstDisplayedScrollingRowIndex = merged_channel_index - MergedLineupGridView.DisplayedRowCount(false) + 1; } } }
internal static int CompareInBand(MergedChannel ch1, MergedChannel ch2) { return ch2.IgnoreInbandSchedule.CompareTo(ch1.IgnoreInbandSchedule); }
private string SerializeSourceChannelList(MergedChannel mc) { StringBuilder sb = new StringBuilder(); if (mc.PrimaryChannel != null) AppendSourceChannel(mc.PrimaryChannel, sb); foreach (Channel ch in mc.SecondaryChannels) { sb.Append(", "); AppendSourceChannel(ch, sb); } return sb.ToString(); }
private void SyncButton_Click(object sender, EventArgs e) { foreach (Channel ch in selected_wmi_lineup.GetChannels()) { ChannelNumber channel_number = ch.ChannelNumber; Channel merged_channel = selected_merged_lineup.GetChannelFromNumber(channel_number.Number, channel_number.SubNumber); if (merged_channel == null) { // missing channel switch ((MissingChannelOptions)MissingChannelOptionsComboBox.SelectedIndex) { case MissingChannelOptions.AddMissingChannels: AppendDebugLine("Adding channel " + channel_number.ToString() + " callsign: " + ch.CallSign); Channel user_channel = ChannelEditing.AddUserChannelToLineupWithoutMerge( selected_scanned_lineup, ch.CallSign, channel_number.Number, channel_number.SubNumber, ModulationType.BDA_MOD_NOT_SET, ch.Service, selected_scanned_lineup.ScanDevices, ChannelType.CalculatedScanned); user_channel.Update(); MergedChannel new_merged_channel = ChannelEditing.CreateMergedChannelFromChannels( new List <Channel>(new Channel[] { user_channel }), channel_number.Number, channel_number.SubNumber, ChannelType.AutoMapped); new_merged_channel.Update(); break; case MissingChannelOptions.SkipMissingChannels: break; } } else { // existing channel switch ((ExistingChannelOptions)ExistingChannelOptionsComboBox.SelectedIndex) { case ExistingChannelOptions.ReplaceListing: if (merged_channel.Service.IsSameAs(ch.Service)) { AppendDebugLine("Channel " + channel_number.ToString() + " already good!"); break; } AppendDebugLine("Replacing listing on channel " + channel_number.ToString() + " old callsign: " + merged_channel.CallSign + " new callsign: " + ch.CallSign); merged_channel.Service = ch.Service; merged_channel.Update(); break; case ExistingChannelOptions.SkipExistingChannels: break; } } } foreach (Channel ch in selected_merged_lineup.GetChannels().ToArray()) { ChannelNumber channel_number = ch.ChannelNumber; Channel wmi_channel = selected_wmi_lineup.GetChannelFromNumber(channel_number.Number, channel_number.SubNumber); if (channel_number == null) { // extra channel switch ((ExtraChannelOptions)ExtraChannelOptionsComboBox.SelectedIndex) { case ExtraChannelOptions.KeepExtraChannels: break; case ExtraChannelOptions.RemoveExtraChannels: AppendDebugLine("Removing Extra channel " + channel_number.ToString() + " callsign: " + ch.CallSign); ChannelEditing.DeleteChannel(ch); break; } } } }