public virtual async Task <IRandomAccessStream> GetRandomAccessStreamFromFileAsync(FileAccessMode Mode)
 {
     if (StorageItem is StorageFile File)
     {
         return(await File.OpenAsync(Mode));
     }
     else
     {
         return(await FileRandomAccessStream.OpenAsync(Path, Mode));
     }
 }
示例#2
0
        public static async Task <BitmapImage> LoadImageAsync(string imagePath)
        {
            using (IRandomAccessStream fileStream = await FileRandomAccessStream.OpenAsync(imagePath, Windows.Storage.FileAccessMode.Read))
            {
                // Set the image source to the selected bitmap
                BitmapImage bitmapImage = new BitmapImage();
                bitmapImage.DecodePixelWidth = 500; //match the target Image.Width, not shown
                await bitmapImage.SetSourceAsync(fileStream);

                System.Diagnostics.Debug.WriteLine(imagePath + " finished loading thumb!");
                return(bitmapImage);
                //Image = bitmapImage;
                //System.Diagnostics.Debug.WriteLine(title + " finished loading thumb!");
            }
        }
示例#3
0
        /// <summary>
        /// Fixes 3D printing inputFile and returns path to fixed file.
        /// </summary>
        /// <param name="inputFile">The absolute path to the file to be fixed.</param>
        /// <param name="outputFile">The absolute path to the output fixed file. Defaults to appending '_fixed' to the InputFile file name.</param>
        /// <returns>The absolute path to the fixed file.</returns>
        public async Task <string> FixAsync(string inputFile, string outputFile = "")
        {
            InputFile  = inputFile;
            OutputFile = outputFile;

            var package = new Printing3D3MFPackage();

            using var stream = await FileRandomAccessStream.OpenAsync(InputFile, FileAccessMode.ReadWrite);

            var model = await package.LoadModelFromPackageAsync(stream);

            await model.RepairAsync();

            await package.SaveModelToPackageAsync(model);

            using var outstream = WindowsRuntimeStreamExtensions.AsStream(await package.SaveAsync());
            using var outfile   = File.Create(OutputFile);

            outstream.Seek(0, SeekOrigin.Begin);
            outstream.CopyTo(outfile);

            return(OutputFile);
        }
示例#4
0
 public virtual async Task <IRandomAccessStream> GetRandomAccessStreamFromFileAsync(FileAccessMode Mode)
 {
     return(await FileRandomAccessStream.OpenAsync(Path, Mode, StorageOpenOptions.AllowReadersAndWriters, FileOpenDisposition.OpenExisting));
 }
示例#5
0
 public virtual async Task <IRandomAccessStream> GetRandomAccessStreamFromFileAsync(FileAccessMode Mode)
 {
     return(await FileRandomAccessStream.OpenAsync(Path, Mode));
 }