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


C# Storage.StorageFile类代码示例

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


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

示例1: WriteDataToFileAsync

 public async Task WriteDataToFileAsync(StorageFile file, byte[] data)
 {
     using (var s = await file.OpenStreamForWriteAsync())
     {
         await s.WriteAsync(data, 0, data.Length);
     }
 }
开发者ID:tgptom,项目名称:aerogear-cordova-otp,代码行数:7,代码来源:Repository.cs

示例2: PictureCropControl

 public PictureCropControl(StorageFile file, AspectRatio aspect = AspectRatio.Custom, CropSelectionSize cropsize = CropSelectionSize.Half)
 {
     this.InitializeComponent();
     this.file = file;
     this.aspect = aspect;
     this.cropsize = cropsize;
 }
开发者ID:chenjianwp,项目名称:UWP_ToolKit_CommonLibrary,代码行数:7,代码来源:PictureCropControl.xaml.cs

示例3: Create

 public static async Task<WaveFile> Create(StorageFile file)
 {
     WaveFile w = new WaveFile();
     await w.Initialize(file);
     w.SmoothSamples(200);
     return w;
 }
开发者ID:david-wb,项目名称:Transcriber,代码行数:7,代码来源:WaveFile.cs

示例4: LoadAsync

 /// <summary>
 /// Loads the WriteableBitmap asynchronously given the storage file and the dimensions.
 /// </summary>
 /// <param name="storageFile">The storage file.</param>
 /// <param name="decodePixelWidth">Width in pixels of the decoded bitmap.</param>
 /// <param name="decodePixelHeight">Height in pixels of the decoded bitmap.</param>
 /// <returns></returns>
 public static async Task<WriteableBitmap> LoadAsync(
     StorageFile storageFile,
     uint decodePixelWidth,
     uint decodePixelHeight)
 {
     return await new WriteableBitmap(1, 1).LoadAsync(storageFile, decodePixelWidth, decodePixelHeight);
 }
开发者ID:siatwangmin,项目名称:WinRTXamlToolkit,代码行数:14,代码来源:WriteableBitmapLoadExtensions.cs

示例5: OpenCheckList

        //-------------------------------------------------------------------------------
        #region +OpenCheckList チェックリストを開く
        //-------------------------------------------------------------------------------
        //
        public async Task<bool> OpenCheckList(StorageFile file, Func<char, Task<int>> dayToDayIndexFunc, Func<int, Task<ComiketCircleAndLayout>> updateIdToCircle)
        {
            string enc_str = null;
            using (var str = await file.OpenReadAsync())
            using (StreamReader sr = new StreamReader(str.AsStreamForRead())) {
                string line = sr.ReadLine();
                enc_str = CheckList.CheckEncode(line);
                if (enc_str == null) { return false; }
                int comiketNo = CheckList.CheckComiketNo(line);
                if (comiketNo != _comiketNo) { return false; }
            }

            Encoding enc = Encoding.GetEncoding(enc_str);

            bool res;
            using (var str = await file.OpenReadAsync())
            using (StreamReader sr = new StreamReader(str.AsStreamForRead(), enc)) {
                var lines = CheckList.FileReadLine(sr);
                res = await this.ReadCSV(lines, dayToDayIndexFunc, updateIdToCircle);
            }

            if (res) {
                await this.ReadTimeFile();
            }

            return res;
        }
开发者ID:kavenblog,项目名称:ComicStarViewer,代码行数:31,代码来源:CheckList.cs

示例6: LoadData

        public async void LoadData(IEnumerable<XElement> sprites, StorageFile spriteSheetFile, string appExtensionId)
        {
            var bitmapImage = new BitmapImage();
            using (var stream = await spriteSheetFile.OpenReadAsync()) {
                await bitmapImage.SetSourceAsync(stream);
            }
            
            //xaml
            List<ImageListItem> listOfImages = new List<ImageListItem>();
            foreach (var sprite in sprites) {
                var row = int.Parse(sprite.Attributes("Row").First().Value);
                var col = int.Parse(sprite.Attributes("Column").First().Value);

                var brush = new ImageBrush();
                brush.ImageSource = bitmapImage;
                brush.Stretch = Stretch.UniformToFill;
                brush.AlignmentX = AlignmentX.Left;
                brush.AlignmentY = AlignmentY.Top;
                brush.Transform = new CompositeTransform() { ScaleX = 2.35, ScaleY = 2.35, TranslateX = col * (-140), TranslateY = row * (-87) };
                listOfImages.Add(new ImageListItem() {
                    Title = sprite.Attributes("Title").First().Value,
                    SpriteSheetBrush = brush,
                    File = sprite.Attributes("File").First().Value,
                    AppExtensionId = appExtensionId
                });
            }
            lbPictures.ItemsSource = listOfImages;
        }
开发者ID:liquidboy,项目名称:X,代码行数:28,代码来源:ImagePicker.xaml.cs

示例7: ProccesImage

        public async void ProccesImage(StorageFile imageFile)
        {
            var data = await FileIO.ReadBufferAsync(imageFile);

            // create a stream from the file
            var ms = new InMemoryRandomAccessStream();
            var dw = new DataWriter(ms);
            dw.WriteBuffer(data);
            await dw.StoreAsync();
            ms.Seek(0);

            // find out how big the image is, don't need this if you already know
            var bm = new BitmapImage();
            await bm.SetSourceAsync(ms);

            // create a writable bitmap of the right size
            var wb = new WriteableBitmap(bm.PixelWidth, bm.PixelHeight);
            ms.Seek(0);

            // load the writable bitpamp from the stream
            await wb.SetSourceAsync(ms);

            Bitmap bmp = (Bitmap)wb;

            //var filter1 = Grayscale.CommonAlgorithms.BT709;

            //bmp = filter1.Apply(bmp);

            wb = (WriteableBitmap)bmp;

            var file = await this.WriteableBitmapToStorageFile(wb, FileFormat.Jpeg);
        }
开发者ID:epustovit,项目名称:Scanner,代码行数:32,代码来源:ImageProccesing.cs

示例8: previewElement_Tapped

        private async void previewElement_Tapped(object sender, TappedRoutedEventArgs e)
        {
            // Block multiple taps.
            if (!IsCaptureInProgress)
            {
                IsCaptureInProgress = true;

                // Create the temporary storage file.
                media = await ApplicationData.Current.LocalFolder
                    .CreateFileAsync("capture_file.jpg", CreationCollisionOption.ReplaceExisting);

                // Take the picture and store it locally as a JPEG.
                await cameraCapture.CapturePhotoToStorageFileAsync(
                    ImageEncodingProperties.CreateJpeg(), media);

                captureButtons.Visibility = Visibility.Visible;

                // Use the stored image as the preview source.
                BitmapImage tempBitmap = new BitmapImage(new Uri(media.Path));
                imagePreview.Source = tempBitmap;
                imagePreview.Visibility = Visibility.Visible;
                previewElement.Visibility = Visibility.Collapsed;
                IsCaptureInProgress = false;
            }
        }
开发者ID:Ronacs,项目名称:WinDevCamp,代码行数:25,代码来源:MainPage.xaml.cs

示例9: SaveToFile

        public static async Task SaveToFile(
            this WriteableBitmap writeableBitmap,
            StorageFile outputFile,
            Guid encoderId)
        {
            try
            {
                Stream stream = writeableBitmap.PixelBuffer.AsStream();
                byte[] pixels = new byte[(uint)stream.Length];
                await stream.ReadAsync(pixels, 0, pixels.Length);

                using (var writeStream = await outputFile.OpenAsync(FileAccessMode.ReadWrite))
                {
                    var encoder = await BitmapEncoder.CreateAsync(encoderId, writeStream);
                    encoder.SetPixelData(
                        BitmapPixelFormat.Bgra8,
                        BitmapAlphaMode.Premultiplied,
                        (uint)writeableBitmap.PixelWidth,
                        (uint)writeableBitmap.PixelHeight,
                        96,
                        96,
                        pixels);
                    await encoder.FlushAsync();

                    using (var outputStream = writeStream.GetOutputStreamAt(0))
                    {
                        await outputStream.FlushAsync();
                    }
                }
            }
            catch (Exception ex)
            {
                string s = ex.ToString();
            }
        }
开发者ID:chao-zhou,项目名称:PomodoroTimer,代码行数:35,代码来源:WriteableBitmapSaveExtensions.cs

示例10: Load

		public static async Task<List<ROI>> Load(StorageFile file)
		{		
			// read content
			var lines = await Windows.Storage.FileIO.ReadLinesAsync(file);

			// Read in all the lines
			//string[] lines = System.IO.File.ReadAllLines(_fullPath);
			List<ROI> regionsOfInterest = new List<ROI>();

			foreach (var line in lines)
			{
				var fields = line.Split('\t');

				ROI roi = new ROI()
				{
					Index = Int32.Parse(fields[0]),
					Name = fields[1],
					Ident = Int32.Parse(fields[2]),
					X = Double.Parse(fields[6]),
					Y = Double.Parse(fields[7]),
					Z = Double.Parse(fields[8]),
                    TX = Double.Parse(fields[10]),
                    TY = Double.Parse(fields[11]),
                    TZ = Double.Parse(fields[12]),
				};
				
				regionsOfInterest.Add(roi);
			}

			return regionsOfInterest;
		}
开发者ID:digitalnelson,项目名称:BrainGraph,代码行数:31,代码来源:ROILoader.cs

示例11: 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

示例12: LoadImage

 private async Task<BitmapImage> LoadImage(StorageFile file)
 {
     var image  = new BitmapImage();
     FileRandomAccessStream stream = (FileRandomAccessStream)await file.OpenAsync(FileAccessMode.Read);
     image.SetSource(stream);
     return image;
 }
开发者ID:ma1982en,项目名称:curly-octo-pancake,代码行数:7,代码来源:ChoosingViewModel.cs

示例13: Save

        public async Task Save(StorageFile file)
        {
            var image = GetImage();

            // Measure the extent of the image (which may be cropped).
            Rect imageBounds;

            using (var commandList = new CanvasCommandList(sourceBitmap.Device))
            using (var drawingSession = commandList.CreateDrawingSession())
            {
                imageBounds = image.GetBounds(drawingSession);
            }

            // Rasterize the image into a rendertarget.
            using (var renderTarget = new CanvasRenderTarget(sourceBitmap.Device, (float)imageBounds.Width, (float)imageBounds.Height, 96))
            {
                using (var drawingSession = renderTarget.CreateDrawingSession())
                {
                    drawingSession.Blend = CanvasBlend.Copy;

                    drawingSession.DrawImage(image, -(float)imageBounds.X, -(float)imageBounds.Y);
                }

                // Save it out.
                var format = file.FileType.Equals(".png", StringComparison.OrdinalIgnoreCase) ? CanvasBitmapFileFormat.Png : CanvasBitmapFileFormat.Jpeg;

                using (var stream = await file.OpenAsync(FileAccessMode.ReadWrite))
                {
                    stream.Size = 0;

                    await renderTarget.SaveAsync(stream, format);
                }
            }
        }
开发者ID:shawnhar,项目名称:stuart,代码行数:34,代码来源:Photo.cs

示例14: DisplayStorageFileAsync

        private async Task DisplayStorageFileAsync(StorageFile storageFile)
        {
            var bitmapImage = new BitmapImage();
            bitmapImage.SetSource(await _storageFile.OpenAsync(FileAccessMode.Read));

            ImagePhoto.Source = bitmapImage;
        }
开发者ID:hwangtamu,项目名称:flickr-sdk,代码行数:7,代码来源:MainPage.xaml.cs

示例15: UnzipFromStorage

 public static async Task UnzipFromStorage(StorageFile pSource, StorageFolder pDestinationFolder, IEnumerable<string> pIgnore)
 {
     using (var stream = await pSource.OpenStreamForReadAsync())
     {
         await UnzipFromStream(stream, pDestinationFolder,pIgnore.ToList());
     }
 }
开发者ID:bigfool,项目名称:WPTelnetD,代码行数:7,代码来源:ZipHelper.cs


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