public NewsFeedModel GetNews(string newsFeed, string storyCount) { _news = new NewsFeedModel(); var loadedEventArgs = new LoadEventArgs(); string queryString = string.Format("{0}?feed={1}&pageSize={2}", Settings.NewsUrl, newsFeed ?? "", storyCount ?? ""); var webClient = new SharpGIS.GZipWebClient(); Observable.FromEvent <DownloadStringCompletedEventArgs>(webClient, "DownloadStringCompleted") .ObserveOn(Scheduler.ThreadPool) .Select(x => ProcessNews(x.EventArgs.Result)) .ObserveOn(Scheduler.Dispatcher) .Subscribe(s => { BuildNewsFeedModel(s); loadedEventArgs.IsLoaded = true; loadedEventArgs.Message = ""; OnNewsLoaded(loadedEventArgs); }, e => { loadedEventArgs.IsLoaded = false; loadedEventArgs.Message = e.Message.ToString(CultureInfo.InvariantCulture); OnNewsLoaded(loadedEventArgs); }); webClient.DownloadStringAsync(new Uri(queryString)); return(_news); }
protected virtual void OnFinalScoresLoaded(LoadEventArgs e) { if (FinalScoresLoaded != null) { FinalScoresLoaded(this, e); } }
protected virtual void OnFeaturesLoaded(LoadEventArgs e) { if (FeaturesLoaded != null) { FeaturesLoaded(this, e); } }
/// <summary> /// Helper function used to fire load events. /// </summary> /// <param name="e">The load event arguments.</param> /// <param name="clearOnly">Only clear the action, don't fire the event.</param> private void OnLoad(LoadEventArgs e, bool clearOnly) { if (!clearOnly && Load != null) { Load(this, e); } }
private static bool ProcessLoadEvent(LoadEventArgs args) { if (args == null || args.Loader == null) { return(false); } try { if (!args.Loader.Load()) { Interlocked.Increment(ref _isLoadError); if (args.IgnoreError) { TraceLog.WriteError("GameLoader[{0}] data:\"{1}\" failure.", _isLoadError, args.Loader.LoadTypeName); return(false); } throw new Exception(string.Format("GameLoader[{0}] data:\"{1}\" failure.", _isLoadError, args.Loader.LoadTypeName)); } return(true); } catch (Exception ex) { Interlocked.Increment(ref _isLoadError); if (args.IgnoreError) { TraceLog.WriteError("GameLoader[{0}] error:{1}", _isLoadError, ex); return(false); } throw new Exception("GameLoader error:", ex); } }
protected virtual void OnUpcomingScheduleLoaded(LoadEventArgs e) { if (ServiceLoaded != null) { ServiceLoaded(this, e); } }
protected virtual void OnTwitterLoaded(LoadEventArgs e) { if (ServiceLoaded != null) { ServiceLoaded(this, e); } }
protected virtual void OnNewsStreamLoaded(LoadEventArgs e) { if (NewsStreamLoaded != null) { NewsStreamLoaded(this, e); } }
void lampDimmer_LoadStateChange(LightingBase lightingObject, LoadEventArgs args) { if (EventIds.ContainsKey(args.EventId)) { CrestronConsole.PrintLine("Lamp dimmer: {0}", EventIds[args.EventId]); } // use this structure to react to the different events switch (args.EventId) { case LoadEventIds.IsOnEventId: xp.BooleanInput[1].BoolValue = !lampDimmer.DimmingLoads[1].IsOn; xp.BooleanInput[2].BoolValue = lampDimmer.DimmingLoads[1].IsOn; break; case LoadEventIds.LevelChangeEventId: xp.UShortInput[1].UShortValue = lampDimmer.DimmingLoads[1].LevelFeedback.UShortValue; break; case LoadEventIds.LevelInputChangedEventId: xp.UShortInput[1].CreateRamp(lampDimmer.DimmingLoads[1].Level.RampingInformation); break; default: break; } }
/// <summary> /// Updates control size after load of the parent control /// </summary> /// <param name="e"></param> public void OnLoad(LoadEventArgs e) { if (e == null) { throw new InvalidArgumentException("parameter \"e\" is null"); } this.View.SetBounds(e.Rect.Left, e.Rect.Top, e.Rect.Width, e.Rect.Height); }
public NewsFeature GetFeatures(string team, string pageSize) { _features = new NewsFeature(); _features.FeatureItems.Clear(); var loadedEventArgs = new LoadEventArgs(); string qS = string.Format("{0}?feed={1}&pageSize={2}", Settings.FeaturesUrl, team ?? "", pageSize ?? ""); var wb = new SharpGIS.GZipWebClient(); Observable.FromEvent <DownloadStringCompletedEventArgs>(wb, "DownloadStringCompleted") .ObserveOn(Scheduler.ThreadPool) .Select(newString => ProcessFeatures(newString.EventArgs.Result)) .Subscribe(s => { loadedEventArgs.IsLoaded = true; loadedEventArgs.Message = ""; _features.Copyright = s.Copyright; _features.Description = s.Description; _features.Language = s.Language; _features.Link = s.Link; _features.Title = s.Title; for (int i = 0; i < s.FeatureItems.Count; i++) { NewsFeatureItem newsFeatureItem = s.FeatureItems[i]; Deployment.Current.Dispatcher.BeginInvoke(() => _features.FeatureItems.Add(newsFeatureItem)); } Deployment.Current.Dispatcher.BeginInvoke(() => OnFeaturesLoaded(loadedEventArgs)); if (!(App.isoSettings.Contains("Features"))) { ThreadPool.QueueUserWorkItem(o => { var json = JsonHelpers.SerializeJson(_features); App.isoSettings.Add("Features", json); }); } else { ThreadPool.QueueUserWorkItem(o => { var json = JsonHelpers.SerializeJson(_features); App.isoSettings["Features"] = json; }); } }, e => { loadedEventArgs.IsLoaded = false; loadedEventArgs.Message = e.Message.ToString(CultureInfo.InvariantCulture); } ); wb.DownloadStringAsync(new Uri(qS)); return(_features); }
internal void DoAfterLoad(LoadEventArgs e) { var handler = AfterLoad; if (handler != null) { handler(this, e); } }
internal void DoBeforeLoad(LoadEventArgs e) { var handler = BeforeLoad; if (handler != null) { handler(this, e); } }
private void GraphControl_Load(object sender, EventArgs e) { var size = new Size(this.ControlSize.Width, this.ControlSize.Height); size.Height = this.btnFitToScreenByTime.Top - 10; var args = new LoadEventArgs(new Rect(0, 0, size.Width, size.Height)); this.Load?.Invoke(this, args); }
private static void ComponentTemplateCreate(ComponentTemplate ct, LoadEventArgs args, EventPhases phase) { if (ct.Version != 0) { return; } // add your TBBs here }
void wallDimmer_LoadStateChange(LightingBase lightingObject, LoadEventArgs args) { if (EventIds.ContainsKey(args.EventId)) { CrestronConsole.PrintLine("Wall dimmer: {0}", EventIds[args.EventId]); } // see below }
protected virtual void OnLoadingProcessChanged(LoadEventArgs e) { var handler = this.LoadingProcessChanged; if (handler != null) { handler(this, e); } }
private void OnLoad <T>(T loadedObject) { if (Loaded != null) { LoadEventArgs args = new LoadEventArgs { LoadedObject = loadedObject }; Loaded(this, args); } }
private void RetrieveTwitterValues(Uri twitterFeed, ObservableCollectionEx <TwitterStatusModel> twitterStatus) { var wc = new GZipWebClient(); ErrorService service = new ErrorService("Unable to retrieve the twitter feed.", "").ErrorDialog(true); var loadedEventArgs = new LoadEventArgs(); IObservable <IEvent <DownloadStringCompletedEventArgs> > o = Observable.FromEvent <DownloadStringCompletedEventArgs>(wc, "DownloadStringCompleted"); o.Subscribe(s => { if (s.EventArgs != null) { try { string twitterResults = s.EventArgs.Result; if (!String.IsNullOrWhiteSpace(twitterResults)) { XDocument doc = XDocument.Parse(twitterResults); ParseTwitterResults(doc, twitterStatus); } else { service.HandleError(); } } catch (Exception) { service.HandleError(); } finally { loadedEventArgs.IsLoaded = true; OnTwitterLoaded(loadedEventArgs); } } else { service.HandleError(); loadedEventArgs.IsLoaded = true; OnTwitterLoaded(loadedEventArgs); } }, e => { loadedEventArgs.IsLoaded = true; loadedEventArgs.Message = e.Message.ToString(CultureInfo.InvariantCulture); OnTwitterLoaded(loadedEventArgs); service.HandleError(); } ); wc.DownloadStringAsync(twitterFeed); }
public static bool Add(DataLoader dataLoader, bool ignoreError) { var args = new LoadEventArgs() { Loader = dataLoader, IgnoreError = ignoreError }; LoadEventHandle callbackFunc = LoadEvent; if (callbackFunc != null) { return callbackFunc(args); } return false; }
public ObservableCollection <UpComingViewSchedule> GetUpcomingSchedule(string url, string pageStart, string pageSize) { _upcoming = new ObservableCollection <UpComingViewSchedule>(); var upcoming2 = new List <UpComingSchedule>(); var loadedEventArgs = new LoadEventArgs(); string queryString = String.Format("{0}?start={1}&pageSize={2}", url, pageStart ?? "", pageSize ?? ""); var wb = new GZipWebClient(); Observable.FromEvent <DownloadStringCompletedEventArgs>(wb, "DownloadStringCompleted") .ObserveOn(Scheduler.ThreadPool) .Select(x => ProcessUpcomingItems(x.EventArgs.Result)) .ObserveOn(Scheduler.Dispatcher) .Subscribe(s => { loadedEventArgs.IsLoaded = true; loadedEventArgs.Message = ""; foreach (UpComingSchedule upComingSchedule in s) { upcoming2.Add(upComingSchedule); _upcoming.Add(ConvertToView(upComingSchedule)); } ThreadPool.QueueUserWorkItem(o => { InsertIntoIS(upcoming2); CacheUpComingSchedule(_upcoming); }); OnUpcomingScheduleLoaded(loadedEventArgs); }, e => { loadedEventArgs.IsLoaded = true; //TODO: LOG Error ErrorService error = new ErrorService( "Unable to retrieve any upcoming events", "") .ErrorDialog(true); error.HandleError(); OnUpcomingScheduleLoaded(loadedEventArgs); } ); wb.DownloadStringAsync(new Uri(queryString)); //TODO: Add this to the service //if (!_upcoming.Any()) //{ // _upcoming.Add(new UpComingViewSchedule{Teams = "Regular season complete", GameDateTime = "Enjoy the playoffs"}); //} return(_upcoming); }
private void SetControlApps() { if (selectedDevice != null) { GoogleCommand.Enabled = selectedDevice.HasCapability(Launcher.Browser); ShowToastCommand.Enabled = selectedDevice.HasCapability(ToastControl.ShowToast); NetflixCommand.Enabled = selectedDevice.HasCapability(Launcher.Netflix) || selectedDevice.HasCapability(Launcher.NetflixParams); YouTubeCommand.Enabled = selectedDevice.HasCapability(Launcher.YouTube); MyDialAppCommand.Enabled = selectedDevice.HasCapability("Launcher.Levak"); AppStoreCommand.Enabled = selectedDevice.HasCapability(Launcher.AppStoreParams); if (selectedDevice.HasCapability(Launcher.RunningAppSubscribe)) { var runningAppListener = new ResponseListener ( loadEventArg => { var appInfo = LoadEventArgs.GetValue <AppInfo>(loadEventArg); App.MainDispatcher.RunAsync(CoreDispatcherPriority.High, () => { selectedApp = appInfo; }); }, serviceCommandError => { } ); launcher.SubscribeRunningApp(runningAppListener); } if (selectedDevice.HasCapability(Launcher.ApplicationList)) { var rappListListener = new ResponseListener ( loadEventArg => { var apps = LoadEventArgs.GetValue <List <AppInfo> >(loadEventArg); App.MainDispatcher.RunAsync(CoreDispatcherPriority.High, () => { AppsList = apps; }); }, serviceCommandError => { } ); launcher.GetAppList(rappListListener); } } }
void SampleCarnivore_Load(object sender, LoadEventArgs e) { try { if (_targetAnimal == null) { _targetAnimal = (AnimalState)LookFor(_targetAnimal); } } catch (Exception exc) { WriteTrace(exc.ToString()); } }
public static bool Add(DataLoader dataLoader, bool ignoreError) { var args = new LoadEventArgs() { Loader = dataLoader, IgnoreError = ignoreError }; LoadEventHandle callbackFunc = LoadEvent; if (callbackFunc != null) { return(callbackFunc(args)); } return(false); }
private void InputCommandExecute(object obj) { var listener = new ResponseListener ( loadEventArg => { var launchPickerSession = LoadEventArgs.GetValue <LaunchSession>(loadEventArg); inputPickerSession = launchPickerSession; }, serviceCommandError => { } ); externalInputControl.LaunchInputPicker(listener); }
private void SetControlKeys() { if (selectedDevice != null) { KeyCommand.Enabled = selectedDevice.HasCapability(KeyControl.KeyCode); ChannelCommand.Enabled = selectedDevice.HasCapability(TvControl.ChannelUp); PowerCommand.Enabled = selectedDevice.HasCapability(PowerControl.Off); if (selectedDevice.HasCapability(TvControl.ChannelList)) { var listener = new ResponseListener ( loadEventArg => { var channels = LoadEventArgs.GetValue <List <ChannelInfo> >(loadEventArg); App.MainDispatcher.RunAsync(CoreDispatcherPriority.High, () => { Channels = channels; }); }, serviceCommandError => { } ); tvControl.GetChannelList(listener); } if (selectedDevice.HasCapability(TvControl.ChannelSubscribe)) { var listener = new ResponseListener ( loadEventArg => { var channel = LoadEventArgs.GetValue <ChannelInfo>(loadEventArg); App.MainDispatcher.RunAsync(CoreDispatcherPriority.High, () => { SelectedChannel = channel; }); }, serviceCommandError => { } ); tvControl.SubscribeCurrentChannel(listener); } } }
// First event fired on an organism each turn void LoadEvent(object sender, LoadEventArgs e) { try { if (targetPlant != null) { // See if our target plant still exists (it may have died) // LookFor returns null if it isn't found targetPlant = (PlantState)LookFor(targetPlant); } } catch (Exception exc) { // WriteTrace is useful in debugging creatures WriteTrace(exc.ToString()); } }
private void ProgressChanged(object sender, LoadEventArgs e) { int n = 0; var listbox = logListBox[n]; if (e.line_number > 0) statusline1.Content = "" + e.line_number; if (firstLoad) { listbox.Items.Clear(); for (int i=0; i< e.line_number;i++) { listbox.Items.Add(logEntries[new Common.EntryId(i)]); } } firstLoad = false; }
// First event fired on an organism each turn void LoadEvent(object sender, LoadEventArgs e) { try { if(targetAnimal != null) { // See if our target animal still exists (it may have died) // LookFor returns null if it isn't found targetAnimal = (AnimalState) LookFor(targetAnimal); } } catch(Exception exc) { // WriteTrace is useful in debugging creatures WriteTrace(exc.ToString()); } }
public ObservableCollection <CompletedViewSchedule> GetFinalScores(string url, string pageStart, string pageSize) { _finalScores = new ObservableCollection <CompletedViewSchedule>(); var finalScores2 = new List <CompletedSchedule>(); var loadedEventArgs = new LoadEventArgs(); string queryString = string.Format("{0}?start={1}&pageSize={2}", url, pageStart ?? "", pageSize ?? ""); var wb = new SharpGIS.GZipWebClient(); Observable.FromEvent <DownloadStringCompletedEventArgs>(wb, "DownloadStringCompleted") .ObserveOn(Scheduler.ThreadPool) .Select(x => ProcessFinalItems(x.EventArgs.Result)) .ObserveOn(Scheduler.Dispatcher) .Subscribe(s => { loadedEventArgs.IsLoaded = true; loadedEventArgs.Message = ""; foreach (CompletedSchedule finalScores in s) { finalScores2.Add(finalScores); _finalScores.Add(ConvertToFinalView(finalScores)); } ThreadPool.QueueUserWorkItem(o => { InsertIntoIS(finalScores2); CacheFinalScores(_finalScores); }); OnFinalScoresLoaded(loadedEventArgs); }, e => { loadedEventArgs.IsLoaded = true; //TODO: LOG Error ErrorService error = new ErrorService( "Unable to retrieve any upcoming events", "") .ErrorDialog(true); error.HandleError(); OnFinalScoresLoaded(loadedEventArgs); } ); wb.DownloadStringAsync(new Uri(queryString)); return(_finalScores); }
private void ModelsOnOnWorldLoad(object sender, LoadEventArgs args) { switch (args.Status) { case LoadEventArgs.LoadStatus.Started: loadingPath = args.Message; m_cancelDialog = new SceneLoadStatus(Path.GetFileName(loadingPath)); m_cancelDialog.PropertyChanged += CancelDialogOnPropertyChanged; hasCancelled = false; break; case LoadEventArgs.LoadStatus.Loading: break; case LoadEventArgs.LoadStatus.Failed: m_cancelDialog?.Close(); m_cancelDialog = null; if (!hasCancelled && m_models.Settings.LastWorlds.Contains(loadingPath)) { if (MessageBox.Show("World file could not be loaded: " + args.Message + "; should it " + "be removed from the list of recent scenes?", "Unable to load scene", MessageBoxButton.YesNo, MessageBoxImage.Error) == MessageBoxResult.Yes) { int index = m_models.Settings.LastWorlds.IndexOf(loadingPath); if (index >= 0) { m_models.Settings.LastWorlds.RemoveAt(index); } } } else { MessageBox.Show(args.Message, "Unable to load scene", MessageBoxButton.OK); } break; case LoadEventArgs.LoadStatus.Finished: m_cancelDialog?.Close(); m_cancelDialog = null; break; } }
private void StartApp(object arg) { var app = arg as AppInfo; var listener = new ResponseListener ( loadEventArg => { var session = LoadEventArgs.GetValue <LaunchSession>(loadEventArg); SetRunningAppInfo(session); }, serviceCommandError => { } ); launcher.LaunchAppWithInfo(app, null, listener); }
// First event fired on an organism each turn private void MyAnimal_Load(object sender, LoadEventArgs e) { try { if (targetPlant != null) { // See if our target plant still exists (it may have died) // LookFor returns null if it isn't found targetPlant = (PlantState) LookFor(targetPlant); if (targetPlant == null) // WriteTrace is the best way to debug your creatures. WriteTrace("Target plant disappeared."); } } catch (Exception exc) { WriteTrace(exc.ToString()); } }
async public Task<bool> GetData() { SessionList = new ObservableCollection<Session>(); SpeakerList = new ObservableCollection<Speaker>(); DateTime sessionLastDownload = DateTime.MinValue; // Get the data from Isolated storage if it is there if (IsolatedStorageSettings.ApplicationSettings.Contains("SessionData")) { var converted = (IsolatedStorageSettings.ApplicationSettings["SessionData"] as IEnumerable<Session>); SessionList = converted.ToObservableCollection(SessionList); var loadedEventArgs = new LoadEventArgs { IsLoaded = true, Message = string.Empty }; OnDataLoaded(loadedEventArgs); } // Get the data from Isolated storage if it is there if (IsolatedStorageSettings.ApplicationSettings.Contains("SpeakerData")) { var converted = (IsolatedStorageSettings.ApplicationSettings["SpeakerData"] as IEnumerable<Speaker>); SpeakerList = converted.ToObservableCollection(SpeakerList); var loadedEventArgs = new LoadEventArgs { IsLoaded = true, Message = string.Empty }; OnDataLoaded(loadedEventArgs); } // Get the last time the data was downloaded. if (IsolatedStorageSettings.ApplicationSettings.Contains("SessionLastDownload")) { sessionLastDownload = (DateTime)IsolatedStorageSettings.ApplicationSettings["SessionLastDownload"]; } // Check if we need to download the latest data, or if we can just use the isolated storage data // Cache the data for 2 hours if ((sessionLastDownload.AddHours(2) < DateTime.Now) || !IsolatedStorageSettings.ApplicationSettings.Contains("SessionData")) { var responseString = string.Empty; // Download the session data var httpClient = new HttpClient(new HttpClientHandler()); //new SharpGIS.GZipWebClient(); var response = await httpClient.GetAsync(Settings.ConferenceDataUri); response.EnsureSuccessStatusCode(); responseString = await response.Content.ReadAsStringAsync(); LoadFromString(responseString); //conferenceWebClient.DownloadStringCompleted += conferenceWebClient_DownloadStringCompleted; //conferenceWebClient.DownloadStringAsync(new Uri(Settings.ConferenceDataUri)); // Download speaker data //var speakerWebClient = new SharpGIS.GZipWebClient(); //speakerWebClient.DownloadStringCompleted += speakerWebClient_DownloadStringCompleted; //speakerWebClient.DownloadStringAsync(new Uri(Settings.SpeakerServiceUri)); } return true; }
private static bool ProcessLoadEvent(LoadEventArgs args) { if (args == null || args.Loader == null) { return false; } try { if (!args.Loader.Load()) { Interlocked.Increment(ref _isLoadError); if (args.IgnoreError) { TraceLog.WriteError("GameLoader[{0}] data:\"{1}\" failure.", _isLoadError, args.Loader.LoadTypeName); return false; } throw new Exception(string.Format("GameLoader[{0}] data:\"{1}\" failure.", _isLoadError, args.Loader.LoadTypeName)); } return true; } catch (Exception ex) { Interlocked.Increment(ref _isLoadError); if (args.IgnoreError) { TraceLog.WriteError("GameLoader[{0}] error:{1}", _isLoadError, ex); return false; } throw new Exception("GameLoader error:", ex); } }
void lampDimmer_LoadStateChange(LightingBase lightingObject, LoadEventArgs args) { if (EventIds.ContainsKey(args.EventId)) CrestronConsole.PrintLine("Lamp dimmer: {0}", EventIds[args.EventId]); // use this structure to react to the different events switch (args.EventId) { case LoadEventIds.IsOnEventId: xp.BooleanInput[1].BoolValue = !lampDimmer.DimmingLoads[1].IsOn; xp.BooleanInput[2].BoolValue = lampDimmer.DimmingLoads[1].IsOn; break; case LoadEventIds.LevelChangeEventId: xp.UShortInput[1].UShortValue = lampDimmer.DimmingLoads[1].LevelFeedback.UShortValue; break; case LoadEventIds.LevelInputChangedEventId: xp.UShortInput[1].CreateRamp(lampDimmer.DimmingLoads[1].Level.RampingInformation); break; default: break; } }
void SampleCarnivore_Load(object sender, LoadEventArgs e) { try { if (_targetAnimal == null) { _targetAnimal = (AnimalState) LookFor(_targetAnimal); } } catch (Exception exc) { WriteTrace(exc.ToString()); } }
private static void LoadEvent(object sender, LoadEventArgs e) { throw new OrganismBlacklistedException(); }
void wallDimmer_LoadStateChange(LightingBase lightingObject, LoadEventArgs args) { if (EventIds.ContainsKey(args.EventId)) CrestronConsole.PrintLine("Wall dimmer: {0}", EventIds[args.EventId]); // see below }
//void sessionWebClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) //{ // try // { // var deserialized = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ConferenceService.SessionsResponse>>(e.Result); // { // DateTime tempTime; // var converted = (from s in deserialized // orderby s.Code // select new Session // { // Id = s.Id, // Code = s.Code, // Title = s.Title, // Description = StripHtmlTags(s.Description), // Location = s.Room, // Date = (DateTime.TryParse(s.Starts, out tempTime) ? DateTime.Parse(s.Starts) : DateTime.MinValue), // //Speakers = s.Speakers.Select(p => new Speaker { Id = p.SpeakerId, FirstName = p.First, LastName = p.Last, PictureUrl = p.SmallImage }).ToObservableCollection() // //Build specific // SpeakerIds = (s.SpeakerIds != null ? s.SpeakerIds.ToObservableCollection() : null), // Link = s.Link, // SlidesUri = s.Slides, // Thumbnail = s.ThumbnailImage, // WmvUri = s.Wmv, // }).ToList(); // // Display the data on the screen ONLY if we didn't already load from the cache // // Don't bother about rebinding everything, just wait until the user launches the next time. // if (SessionList.Count < 1) // System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() => // { // SessionList = converted.ToObservableCollection(SessionList); // //SpeakerList = SessionList.SelectMany(p => p.Speakers).Distinct().OrderBy(p => p.SurnameFirstname).ToObservableCollection(SpeakerList); // var loadedEventArgs = new LoadEventArgs { IsLoaded = true, Message = string.Empty }; // OnDataLoaded(loadedEventArgs); // }); // // Make sure the sessions are online before caching // if (converted.Count > 1) // { // // Save the results into the cache. // // First save the data // if (IsolatedStorageSettings.ApplicationSettings.Contains("SessionData")) // IsolatedStorageSettings.ApplicationSettings.Remove("SessionData"); // IsolatedStorageSettings.ApplicationSettings.Add("SessionData", converted); // // then update the last updated key // if (IsolatedStorageSettings.ApplicationSettings.Contains("SessionLastDownload")) // IsolatedStorageSettings.ApplicationSettings.Remove("SessionLastDownload"); // IsolatedStorageSettings.ApplicationSettings.Add("SessionLastDownload", DateTime.Now); // IsolatedStorageSettings.ApplicationSettings.Save(); // trigger a save // } // else // SessionsAreNotOnlineYet = true; // } // } // catch (WebException ex) // { // System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() => // { // var loadedEventArgs = new LoadEventArgs { IsLoaded = false, Message = "There was a network error. Close the app and try again." }; // OnDataLoaded(loadedEventArgs); // System.Windows.MessageBox.Show("There was a network error. Close the app and try again."); // }); // } // catch (Exception ex) // { // throw; // } //} //void speakerWebClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) //{ // try // { // var deserialized = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ConferenceService.SpeakerResponse>>(e.Result); // { // var converted = (from s in deserialized // orderby s.Last // select new Speaker // { // Id = s.Id, // Bio = StripHtmlTags(s.Bio ?? ""), // FirstName = s.First, // LastName = s.Last, // PictureUrl = s.Photo, // //Build specific // SessionIds = (s.SessionIds != null ? s.SessionIds.ToObservableCollection() : null), // }).ToList(); // // Display the data on the screen ONLY if we didn't already load from the cache // // Don't bother about rebinding everything, just wait until the user launches the next time. // if (SpeakerList.Count < 1) // System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() => // { // SpeakerList = converted.ToObservableCollection(SpeakerList); // var loadedEventArgs = new LoadEventArgs { IsLoaded = true, Message = string.Empty }; // OnDataLoaded(loadedEventArgs); // }); // // Make sure the sessions are online before caching // if (converted.Count > 1) // { // // Save the results into the cache. // // First save the data // if (IsolatedStorageSettings.ApplicationSettings.Contains("SpeakerData")) // IsolatedStorageSettings.ApplicationSettings.Remove("SpeakerData"); // IsolatedStorageSettings.ApplicationSettings.Add("SpeakerData", converted); // // then update the last updated key // if (IsolatedStorageSettings.ApplicationSettings.Contains("SpeakerLastDownload")) // IsolatedStorageSettings.ApplicationSettings.Remove("SpeakerLastDownload"); // IsolatedStorageSettings.ApplicationSettings.Add("SpeakerLastDownload", DateTime.Now); // IsolatedStorageSettings.ApplicationSettings.Save(); // trigger a save // } // } // } // catch (WebException) // { // System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() => // { // var loadedEventArgs = new LoadEventArgs { IsLoaded = false, Message = "There was a network error. Close the app and try again." }; // OnDataLoaded(loadedEventArgs); // System.Windows.MessageBox.Show("There was a network error. Close the app and try again."); // }); // } // catch (Exception ex) // { // throw; // } //} protected virtual void OnDataLoaded(LoadEventArgs e) { if (DataLoaded != null) { DataLoaded(this, e); } }