private void LoadThumbnailsThread(MediaFolder folder) { try { RaiseStatusUpdatedEvent("Loading thumbnails..."); using (GalleryDatabase database = GalleryDatabase.Open(Gallery.FilePath, Gallery.EncryptionAlgorithm, Gallery.Password, false)) { foreach (MediaFile mediaFile in folder.Files) { bool thumbnailLoaded = false; using (Stream stream = database.ExtractEntry(mediaFile.DatabaseThumbnailPathName)) { if (stream != null && stream.Length > 0) { mediaFile.ThumbnailImage = Image.FromStream(stream); thumbnailLoaded = true; } } if (thumbnailLoaded) { FileUpdated(mediaFile); } } } RaiseDatabaseOperationCompletedEvent(OperationType.LoadThumbnails); } catch (Exception ex) { CommonWorker.ShowError(ex); } }
public void OpenMediaFile(MediaFile mediaFile, bool preview = false) { string filePath = string.Empty; if (mediaFile is ImageFile || !preview) { filePath = Path.Combine(mediaFile.Source.RootedPath, mediaFile.RelativePathName); } else if (mediaFile is VideoFile) { FileSystemHandler.ClearWorkingDirectory(); using (GalleryDatabase database = GalleryDatabase.Open(Gallery.FilePath, Gallery.EncryptionAlgorithm, Gallery.Password, false)) { filePath = database.ExtractEntry(mediaFile.DatabasePreviewPathName, ObjectPool.CompleteWorkingDirectory); } } if (File.Exists(filePath)) { Process process = new Process() { StartInfo = { FileName = filePath, Verb = "Open" } }; process.Start(); } }
private void LoadGalleryThread() { try { RaiseStatusUpdatedEvent("Loading gallery (" + Gallery.FilePath + ")..."); using (GalleryDatabase database = GalleryDatabase.Open(Gallery.FilePath, Gallery.EncryptionAlgorithm, Gallery.Password, false)) { using (Stream stream = database.ExtractEntry(GALLERY_FILE_NAME)) { XmlReader reader = XmlReader.Create(stream, new XmlReaderSettings() { CheckCharacters = false }); DataContractSerializer serializer = new DataContractSerializer(typeof(Gallery), _serializableDataObjectTypes); Gallery = (Gallery)serializer.ReadObject(reader, true); Gallery.UpdateMediaCount(); reader.Close(); } } RaiseGalleryLoadedEvent(); Gallery.Sources.ForEach(source => FolderAdded(source.RootFolder)); RaiseDatabaseOperationCompletedEvent(OperationType.LoadGallery); } catch (Exception ex) { CommonWorker.ShowError(ex); } }