1.1 --- a/MainForm.cs Thu Oct 04 19:25:35 2018 +0200
1.2 +++ b/MainForm.cs Sat Oct 06 14:07:31 2018 +0200
1.3 @@ -15,7 +15,13 @@
1.4
1.5 namespace SatChanGen
1.6 {
1.7 - public partial class MainForm : Form
1.8 + public struct ProgressReport
1.9 + {
1.10 + public int Max { get; set; }
1.11 + public int Value { get; set; }
1.12 + }
1.13 +
1.14 + public partial class MainForm : Form, IProgress<ProgressReport>
1.15 {
1.16 public MainForm()
1.17 {
1.18 @@ -40,5 +46,67 @@
1.19 //Export to XML for MediaPortal to import
1.20 MediaPortal.Export(channels, tuners, "channels.xml", false);
1.21 }
1.22 +
1.23 + /// <summary>
1.24 + ///
1.25 + /// </summary>
1.26 + /// <param name="sender"></param>
1.27 + /// <param name="e"></param>
1.28 + private async void iButtonSatIndex_Click(object sender, EventArgs e)
1.29 + {
1.30 + await Task.Run(() => FetchSatIndexChannels());
1.31 + }
1.32 +
1.33 + /// <summary>
1.34 + ///
1.35 + /// </summary>
1.36 + private void FetchSatIndexChannels()
1.37 + {
1.38 + List<Channel> channels = new List<Channel>();
1.39 +
1.40 + channels.AddRange(SatIndex.Parse(this, channels, "http://www.satindex.de/tv/1/1/", "19.2°E", true));
1.41 + //channels.AddRange(KingOfSat.Parse(channels, "http://en.kingofsat.net/pack-hdplus.php", "19.2°E", true));
1.42 + //channels.AddRange(KingOfSat.Parse(channels, "http://en.kingofsat.net/pack-arddigital.php", "19.2°E", true));
1.43 + //channels.AddRange(KingOfSat.Parse(channels, "http://en.kingofsat.net/pack-zdfvision.php", "19.2°E", true));
1.44 + //channels.AddRange(KingOfSat.Parse(channels, "http://en.kingofsat.net/pack-tntsat.php", "19.2°E", true, "TNTSAT"));
1.45 +
1.46 + //Discard non HD channels we don't need
1.47 + channels = SatIndex.CleanChannelList(channels);
1.48 +
1.49 + //Declare tuner cards so that we don't need to create mapping manually after import
1.50 + List<string> tuners = new List<string>() { "3", "4" };
1.51 +
1.52 + //Export to XML for MediaPortal to import
1.53 + MediaPortal.Export(channels, tuners, "channels.xml", false);
1.54 +
1.55 + }
1.56 +
1.57 + /// <summary>
1.58 + ///
1.59 + /// </summary>
1.60 + /// <param name="aProgress"></param>
1.61 + public void Report(ProgressReport aProgress)
1.62 + {
1.63 + MethodInvoker methodInvokerDelegate = delegate ()
1.64 + {
1.65 + toolStripProgressBar.Maximum = aProgress.Max;
1.66 + toolStripProgressBar.Value = aProgress.Value;
1.67 + toolStripStatusLabel.Text = aProgress.Value + " / " + aProgress.Max;
1.68 + };
1.69 +
1.70 + //This will be true if Current thread is not UI thread.
1.71 + if (InvokeRequired)
1.72 + {
1.73 + Invoke(methodInvokerDelegate);
1.74 + }
1.75 + else
1.76 + {
1.77 + methodInvokerDelegate();
1.78 + }
1.79 +
1.80 + }
1.81 +
1.82 +
1.83 +
1.84 }
1.85 }