Пример #1
0
        public FolderInfoM ShallowCopy()
        {
            FolderInfoM returnValue = (FolderInfoM)this.MemberwiseClone();

            returnValue.Files = new ObservableCollection <FileInfoM>();
            return(returnValue);
        }
Пример #2
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);
Пример #3
0
 /// <summary>
 ///     GetFiles
 /// </summary>
 /// <returns></returns>
 public abstract Task<IList<FileInfoM>> GetFilesAsync(FolderInfoM folderInfo);
Пример #4
0
 /// <summary>
 /// Folder에서 SubFolder를 반환한다.
 /// </summary>
 /// <param name="folderInfo"></param>
 /// <returns></returns>
 public abstract Task<IList<FolderInfoM>> GetSubFolderAsync(FolderInfoM folderInfo);
Пример #5
0
 /// <summary>
 /// FutureAccessList에서 폴더 접근 권한을 가지고 폴더 정보를 반환받아서 넣어 준다.
 /// </summary>
 /// <param name="folderInfo"></param>
 /// <returns></returns>
 public abstract Task GetFolderAsync(FolderInfoM folderInfo);
Пример #6
0
 public abstract Task<FolderInfoM> CreateFolderAsync(FolderInfoM parentFolder, string createFolderName);
Пример #7
0
 /// <summary>
 /// Move Folder
 /// </summary>
 /// <param name="sourceFiles"></param>
 /// <param name="destFolder"></param>
 /// <returns></returns>
 public abstract Task<string> MoveFilesAsync(IList<FileInfoM> sourceFiles, FolderInfoM destFolder);
Пример #8
0
 /// <summary>
 /// Delete Folder
 /// </summary>
 /// <param name="folder"></param>
 /// <returns></returns>
 public abstract Task<string> DeleteFolderAsync(FolderInfoM folder);
Пример #9
0
        public override async Task<string> MoveFilesAsync(IList<FileInfoM> sourceFiles, FolderInfoM destFolder)
        {
            var errorMessage = string.Empty;

            if (destFolder == null || destFolder.StorageFolder == null || !(destFolder.StorageFolder is StorageFolder))
            {
                errorMessage = "Folder information is not correct.";
                return errorMessage;
            }

            foreach (var file in sourceFiles)
            {
                var storageFile = file.StorageFile as StorageFile;
                if (storageFile != null)
                {
                    try
                    {
                        await storageFile.MoveAsync(destFolder.StorageFolder as StorageFolder);
                    }
                    catch (Exception ex)
                    {
                        errorMessage = ex.Message;
                        break;
                    }
                }
            }

            return errorMessage;
        }
Пример #10
0
        public override async Task<string> DeleteFolderAsync(FolderInfoM folder)
        {
            var errorMessage = string.Empty;

            if (folder != null && folder.StorageFolder is StorageFolder)
            {
                try
                {
                    await ((StorageFolder)folder.StorageFolder).DeleteAsync();
                }
                catch (Exception ex)
                {
                    errorMessage = ex.Message;
                }
            }

            return errorMessage;
        }
Пример #11
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;
        }
Пример #12
0
        /// <summary>
        ///     폴더에 있는 파일 목록 반환
        /// </summary>
        /// <returns></returns>
        public override async Task<IList<FileInfoM>> GetFilesAsync(FolderInfoM folderInfo)
        {
            if (folderInfo == null) return null;
            var workFolder = (StorageFolder) folderInfo.StorageFolder;
            var files = await workFolder.GetFilesAsync();
            if (files == null) return null;
            var returnFiles = (from kkk in files
                orderby kkk.DateCreated descending
                select new FileInfoM
                {
                    FileName = kkk.DisplayName,
                    ExtName = kkk.FileType,
                    StorageFile = kkk,
                    IsLocalFile = false,
                    Path = kkk.Path,
                    DateCreated = kkk.DateCreated.ToString(),
                }).ToList();

            return returnFiles;
        }
Пример #13
0
        public override async Task<IList<FolderInfoM>> GetSubFolderAsync(FolderInfoM folderInfo)
        {
            var folder = folderInfo.StorageFolder as StorageFolder;
            if (folder == null)
                return null;

            var subFolders = await folder.GetFoldersAsync();
            var returnFolders = (from kkk in subFolders
                select new FolderInfoM
                {
                    StorageFolder = kkk,
                    FolderName = kkk.DisplayName,
                    Path = kkk.Path,
                    Token = Cipher.encrypt(kkk.Path),
                }).ToList();
            return returnFolders;
        }
Пример #14
0
 public override async Task GetFolderAsync(FolderInfoM folderInfo)
 {
     var returnValue = await StorageApplicationPermissions.FutureAccessList.GetFolderAsync(folderInfo.Token);
     folderInfo.StorageFolder = returnValue;
 }
Пример #15
0
        /// <summary>
        ///     Folder Picker
        /// </summary>
        /// <param name="suggestedStartLocation"></param>
        /// <param name="fileTypeFilters"></param>
        /// <returns>FolderInfoM</returns>
        public override async Task<FolderInfoM> GetFolderAsync(CFPickerLocationId suggestedStartLocation,
            IList<string> fileTypeFilters)
        {
            var folderPicker = new FolderPicker
            {
                SuggestedStartLocation =
                    (PickerLocationId) Enum.Parse(typeof (PickerLocationId), ((int) suggestedStartLocation).ToString())
            };
            foreach (string item in fileTypeFilters)
            {
                folderPicker.FileTypeFilter.Add(item);
            }

            var folder = await folderPicker.PickSingleFolderAsync();
            if (folder == null) return null;
            var folderInfo = new FolderInfoM
            {
                StorageFolder = folder,
                FolderName = folder.DisplayName,
                Path = folder.Path,
                Token = Cipher.encrypt(folder.Path),
            };

            StorageApplicationPermissions.FutureAccessList.AddOrReplace(folderInfo.Token, folder);
            return folderInfo;
        }
Пример #16
0
 /// <summary>
 /// Create folder
 /// </summary>
 /// <param name="parentFolder"></param>
 /// <param name="createFolderName"></param>
 /// <returns></returns>
 public override async Task<FolderInfoM> CreateFolderAsync(FolderInfoM parentFolder, string createFolderName)
 {
     var storageFolder = parentFolder.StorageFolder as StorageFolder;
     if (storageFolder == null) return null;
     try
     {
         var createFolder = await storageFolder.CreateFolderAsync(createFolderName);
         return new FolderInfoM
         {
             StorageFolder = createFolder,
             FolderName = createFolder.DisplayName,
             Path = createFolder.Path,
             Token = Cipher.encrypt(createFolder.Path),
         };
     }
     catch (Exception)
     {
         return null;
     }
 }