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; } }
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; } } } }