Beispiel #1
0
 public static void AddColumnSelectedFiles(
     DataGridView dataGridView, ThumbnailPosterDatabaseCache databaseAndCacheThumbnail, HashSet <FileEntry> imageListViewItems,
     ReadWriteAccess readWriteAccessForColumn, ShowWhatColumns showWhatColumns, DataGridViewGenericCellStatus dataGridViewGenericCellStatusDefault)
 {
     foreach (FileEntry imageListViewItem in imageListViewItems)
     {
         FileEntryAttribute fileEntryAttribute = new FileEntryAttribute(imageListViewItem.FileFullPath, imageListViewItem.LastWriteDateTime, FileEntryVersion.CurrentVersionInDatabase);
         Image thumbnail = null;
         if (databaseAndCacheThumbnail != null)
         {
             thumbnail = databaseAndCacheThumbnail.ReadThumbnailFromCacheOnly(fileEntryAttribute.FileEntry);
         }
         DataGridViewHandler.AddColumnOrUpdateNew(dataGridView, fileEntryAttribute, thumbnail, null, readWriteAccessForColumn, showWhatColumns, dataGridViewGenericCellStatusDefault, out _);
     }
 }
Beispiel #2
0
 private DataGridViewGenericRow(string headerName, string rowName, ReadWriteAccess readWriteAcess, bool isHeader, bool isMultiLine, PropertyKey propertyKey,
                                Metadata metadata, FileEntryAttribute fileEntryAttribute,
                                MetadataPriorityKey metadataPriorityKey, LocationCoordinate locationCoordinate)
 {
     this.HeaderName          = headerName ?? throw new ArgumentNullException(nameof(rowName));
     this.RowName             = rowName == null ? "" : rowName;
     this.ReadWriteAccess     = readWriteAcess;
     this.IsHeader            = isHeader;
     this.IsEqual             = false;
     this.IsFavourite         = false;
     this.IsMultiLine         = isMultiLine;
     this.PropertyKey         = propertyKey;
     this.Metadata            = metadata;
     this.FileEntryAttribute  = fileEntryAttribute;
     this.MetadataPriorityKey = metadataPriorityKey;
     this.LocationCoordinate  = locationCoordinate;
 }
Beispiel #3
0
        public static int PopulateFile(DataGridView dataGridView, FileEntryAttribute fileEntryAttribute, ShowWhatColumns showWhatColumns, Metadata metadataAutoCorrected, bool onlyRefresh)
        {
            //-----------------------------------------------------------------
            //Chech if need to stop
            if (GlobalData.IsApplicationClosing)
            {
                return(-1);
            }
            if (!DataGridViewHandler.GetIsAgregated(dataGridView))
            {
                return(-1);                                                        //Not default columns or rows added
            }
            if (DataGridViewHandler.GetIsPopulatingFile(dataGridView))
            {
                return(-1);                                                        //In progress doing so
            }
            //Check if file is in DataGridView
            if (!DataGridViewHandler.DoesColumnFilenameExist(dataGridView, fileEntryAttribute.FileFullPath))
            {
                return(-1);
            }

            //When file found, Tell it's populating file, avoid two process updates
            DataGridViewHandler.SetIsPopulatingFile(dataGridView, true);

            //-----------------------------------------------------------------
            FileEntryBroker fileEntryBrokerReadVersion = fileEntryAttribute.GetFileEntryBroker(MetadataBrokerType.ExifTool);
            Image           thumbnail = DatabaseAndCacheThumbnail.ReadThumbnailFromCacheOnly(fileEntryBrokerReadVersion);

            if (thumbnail == null && metadataAutoCorrected != null)
            {
                thumbnail = DatabaseAndCacheThumbnail.ReadThumbnailFromCacheOnly(metadataAutoCorrected.FileEntry);
            }

            Metadata metadataExiftool = DatabaseAndCacheMetadataExiftool.ReadMetadataFromCacheOnly(fileEntryBrokerReadVersion);

            if (metadataExiftool != null)
            {
                metadataExiftool = new Metadata(metadataExiftool);
            }
            if (metadataAutoCorrected != null)
            {
                metadataExiftool = metadataAutoCorrected;                                //If AutoCorrect is run, use AutoCorrect values. Needs to be after DataGridViewHandler.AddColumnOrUpdateNew, so orignal metadata stored will not be overwritten
            }
            ReadWriteAccess readWriteAccessColumn =
                (FileEntryVersionHandler.IsReadOnlyType(fileEntryAttribute.FileEntryVersion) ||
                 metadataExiftool == null) ? ReadWriteAccess.ForceCellToReadOnly : ReadWriteAccess.AllowCellReadAndWrite;

            int columnIndex = DataGridViewHandler.AddColumnOrUpdateNew(
                dataGridView, fileEntryAttribute, thumbnail, metadataExiftool, readWriteAccessColumn, showWhatColumns,
                DataGridViewGenericCellStatus.DefaultEmpty(), out FileEntryVersionCompare fileEntryVersionCompareReason);

            //Chech if populated and new refresh data
            if (onlyRefresh && FileEntryVersionHandler.NeedUpdate(fileEntryVersionCompareReason) && !DataGridViewHandler.IsColumnPopulated(dataGridView, columnIndex))
            {
                fileEntryVersionCompareReason = FileEntryVersionCompare.LostNoneEqualFound_ContinueSearch; //No need to populate
            }
            //-----------------------------------------------------------------

            if (FileEntryVersionHandler.NeedUpdate(fileEntryVersionCompareReason))
            {
                //Media
                DataGridViewHandler.AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerMedia), false);
                DataGridViewHandler.AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerMedia, tagMediaDateTaken), TimeZoneLibrary.ToStringSortable(metadataExiftool?.MediaDateTaken), false, false);
                DataGridViewHandler.AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerMedia, tagGPSLocationDateTime), TimeZoneLibrary.ToStringW3CDTF_UTC_Convert(metadataExiftool?.LocationDateTime), false, false);

                //Suggestion header
                DataGridViewHandler.AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerSuggestion), false);

                //Dates and/or time in filename
                DataGridViewHandler.AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerDatesTimeInFilename), false);

                FileDateTimeReader fileDateTimeReader = new FileDateTimeReader(Properties.Settings.Default.RenameDateFormats);
                List <DateTime>    dates = fileDateTimeReader.ListAllDateTimes(Path.GetFileNameWithoutExtension(fileEntryAttribute.FileFullPath));
                for (int i = 0; i < dates.Count; i++)
                {
                    DataGridViewHandler.AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerDatesTimeInFilename, tagDatesFoundInFilename + (i + 1).ToString()), TimeZoneLibrary.ToStringSortable(dates[i]), true, false);
                }

                //Metadata
                DataGridViewHandler.AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerMetadataDates), false);
                DataGridViewHandler.AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerMetadataDates, tagFileDate), TimeZoneLibrary.ToStringW3CDTF(metadataExiftool?.FileDate), true, false);
                DataGridViewHandler.AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerMetadataDates, tagFileSmartDate), TimeZoneLibrary.ToStringW3CDTF(metadataExiftool?.FileSmartDate(Properties.Settings.Default.RenameDateFormats)), true, false);

                DataGridViewHandler.AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerMetadataDates, tagFileDateCreated), TimeZoneLibrary.ToStringW3CDTF(metadataExiftool?.FileDateCreated), true, false);
                DataGridViewHandler.AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerMetadataDates, tagFileDateModified), TimeZoneLibrary.ToStringW3CDTF(metadataExiftool?.FileDateModified), true, false);
                DataGridViewHandler.AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerMetadataDates, tagFileLastAccessed), TimeZoneLibrary.ToStringW3CDTF(metadataExiftool?.FileDateAccessed), true, false);

                //BeginInvoke(new Action<DataGridView, FileEntryAttribute>(PopulateExiftoolData), dataGridView, fileEntryAttribute);
                //PopulateExiftoolData(dataGridView, fileEntryAttribute);
                PopulateTimeZone(dataGridView, columnIndex, null);

                DataGridViewHandler.SetColumnPopulatedFlag(dataGridView, columnIndex, true);
            }

            //-----------------------------------------------------------------
            DataGridViewHandler.SetIsPopulatingFile(dataGridView, false);
            //-----------------------------------------------------------------
            return(columnIndex);
        }
        public static int PopulateFile(DataGridView dataGridView, FileEntryAttribute fileEntryAttribute, ShowWhatColumns showWhatColumns, Metadata metadataAutoCorrected, bool onlyRefresh)
        {
            //-----------------------------------------------------------------
            //Chech if need to stop
            if (GlobalData.IsApplicationClosing)
            {
                return(-1);
            }
            if (!DataGridViewHandler.GetIsAgregated(dataGridView))
            {
                return(-1);                                                        //Not default columns or rows added
            }
            if (DataGridViewHandler.GetIsPopulatingFile(dataGridView))
            {
                return(-1);                                                        //In progress doing so
            }
            //Check if file is in DataGridView
            if (!DataGridViewHandler.DoesColumnFilenameExist(dataGridView, fileEntryAttribute.FileFullPath))
            {
                return(-1);
            }

            //When file found, Tell it's populating file, avoid two process updates
            DataGridViewHandler.SetIsPopulatingFile(dataGridView, true);

            //-----------------------------------------------------------------
            FileEntryBroker fileEntryBrokerReadVersion = fileEntryAttribute.GetFileEntryBroker(MetadataBrokerType.ExifTool);
            Image           thumbnail = DatabaseAndCacheThumbnail.ReadThumbnailFromCacheOnly(fileEntryBrokerReadVersion);

            if (thumbnail == null && metadataAutoCorrected != null)
            {
                thumbnail = DatabaseAndCacheThumbnail.ReadThumbnailFromCacheOnly(metadataAutoCorrected.FileEntry);
            }

            Metadata metadataExiftool = DatabaseAndCacheMetadataExiftool.ReadMetadataFromCacheOnly(fileEntryBrokerReadVersion);

            if (metadataExiftool != null)
            {
                metadataExiftool = new Metadata(metadataExiftool);
            }
            if (metadataAutoCorrected != null)
            {
                metadataExiftool = metadataAutoCorrected;                                //If AutoCorrect is run, use AutoCorrect values. Needs to be after DataGridViewHandler.AddColumnOrUpdateNew, so orignal metadata stored will not be overwritten
            }
            ReadWriteAccess readWriteAccessColumn =
                (FileEntryVersionHandler.IsReadOnlyType(fileEntryAttribute.FileEntryVersion) ||
                 metadataExiftool == null) ? ReadWriteAccess.ForceCellToReadOnly : ReadWriteAccess.AllowCellReadAndWrite;

            int columnIndex = DataGridViewHandler.AddColumnOrUpdateNew(
                dataGridView, fileEntryAttribute, thumbnail, metadataExiftool, readWriteAccessColumn, showWhatColumns,
                DataGridViewGenericCellStatus.DefaultEmpty(), out FileEntryVersionCompare fileEntryVersionCompareReason);

            //Chech if populated and new refresh data
            if (onlyRefresh && FileEntryVersionHandler.NeedUpdate(fileEntryVersionCompareReason) && !DataGridViewHandler.IsColumnPopulated(dataGridView, columnIndex))
            {
                fileEntryVersionCompareReason = FileEntryVersionCompare.LostNoneEqualFound_ContinueSearch; //No need to populate
            }
            //-----------------------------------------------------------------

            if (FileEntryVersionHandler.NeedUpdate(fileEntryVersionCompareReason))
            {
                DataGridViewHandler.SetDataGridViewAllowUserToAddRows(dataGridView, true);
                //Media
                int rowIndex;
                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerMedia), false);

                rowIndex = AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerMedia, tagAlbum), metadataExiftool?.PersonalAlbum, false);
                List <string> newKeywords = AutoKeywordHandler.NewKeywords(AutoKeywordConvertions, null, null, metadataExiftool?.PersonalAlbum, null, null, null);
                DataGridViewHandler.SetCellToolTipText(dataGridView, columnIndex, rowIndex, "Running AutoCorrect will add these keywords", newKeywords);

                rowIndex    = AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerMedia, tagTitle), metadataExiftool?.PersonalTitle, false);
                newKeywords = AutoKeywordHandler.NewKeywords(AutoKeywordConvertions, null, metadataExiftool?.PersonalTitle, null, null, null, null);
                DataGridViewHandler.SetCellToolTipText(dataGridView, columnIndex, rowIndex, "Running AutoCorrect will add these keywords", newKeywords);

                rowIndex    = AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerMedia, tagDescription), metadataExiftool?.PersonalDescription, false);
                newKeywords = AutoKeywordHandler.NewKeywords(AutoKeywordConvertions, null, null, null, metadataExiftool?.PersonalDescription, null, null);
                DataGridViewHandler.SetCellToolTipText(dataGridView, columnIndex, rowIndex, "Running AutoCorrect will add these keywords", newKeywords);

                rowIndex    = AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerMedia, tagComments), metadataExiftool?.PersonalComments, false);
                newKeywords = AutoKeywordHandler.NewKeywords(AutoKeywordConvertions, null, null, null, null, metadataExiftool?.PersonalComments, null);
                DataGridViewHandler.SetCellToolTipText(dataGridView, columnIndex, rowIndex, "Running AutoCorrect will add these keywords", newKeywords);

                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerMedia, tagRating), metadataExiftool?.PersonalRating, false);
                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerMedia, tagAuthor), metadataExiftool?.PersonalAuthor, false);

                // Microsoft Phontos
                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerMicrosoftPhotos), false);
                Metadata metadataMicrosoftPhotos = null;
                if (metadataExiftool != null)
                {
                    metadataMicrosoftPhotos = DatabaseAndCacheMetadataMicrosoftPhotos.ReadMetadataFromCacheOrDatabase(new FileEntryBroker(fileEntryBrokerReadVersion, MetadataBrokerType.MicrosoftPhotos));
                }
                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerMicrosoftPhotos, tagAlbum), metadataMicrosoftPhotos?.PersonalAlbum, true);
                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerMicrosoftPhotos, tagTitle), metadataMicrosoftPhotos?.PersonalTitle, true);

                // Folder path as Album
                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerFolder), false);
                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerFolder, tagAlbum), new DirectoryInfo(fileEntryBrokerReadVersion.Directory).Name, true);

                //Windows Live Photo Gallery
                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerWindowsLivePhotoGallery), false);
                Metadata metadataWindowsLivePhotoGallery = null;
                if (metadataExiftool != null)
                {
                    metadataWindowsLivePhotoGallery = DatabaseAndCacheMetadataWindowsLivePhotoGallery.ReadMetadataFromCacheOrDatabase(new FileEntryBroker(fileEntryBrokerReadVersion, MetadataBrokerType.WindowsLivePhotoGallery));
                }

                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerWindowsLivePhotoGallery, tagTitle), metadataWindowsLivePhotoGallery?.PersonalTitle, true);
                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerWindowsLivePhotoGallery, tagRating), metadataWindowsLivePhotoGallery?.PersonalRating, true);

                // WebScarping
                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerWebScraping), false);
                Metadata metadataWebScraping = null;
                if (metadataExiftool != null)
                {
                    metadataWebScraping = DatabaseAndCacheMetadataExiftool.ReadWebScraperMetadataFromCacheOrDatabase(new FileEntryBroker(fileEntryBrokerReadVersion, MetadataBrokerType.WebScraping));
                }
                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerWebScraping, tagAlbum), metadataWebScraping?.PersonalAlbum, true);
                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerWebScraping, tagTitle), metadataWebScraping?.PersonalTitle, true);


                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerKeywords), false);

                if (fileEntryAttribute.FileEntryVersion == FileEntryVersion.CompatibilityFixedAndAutoUpdated ||
                    fileEntryAttribute.FileEntryVersion == FileEntryVersion.MetadataToSave)
                {
                    int keywordsStarts = DataGridViewHandler.GetRowHeaderItemStarts(dataGridView, headerKeywords);
                    int keywordsEnds   = DataGridViewHandler.GetRowHeaderItemsEnds(dataGridView, headerKeywords);
                    for (int rowIndexToClean = keywordsStarts; rowIndexToClean <= keywordsEnds; rowIndexToClean++)
                    {
                        DataGridViewGenericCellStatus dataGridViewGenericCellStatus = new DataGridViewGenericCellStatus(MetadataBrokerType.Empty, SwitchStates.Undefine, true);
                        DataGridViewHandler.SetCellReadOnlyDependingOfStatus(dataGridView, columnIndex, rowIndexToClean, dataGridViewGenericCellStatus);
                        DataGridViewHandler.SetCellStatus(dataGridView, columnIndex, rowIndexToClean, dataGridViewGenericCellStatus, false);
                    }
                }

                if (metadataExiftool != null)
                {
                    PopulateKeywords(dataGridView, metadataExiftool, columnIndex, metadataExiftool.Broker, fileEntryAttribute);
                }
                if (metadataMicrosoftPhotos != null)
                {
                    PopulateKeywords(dataGridView, metadataMicrosoftPhotos, columnIndex, metadataMicrosoftPhotos.Broker, fileEntryAttribute);
                }
                if (metadataWindowsLivePhotoGallery != null)
                {
                    PopulateKeywords(dataGridView, metadataWindowsLivePhotoGallery, columnIndex, metadataWindowsLivePhotoGallery.Broker, fileEntryAttribute);
                }
                if (metadataWebScraping != null)
                {
                    PopulateKeywords(dataGridView, metadataWebScraping, columnIndex, metadataWebScraping.Broker, fileEntryAttribute);
                }


                DataGridViewHandler.SetColumnPopulatedFlag(dataGridView, columnIndex, true);
            }
            //-----------------------------------------------------------------
            DataGridViewHandler.SetIsPopulatingFile(dataGridView, false);
            //-----------------------------------------------------------------
            return(columnIndex);
        }
Beispiel #5
0
 public DataGridViewGenericRow(string headerName, string rowName, ReadWriteAccess readWriteAccess, bool isMultiLine, PropertyKey propertyKey)
     : this(headerName, rowName, readWriteAccess, false, isMultiLine, propertyKey, null, null, null, null)
 {
 }
Beispiel #6
0
 public DataGridViewGenericRow(string headerName, string rowName, ReadWriteAccess readWriteAccess)
     : this(headerName, rowName, readWriteAccess, false, false, null, null, null, null, null)
 {
 }
        public static int PopulateFile(DataGridView dataGridView, FileEntryAttribute fileEntryAttribute, ShowWhatColumns showWhatColumns, Metadata metadataAutoCorrected, bool onlyRefresh)
        {
            //-----------------------------------------------------------------
            //Chech if need to stop
            if (GlobalData.IsApplicationClosing)
            {
                return(-1);
            }
            if (!DataGridViewHandler.GetIsAgregated(dataGridView))
            {
                return(-1);                                                        //Not default columns or rows added
            }
            if (DataGridViewHandler.GetIsPopulatingFile(dataGridView))
            {
                return(-1);                                                        //In progress doing so
            }
            //Check if file is in DataGridView, and needs updated
            if (!DataGridViewHandler.DoesColumnFilenameExist(dataGridView, fileEntryAttribute.FileFullPath))
            {
                return(-1);
            }

            //When file found, Tell it's populating file, avoid two process updates
            DataGridViewHandler.SetIsPopulatingFile(dataGridView, true);
            //-----------------------------------------------------------------

            List <string> regionNamesAddedPeople       = new List <string>();
            List <string> regionNamesAddedTopMost      = new List <string>();
            List <string> regionNamesAddedDateInterval = new List <string>();


            for (int rowIndex = 0; rowIndex < DataGridViewHandler.GetRowCountWithoutEditRow(dataGridView); rowIndex++)
            {
                DataGridViewGenericRow dataGridViewGenericRow = DataGridViewHandler.GetRowDataGridViewGenericRow(dataGridView, rowIndex);
                if (dataGridViewGenericRow != null && !dataGridViewGenericRow.IsHeader)
                {
                    if (dataGridViewGenericRow.HeaderName == headerPeople && !regionNamesAddedPeople.Contains(dataGridViewGenericRow.RowName))
                    {
                        regionNamesAddedPeople.Add(dataGridViewGenericRow.RowName);
                    }
                    else if (dataGridViewGenericRow.HeaderName == headerPeopleSuggestion && !regionNamesAddedDateInterval.Contains(dataGridViewGenericRow.RowName))
                    {
                        regionNamesAddedDateInterval.Add(dataGridViewGenericRow.RowName);
                    }
                    else if (dataGridViewGenericRow.HeaderName == headerPeopleMostUsed && !regionNamesAddedTopMost.Contains(dataGridViewGenericRow.RowName))
                    {
                        regionNamesAddedTopMost.Add(dataGridViewGenericRow.RowName);
                    }
                }
            }

            //-----------------------------------------------------------------

            FileEntryBroker fileEntryBrokerReadVersion = fileEntryAttribute.GetFileEntryBroker(MetadataBrokerType.ExifTool);
            Image           thumbnail = DatabaseAndCacheThumbnail.ReadThumbnailFromCacheOnly(fileEntryBrokerReadVersion);

            if (thumbnail == null && metadataAutoCorrected != null)
            {
                thumbnail = DatabaseAndCacheThumbnail.ReadThumbnailFromCacheOnly(metadataAutoCorrected.FileEntry);
            }

            Metadata metadataExiftool = DatabaseAndCacheMetadataExiftool.ReadMetadataFromCacheOnly(fileEntryBrokerReadVersion);

            if (metadataExiftool != null)
            {
                metadataExiftool = new Metadata(metadataExiftool);
            }
            if (metadataAutoCorrected != null)
            {
                metadataExiftool = metadataAutoCorrected;                                //If AutoCorrect is run, use AutoCorrect values. Needs to be after DataGridViewHandler.AddColumnOrUpdateNew, so orignal metadata stored will not be overwritten
            }
            ReadWriteAccess readWriteAccessColumn =
                (FileEntryVersionHandler.IsReadOnlyType(fileEntryAttribute.FileEntryVersion) ||
                 metadataExiftool == null) ? ReadWriteAccess.ForceCellToReadOnly : ReadWriteAccess.AllowCellReadAndWrite;

            int columnIndex = DataGridViewHandler.AddColumnOrUpdateNew(
                dataGridView, fileEntryAttribute, thumbnail, metadataExiftool, readWriteAccessColumn, showWhatColumns,
                DataGridViewGenericCellStatus.DefaultEmpty(), out FileEntryVersionCompare fileEntryVersionCompareReason);


            //Chech if populated and new refresh data
            if (onlyRefresh && FileEntryVersionHandler.NeedUpdate(fileEntryVersionCompareReason) && !DataGridViewHandler.IsColumnPopulated(dataGridView, columnIndex))
            {
                fileEntryVersionCompareReason = FileEntryVersionCompare.LostNoneEqualFound_ContinueSearch; //No need to populate
            }
            //-----------------------------------------------------------------

            if (FileEntryVersionHandler.NeedUpdate(fileEntryVersionCompareReason))
            {
                DataGridViewHandler.SetDataGridViewAllowUserToAddRows(dataGridView, true);

                AddRowHeader(dataGridView, columnIndex, new DataGridViewGenericRow(headerPeople), false);

                //Remove column data, due to Populate People append data -
                for (int rowIndex = 0; rowIndex < DataGridViewHandler.GetRowCountWithoutEditRow(dataGridView); rowIndex++)
                {
                    DataGridViewHandler.SetCellValue(dataGridView, columnIndex, rowIndex, null, false);
                    DataGridViewGenericCellStatus dataGridViewGenericCellStatusDefault = new DataGridViewGenericCellStatus(MetadataBrokerType.Empty, SwitchStates.Disabled, true);
                    DataGridViewHandler.SetCellDefaultAfterUpdated(dataGridView, dataGridViewGenericCellStatusDefault, columnIndex, rowIndex);
                }

                if (metadataExiftool != null)
                {
                    Metadata metadataCopy = new Metadata(metadataExiftool);
                    Metadata metadataWindowsLivePhotoGallery     = DatabaseAndCacheMetadataWindowsLivePhotoGallery.ReadMetadataFromCacheOrDatabase(new FileEntryBroker(fileEntryBrokerReadVersion, MetadataBrokerType.WindowsLivePhotoGallery));
                    Metadata metadataWindowsLivePhotoGalleryCopy = metadataWindowsLivePhotoGallery == null ? null : new Metadata(metadataWindowsLivePhotoGallery);
                    Metadata metadataMicrosoftPhotos             = DatabaseAndCacheMetadataMicrosoftPhotos.ReadMetadataFromCacheOrDatabase(new FileEntryBroker(fileEntryBrokerReadVersion, MetadataBrokerType.MicrosoftPhotos));
                    Metadata metadataMicrosoftPhotosCopy         = metadataMicrosoftPhotos == null ? null : new Metadata(metadataMicrosoftPhotos);
                    Metadata metadataWebScraping     = DatabaseAndCacheMetadataExiftool.ReadWebScraperMetadataFromCacheOrDatabase(new FileEntryBroker(fileEntryBrokerReadVersion, MetadataBrokerType.WebScraping));
                    Metadata metadataWebScrapingCopy = metadataWebScraping == null ? null : new Metadata(metadataWebScraping);

                    //Remove doubles and add names where missing, only work with copy, don't change metadata in buffer.
                    //Don't remove region in ExifTool metadata when found other places

                    if (metadataWindowsLivePhotoGalleryCopy != null)
                    {
                        metadataCopy.PersonalRegionSetNamelessRegions(metadataWindowsLivePhotoGalleryCopy.PersonalRegionList);
                    }
                    if (metadataMicrosoftPhotosCopy != null)
                    {
                        metadataCopy.PersonalRegionSetNamelessRegions(metadataMicrosoftPhotosCopy.PersonalRegionList);
                    }

                    if (metadataWebScrapingCopy != null)
                    {
                        metadataWebScrapingCopy.MediaHeight      = metadataCopy.MediaHeight;
                        metadataWebScrapingCopy.MediaWidth       = metadataCopy.MediaWidth;
                        metadataWebScrapingCopy.MediaOrientation = metadataCopy.MediaOrientation;
                        metadataWebScrapingCopy.MediaVideoLength = metadataCopy.MediaVideoLength;

                        if (metadataCopy != null)
                        {
                            metadataCopy.PersonalRegionSetRegionlessRegions(metadataWebScrapingCopy.PersonalRegionList);
                        }
                        if (metadataWindowsLivePhotoGalleryCopy != null)
                        {
                            metadataWindowsLivePhotoGalleryCopy.PersonalRegionSetRegionlessRegions(metadataWebScrapingCopy.PersonalRegionList);
                        }
                        if (metadataMicrosoftPhotosCopy != null)
                        {
                            metadataMicrosoftPhotosCopy.PersonalRegionSetRegionlessRegions(metadataWebScrapingCopy.PersonalRegionList);
                        }
                    }


                    //Populate
                    PopulatePeople(dataGridView, metadataCopy, columnIndex, metadataCopy.Broker);
                    if (metadataWindowsLivePhotoGalleryCopy != null)
                    {
                        PopulatePeople(dataGridView, metadataWindowsLivePhotoGalleryCopy, columnIndex, metadataWindowsLivePhotoGalleryCopy.Broker);
                    }
                    if (metadataMicrosoftPhotosCopy != null)
                    {
                        PopulatePeople(dataGridView, metadataMicrosoftPhotosCopy, columnIndex, metadataMicrosoftPhotosCopy.Broker);
                    }
                    if (metadataWebScrapingCopy != null)
                    {
                        PopulatePeople(dataGridView, metadataWebScrapingCopy, columnIndex, metadataWebScrapingCopy.Broker);
                    }

                    //Remember names added
                    foreach (RegionStructure regionStructure in metadataExiftool.PersonalRegionList)
                    {
                        if (!regionNamesAddedPeople.Contains(regionStructure.Name))
                        {
                            regionNamesAddedPeople.Add(regionStructure.Name);
                        }
                    }
                }

                DataGridViewHandler.SetColumnPopulatedFlag(dataGridView, columnIndex, true);
            }

            if (FileEntryVersionHandler.IsCurrenOrUpdatedVersion(fileEntryAttribute.FileEntryVersion) && metadataExiftool != null)
            {
                #region Suggestion of Names - Near date
                int           columnIndexDummy     = -1;
                List <string> regioNameSuggestions = null;
                DateTime?     dateTimeSmartDate    = metadataExiftool.FileSmartDate(RenameDateFormats);

                if (dateTimeSmartDate != null)
                {
                    DateTime date         = new DateTime(((DateTime)dateTimeSmartDate).Year, ((DateTime)dateTimeSmartDate).Month, ((DateTime)dateTimeSmartDate).Day);
                    DateTime dateTimeFrom = date.AddDays(-SuggestRegionNameNearByDays);
                    DateTime dateTimeTo   = date.AddDays(SuggestRegionNameNearByDays);

                    bool isHeaderPeopleSuggestionAdded = false;
                    regioNameSuggestions = DatabaseAndCacheMetadataExiftool.ListAllRegionNamesNearByCache(MetadataBrokerType.ExifTool,
                                                                                                          (DateTime)dateTimeFrom, (DateTime)dateTimeTo, SuggestRegionNameNearByTopMostCount);

                    if (regioNameSuggestions != null && regioNameSuggestions.Count > 0)
                    {
                        foreach (string regionName in regioNameSuggestions)
                        {
                            if (!string.IsNullOrWhiteSpace(regionName))
                            {
                                if (regionNamesAddedTopMost.Contains(regionName))
                                {
                                    DataGridViewHandler.DeleteRow(dataGridView, headerPeopleMostUsed, regionName);
                                    regionNamesAddedTopMost.Remove(regionName);
                                }

                                if (!regionNamesAddedPeople.Contains(regionName))
                                {
                                    if (!isHeaderPeopleSuggestionAdded)
                                    {
                                        AddRowHeader(dataGridView, columnIndexDummy, new DataGridViewGenericRow(headerPeopleSuggestion), false);
                                        isHeaderPeopleSuggestionAdded = true;
                                    }
                                    AddRowHeader(dataGridView, columnIndexDummy, new DataGridViewGenericRow(headerPeopleSuggestion, regionName), true);
                                }
                            }
                        }
                    }
                }
                #endregion

                #region Suggestion of names - Top Most
                List <string> regioNamesTopMost = DatabaseAndCacheMetadataExiftool.ListAllPersonalRegionName(SuggestRegionNameNearByTopMostCount - regionNamesAddedTopMost.Count, regionNamesAddedPeople, regioNameSuggestions);
                if (regioNamesTopMost != null && regioNamesTopMost.Count > 0)
                {
                    AddRowHeader(dataGridView, columnIndexDummy, new DataGridViewGenericRow(headerPeopleMostUsed), false);
                    foreach (string regionName in regioNamesTopMost)
                    {
                        AddRowHeader(dataGridView, columnIndexDummy, new DataGridViewGenericRow(headerPeopleMostUsed, regionName), true);
                    }
                }
                #endregion

                AddRowHeader(dataGridView, columnIndexDummy, new DataGridViewGenericRow(headerPeopleAdded), false);
            }


            //DataGridViewHandler.Refresh(dataGridView);

            //-----------------------------------------------------------------
            DataGridViewHandler.SetIsPopulatingFile(dataGridView, false);
            //-----------------------------------------------------------------

            return(columnIndex);
        }
 public DataGridViewGenericColumn(FileEntryAttribute fileEntryAttribute, Image thumbnail, Metadata metadata, ReadWriteAccess readWriteAccess)
 {
     this.FileEntryAttribute = fileEntryAttribute;
     this.Metadata           = metadata;
     this.ReadWriteAccess    = readWriteAccess;
     this.Thumbnail          = thumbnail;
 }
Beispiel #9
0
 public DataGridViewGenericRowAndValue(string headerName, string rowName, PropertyKey propertyKey, ReadWriteAccess readWriteAccess, bool isMultiLine, bool cellReadyOnly, object value)
 {
     DataGridViewGenericRow  = new DataGridViewGenericRow(headerName, rowName, readWriteAccess, isMultiLine, propertyKey);
     DataGridViewGenericCell = new DataGridViewGenericCell(value, new DataGridViewGenericCellStatus(cellReadyOnly));
 }
Beispiel #10
0
        public static int PopulateFile(DataGridView dataGridView, DataGridView dataGridViewDate, FileEntryAttribute fileEntryAttribute, ShowWhatColumns showWhatColumns, Metadata metadataAutoCorrected, bool onlyRefresh)
        {
            //-----------------------------------------------------------------
            //Chech if need to stop
            if (GlobalData.IsApplicationClosing)
            {
                return(-1);
            }
            if (!DataGridViewHandler.GetIsAgregated(dataGridView))
            {
                return(-1);                                                        //Not default columns or rows added
            }
            if (DataGridViewHandler.GetIsPopulatingFile(dataGridView))
            {
                return(-1);                                                        //In progress doing so
            }
            //Check if file is in DataGridView, and needs updated
            if (!DataGridViewHandler.DoesColumnFilenameExist(dataGridView, fileEntryAttribute.FileFullPath))
            {
                return(-1);
            }

            //When file found, Tell it's populating file, avoid two process updates
            DataGridViewHandler.SetIsPopulatingFile(dataGridView, true);

            //-----------------------------------------------------------------
            FileEntryBroker fileEntryBrokerReadVersion = fileEntryAttribute.GetFileEntryBroker(MetadataBrokerType.ExifTool);
            Image           thumbnail = DatabaseAndCacheThumbnail.ReadThumbnailFromCacheOnly(fileEntryBrokerReadVersion);

            if (thumbnail == null && metadataAutoCorrected != null)
            {
                thumbnail = DatabaseAndCacheThumbnail.ReadThumbnailFromCacheOnly(metadataAutoCorrected.FileEntry);
            }

            Metadata metadataExiftool = DatabaseAndCacheMetadataExiftool.ReadMetadataFromCacheOnly(fileEntryBrokerReadVersion);

            if (metadataExiftool != null)
            {
                metadataExiftool = new Metadata(metadataExiftool);
            }
            if (metadataAutoCorrected != null)
            {
                metadataExiftool = metadataAutoCorrected;                                //If AutoCorrect is run, use AutoCorrect values. Needs to be after DataGridViewHandler.AddColumnOrUpdateNew, so orignal metadata stored will not be overwritten
            }
            ReadWriteAccess readWriteAccessColumn =
                (FileEntryVersionHandler.IsReadOnlyType(fileEntryAttribute.FileEntryVersion) ||
                 metadataExiftool == null) ? ReadWriteAccess.ForceCellToReadOnly : ReadWriteAccess.AllowCellReadAndWrite;

            int columnIndex = DataGridViewHandler.AddColumnOrUpdateNew(
                dataGridView, fileEntryAttribute, thumbnail, metadataExiftool, readWriteAccessColumn, showWhatColumns,
                DataGridViewGenericCellStatus.DefaultEmpty(), out FileEntryVersionCompare fileEntryVersionCompareReason);

            //Chech if populated and new refresh data
            if (onlyRefresh && FileEntryVersionHandler.NeedUpdate(fileEntryVersionCompareReason) && !DataGridViewHandler.IsColumnPopulated(dataGridView, columnIndex))
            {
                fileEntryVersionCompareReason = FileEntryVersionCompare.LostNoneEqualFound_ContinueSearch; //No need to populate
            }
            //-----------------------------------------------------------------

            if (FileEntryVersionHandler.NeedUpdate(fileEntryVersionCompareReason))
            {
                //Media
                int rowIndex;
                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerMedia));
                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerMedia, tagMediaCoordinates), metadataExiftool?.LocationCoordinate, false);
                rowIndex = AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerMedia, tagLocationName), metadataExiftool?.LocationName, false);
                List <string> newKeywords = AutoKeywordHandler.NewKeywords(AutoKeywordConvertions, metadataExiftool?.LocationName, null, null, null, null, null);
                DataGridViewHandler.SetCellToolTipText(dataGridView, columnIndex, rowIndex, "Running AutoCorrect will add these keywords", newKeywords);

                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerMedia, tagCity), metadataExiftool?.LocationCity, false);
                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerMedia, tagProvince), metadataExiftool?.LocationState, false);
                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerMedia, tagCountry), metadataExiftool?.LocationCountry, false);

                //List<string> newKeywords = AutoKeywordHandler.NewKeywords(autoKeywordConvertions, metadataCopy.LocationName, metadataCopy.PersonalTitle,
                //  metadataCopy.PersonalAlbum, metadataCopy.PersonalDescription, metadataCopy.PersonalComments, metadataCopy.PersonalKeywordTags);

                //Google location history
                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerGoogleLocations));

                if (metadataExiftool != null)
                {
                    CameraOwner cameraOwnerPrint = new CameraOwner(metadataExiftool.CameraMake, metadataExiftool.CameraModel, "");
                    AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerGoogleLocations, tagCameraMakeModel), cameraOwnerPrint, true);
                    AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerGoogleLocations, tagCameraOwner), "Owner???", false);

                    DataGridViewGenericColumn gridViewGenericColumnCheck = DataGridViewHandler.GetColumnDataGridViewGenericColumn(dataGridView, columnIndex);
                    PopulateCameraOwner(dataGridView, columnIndex, readWriteAccessColumn, metadataExiftool.CameraMake, metadataExiftool.CameraModel);
                }
                else
                {
                    if (!DataGridViewHandler.IsColumnPopulated(dataGridView, columnIndex))
                    {
                        AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerMedia, tagCameraMakeModel), "", false);
                        AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerGoogleLocations, tagCameraOwner), "Select Camera owner/locations", true);
                    }
                }

                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerGoogleLocations, tagGoogleCoordinateUTC), metadataExiftool?.LocationCoordinate, true);
                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerNearByLocations));

                PopulateGoogleHistoryCoordinateAndNearby(dataGridView, dataGridViewDate, columnIndex, TimeZoneShift, AccepedIntervalSecound);

                //Nominatim.API
                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerNominatim));
                PopulateGrivViewMapNomnatatim(dataGridView, columnIndex, metadataExiftool?.LocationCoordinate,
                                              onlyFromCache: true, canReverseGeocoder: false, forceReloadUsingReverseGeocoder: false, createNewAccurateLocationUsingSearchLocation: false);

                //WebScraper
                //headerWebScraping = "WebScraper";
                // WebScarping
                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerWebScraping));
                Metadata metadataWebScraping = null;
                if (metadataExiftool != null)
                {
                    metadataWebScraping = DatabaseAndCacheMetadataExiftool.ReadWebScraperMetadataFromCacheOrDatabase(new FileEntryBroker(fileEntryBrokerReadVersion, MetadataBrokerType.WebScraping));
                }
                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerWebScraping, tagLocationName), metadataWebScraping?.LocationName, true);
                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerWebScraping, tagCountry), metadataWebScraping?.LocationCountry, true);

                //Microsoft Photos Locations
                Metadata metadataMicrosoftPhotos = null;
                if (metadataExiftool != null)
                {
                    metadataMicrosoftPhotos = DatabaseAndCacheMetadataMicrosoftPhotos.ReadMetadataFromCacheOrDatabase(
                        new FileEntryBroker(fileEntryBrokerReadVersion, MetadataBrokerType.MicrosoftPhotos));
                }

                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerMicrosoftPhotos));
                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerMicrosoftPhotos, tagExternalCoordinates), metadataMicrosoftPhotos?.LocationCoordinate, true);
                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerMicrosoftPhotos, tagLocationName), metadataMicrosoftPhotos?.LocationName, true);
                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerMicrosoftPhotos, tagCity), metadataMicrosoftPhotos?.LocationCity, true);
                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerMicrosoftPhotos, tagProvince), metadataMicrosoftPhotos?.LocationState, true);
                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerMicrosoftPhotos, tagCountry), metadataMicrosoftPhotos?.LocationCountry, true);

                //Windows Live Photo Gallary Locations
                Metadata metadataWindowsLivePhotoGallery = null;
                if (metadataExiftool != null)
                {
                    metadataWindowsLivePhotoGallery = DatabaseAndCacheMetadataWindowsLivePhotoGallery.ReadMetadataFromCacheOrDatabase(
                        new FileEntryBroker(fileEntryBrokerReadVersion, MetadataBrokerType.WindowsLivePhotoGallery));
                }

                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerWindowsLivePhotoGallery));
                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerWindowsLivePhotoGallery, tagExternalCoordinates), metadataWindowsLivePhotoGallery?.LocationCoordinate, true);
                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerWindowsLivePhotoGallery, tagLocationName), metadataWindowsLivePhotoGallery?.LocationName, true);

                //Browser
                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerBrowser));
                AddRow(dataGridView, columnIndex, new DataGridViewGenericRow(headerBrowser, tagExternalCoordinates), "", true);

                DataGridViewHandler.SetColumnPopulatedFlag(dataGridView, columnIndex, true);
            }

            //-----------------------------------------------------------------
            DataGridViewHandler.SetIsPopulatingFile(dataGridView, false);
            //-----------------------------------------------------------------
            return(columnIndex);
        }
Beispiel #11
0
        public static void PopulateCameraOwner(DataGridView dataGridView, int columnIndex, ReadWriteAccess readWriteAccessColumn, string cameraMake, string cameraModel)
        {
            int    rowIndex    = DataGridViewHandler.GetRowIndex(dataGridView, headerGoogleLocations, tagCameraOwner);
            string cameraOwner = DatabaseAndCacheCameraOwner.GetOwenerForCameraMakeModel(cameraMake, cameraModel);

            if (dataGridViewComboBoxCellCameraOwners == null || DatabaseAndCacheCameraOwner.IsCameraMakeModelAndOwnerDirty())
            {
                //Create or updated common dropbox for all cells with "List of camera owners"
                dataGridViewComboBoxCellCameraOwners           = null;
                dataGridViewComboBoxCellCameraOwners           = new DataGridViewComboBoxCell();
                dataGridViewComboBoxCellCameraOwners.FlatStyle = FlatStyle.Flat;
                dataGridViewComboBoxCellCameraOwners.Items.AddRange(DatabaseAndCacheCameraOwner.ReadCameraOwners().ToArray());
            }

            if (readWriteAccessColumn == ReadWriteAccess.AllowCellReadAndWrite)
            {
                DataGridViewHandler.SetCellControlType(dataGridView, columnIndex, rowIndex, dataGridViewComboBoxCellCameraOwners);

                if (!string.IsNullOrWhiteSpace(cameraOwner) && dataGridViewComboBoxCellCameraOwners.Items.Contains(cameraOwner))
                {
                    DataGridViewHandler.SetCellValue(dataGridView, columnIndex, rowIndex, cameraOwner, false);
                }
                else
                {
                    DataGridViewHandler.SetCellValue(dataGridView, columnIndex, rowIndex, null, false);
                }
            }
            else
            {
                DataGridViewHandler.SetCellValue(dataGridView, columnIndex, rowIndex, cameraOwner, false);
            }
        }