示例#1
0
        private void channelScanWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            int numChannels = this.MaxChannel.PhysicalChannel - this.MinChannel.PhysicalChannel;
            IVirtualChannelProvider _virtualChannelTuner = this as IVirtualChannelProvider;

            for (int i = this.MinChannel.PhysicalChannel; i <= this.MaxChannel.PhysicalChannel; i++)
            {
                if (CheckScanCanceled(e))
                {
                    return;
                }

                this.SetChannel(new Channel(i));
                Thread.Sleep(500);

                if (CheckScanCanceled(e))
                {
                    return;
                }

                int str = this.GetSignalStrength();
                AppLogger.Message("Try channel : " + i + " str=" + str);
                if (str != 0)
                {
                    Channel actual = this.GetChannel();
                    if (actual.MajorChannel != -1)
                    {
                        if (_virtualChannelTuner != null)
                        {
                            List <Channel> virtualChannels = _virtualChannelTuner.GetVirtualChannels();
                            foreach (Channel ch in virtualChannels)
                            {
                                if ((ch.MajorChannel == actual.MajorChannel) && (ch.MinorChannel > 0))
                                {
                                    ch.CarrierFrequency = actual.CarrierFrequency;
                                    _foundChannels.Add(ch);
                                }
                            }
                        }
                        else
                        {
                            _foundChannels.Add(actual);
                        }
                    }
                }

                if (CheckScanCanceled(e))
                {
                    return;
                }
                channelScanWorker.ReportProgress((int)(((double)(i - this.MinChannel.PhysicalChannel) / (double)numChannels) * 100));
            }
        }
示例#2
0
        public ChannelScanner(TVGraphs.BaseLocalTuner graph)
        {
            if (graph == null)
            {
                throw new ArgumentNullException("graph", "graph must not be null!");
            }

            _baseTuner           = graph;
            _virtualChannelTuner = _baseTuner as IVirtualChannelProvider;

            _min          = graph.MinChannel;
            _max          = graph.MaxChannel;
            totalChannels = _max.PhysicalChannel - _min.PhysicalChannel;
            Current       = _min;

            _timer          = new System.Windows.Forms.Timer();
            _timer.Tick    += new EventHandler(Timer_Tick);
            _timer.Interval = 1000;
        }