Exemple #1
0
        public override string CopyFile(FileInfoM file)
        {
            string errorMessage = string.Empty;

            if (file.StorageFile == null || (file.StorageFile is StorageFile) == false)
            {
                errorMessage = "Have no StorageFile";
                return(errorMessage);
            }

            var dataPackage = new DataPackage();

            dataPackage.SetStorageItems(new List <StorageFile> {
                (StorageFile)file.StorageFile
            }, true);
            dataPackage.RequestedOperation = DataPackageOperation.Copy;
            try
            {
                Clipboard.SetContent(dataPackage);
            }
            catch (Exception ex)
            {
                errorMessage = ex.Message;
            }
            return(errorMessage);
        }
Exemple #2
0
        public override async Task RemoveFile(FileInfoM removeFile)
        {
            var storageFile = removeFile.StorageFile as IStorageFile;

            if (storageFile != null)
            {
                await storageFile.DeleteAsync();
            }
        }
Exemple #3
0
        public override async Task GetWriteableBitmapAsync(FileInfoM fileInfo, bool isThumbnail = true)
        {
            if (fileInfo == null || fileInfo.StorageFile == null)
            {
                return;
            }
            var workFile = (StorageFile)fileInfo.StorageFile;

            WriteableBitmap wb;

            if (isThumbnail)
            {
                //요약본 사이즈와 크기
                StorageItemThumbnail scaledImage =
                    await workFile.GetScaledImageAsThumbnailAsync(ThumbnailMode.SingleItem);

                if (scaledImage != null)
                {
                    wb = new WriteableBitmap((int)scaledImage.OriginalWidth, (int)scaledImage.OriginalHeight);
                    await wb.SetSourceAsync(scaledImage);

                    if (fileInfo.Data != null)
                    {
                        fileInfo.Data = null;
                    }
                    fileInfo.Data = wb;
                }
            }
            else
            {
                //원본 사이즈와 크기 - ImageProcessDiabloIII에서 호출하는 경우에는 ImageInfoM이라고 판단한다.
                ImageProperties property = await workFile.Properties.GetImagePropertiesAsync();

                wb = new WriteableBitmap((int)property.Width, (int)property.Height);
                using (IRandomAccessStream fileStream = await workFile.OpenAsync(FileAccessMode.Read))
                {
                    await wb.SetSourceAsync(fileStream);

                    var image = ((ImageInfoM)fileInfo);
                    if (image.WorkedImage != null)
                    {
                        image.WorkedImage = null;
                    }
                    image.WorkedImage = wb;
                }
            }
        }
Exemple #4
0
        public override async Task GetBitmapImageAsync(FileInfoM fileInfo)
        {
            if (fileInfo == null || fileInfo.StorageFile == null)
            {
                return;
            }

            var workFile = (StorageFile)fileInfo.StorageFile;

            var bitmapImage = new BitmapImage();

            using (IRandomAccessStream fileStream = await workFile.OpenAsync(FileAccessMode.Read))
            {
                // Set the image source to the selected bitmap
                ImageProperties property = await workFile.Properties.GetImagePropertiesAsync();

                bitmapImage.DecodePixelHeight = (int)property.Height;
                bitmapImage.DecodePixelWidth  = (int)property.Width;

                await bitmapImage.SetSourceAsync(fileStream);

                fileInfo.Data = bitmapImage;
            }
        }
Exemple #5
0
        /// <summary>
        ///     이미지 저장
        /// </summary>
        public override async Task SaveFileWriteableBitmapAsync(FolderInfoM saveFolder, FileInfoM saveFile, bool isShareTarget = false)
        {
            if (saveFolder == null || saveFolder.StorageFolder == null)
            {
                return;
            }
            var folder = (StorageFolder)saveFolder.StorageFolder;

            IStorageItem createFile = await folder.TryGetItemAsync(saveFile.FileName + saveFile.ExtName) ??
                                      await folder.CreateFileAsync(saveFile.FileName + saveFile.ExtName);

            using (IRandomAccessStream stream = await((StorageFile)createFile).OpenAsync(FileAccessMode.ReadWrite))
            {
                var           wb      = (WriteableBitmap)((ImageInfoM)saveFile).WorkedImage;
                BitmapEncoder encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.JpegEncoderId, stream);

                Stream pixelStream = wb.PixelBuffer.AsStream();
                var    pixels      = new byte[pixelStream.Length];
                await pixelStream.ReadAsync(pixels, 0, pixels.Length);

                encoder.SetPixelData(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Ignore, (uint)wb.PixelWidth,
                                     (uint)wb.PixelHeight, 96.0, 96.0, pixels);
                await encoder.FlushAsync();
            }
            saveFile.StorageFile = createFile;
            if (isShareTarget == false)
            {
                saveFile.IsLocalFile = true;
            }
        }
 /// <summary>
 ///     File Copy
 /// </summary>
 /// <param name="file"></param>
 public abstract string CopyFile(FileInfoM file);
 /// <summary>
 ///     WriteableBitmap Save
 /// </summary>
 /// <param name="saveFolder"></param>
 /// <param name="saveFile"></param>
 /// <param name="isShareTarget"></param>
 /// <returns></returns>
 public abstract Task SaveFileWriteableBitmapAsync(FolderInfoM saveFolder, FileInfoM saveFile,
                                                   bool isShareTarget = false);
 /// <summary>
 ///     파일에서 WriteableBitmp 반환
 /// </summary>
 /// <param name="file"></param>
 /// <param name="isThumbnail"></param>
 /// <returns></returns>
 public abstract Task GetWriteableBitmapAsync(FileInfoM file, bool isThumbnail = true);
 public abstract Task GetBitmapImageAsync(FileInfoM file);
Exemple #10
0
        //public abstract void OpenFolder(FolderInfoM folderInfo);

        public abstract Task RemoveFile(FileInfoM removeFile);