private void Form1_Load(object sender, EventArgs e) { _soundPlayer.LoadAsync(); AlertsSourceConfig[] configs = new AlertsSourceConfig[] { new AlertsSourceConfig() { Uri = "http://www.oref.org.il/WarningMessages/alerts.json", Format = AlertsFormat.Oref, RegularPollingFrequency = TimeSpan.FromMilliseconds(500), FastPollingFrequency = TimeSpan.FromMilliseconds(200) }, new AlertsSourceConfig() { Uri = "http://www.mako.co.il/Collab/amudanan/adom.txt", Format = AlertsFormat.Oref, RegularPollingFrequency = TimeSpan.FromMilliseconds(500), FastPollingFrequency = TimeSpan.FromMilliseconds(200) }, new AlertsSourceConfig() { Uri = "http://alerts.ynet.co.il/alertsrss/YnetPicodeHaorefAlertFiles.js?callback=jsonCallback", Format = AlertsFormat.Ynet, RegularPollingFrequency = TimeSpan.FromMilliseconds(500), FastPollingFrequency = TimeSpan.FromMilliseconds(200) }, }; _resolvers = configs.ToDictionary(config => new DnsAlertsSourceResolver(config), config => config); _sources = new Dictionary <IAlertsSource, IAlertsSourcePoller>(); foreach (DnsAlertsSourceResolver resolver in _resolvers.Keys) { resolver.AlertsSourceCreated += new EventHandler <AlertsSourceEventArgs>(resolver_AlertsSourceCreated); resolver.AlertsSourceRemoved += new EventHandler <AlertsSourceEventArgs>(resolver_AlertsSourceRemoved); resolver.Start(); } _alertsSourcesPoller = new AlertsSourcesPoller(); _alertsSourcesPoller.ActiveAlertsChanged += new EventHandler <AlertsEventArgs>(_alerts_ActiveAlertsChanged); _alertsSourcesPoller.Connected += new EventHandler(_alerts_Connected); _alertsSourcesPoller.Connecting += new EventHandler(_alerts_Connecting); _alertsSourcesPoller.Start(); UserConfiguration.ConfigurationChanged += new EventHandler <ConfigurationChangedEventArgs>(UserConfiguration_ConfigurationChanged); LoadUserConfiguration(); //startup minimized this.WindowState = FormWindowState.Minimized; }
private void resolver_AlertsSourceCreated(object sender, AlertsSourceEventArgs e) { if (InvokeRequired) { InvokeAsync(() => resolver_AlertsSourceCreated(sender, e)); return; } AlertsSourceConfig config = _resolvers[sender as DnsAlertsSourceResolver]; AlertsSourcePoller poller = new AlertsSourcePoller(e.Source, config.RegularPollingFrequency, config.FastPollingFrequency); _sources.Add(e.Source, poller); _alertsSourcesPoller.Add(poller); }
public DnsAlertsSourceResolver(AlertsSourceConfig config) { _uri = new Uri(config.Uri); Config = config; }