Esempio n. 1
0
 /// <summary>
 /// 모델 생성자2
 /// </summary>
 /// <param name="fileInfo"></param>
 public ImageInfoM(FileInfoM fileInfo)
     : this()
 {
     FileName = fileInfo.FileName;
     ExtName = fileInfo.ExtName;
     StorageFile = fileInfo.StorageFile;
     IsLocalFile = fileInfo.IsLocalFile;
     Data = fileInfo.Data;
     Path = fileInfo.Path;
     DateCreated = fileInfo.DateCreated;
 }
Esempio n. 2
0
 /// <summary>
 /// 모델 생성자2
 /// </summary>
 /// <param name="fileInfo"></param>
 public ImageInfoM(FileInfoM fileInfo)
     : this()
 {
     FileName    = fileInfo.FileName;
     ExtName     = fileInfo.ExtName;
     StorageFile = fileInfo.StorageFile;
     IsLocalFile = fileInfo.IsLocalFile;
     Data        = fileInfo.Data;
     Path        = fileInfo.Path;
     DateCreated = fileInfo.DateCreated;
 }
Esempio n. 3
0
 /// <summary>
 ///     File Copy
 /// </summary>
 /// <param name="file"></param>
 public abstract string CopyFile(FileInfoM file);
Esempio n. 4
0
 /// <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);
Esempio n. 5
0
 /// <summary>
 ///     파일에서 WriteableBitmp 반환
 /// </summary>
 /// <param name="file"></param>
 /// <param name="isThumbnail"></param>
 /// <returns></returns>
 public abstract Task GetWriteableBitmapAsync(FileInfoM file, bool isThumbnail = true);
Esempio n. 6
0
 public abstract Task GetBitmapImageAsync(FileInfoM file);
Esempio n. 7
0
        //public abstract void OpenFolder(FolderInfoM folderInfo);

        public abstract Task RemoveFile(FileInfoM removeFile);
 public override async Task RemoveFile(FileInfoM removeFile)
 {
     var storageFile = removeFile.StorageFile as IStorageFile;
     if (storageFile != null)
     {
         await storageFile.DeleteAsync();
     }
 }
        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;
        }
        /// <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;
        }
        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;
                }
            }
        }
        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;
            }
        }