Esempio n. 1
0
 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);
     }
 }
Esempio n. 2
0
 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);
     }
 }
Esempio n. 3
0
 public void SetWorkingDirectory()
 {
     try
     {
         FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
         folderBrowserDialog.Description  = "Please select a working directory...";
         folderBrowserDialog.SelectedPath = ObjectPool.CompleteWorkingDirectory;
         if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
         {
             ObjectPool.SetWorkingDirectory(folderBrowserDialog.SelectedPath);
             RegistryHandler.SaveSettings(SettingsType.WorkingDirectory);
             RaiseWorkingDirectoryUpdatedEvent(ObjectPool.WorkingDirectory);
         }
     }
     catch (Exception ex)
     {
         CommonWorker.ShowError(ex);
     }
 }
Esempio n. 4
0
 private void ScanSourceThread(GallerySource source, bool reScan)
 {
     try
     {
         using (GalleryDatabase database = GalleryDatabase.Open(Gallery.FilePath, Gallery.EncryptionAlgorithm, Gallery.Password, true))
         {
             database.RegisterStreamProvider <Gallery>(GalleryMetadataStreamProvider);
             database.RegisterStreamProvider <MediaFile>(MediaFileStreamProvider);
             FileSystemHandler.ScanFolders(database, source, reScan);
             source.ScanDate = DateTime.Now;
             source.UpdateMediaCount();
             database.UpdateEntry(GALLERY_FILE_NAME, string.Empty, Gallery, true);
             database.Save();
         }
         RaiseDatabaseOperationCompletedEvent(OperationType.ScanSource);
     }
     catch (Exception ex)
     {
         CommonWorker.ShowError(ex);
     }
 }
Esempio n. 5
0
 public void SetVideoThumbnailsMakerPreset()
 {
     try
     {
         OpenFileDialog openFileDialog = new OpenFileDialog();
         openFileDialog.Title            = "Please select a Video Thumbnails Maker preset file...";
         openFileDialog.InitialDirectory = Path.GetDirectoryName(ObjectPool.CompleteVideoThumbnailsMakerPresetPath);
         openFileDialog.FileName         = Path.GetFileName(ObjectPool.CompleteVideoThumbnailsMakerPresetPath);
         openFileDialog.Filter           = "Video Thumbnails Maker presets (*.vtm)|*.vtm|All files (*.*)|*.*";
         openFileDialog.FilterIndex      = 0;
         if (openFileDialog.ShowDialog() == DialogResult.OK)
         {
             ObjectPool.SetVideoThumbnailsMakerPresetPath(openFileDialog.FileName);
             RegistryHandler.SaveSettings(SettingsType.VideoThumbnailsMakerPresetPath);
             RaiseVideoThumbnailsMakerPresetUpdatedEvent(ObjectPool.VideoThumbnailsMakerPresetPath);
         }
     }
     catch (Exception ex)
     {
         CommonWorker.ShowError(ex);
     }
 }