Exemplo n.º 1
0
        private void AvailLineupGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0 || e.RowIndex >= avail_channels_.Count())
            {
                return;
            }
            Channel ch = avail_channels_[e.RowIndex];
            AvailableSourceGridColumn column = AvailableSourceColumnFromIndex(e.ColumnIndex);

            switch (column)
            {
            case AvailableSourceGridColumn.AddFirst:
                ChannelEditing.AddScannedChannelToMergedChannel(ch, merged_channel_, true);
                RefreshSubchannelsGrid();
                break;

            case AvailableSourceGridColumn.AddLast:
                ChannelEditing.AddScannedChannelToMergedChannel(ch, merged_channel_, false);
                RefreshSubchannelsGrid();
                break;
            }
        }
Exemplo n.º 2
0
        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;
            }
        }