当前位置: 首页>>代码示例>>C#>>正文


C# StorageFile.GetThumbnailAsync方法代码示例

本文整理汇总了C#中Windows.Storage.StorageFile.GetThumbnailAsync方法的典型用法代码示例。如果您正苦于以下问题:C# StorageFile.GetThumbnailAsync方法的具体用法?C# StorageFile.GetThumbnailAsync怎么用?C# StorageFile.GetThumbnailAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Windows.Storage.StorageFile的用法示例。


在下文中一共展示了StorageFile.GetThumbnailAsync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: fromStorageFile

        // Fetches all the data for the specified file
        public async static Task<FileItem> fromStorageFile(StorageFile f, CancellationToken ct)
        {
            FileItem item = new FileItem();
            item.Filename = f.DisplayName;
            
            // Block to make sure we only have one request outstanding
            await gettingFileProperties.WaitAsync();

            BasicProperties bp = null;
            try
            {
                bp = await f.GetBasicPropertiesAsync().AsTask(ct);
            }
            catch (Exception) { }
            finally
            {
                gettingFileProperties.Release();
            }

            ct.ThrowIfCancellationRequested();

            item.Size = (int)bp.Size;
            item.Key = f.FolderRelativeId;

            StorageItemThumbnail thumb = await f.GetThumbnailAsync(ThumbnailMode.SingleItem).AsTask(ct);
            ct.ThrowIfCancellationRequested();
            BitmapImage img = new BitmapImage();
            await img.SetSourceAsync(thumb).AsTask(ct);

            item.ImageData = img;
            return item;
        }
开发者ID:C-C-D-I,项目名称:Windows-universal-samples,代码行数:33,代码来源:FileItem.cs

示例2: Button_Click

 private async void Button_Click(object sender, RoutedEventArgs e)
 {
     FolderPicker fp = new FolderPicker();
     fp.FileTypeFilter.Add("*");
     fp.SuggestedStartLocation = PickerLocationId.Desktop;
     fp.ViewMode = PickerViewMode.Thumbnail;
     var files = await fp.PickSingleFolderAsync();
     iol = await files.GetFilesAsync();
    //IReadOnlyList<StorageFolder> file = iol
     Myobj myobj = new Myobj();
     ObservableCollection<Myobj> datasource = new ObservableCollection<Myobj>();
    //Windows.Storage.Streams.IRandomAccessStream iras = await sf.OpenAsync(FileAccessMode.Read);
    sf = iol[0];
    //IReadOnlyList<IStorageFile> file = ;
    foreach (StorageFile a in iol)
    {
        myobj.Name = sf.DisplayName.ToString();
        //gw.DisplayMemberPath = "Name";
        var tn = await sf.GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode.PicturesView);
        BitmapImage bi = new BitmapImage();
        bi.SetSource(tn);
        myobj.Thumbnail = bi;
        datasource.Add(myobj);
    }
        this.gw.ItemsSource = datasource;
      //  gw.DisplayMemberPath = "data";
        
    
 }
开发者ID:madinedihareesh,项目名称:NewFile,代码行数:29,代码来源:MainPage.xaml.cs

示例3: GetThumbnailForFile

		private async Task<StorageItemThumbnail> GetThumbnailForFile(StorageFile file)
		{
			try
			{
				return await file.GetThumbnailAsync(ThumbnailMode.ListView, 120);
			}
			catch
			{
			}

			var assetsFolder = await Package.Current.InstalledLocation.GetFolderAsync("Assets");
			StorageFile iconFile = null;
			try
			{
				iconFile = await assetsFolder.GetFileAsync(string.Format("{0}-icon.png", file.FileType.Trim('.')));
			}
			catch
			{
			}

			if (iconFile == null)
			{
				iconFile = await assetsFolder.GetFileAsync("generic-icon.png");
			}

			return await iconFile.GetThumbnailAsync(ThumbnailMode.ListView, 120);
		}
开发者ID:viciousviper,项目名称:pCloud.NET,代码行数:27,代码来源:SharedFileViewModel.cs

示例4: ThumbnailPhoto

        private async Task ThumbnailPhoto(ExplorerItem item, StorageFile sf, bool file = false)
        {
            if (item == null && item.Image != null) return;

            StorageItemThumbnail fileThumbnail = await sf.GetThumbnailAsync(ThumbnailMode.SingleItem, 250);
            BitmapImage bitmapImage = new BitmapImage();
            bitmapImage.SetSource(fileThumbnail);
            if (file == false)
                item.Image = bitmapImage;
            else
                item.Image = bitmapImage;
        }
开发者ID:CasaTeam,项目名称:MetroExplorer,代码行数:12,代码来源:PageExplorerTimer.cs

示例5: ReportPhoto

        public ReportPhoto(StorageFile file)
        {
            FilePath = file.Path;

            StorageItemThumbnail thumbnail = file.GetThumbnailAsync(ThumbnailMode.ListView).AsTask().Result;
            BitmapImage thumbnailImage = new BitmapImage();
            var ignore = thumbnailImage.SetSourceAsync(thumbnail);
            ThumbnailSource = thumbnailImage;

            StorageItemThumbnail imageAsThumbnail = file.GetScaledImageAsThumbnailAsync(ThumbnailMode.SingleItem).AsTask().Result;
            WriteableBitmap bitmap = new WriteableBitmap((int)imageAsThumbnail.OriginalWidth, (int)imageAsThumbnail.OriginalHeight);
            ignore = bitmap.SetSourceAsync(imageAsThumbnail);
            Bitmap = bitmap;
        }
开发者ID:KlubJagiellonski,项目名称:pola-windowsphone,代码行数:14,代码来源:ReportPhoto.cs

示例6: GetThumbnail

        public async Task<StorageItemThumbnail> GetThumbnail(StorageFile file)
        {
            StorageItemThumbnail thumb = null;

            try
            {
                thumb = await file.GetThumbnailAsync(ThumbnailMode.VideosView);
            }
            catch (Exception ex)
            {
                LogHelper.Log("Error getting thumbnail: ");
                LogHelper.Log(ex);
            }
            return thumb;
        }
开发者ID:robUx4,项目名称:vlc-winrt,代码行数:15,代码来源:ThumbnailService.cs

示例7: affectBitmapImageToNewDisplayablePhotoObject

 private static async Task affectBitmapImageToNewDisplayablePhotoObject(StorageFile file, VideoDataStructure pds)
 {
     StorageItemThumbnail fileThumbnail = await file.GetThumbnailAsync(ThumbnailMode.SingleItem, 900);
     BitmapImage bitmapImage = new BitmapImage();
     bitmapImage.SetSource(fileThumbnail);
     pds.Image = bitmapImage;
 }
开发者ID:comiscienceknight,项目名称:put-em-on-maps,代码行数:7,代码来源:VideoAlbumModifyView.xaml.cs

示例8: fillBackgroundImage

        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);
        }
开发者ID:comiscienceknight,项目名称:put-em-on-maps,代码行数:28,代码来源:MainPage.xaml.cs

示例9: FillFileProperties

        public async static Task FillFileProperties(IFileProperties fileProps, StorageFile file, StorageFolder topFolder, string fileSubPath, BasicProperties basicProps)
        {
            try
            {
                fileProps.FileName = file.Name;
                fileProps.AbsolutePath = file.Path;

                fileProps.SelectedFolder = Util.FolderPath(topFolder);

                if (!string.IsNullOrEmpty(fileSubPath))
                    fileProps.ContainingFolder = fileSubPath;
                else
                    fileProps.ContainingFolder = ""; //fileProps.HideContainingFolder();

                string ftype = GetFileTypeText(file, false);
                if (!string.IsNullOrEmpty(ftype))
                    fileProps.FileType = ftype;
                else
                    fileProps.HideFileType();

                if (basicProps != null)
                    fileProps.FileSize = Util.SizeToString(basicProps.Size, "B");
                else
                    fileProps.HideFileSize();

                if (!string.IsNullOrEmpty(file.Provider.DisplayName))
                {
                    string flocation = file.Provider.DisplayName;
                    if (!string.IsNullOrEmpty(file.Provider.Id) && file.Provider.DisplayName.IndexOf(file.Provider.Id, StringComparison.OrdinalIgnoreCase) <= -1)
                        flocation += " (" + file.Provider.Id.Substring(0, 1).ToUpper() + file.Provider.Id.Substring(1) + ") ";
                    fileProps.FileLocation = flocation;
                }
                else if (!string.IsNullOrEmpty(file.Provider.Id))
                    fileProps.FileLocation = file.Provider.Id;
                else
                    fileProps.HideFileLocation();

                StorageItemThumbnail thumbnail = await file.GetThumbnailAsync(ThumbnailMode.DocumentsView, 260, ThumbnailOptions.None);
                Image image = Util.GetImage(thumbnail);
                if (image != null)
                    fileProps.FileImage = image.Source;
            }
            catch (Exception ex) { Debug.WriteLine(ex.ToString()); }
        }
开发者ID:mdavidov,项目名称:searchfiles-winstore,代码行数:44,代码来源:Util.cs

示例10: AddThumbnail

 public async void AddThumbnail(StorageFile file, VideoDataItem item) {
     StorageItemThumbnail thumb = await file.GetThumbnailAsync(ThumbnailMode.VideosView);
     if(thumb != null) {
         BitmapImage img = new BitmapImage();
         await img.SetSourceAsync(thumb);
         item.Image = img; } }
开发者ID:savage81,项目名称:libmpeg2-winrt,代码行数:6,代码来源:App.xaml.cs

示例11: setAlbumProfileImage

 private async Task setAlbumProfileImage(DataModel.LifeMapStructure lifeMap, StorageFile file)
 {
     StorageItemThumbnail fileThumbnail = await file.GetThumbnailAsync(ThumbnailMode.SingleItem, 700);
     BitmapImage bitmapImage = new BitmapImage();
     bitmapImage.SetSource(fileThumbnail);
     lifeMap.Image = bitmapImage;
 }
开发者ID:comiscienceknight,项目名称:put-em-on-maps,代码行数:7,代码来源:LifeMapManager.cs

示例12: GetThumbnailFromStorageFile

        public static async Task<BitmapImage> GetThumbnailFromStorageFile(StorageFile file)
        {
            ThumbnailMode thumbnailMode = ThumbnailMode.ListView;
            ThumbnailOptions thumbnailOptions = ThumbnailOptions.UseCurrentScale;

            BitmapImage bitmapThumbnail = new BitmapImage();
            StorageItemThumbnail thumbnail = await file.GetThumbnailAsync(thumbnailMode, ThumbnailSize, thumbnailOptions);
            if (thumbnail != null)
            {
                bitmapThumbnail.SetSource(thumbnail);
                return bitmapThumbnail;
            }
            else
            {
                return null;
            }
        }
开发者ID:karolinadub,项目名称:Patronage2016,代码行数:17,代码来源:ImageManager.cs

示例13: albumart

        public async void albumart(StorageFile fil)
        {
            using (StorageItemThumbnail storageItemThumbnail = await fil.GetThumbnailAsync(ThumbnailMode.SingleItem, 200, ThumbnailOptions.ResizeThumbnail))

            using (IInputStream inputStreamAt = storageItemThumbnail.GetInputStreamAt(0))
            using (var dataReader = new DataReader(inputStreamAt))
            {
                uint u = await dataReader.LoadAsync((uint)storageItemThumbnail.Size);
                IBuffer readBuffer = dataReader.ReadBuffer(u);

                var tempFolder = ApplicationData.Current.RoamingFolder;
                try
                {
                    var imageFile = await tempFolder.CreateFileAsync(fil.DisplayName + ".png", CreationCollisionOption.OpenIfExists);

                    using (IRandomAccessStream randomAccessStream = await imageFile.OpenAsync(FileAccessMode.ReadWrite))
                    using (IOutputStream outputStreamAt = randomAccessStream.GetOutputStreamAt(0))
                    {
                        await outputStreamAt.WriteAsync(readBuffer);
                        await outputStreamAt.FlushAsync();
                    }
                }
                catch
                {

                    //  ErrorCorrecting("013");

                }

            }
        }
开发者ID:prabaprakash,项目名称:Visual-Studio-2013,代码行数:31,代码来源:MainPage.xaml.cs

示例14: affectBitmapImageToNewDisplayablePhotoObject

        private static async Task affectBitmapImageToNewDisplayablePhotoObject(StorageFile file, PhotoDataStructure pds)
        {
			try
			{
				if(file == null || pds == null) return;
				StorageItemThumbnail fileThumbnail = await file.GetThumbnailAsync(ThumbnailMode.SingleItem, 600);
				BitmapImage bitmapImage = new BitmapImage();
				bitmapImage.SetSource(fileThumbnail);
				pds.Image = bitmapImage;
			}
			catch(Exception exp)
			{
				throw exp;
			}
        }
开发者ID:comiscienceknight,项目名称:put-em-on-maps,代码行数:15,代码来源:AlbumModifyView.xaml.cs

示例15: setAlbumProfileImage

 private static async Task<bool> setAlbumProfileImage(DataModel.AlbumDataStructure item, StorageFile file)
 {
     try
     {
         StorageItemThumbnail fileThumbnail = await file.GetThumbnailAsync(ThumbnailMode.SingleItem, 400);
         BitmapImage bitmapImage = new BitmapImage();
         bitmapImage.SetSource(fileThumbnail);
         item.ImagePath = bitmapImage;
         return true;
     }
     catch
     {
         return false;
     }
 }
开发者ID:comiscienceknight,项目名称:put-em-on-maps,代码行数:15,代码来源:AlbumCollectionView.xaml.cs


注:本文中的Windows.Storage.StorageFile.GetThumbnailAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。