} // buttonOk_Click_Implementation #endregion #region 'General' form setup & get data private void InitGeneralData() { // service logo var serviceLogo = AppUiConfiguration.Current.ServiceLogoMappings.FromServiceKey(Task.Channel.ServiceKey); pictureChannelLogo.Image = serviceLogo.GetImage(LogoSize.Size64); // service name labelChannelName.Text = string.Format("{0} {1}", Task.Channel.LogicalNumber, Task.Channel.Name); // program name if (Task.Program != null) { labelProgramDescription.Text = Task.Program.Title; labelProgramSchedule.Text = string.Format("{0} ({1})", FormatString.DateTimeFromToMinutes(Task.Program.LocalStartTime, Task.Program.LocalEndTime, LocalReferenceTime), FormatString.TimeSpanTotalMinutes(Task.Program.Duration, FormatString.Format.Extended)); } else { labelChannelName.Top = pictureChannelLogo.Top; labelChannelName.Height = pictureChannelLogo.Height; labelProgramDescription.Visible = false; labelProgramSchedule.Visible = false; } // if-else } // InitGeneralData
} // constructor public void DisplayData(UiBroadcastService service, EpgProgram epgProgram, DateTime referenceTime, string caption) { Service = service; EpgProgram = epgProgram; labelProgramCaption.Text = caption; labelProgramCaption.Visible = caption != null; labelProgramTime.Visible = (epgProgram != null); labelProgramDetails.Visible = (epgProgram != null); pictureProgramThumbnail.ImageLocation = null; buttonProgramProperties.Visible = (epgProgram != null); pictureProgramThumbnail.Cursor = (epgProgram != null) ? Cursors.Hand : Cursors.Default; if (EpgProgram == null) { labelProgramTitle.Text = Properties.Texts.EpgNoInformation; pictureProgramThumbnail.Image = Properties.Resources.EpgNoProgramImage; } else { labelProgramTitle.Text = EpgProgram.Title; labelProgramTime.Text = string.Format("{0} ({1})", FormatString.DateTimeFromToMinutes(EpgProgram.LocalStartTime, EpgProgram.LocalEndTime, referenceTime), FormatString.TimeSpanTotalMinutes(EpgProgram.Duration, FormatString.Format.Extended)); labelProgramDetails.Text = string.Format("{0} / {1}", (EpgProgram.Genre != null) ? EpgProgram.Genre.Description : Properties.Texts.EpgNoGenre, (EpgProgram.ParentalRating != null) ? EpgProgram.ParentalRating.Description : Properties.Texts.EpgNoParentalRating); pictureProgramThumbnail.Image = Properties.Resources.EpgLoadingProgramImage; pictureProgramThumbnail.ImageLocation = null; // TODO: EPG // pictureProgramThumbnail.ImageLocation = IpTvProvider.Current.EpgInfo.GetEpgProgramThumbnailUrl(service, EpgProgram, false); } // if-else } // DisplayData
} // DisplayEpgPrograms private void DisplayEpgProgram(int index) { TimeSpan ellapsed; if ((index < 0) || (index > 3)) { return; } EpgIndex = index; epgProgressBar.Visible = (index == 1); labelEndTime.Visible = (index == 1); labelStartTime.Visible = (index == 1); labelFromTo.Visible = (index != 1); var epgProgram = EpgPrograms?[EpgIndex]; buttonDetails.Enabled = DetailsEnabled && (epgProgram != null) && (!epgProgram.IsBlank); labelProgramTitle.Text = (epgProgram != null) ? epgProgram.Title : Properties.Texts.EpgNoInformation; if (epgProgram == null) { labelFromTo.Text = null; labelStartTime.Text = null; labelEllapsed.Text = null; EnableBackForward(false, false); return; } // if switch (EpgIndex) { case 0: labelFromTo.Text = FormatString.DateTimeFromToMinutes(epgProgram.LocalStartTime, epgProgram.LocalEndTime, LocalReferenceTime); ellapsed = (LocalReferenceTime - epgProgram.LocalEndTime); labelEllapsed.Text = string.Format(Properties.Texts.ProgramEnded, FormatString.TimeSpanTotalMinutes(ellapsed, FormatString.Format.Extended)); EnableBackForward(false, EpgPrograms[1] != null); break; case 1: labelStartTime.Text = string.Format("{0:HH:mm}", epgProgram.LocalStartTime); labelEndTime.Text = string.Format("{0:t}", epgProgram.LocalEndTime); ellapsed = (LocalReferenceTime - epgProgram.LocalStartTime); epgProgressBar.MaximumValue = epgProgram.Duration.TotalMinutes; epgProgressBar.Value = ellapsed.TotalMinutes; labelEllapsed.Text = string.Format(Properties.Texts.ProgramStarted, FormatString.TimeSpanTotalMinutes(ellapsed, FormatString.Format.Extended)); EnableBackForward(EpgPrograms[0] != null, EpgPrograms[2] != null); break; default: labelFromTo.Text = FormatString.DateTimeFromToMinutes(epgProgram.LocalStartTime, epgProgram.LocalEndTime, LocalReferenceTime); ellapsed = (epgProgram.LocalStartTime - LocalReferenceTime); labelEllapsed.Text = string.Format(Properties.Texts.ProgramWillStart, FormatString.TimeSpanTotalMinutes(ellapsed, FormatString.Format.Extended)); EnableBackForward(SafeGetItem(EpgPrograms, EpgIndex - 1) != null, SafeGetItem(EpgPrograms, EpgIndex + 1) != null); break; } // switch } // DisplayEpgProgram
} // ChangeOkButtonText private void SetChannelDetails() { pictureChannelLogo.Image = SelectedService.Logo.GetImage(Configuration.Logos.LogoSize.Size64); labelChannelName.Text = string.Format("{0} {1}", SelectedService.DisplayLogicalNumber, SelectedService.DisplayName); if (SelectedProgram != null) { labelProgramDescription.Text = SelectedProgram.Title; labelProgramSchedule.Text = string.Format("{0} ({1})", FormatString.DateTimeFromToMinutes(SelectedProgram.LocalStartTime, SelectedProgram.LocalEndTime, LocalReferenceTime), FormatString.TimeSpanTotalMinutes(SelectedProgram.Duration, FormatString.Format.Extended)); } else { labelChannelName.Top = pictureChannelLogo.Top; labelChannelName.Height = pictureChannelLogo.Height; labelProgramDescription.Visible = false; labelProgramSchedule.Visible = false; } // if-else } // SetChannelDetails
static int Main(string[] args) { try { var StartTime = DateTime.Now; // Set console icon using (var icon = Properties.Resources.ConsoleEpgLoader) { UnsafeNativeMethods.SetConsoleIcon(icon.Handle); } // using icon Console.Title = "TV-Anytime EPG loader utility"; if (!ProcessArguments(args)) { return(1); } // if DisplayLogo(); var downloader = new UiDvbStpSimpleDownloader() { Request = new UiDvbStpSimpleDownloadRequest() { NoDataTimeout = 180000, PayloadId = 0x06, SegmentId = null, // accept any segment MulticastAddress = DiscoveryEndpoint.Address, MulticastPort = DiscoveryEndpoint.Port, Description = "Downloading list of EPG servers...", DescriptionParsing = "Processing list of EPG servers...", PayloadDataType = typeof(BroadcastContentGuideDiscoveryRoot), AllowXmlExtraWhitespace = false, XmlNamespaceReplacer = NamespaceUnification.Replacer, }, }; Console.Write("Downloading list of EPG servers..."); downloader.Download(null); if (!downloader.IsOk) { Console.WriteLine(" failed"); return(-1); } // if Console.WriteLine(" ok"); var bcgDiscovery = downloader.Response.DeserializedPayloadData as BroadcastContentGuideDiscoveryRoot; if ((bcgDiscovery == null) || (bcgDiscovery.Offering == null) || (bcgDiscovery.Offering.Length < 1) || (bcgDiscovery.Offering[0].ContentGuides == null)) { throw new ApplicationException("List is EPG servers is empty!"); } // if var serversList = new List <IPEndPoint>(); foreach (var item in bcgDiscovery.Offering[0].ContentGuides) { if ((item.Id == "p_f") || (item.TransportMode == null) || (item.TransportMode.Push == null)) { continue; } foreach (var pushServer in item.TransportMode.Push) { serversList.Add(new IPEndPoint(IPAddress.Parse(pushServer.Address), pushServer.Port)); } // foreach } // if if (serversList.Count == 0) { throw new ApplicationException("List is push EPG servers is empty!"); } // if PrepareDatabase(); CompactDatabase(); ProcessEpgSource(serversList); Log("Main thread {0} waiting for processing threads to end...", Thread.CurrentThread.ManagedThreadId); MainEvent = new AutoResetEvent(false); MainEvent.WaitOne(); UpdateDbStatus(0); CompactDatabase(); Console.WriteLine(); Console.WriteLine("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"); Console.WriteLine("Ellapsed time: {0}", FormatString.TimeSpanTotalMinutes(DateTime.Now - StartTime, FormatString.Format.Extended)); Console.WriteLine(); return(0); } catch (Exception ex) { Exception = ex; } // try-catch if (Exception != null) { try { UpdateDbStatus(-1); } catch { // ignore } // try-catch Console.WriteLine(); Console.WriteLine("UNEXPECTED EXCEPTION!"); Console.WriteLine(Exception.GetType().FullName); Console.WriteLine(Exception.Message); Console.WriteLine(); MyApplication.HandleException(null, Exception); return(-1); } // if return(0); } // Main