private void buttonScanChannels_Click(object sender, EventArgs e)
{
if (this.propertyGridChannel.SelectedObject != null && this.propertyGridChannel.SelectedObject is ChannelTV)
{
MainForm.ClearGraph();
this.continueScanning = true;
this.buttonScanChannels.Enabled = false;
this.buttonScanStop.Enabled = true;
ChannelTV templateChannelTV = this.propertyGridChannel.SelectedObject as ChannelTV;
ChannelTV currentChannelTV;
bool needRebuild = true;
if (templateChannelTV is ChannelDVB)
{
if (this.tabControlScanner.SelectedTab == this.tabPageScanPredefined)
{
List<string> region;
if (this.currentCountries.TryGetValue((string)this.comboBoxScanRegion.SelectedItem, out region))
{
foreach (string currentFrequency in region)
{
if (!continueScanning) break;
currentChannelTV = templateChannelTV.MakeCopy() as ChannelTV;
TransponderReader.PopulateChannelWithTransponderSettings(ref currentChannelTV, currentFrequency);
needRebuild = ScanProbeFrequency(currentChannelTV, needRebuild);
}
}
}
else if (this.tabControlScanner.SelectedTab == this.tabPageScanManual)
{
int startFrequency = int.Parse(this.textBoxScanStartFrequency.Text);
int stopFrequency = int.Parse(this.textBoxScanStopFrequency.Text);
int bandwidth = int.Parse(this.textBoxScanBandwidth.Text);
int currentFrequency = startFrequency;
while (currentFrequency <= stopFrequency && continueScanning)
{
currentChannelTV = templateChannelTV.MakeCopy() as ChannelTV;
(currentChannelTV as ChannelDVB).Frequency = currentFrequency;
currentFrequency += bandwidth;
needRebuild = ScanProbeFrequency(currentChannelTV, needRebuild);
}
}
}
else if (templateChannelTV is ChannelAnalogic)
{
int startChannelNumber = 0; // int.Parse(this.textBoxScanStartFrequency.Text);
int stopChannelNumber = 100; // int.Parse(this.textBoxScanStopFrequency.Text);
int currentChannelNumber = startChannelNumber;
while (currentChannelNumber <= stopChannelNumber && continueScanning)
{
currentChannelTV = templateChannelTV.MakeCopy() as ChannelTV;
(currentChannelTV as ChannelAnalogic).Channel = currentChannelNumber;
currentChannelNumber++;
needRebuild = ScanProbeFrequency(currentChannelTV, needRebuild);
}
}
this.buttonScanChannels.Enabled = true;
this.buttonScanStop.Enabled = false;
}
else
MessageBox.Show(Properties.Resources.WizardYouMustCreateChannelTemplate);
}