protected override void OnPageLoad() { base.OnPageLoad(); if (string.IsNullOrEmpty(_currentPicture) || !File.Exists(_currentPicture)) { ReturnToPreviousWindow(); return; } _currentMetaData = PictureDatabase.GetExifFromDB(_currentPicture); if (_currentMetaData.IsEmpty()) { _currentMetaData = PictureDatabase.GetExifFromFile(_currentPicture); } if (_currentMetaData.IsEmpty()) { ReturnToPreviousWindow(); return; } GUIPropertyManager.SetProperty("#pictures.exif.images.vertical", string.Empty); GUIPropertyManager.SetProperty("#pictures.exif.images.horizontal", string.Empty); SetExifGUIListItems(); Update(); Refresh(); }
private void CreateThumbsAndAddPictureToDB(string file) { int iRotate = PictureDatabase.GetRotation(file); if (iRotate == -1) { Log.Debug("GUIPictures Setting : Database is not available. File {0} has not been added", file); } string thumbnailImage = Util.Utils.GetPicturesThumbPathname(file); string thumbnailImageL = Util.Utils.GetPicturesLargeThumbPathname(file); if (!_noLargeThumbnails && !File.Exists(thumbnailImageL)) { if (Util.Picture.CreateThumbnail(file, thumbnailImageL, (int)Thumbs.ThumbLargeResolution, (int)Thumbs.ThumbLargeResolution, iRotate, Thumbs.SpeedThumbsLarge, true, false)) { Log.Debug("GUIPictures Setting : Creation of missing large thumb successful for {0}", file); count++; SetStatus(String.Format("{0}/{1} thumbnails generated", count, totalFiles)); } } if (!File.Exists(thumbnailImage)) { if (Util.Picture.CreateThumbnail(file, thumbnailImage, (int)Thumbs.ThumbResolution, (int)Thumbs.ThumbResolution, iRotate, Thumbs.SpeedThumbsSmall, false, false)) { Log.Debug("GUIPictures Setting : Creation of missing thumb successful for {0}", file); count++; SetStatus(String.Format("{0}/{1} thumbnails generated", count, totalFiles)); } } }
protected override void OnShowContextMenu() { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(498); // Menu // Dialog items dlg.AddLocalizedString(2168); // Update Exif // Show dialog menu dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } switch (dlg.SelectedId) { case 2168: // Update Exif Log.Debug("GUIPicturesExif: Update Exif {0}: {1}", PictureDatabase.UpdatePicture(_currentPicture, -1), _currentPicture); _currentMetaData = PictureDatabase.GetExifFromDB(_currentPicture); SetExifGUIListItems(); Update(); Refresh(); break; } }
private void Update() { try { if (listExifProperties != null && !listExifProperties.IsVisible) { listExifProperties.IsVisible = true; if (!listExifProperties.IsEnabled) { GUIControl.EnableControl(GetID, listExifProperties.GetID); } GUIControl.SelectControl(GetID, listExifProperties.GetID); GUIControl.FocusControl(GetID, listExifProperties.GetID); GUIPropertyManager.SetProperty("#itemcount", Util.Utils.GetObjectCountLabel(listExifProperties.Count)); listExifProperties.SelectedListItemIndex = _currentSelectedItem; SelectItem(); } if (imgPicture != null) { imgPicture.Rotation = PictureDatabase.GetRotation(_currentPicture); imgPicture.Dispose(); imgPicture.AllocResources(); } GUIPropertyManager.SetProperty("#pictures.exif.picture", _currentPicture); } catch (Exception ex) { Log.Error("GUIPictureExif Update controls Error: {1}", ex.Message); } }
private void OnResetDatabase() { GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_YES_NO); if (dlgYesNo != null) { dlgYesNo.SetHeading(GUILocalizeStrings.Get(927)); // Warning dlgYesNo.SetLine(1, GUILocalizeStrings.Get(300026)); //Are you sure... dlgYesNo.DoModal(GetID); if (dlgYesNo.IsConfirmed) { string database = Config.GetFile(Config.Dir.Database, "PictureDatabase.db3"); if (File.Exists(database)) { PictureDatabase.Dispose(); try { File.Delete(database); } catch (Exception ex) { Log.Error("GUISettingsPictures: OnResetDatabase {0}", ex.Message); } finally { PictureDatabase.ReOpen(); } } } } }
private static void DisposeDBs() { string dbPath = FolderSettings.DatabaseName; bool isRemotePath = (!string.IsNullOrEmpty(dbPath) && PathIsNetworkPath(dbPath)); if (isRemotePath) { Log.Info("Settings: disposing FolderDatabase3 sqllite database."); FolderSettings.Dispose(); } dbPath = PictureDatabase.DatabaseName; isRemotePath = (!string.IsNullOrEmpty(dbPath) && PathIsNetworkPath(dbPath)); if (isRemotePath) { Log.Info("Settings: disposing PictureDatabase sqllite database."); PictureDatabase.Dispose(); } dbPath = MediaPortal.Video.Database.VideoDatabase.DatabaseName; isRemotePath = (!string.IsNullOrEmpty(dbPath) && PathIsNetworkPath(dbPath)); if (isRemotePath) { Log.Info("Settings: disposing VideoDatabaseV5.db3 sqllite database."); MediaPortal.Video.Database.VideoDatabase.Dispose(); } dbPath = MediaPortal.Music.Database.MusicDatabase.Instance.DatabaseName; isRemotePath = (!string.IsNullOrEmpty(dbPath) && PathIsNetworkPath(dbPath)); if (isRemotePath) { Log.Info("Settings: disposing MusicDatabase db3 sqllite database."); MediaPortal.Music.Database.MusicDatabase.Dispose(); } }
public SlidePicture(string strFilePath, bool useActualSizeTexture) { _filePath = strFilePath; _rotation = PictureDatabase.GetRotation(_filePath); int iMaxWidth = GUIGraphicsContext.OverScanWidth; int iMaxHeight = GUIGraphicsContext.OverScanHeight; _useActualSizeTexture = useActualSizeTexture; if (_useActualSizeTexture) { iMaxWidth = MAX_PICTURE_WIDTH; iMaxHeight = MAX_PICTURE_HEIGHT; } if (!MediaPortal.Util.Utils.IsPicture(strFilePath)) { return; } else { _texture = Picture.Load(strFilePath, _rotation, iMaxWidth, iMaxHeight, true, false, true, out _width, out _height); } }
private void DeleteFromDatabase(GUIListItem item) { // delete from database if (Util.Utils.IsPicture(item.Path)) { //Remove from picture database PictureDatabase.DeletePicture(item.Path); } else if (Util.Utils.IsVideo(item.Path)) { //Remove from video database VideoDatabase.DeleteMovie(item.Path); } else if (Util.Utils.IsAudio(item.Path)) { //Remove from music database if (dbMusic == null) { dbMusic = MusicDatabase.Instance; } if (dbMusic != null) { dbMusic.DeleteSong(item.Path, true); } } }
private void Update() { if (m_pTexture != null) { m_pTexture.Dispose(); } SetLabel(lblCameraModel, string.Empty); SetLabel(lblDateTakenLabel, string.Empty); SetLabel(lblEquipmentMake, string.Empty); SetLabel(lblExposureCompensation, string.Empty); SetLabel(lblExposureTime, string.Empty); SetLabel(lblFlash, string.Empty); SetLabel(lblFstop, string.Empty); SetLabel(lblImgDimensions, string.Empty); SetLabel(lblImgTitle, string.Empty); SetLabel(lblMeteringMode, string.Empty); SetLabel(lblResolutions, string.Empty); SetLabel(lblShutterSpeed, string.Empty); SetLabel(lblViewComments, string.Empty); if (!File.Exists(FileName)) { GUIPropertyManager.SetProperty("#selectedthumb", string.Empty); return; } int iRotate = PictureDatabase.GetRotation(FileName); m_pTexture = Util.Picture.Load(FileName, iRotate, (int)Thumbs.LargeThumbSize.uhd, (int)Thumbs.LargeThumbSize.uhd, true, false, out m_iTextureWidth, out m_iTextureHeight); ExifMetadata.Metadata metaData = PictureDatabase.GetExifFromDB(FileName); if (metaData.IsEmpty()) { metaData = PictureDatabase.GetExifFromFile(FileName); } if (!metaData.IsEmpty()) { SetLabel(lblCameraModel, metaData.CameraModel.DisplayValue); SetLabel(lblDateTakenLabel, metaData.DatePictureTaken.DisplayValue); SetLabel(lblEquipmentMake, metaData.EquipmentMake.DisplayValue); SetLabel(lblExposureCompensation, metaData.ExposureCompensation.DisplayValue); SetLabel(lblExposureTime, metaData.ExposureTime.DisplayValue); SetLabel(lblFlash, metaData.Flash.DisplayValue, true); SetLabel(lblFstop, metaData.Fstop.DisplayValue); SetLabel(lblImgDimensions, metaData.ImageDimensionsAsString()); SetLabel(lblImgTitle, Path.GetFileNameWithoutExtension(FileName)); SetLabel(lblMeteringMode, metaData.MeteringMode.DisplayValue, true); SetLabel(lblResolutions, metaData.ResolutionAsString()); SetLabel(lblShutterSpeed, metaData.ShutterSpeed.DisplayValue); SetLabel(lblViewComments, metaData.ViewerComments.DisplayValue); imgPicture.IsVisible = false; } metaData.SetExifProperties(); GUIPropertyManager.SetProperty("#selectedthumb", FileName); }
private void Update() { if (m_pTexture != null) { m_pTexture.Dispose(); } int iRotate = PictureDatabase.GetRotation(FileName); m_pTexture = Util.Picture.Load(FileName, iRotate, 1024, 1024, true, false, out m_iTextureWidth, out m_iTextureHeight); lblCameraModel.Label = string.Empty; lblDateTakenLabel.Label = string.Empty; lblEquipmentMake.Label = string.Empty; lblExposureCompensation.Label = string.Empty; lblExposureTime.Label = string.Empty; lblFlash.Label = string.Empty; lblFstop.Label = string.Empty; lblImgDimensions.Label = string.Empty; lblImgTitle.Label = string.Empty; lblMeteringMode.Label = string.Empty; lblResolutions.Label = string.Empty; lblShutterSpeed.Label = string.Empty; lblViewComments.Label = string.Empty; using (ExifMetadata extractor = new ExifMetadata()) { ExifMetadata.Metadata metaData = extractor.GetExifMetadata(FileName); lblCameraModel.Label = metaData.CameraModel.DisplayValue; lblDateTakenLabel.Label = metaData.DatePictureTaken.DisplayValue; lblEquipmentMake.Label = metaData.EquipmentMake.DisplayValue; lblExposureCompensation.Label = metaData.ExposureCompensation.DisplayValue; lblExposureTime.Label = metaData.ExposureTime.DisplayValue; lblFlash.Label = metaData.Flash.DisplayValue; lblFstop.Label = metaData.Fstop.DisplayValue; lblImgDimensions.Label = metaData.ImageDimensions.DisplayValue; lblImgTitle.Label = Path.GetFileNameWithoutExtension(FileName); lblMeteringMode.Label = metaData.MeteringMode.DisplayValue; lblResolutions.Label = metaData.Resolution.DisplayValue; lblShutterSpeed.Label = metaData.ShutterSpeed.DisplayValue; lblViewComments.Label = metaData.ViewerComments.DisplayValue; imgPicture.IsVisible = false; } if (File.Exists(FileName)) { GUIPropertyManager.SetProperty("#selectedthumb", FileName); } else { GUIPropertyManager.SetProperty("#selectedthumb", string.Empty); } }
public static void RestartMP() { bool hideTaskBar = false; using (Settings xmlreader = new MPSettings()) { hideTaskBar = xmlreader.GetValueAsBool("general", "hidetaskbar", false); } if (hideTaskBar) { Win32API.EnableStartBar(true); Win32API.ShowStartBar(true); } Log.Info("argustv: OnRestart - prepare for restart!"); File.Delete(Config.GetFile(Config.Dir.Config, "mediaportal.running")); Log.Info("argustv: OnRestart - saving settings..."); Settings.SaveCache(); Log.Info("argustv: disposing databases."); FolderSettings.Dispose(); PictureDatabase.Dispose(); VideoDatabase.Dispose(); MusicDatabase.Dispose(); VolumeHandler.Dispose(); System.Diagnostics.Process restartScript = new System.Diagnostics.Process(); restartScript.EnableRaisingEvents = false; restartScript.StartInfo.WorkingDirectory = Config.GetFolder(Config.Dir.Base); restartScript.StartInfo.FileName = Config.GetFile(Config.Dir.Base, @"restart.vbs"); Log.Debug("argustv: OnRestart - executing script {0}", restartScript.StartInfo.FileName); restartScript.Start(); try { // Maybe the scripting host is not available therefore do not wait infinitely. if (!restartScript.HasExited) { restartScript.WaitForExit(); } } catch (Exception ex) { Log.Error("argustv: OnRestart - WaitForExit: {0}", ex.Message); } }
private void CreateThumbsAndAddPictureToDB(string file) { int iRotate = PictureDatabase.GetRotation(file); if (iRotate == -1) { Log.Debug("PictureDatabase: Database is not available. File {0} has not been added", file); } //Thread.Sleep(30); //add remote check //if () //{ string thumbnailImage = String.Format(@"{0}\{1}.jpg", Thumbs.Pictures, Util.Utils.EncryptLine(file)); //if (recreateThumbs || !File.Exists(thumbnailImage)) if (!File.Exists(thumbnailImage)) { if (Util.Picture.CreateThumbnail(file, thumbnailImage, (int)Thumbs.ThumbResolution, (int)Thumbs.ThumbResolution, iRotate, Thumbs.SpeedThumbsSmall)) { Log.Debug("PictureDatabase: Creation of missing thumb successful for {0}", file); } } if (!noLargeThumbnails) { thumbnailImage = String.Format(@"{0}\{1}L.jpg", Thumbs.Pictures, Util.Utils.EncryptLine(file)); //if (recreateThumbs || !File.Exists(thumbnailImage)) if (!File.Exists(thumbnailImage)) { if (Util.Picture.CreateThumbnail(file, thumbnailImage, (int)Thumbs.ThumbLargeResolution, (int)Thumbs.ThumbLargeResolution, iRotate, Thumbs.SpeedThumbsLarge)) { Log.Debug("PictureDatabase: Creation of missing large thumb successful for {0}", file); } } } //} }
private void CreateThumbsAndAddPictureToDB(string file) { int iRotate = PictureDatabase.GetRotation(file); string thumbnailImage = MediaPortal.Util.Utils.GetPicturesThumbPathname(file); if (!File.Exists(thumbnailImage)) { MediaPortal.Util.Picture.CreateThumbnail(file, thumbnailImage, (int)Thumbs.ThumbResolution, (int)Thumbs.ThumbResolution, iRotate, Thumbs.SpeedThumbsSmall, false, false); } if (!noLargeThumbnails) { thumbnailImage = MediaPortal.Util.Utils.GetPicturesLargeThumbPathname(file); //if (recreateThumbs || !File.Exists(thumbnailImage)) if (!File.Exists(thumbnailImage)) { MediaPortal.Util.Picture.CreateThumbnail(file, thumbnailImage, (int)Thumbs.ThumbLargeResolution, (int)Thumbs.ThumbLargeResolution, iRotate, Thumbs.SpeedThumbsLarge, true, false); } } }
/// <summary> /// /// </summary> private bool ClearDatabase() { string database = Config.GetFile(Config.Dir.Database, PictureDatabase.DatabaseName); if (File.Exists(database)) { PictureDatabase.Dispose(); try { File.Delete(database); } catch (Exception) { return(false); } finally { PictureDatabase.ReOpen(); } } return(true); }
/// <summary> /// creates cached thumbs in MP's thumbs dir /// </summary> private void PerformRequest() { Stopwatch benchclock = new Stopwatch(); benchclock.Start(); string path = _filepath; List <GUIListItem> itemlist = null; vDir.SetExtensions(Util.Utils.PictureExtensions); if (!vDir.IsRemote(path)) { itemlist = vDir.GetDirectoryUnProtectedExt(path, true); foreach (GUIListItem item in itemlist) { if (GUIGraphicsContext.CurrentState == GUIGraphicsContext.State.STOPPING) { return; } if (String.IsNullOrEmpty(item.Path)) { continue; } if (path.Length >= item.Path.Length) { Log.Warn("GUIPictures: Omitting outside path {0} from check share {1}", item.Path, path); continue; } if (!item.IsFolder) { if (item.Path.ToLowerInvariant().Contains(@"folder.jpg")) { continue; } int iRotate = PictureDatabase.GetRotation(item.Path); if (iRotate == -1) { Log.Debug("PictureDatabase: Database is not available. File {0} has not been added", item.Path); } string thumbnailImage = Util.Utils.GetPicturesThumbPathname(item.Path); string thumbnailImageL = Util.Utils.GetPicturesLargeThumbPathname(item.Path); if (!noLargeThumbnails && !File.Exists(thumbnailImageL)) { if (Util.Picture.CreateThumbnail(item.Path, thumbnailImageL, (int)Thumbs.ThumbLargeResolution, (int)Thumbs.ThumbLargeResolution, iRotate, Thumbs.SpeedThumbsLarge, true, false)) { Log.Debug("PictureDatabase: Creation of missing large thumb successful for {0}", item.Path); countfiles++; } } if (!File.Exists(thumbnailImage)) { if (Util.Picture.CreateThumbnail(item.Path, thumbnailImage, (int)Thumbs.ThumbResolution, (int)Thumbs.ThumbResolution, iRotate, Thumbs.SpeedThumbsSmall, false, false)) { Log.Debug("PictureDatabase: Creation of missing thumb successful for {0}", item.Path); countfiles++; } } } } } }
public PhotographerController(PictureDatabase db) { _picDb = db; Logger = new NullLogger <PhotographerController>(); }
public PictureController(ImageLoadWorkQueue workQueue, PictureDatabase db) { _picDb = db; _workQueue = workQueue; Logger = new NullLogger <ImageLoadBackgroundService>(); }
public ReportController(PictureDatabase database) { _database = database; }
public PictureHub(ImageService imageService, PictureDatabase picDb) { _imageService = imageService; _picDb = picDb; }
public ImageService(PictureDatabase picDb) { _picDb = picDb; Logger = new NullLogger <ImageService>(); }
/// <summary> /// Returns latest added Pictures db. /// </summary> /// <param name="type">Type of data to fetch</param> /// <returns>Resultset of matching data</returns> private LatestsCollection GetLatestPictures() { latestPictures = new LatestsCollection(); latestPicturesFiles = new Hashtable(); if (!PictureDatabase.DbHealth) { return(latestPictures); } int x = 0; try { CurrentFacade.HasNew = false; string sqlQuery = "SELECT strFile, strDateTaken FROM picture" + (PictureDatabase.FilterPrivate ? " WHERE idPicture NOT IN (SELECT DISTINCT idPicture FROM picturekeywords WHERE strKeyword = 'Private')" : string.Empty) + " ORDER BY strDateTaken DESC LIMIT " + Utils.FacadeMaxNum + ";"; List <PictureData> pictures = PictureDatabase.GetPicturesByFilter(sqlQuery, "pictures"); if (pictures != null) { if (pictures.Count > 0) { int i0 = 1; for (int i = 0; i < pictures.Count; i++) { string filename = pictures[i].FileName; if (string.IsNullOrEmpty(filename)) { continue; } // string thumb = String.Format(@"{0}\{1}L.jpg", Thumbs.Pictures, MediaPortal.Util.Utils.EncryptLine(filename)); string thumb = MediaPortal.Util.Utils.GetPicturesLargeThumbPathname(filename); if (!File.Exists(thumb)) { // thumb = String.Format(@"{0}\{1}.jpg", Thumbs.Pictures, MediaPortal.Util.Utils.EncryptLine(filename)); thumb = MediaPortal.Util.Utils.GetPicturesThumbPathname(filename); if (!File.Exists(thumb)) { // thumb = "DefaultPictureBig.png"; thumb = filename; } } if (!File.Exists(thumb)) { continue; } bool isnew = false; isnew = (pictures[i].DateTaken > Utils.NewDateTime); if (isnew) { CurrentFacade.HasNew = true; } string title = Path.GetFileNameWithoutExtension(Utils.GetFilenameNoPath(filename)).ToUpperInvariant(); string exif = string.Empty; string exifoutline = string.Empty; if (File.Exists(filename)) { using (ExifMetadata extractor = new ExifMetadata()) { ExifMetadata.Metadata metaData = extractor.GetExifMetadata(filename); if (!metaData.IsEmpty()) { exif = metaData.ToString(); exifoutline = metaData.ToShortString(); } } } latestPictures.Add(new Latest() { DateTimeAdded = pictures[i].DateTaken, Title = title, Subtitle = exifoutline, Thumb = thumb, Fanart = filename, Classification = exif, IsNew = isnew }); latestPicturesFiles.Add(i0, filename); Utils.ThreadToSleep(); x++; i0++; if (x == Utils.FacadeMaxNum) { break; } } } } } catch (Exception ex) { logger.Error("GetLatestPictures: " + ex.ToString()); } return(latestPictures); }