public void SetItems(List<SpotObject> spots) { // If items have something, clear. this.Items.Clear(); // Sorting spots spots.Sort((s1, s2) => { return s1.SpotName.CompareTo(s2.SpotName); }); spots.Sort((s1, s2) => { return s1.SpotDistance.CompareTo(s2.SpotDistance); }); // Convert jarray spots to spot view items and set to view model foreach (SpotObject spot in spots) { // Set new spot view item SpotViewItem spotViewItem = new SpotViewItem(spot); if (spot.IsPrivate) spotViewItem.IsPrivateImage = FileObjectViewModel.IS_PRIVATE_IMAGE_URI; else spotViewItem.IsPrivateImage = FileObjectViewModel.TRANSPARENT_IMAGE_URI; this.Items.Add(spotViewItem); } }
// Get parameters from given spot view item public string GetParameterStringFromSpotViewItem(SpotViewItem spotViewItem) { // Go to File List Page with parameters. string spotId = spotViewItem.SpotId; string spotName = spotViewItem.SpotName; string accountId = spotViewItem.AccountId; string accountName = spotViewItem.AccountName; string parameters = "?spotId=" + spotId + "&spotName=" + spotName + "&accountId=" + accountId + "&accountName=" + accountName; return parameters; }
private async void DeleteSpotAsync(SpotViewItem spotViewItem) { // Show Deleting message base.SetProgressIndicator(true); base.Dispatcher.BeginInvoke(() => { spotViewItem.DeleteImage = FileObjectViewModel.ING_IMAGE_URI; spotViewItem.DeleteImagePress = false; }); // If delete job success to all files, delete spot. // Otherwise, show delete fail image. SpotObject spot = App.SpotManager.GetSpotObject(spotViewItem.SpotId); try { await spot.DeleteFileObjectsAsync(); await App.SpotManager.DeleteSpotAsync(spotViewItem.SpotId); base.Dispatcher.BeginInvoke(() => { this.MySpotViewModel.Items.Remove(spotViewItem); ((SpotViewModel)PhoneApplicationService.Current.State[SPOT_VIEW_MODEL_KEY]).IsDataLoaded = false; if (this.MySpotViewModel.Items.Count < 1) base.SetListUnableAndShowMessage(uiMySpotList, uiMySpotMessage, AppResources.NoMySpotMessage); }); } catch { base.Dispatcher.BeginInvoke(() => { spotViewItem.DeleteImage = FileObjectViewModel.FAIL_IMAGE_URI; }); } // Hide Progress Indicator base.SetProgressIndicator(false); }