コード例 #1
0
        private async void fillBackgroundImage(LifeMapStructure lifeMap, StorageFile storageFile)
        {
            Utils.Constants.StartLoadingAnimation(MainGrid);
            if (lifeMap.ImagePath != "")
            {
                try
                {
                    StorageFile sf = await Windows.Storage.StorageFile.GetFileFromPathAsync(storageFile.Path);
                    StorageItemThumbnail fileThumbnail = await storageFile.GetThumbnailAsync(ThumbnailMode.SingleItem, 800);
                    BitmapImage bitmapImage = new BitmapImage();
                    bitmapImage.SetSource(fileThumbnail);
                    lifeMap.Image = bitmapImage;
                    await Utils.FilesSaver<LifeMapStructure>.SaveData(Data.LifeMapMgr.LifeMaps, Constants.NamingListLifeMaps);
                    Helper.CreateToastNotifications(Constants.ResourceLoader.GetString("UpdatedLiftMapBackground"));
                }
                catch
                {
					lifeMap.ImagePath = "";
                    Utils.Constants.ShowWarningDialog(Constants.ResourceLoader.GetString("2cannotreadfile") + " : " + storageFile.Path + "\n\r" +
                                                      Constants.ResourceLoader.GetString("2possiblereasondocumentlibararycannotaccess"));
                }
            }
            else
            {
                await fillBackgroundImageNonLocal(lifeMap, storageFile);
            }
            Utils.Constants.StopLoadingAnimation(MainGrid);
        }
コード例 #2
0
        private static async Task fillBackgroundImageNonLocal(LifeMapStructure lifeMap, StorageFile storageFile)
        {
            try
            {
                IRandomAccessStream iras = await storageFile.OpenReadAsync();
                Windows.Storage.Streams.Buffer MyBuffer = new Windows.Storage.Streams.Buffer(Convert.ToUInt32(iras.Size));
                IBuffer iBuf = await iras.ReadAsync(MyBuffer, MyBuffer.Capacity, InputStreamOptions.None);
                string filename = DateTime.Now.ToString().Replace(":", "").Replace("/", "_").Replace("\\", "_").Replace(".", "").Replace("\"", "") + "lifemapcover" + storageFile.Name;
                string filePath = await Helper.SaveImages(iBuf, filename);
                lifeMap.ImagePath = filePath;
                await Utils.FilesSaver<LifeMapStructure>.SaveData(Data.LifeMapMgr.LifeMaps, Constants.NamingListLifeMaps);
                StorageFile file = await Windows.Storage.StorageFile.GetFileFromPathAsync(lifeMap.ImagePath);
                StorageItemThumbnail fileThumbnail = await file.GetThumbnailAsync(ThumbnailMode.SingleItem, 800);
                BitmapImage bitmapImage = new BitmapImage();
                bitmapImage.SetSource(fileThumbnail);
                lifeMap.Image = bitmapImage;
                Helper.CreateToastNotifications(Constants.ResourceLoader.GetString("UpdatedLiftMapBackground"));
            }
            catch(Exception exp)
            {
				lifeMap.ImagePath = "";
				Utils.Constants.ShowWarningDialog(Constants.ResourceLoader.GetString("2cannotreadfile") + " : " + exp.Message + "\n\r" +
                                                  Constants.ResourceLoader.GetString("2possiblereasoncannotaccessnonlocalfile"));
            }
        }
コード例 #3
0
 private async Task loadLifeMapData(LifeMapStructure lifeMap)
 {
     var pushpins = await Helper.GetContent<ObservableCollection<PushpinDataStructure>>(lifeMap.Name + "Pushpins");
     if (pushpins != null) ListPushpin = new ObservableCollection<PushpinDataStructure>(pushpins);
     var albums = await Helper.GetContent<ObservableCollection<AlbumDataStructure>>("Albums");
     if (albums != null) ListOfAllAlbums = new ObservableCollection<AlbumDataStructure>(albums);
     var photos = await Helper.GetContent<ObservableCollection<PhotoDataStructure>>("Photos");
     if (photos != null) ListOfAllPhotos = new ObservableCollection<PhotoDataStructure>(photos);
     var videos = await Helper.GetContent<ObservableCollection<VideoDataStructure>>("Videos");
     if (videos != null) ListOfAllVideos = new ObservableCollection<VideoDataStructure>(videos);
 }