private void GetLocationAndShow(MapProvider mapProvider) { try { if (isPopulatingSelectRows) { return; } List <LocationCoordinate> locationCoordinates = new List <LocationCoordinate>(); DataGridView dataGridView = kryptonDataGridViewLocationHistory; foreach (int rowIndex in DataGridViewHandler.GetRowSelected(dataGridView)) { DataGridViewGenericRow dataGridViewGenericRow = DataGridViewHandler.GetRowDataGridViewGenericRow(dataGridView, rowIndex); if (dataGridViewGenericRow != null && !dataGridViewGenericRow.IsHeader && dataGridViewGenericRow.LocationCoordinate != null) { if (!locationCoordinates.Contains(dataGridViewGenericRow.LocationCoordinate)) { locationCoordinates.Add(dataGridViewGenericRow.LocationCoordinate); } } } ShowMediaOnMap.UpdatedBroswerMap(browser, locationCoordinates, GetZoomLevel(), mapProvider); } catch (Exception ex) { //Logger.Error(ex); KryptonMessageBox.Show("Unexpected error occur.\r\nException message:" + ex.Message + "\r\n", "Unexpected error occur", MessageBoxButtons.OK, MessageBoxIcon.Error, showCtrlCopy: true); } finally { } }
private void dataGridViewConvertAndMerge_DragOver(object sender, DragEventArgs e) { DataGridView dataGridView = (DataGridView)sender; Point clientPoint = dataGridView.PointToClient(new Point(e.X, e.Y)); // Get the row index of the item the mouse is below. int rowIndex = dataGridView.HitTest(clientPoint.X, clientPoint.Y).RowIndex; DataGridViewGenericRow dataGridViewGenericRow = DataGridViewHandler.GetRowDataGridViewGenericRow(dataGridView, rowIndex); if (dataGridViewGenericRow != null /*&& dataGridViewGenericRow.IsHeader*/) { e.Effect = DragDropEffects.Move; } else { e.Effect = DragDropEffects.None; } if (e.Effect == DragDropEffects.Move) { dragdropcurrentIndex = dataGridView.HitTest(dataGridView.PointToClient(new Point(e.X, e.Y)).X, dataGridView.PointToClient(new Point(e.X, e.Y)).Y).RowIndex; } else { dragdropcurrentIndex = -1; } if (oldIndex != dragdropcurrentIndex) { dataGridView.Invalidate(); oldIndex = dragdropcurrentIndex; } }
private static int AddRow(DataGridView dataGridView, int columnIndex, DataGridViewGenericRow dataGridViewGenericDataRow, object value, bool cellReadOnly) { int rowIndex = DataGridViewHandler.AddRow(dataGridView, columnIndex, dataGridViewGenericDataRow, value, new DataGridViewGenericCellStatus(MetadataBrokerType.Empty, SwitchStates.Disabled, cellReadOnly), false); return(rowIndex); }
private void dataGridViewConvertAndMerge_MouseDown(object sender, MouseEventArgs e) { DataGridView dataGridView = (DataGridView)sender; convertAndMergeRowIndexFromMouseDown = dataGridView.HitTest(e.X, e.Y).RowIndex; // Get the index of the item the mouse is below. if (convertAndMergeRowIndexFromMouseDown != -1) { DataGridViewGenericRow dataGridViewGenericRow = DataGridViewHandler.GetRowDataGridViewGenericRow(dataGridView, convertAndMergeRowIndexFromMouseDown); if (dataGridViewGenericRow != null && !dataGridViewGenericRow.IsHeader) { // Remember the point where the mouse down occurred. The DragSize indicates the size that the mouse can move before a drag event should be started. Size dragSize = SystemInformation.DragSize; // Create a rectangle using the DragSize, with the mouse position being at the center of the rectangle. convertAndMergeDragBoxFromMouseDown = new Rectangle(new Point(e.X - (dragSize.Width / 2), e.Y - (dragSize.Height / 2)), dragSize); } else { convertAndMergeRowIndexFromMouseDown = -1; convertAndMergeDragBoxFromMouseDown = Rectangle.Empty; } } // Reset the rectangle if the mouse is not over an item in the ListBox. else { convertAndMergeDragBoxFromMouseDown = Rectangle.Empty; } }
private static void PopulatePeople(DataGridView dataGridView, Metadata metadata, int columnIndex, MetadataBrokerType metadataBrokerType) //, ref List<string> regionNames) { foreach (RegionStructure region in metadata.PersonalRegionList) { DataGridViewGenericRow dataGridViewGenericRow = new DataGridViewGenericRow(headerPeople, region.Name, ReadWriteAccess.AllowCellReadAndWrite); AddRowRegion(dataGridView, metadataBrokerType, metadata, columnIndex, dataGridViewGenericRow, new RegionStructure(region), //DataGridViewHandler.DeepCopy(region), new DataGridViewGenericCellStatus(MetadataBrokerType.Empty, SwitchStates.Undefine, true)); //Other cell for this row will by default be Empty and disabled } }
public static void Write(DataGridView dataGridView, out Dictionary <string, string> renameSuccess, out Dictionary <string, RenameToNameAndResult> renameFailed, out HashSet <string> directoryCreated, bool showFullPathIsUsed) { using (new WaitCursor()) { renameSuccess = new Dictionary <string, string>(); renameFailed = new Dictionary <string, RenameToNameAndResult>(); directoryCreated = new HashSet <string>(); int columnIndex = DataGridViewHandler.GetColumnIndexFirstFullFilePath(dataGridView, headerNewFilename, false); if (columnIndex == -1) { return; } for (int rowIndex = 0; rowIndex < DataGridViewHandler.GetRowCountWithoutEditRow(dataGridView); rowIndex++) { DataGridViewGenericCell cellGridViewGenericCell = DataGridViewHandler.GetCellDataGridViewGenericCellCopy(dataGridView, columnIndex, rowIndex); if (!cellGridViewGenericCell.CellStatus.CellReadOnly) { DataGridViewGenericRow dataGridViewGenericRow = DataGridViewHandler.GetRowDataGridViewGenericRow(dataGridView, rowIndex); #region Get Old filename from grid string oldFilename = dataGridViewGenericRow.RowName; string oldDirectory = dataGridViewGenericRow.HeaderName; string oldFullFilename = FileHandler.CombinePathAndName(oldDirectory, oldFilename); #endregion #region Get New filename from grid and rename if (dataGridViewGenericRow.Metadata != null) { string newFullFilename = FileHandler.CombinePathAndName(oldDirectory, DataGridViewHandler.GetCellValueNullOrStringTrim(dataGridView, columnIndex, rowIndex)); string newDirectory = Path.GetDirectoryName(newFullFilename); if (!Directory.Exists(newDirectory) && !directoryCreated.Contains(newDirectory)) { directoryCreated.Add(newDirectory); } FilesCutCopyPasteDrag.RenameFile(oldFullFilename, newFullFilename, ref renameSuccess, ref renameFailed); } #endregion } } } }
public static void UpdateFilenames(DataGridView dataGridView, string newFilenameVariable, bool showFullPath) { int columnIndex = DataGridViewHandler.GetColumnIndexFirstFullFilePath(dataGridView, headerNewFilename, false); if (columnIndex == -1) { return; } for (int rowIndex = 0; rowIndex < DataGridViewHandler.GetRowCountWithoutEditRow(dataGridView); rowIndex++) { DataGridViewGenericRow dataGridViewGenericRow = DataGridViewHandler.GetRowDataGridViewGenericRow(dataGridView, rowIndex); if (!dataGridViewGenericRow.IsHeader) { PopulateFile(dataGridView, dataGridViewGenericRow.FileEntryAttribute, showFullPath, null, true); } } }
private void dataGridViewMap_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex < 0) { return; } if (e.RowIndex < 0) { return; } if (isDataGridViewMaps_CellValueChanging) { return; //Avoid requirng isues } if (GlobalData.IsApplicationClosing) { return; } DataGridView dataGridView = ((DataGridView)sender); if (!dataGridView.Enabled) { return; } if (GlobalData.IsPopulatingMapLocation) { return; } if (DataGridViewHandler.GetIsPopulatingFile(dataGridView)) { return; } if (DataGridViewHandler.GetIsPopulating(dataGridView)) { return; } DataGridViewGenericColumn dataGridViewGenericColumn = DataGridViewHandler.GetColumnDataGridViewGenericColumn(dataGridView, e.ColumnIndex); if (dataGridViewGenericColumn?.Metadata == null) { return; } DataGridViewGenericRow gridViewGenericRow = DataGridViewHandler.GetRowDataGridViewGenericRow(dataGridView, e.RowIndex); isDataGridViewMaps_CellValueChanging = true; /////////////////////////////////////////////////////////////////////////// /// Coordinate changes, updated Nomnatatim address /////////////////////////////////////////////////////////////////////////// if (gridViewGenericRow.HeaderName.Equals(DataGridViewHandlerMap.headerMedia) && gridViewGenericRow.RowName.Equals(DataGridViewHandlerMap.tagMediaCoordinates)) { string coordinate = DataGridViewHandler.GetCellValueNullOrStringTrim(dataGridViewMap, e.ColumnIndex, e.RowIndex); UpdateBrowserMap(coordinate, GetMapProvider()); DataGridViewGenericColumn dataGridViewGenericColumnLookup = DataGridViewHandler.GetColumnDataGridViewGenericColumn(dataGridViewMap, e.ColumnIndex); AddQueueLazyLoadingMapNomnatatimLock(dataGridViewGenericColumnLookup.FileEntryAttribute, forceReloadUsingReverseGeocoder: false); DataGridViewHandlerDate.PopulateTimeZone(dataGridViewDate, null, dataGridViewGenericColumn.FileEntryAttribute); } /////////////////////////////////////////////////////////////////////////// /// Camera make and model owner changed, upated all fields /////////////////////////////////////////////////////////////////////////// else if (gridViewGenericRow.HeaderName.Equals(DataGridViewHandlerMap.headerGoogleLocations) && gridViewGenericRow.RowName.Equals(DataGridViewHandlerMap.tagCameraOwner)) { string selectedCameraOwner = DataGridViewHandlerMap.GetUserInputCameraOwner(dataGridView, e.ColumnIndex); DataGridViewHandlerMap.SetCameraOwner(dataGridView, e.ColumnIndex, selectedCameraOwner); if (!string.IsNullOrWhiteSpace(selectedCameraOwner)) { if (dataGridViewGenericColumn.Metadata != null) { CameraOwner cameraOwner = new CameraOwner( dataGridViewGenericColumn.Metadata.CameraMake, dataGridViewGenericColumn.Metadata.CameraModel, selectedCameraOwner); databaseAndCahceCameraOwner.SaveCameraMakeModelAndOwner(cameraOwner); databaseAndCahceCameraOwner.CameraMakeModelAndOwnerMakeDirty(); for (int columnIndex = 0; columnIndex < DataGridViewHandler.GetColumnCount(dataGridViewMap); columnIndex++) { DataGridViewGenericColumn gridViewGenericColumnCheck = DataGridViewHandler.GetColumnDataGridViewGenericColumn(dataGridView, columnIndex); if (gridViewGenericColumnCheck?.Metadata == null) { //DEBUG } if (dataGridViewGenericColumn.Metadata == null) { //DEBUG } if (gridViewGenericColumnCheck?.Metadata?.CameraMake == dataGridViewGenericColumn.Metadata.CameraMake && gridViewGenericColumnCheck?.Metadata?.CameraModel == dataGridViewGenericColumn.Metadata.CameraModel) { DataGridViewHandlerMap.PopulateCameraOwner(dataGridView, columnIndex, gridViewGenericColumnCheck.ReadWriteAccess, gridViewGenericColumnCheck?.Metadata?.CameraMake, gridViewGenericColumnCheck?.Metadata?.CameraModel); DataGridViewHandlerMap.PopulateGoogleHistoryCoordinateAndNearby(dataGridView, dataGridViewDate, columnIndex, GetTimeZoneShift(), GetAccepedIntervalSecound()); } } } } } /////////////////////////////////////////////////////////////////////////// /// Nomnatatim /////////////////////////////////////////////////////////////////////////// float locationAccuracyLatitude = Properties.Settings.Default.LocationAccuracyLatitude; float locationAccuracyLongitude = Properties.Settings.Default.LocationAccuracyLongitude; if (gridViewGenericRow.HeaderName.Equals(DataGridViewHandlerMap.headerNominatim)) { LocationCoordinate locationCoordinateNomnatatim = DataGridViewHandlerMap.GetUserInputLocationCoordinate(dataGridViewMap, e.ColumnIndex, null); bool createNewAccurateLocation = DataGridViewHandlerMap.GetUserInputIsCreateNewAccurateLocationUsingSearchLocation(dataGridViewMap, e.ColumnIndex, null); if (locationCoordinateNomnatatim != null) { #region Get Coordinateds enter by user LocationCoordinate locationCoordinateSearch = new LocationCoordinate( (float)locationCoordinateNomnatatim.Latitude, (float)locationCoordinateNomnatatim.Longitude); #endregion #region Get Coordinates use to store in database LocationCoordinateAndDescription locationCoordinateAndDescriptionFromDatabase = databaseLocationNameAndLookUp.ReadLocationNameFromDatabaseOrCache( locationCoordinateSearch, locationAccuracyLatitude, locationAccuracyLongitude); #endregion #region Find nearby location in Datbase LocationCoordinate locationCoordinateFromDatabase; if (locationCoordinateAndDescriptionFromDatabase != null && !createNewAccurateLocation) { locationCoordinateFromDatabase = locationCoordinateAndDescriptionFromDatabase.Coordinate; //If exist, updated } else { locationCoordinateFromDatabase = locationCoordinateSearch; //If not, create new } LocationCoordinateAndDescription locationCoordinateAndDescriptionUpdated = new LocationCoordinateAndDescription ( locationCoordinateSearch, new LocationDescription( (string)DataGridViewHandler.GetCellValue(dataGridView, e.ColumnIndex, DataGridViewHandlerMap.headerNominatim, DataGridViewHandlerMap.tagLocationName), //Name (string)DataGridViewHandler.GetCellValue(dataGridView, e.ColumnIndex, DataGridViewHandlerMap.headerNominatim, DataGridViewHandlerMap.tagCity), //City (string)DataGridViewHandler.GetCellValue(dataGridView, e.ColumnIndex, DataGridViewHandlerMap.headerNominatim, DataGridViewHandlerMap.tagProvince), //State (string)DataGridViewHandler.GetCellValue(dataGridView, e.ColumnIndex, DataGridViewHandlerMap.headerNominatim, DataGridViewHandlerMap.tagCountry)) //Country ); #endregion #region Updated the database databaseLocationNameAndLookUp.AddressUpdate(locationCoordinateFromDatabase, locationCoordinateAndDescriptionUpdated, locationAccuracyLatitude, locationAccuracyLongitude); #endregion #region Updated DataGridView with new data for (int columnIndex = 0; columnIndex < dataGridViewMap.ColumnCount; columnIndex++) { DataGridViewGenericColumn dataGridViewGenericColumnLookup = DataGridViewHandler.GetColumnDataGridViewGenericColumn(dataGridViewMap, columnIndex); AddQueueLazyLoadingMapNomnatatimLock(dataGridViewGenericColumnLookup.FileEntryAttribute, forceReloadUsingReverseGeocoder: false); } #endregion } } isDataGridViewMaps_CellValueChanging = false; }
public void Write(DataGridView dataGridView, int columnIndex) { List <PropertyKey> notSet = new List <PropertyKey>(); DataGridViewGenericColumn dataGridViewGenericColumn = DataGridViewHandler.GetColumnDataGridViewGenericColumn(dataGridView, columnIndex); if (dataGridViewGenericColumn == null) { return; //continue; } string fullFileName = dataGridViewGenericColumn.FileEntryAttribute.FileFullPath; using (PropertyStore propertyStore = new PropertyStore(fullFileName, PropertyStore.GetFlags.ReadWrite | PropertyStore.GetFlags.SlowItem)) { for (int rowIndex = 0; rowIndex < DataGridViewHandler.GetRowCountWithoutEditRow(dataGridView); rowIndex++) { bool isReadOnly = DataGridViewHandler.GetCellReadOnly(dataGridView, columnIndex, rowIndex); DataGridViewGenericRow dataGridViewGenericRow = DataGridViewHandler.GetRowDataGridViewGenericRow(dataGridView, rowIndex); object value = DataGridViewHandler.GetCellValue(dataGridView, columnIndex, rowIndex); if (value is string) { PropertyKey propertyKey = dataGridViewGenericRow.PropertyKey; string valueString = (string)value; if (!isReadOnly && propertyStore.IsEditable(propertyKey)) { try { using (PropertyDescription propertyDescription = new PropertyDescription(propertyKey)) { if (!string.IsNullOrEmpty(valueString)) { if (propertyDescription.TypeFlags.IsMultiValued) { valueString = valueString.Replace("\r\n", ";"); PropVariant val = PropVariant.FromStringAsVector(valueString); propertyStore.SetValue(propertyKey, val); } else { switch (propertyDescription.PropertyType) { case VarEnum.VT_UI4: string cleanedString = new string(valueString.Where(char.IsDigit).ToArray()); UInt32 valueUint32; if (UInt32.TryParse(cleanedString, out valueUint32)) { if (propertyKey.CanonicalName == "System.Rating") { valueUint32 = (UInt32)Metadata.ConvertRatingStarsToRatingPercent((byte)valueUint32); } propertyStore.SetValue(propertyKey, new PropVariant(valueUint32, propertyDescription.PropertyType)); } else { propertyStore.SetValue(propertyKey, new PropVariant()); } break; case VarEnum.VT_DATE: case VarEnum.VT_FILETIME: string cleanedString2 = new string(valueString.Where(c => !char.IsControl(c)).ToArray()); // https://social.msdn.microsoft.com/Forums/windows/en-US/61687b42-9882-4025-8b3a-b3251f121f94/how-to-prevent-a-textbox-to-accept-unicode-control-characters?forum=winforms cleanedString2 = Regex.Replace(cleanedString2, @"[\u200e-\u200f]", string.Empty); cleanedString2 = Regex.Replace(cleanedString2, @"[\u202a-\u202e]", string.Empty); cleanedString2 = Regex.Replace(cleanedString2, @"[\u206a-\u206f]", string.Empty); cleanedString2 = Regex.Replace(cleanedString2, @"[\u001e-\u001f]", string.Empty); DateTime valueDateTime; if (DateTime.TryParse(cleanedString2, out valueDateTime)) { propertyStore.SetValue(propertyKey, new PropVariant(valueDateTime.ToUniversalTime(), propertyDescription.PropertyType)); } break; default: propertyStore.SetValue(propertyKey, new PropVariant(valueString, propertyDescription.PropertyType)); break; } } //store.SetValue(key, new PropVariant(_displayProps[key], desc.PropertyType)); } else { propertyStore.SetValue(propertyKey, new PropVariant()); } } continue; } catch (Exception ex) { Logger.Error(ex); } notSet.Add(propertyKey); } } } propertyStore.Commit(); } if (notSet.Count > 0) { throw new Exception("The following keys were not set:\n\t" + string.Join("\n\t", notSet.Select(k => k.CanonicalName))); } }
//Check what data has been updated by users public static void GetUserInputChanges(DataGridView dataGridView, ref Metadata metadata, FileEntryAttribute fileEntryColumn) { int columnIndex = DataGridViewHandler.GetColumnIndexUserInput(dataGridView, fileEntryColumn); if (columnIndex == -1) { return; //Column has not yet become aggregated or has already been removed } if (!DataGridViewHandler.IsColumnPopulated(dataGridView, columnIndex)) { return; } int keywordsStarts = DataGridViewHandler.GetRowHeaderItemStarts(dataGridView, headerKeywords); int keywordsEnds = DataGridViewHandler.GetRowHeaderItemsEnds(dataGridView, headerKeywords); metadata.PersonalAlbum = (string)DataGridViewHandler.GetCellValueNullOrStringTrim(dataGridView, columnIndex, headerMedia, tagAlbum); if (metadata.PersonalAlbum != null) { metadata.PersonalAlbum = metadata.PersonalAlbum.Trim(); } metadata.PersonalTitle = (string)DataGridViewHandler.GetCellValueNullOrStringTrim(dataGridView, columnIndex, headerMedia, tagTitle); if (metadata.PersonalTitle != null) { metadata.PersonalTitle = metadata.PersonalTitle.Trim(); } metadata.PersonalDescription = (string)DataGridViewHandler.GetCellValueNullOrStringTrim(dataGridView, columnIndex, headerMedia, tagDescription); if (metadata.PersonalDescription != null) { metadata.PersonalDescription = metadata.PersonalDescription.Trim(); } metadata.PersonalComments = (string)DataGridViewHandler.GetCellValueNullOrStringTrim(dataGridView, columnIndex, headerMedia, tagComments); if (metadata.PersonalComments != null) { metadata.PersonalComments = metadata.PersonalComments.Trim(); } metadata.PersonalAuthor = (string)DataGridViewHandler.GetCellValueNullOrStringTrim(dataGridView, columnIndex, headerMedia, tagAuthor); if (metadata.PersonalAuthor != null) { metadata.PersonalAuthor = metadata.PersonalAuthor.Trim(); } byte rating = 255; //empty var ratingValue = DataGridViewHandler.GetCellValue(dataGridView, columnIndex, headerMedia, tagRating); if (ratingValue == null) { } else if (ratingValue.GetType() == typeof(byte)) { rating = (byte)ratingValue; } else if (ratingValue.GetType() == typeof(int)) { rating = (byte)(int)ratingValue; } else if (ratingValue.GetType() == typeof(string)) { byte.TryParse((string)ratingValue, out rating); } if (rating >= 0 && rating <= 5) { metadata.PersonalRating = rating; } else { metadata.PersonalRating = null; } for (int rowIndex = keywordsStarts; rowIndex <= keywordsEnds; rowIndex++) { DataGridViewGenericRow dataGridViewGenericRow = DataGridViewHandler.GetRowDataGridViewGenericRow(dataGridView, rowIndex); SwitchStates switchStates = DataGridViewHandler.GetCellStatusSwichStatus(dataGridView, columnIndex, rowIndex); if (switchStates == SwitchStates.On) { //Add tag if (!metadata.PersonalKeywordTags.Contains(new KeywordTag(dataGridViewGenericRow.RowName))) { metadata.PersonalKeywordTags.Add(new KeywordTag(dataGridViewGenericRow.RowName)); } } else { //Remove tag if (metadata.PersonalKeywordTags.Contains(new KeywordTag(dataGridViewGenericRow.RowName))) { metadata.PersonalKeywordTags.Remove(new KeywordTag(dataGridViewGenericRow.RowName)); } } } }
private static void PopulateKeywords(DataGridView dataGridView, Metadata metadata, int columnIndex, MetadataBrokerType metadataBrokerType, FileEntryAttribute fileEntryAttribute) { foreach (KeywordTag tag in metadata.PersonalKeywordTags) { if (tag.Confidence >= MediaAiTagConfidence) { int rowIndex = AddRowKeywords(dataGridView, columnIndex, new DataGridViewGenericRow(headerKeywords, tag.Keyword, ReadWriteAccess.ForceCellToReadOnly), tag.Keyword, new DataGridViewGenericCellStatus(MetadataBrokerType.Empty, SwitchStates.Undefine, true), true); List <KeywordTag> keywordTags = new List <KeywordTag>(); keywordTags.Add(new KeywordTag(tag.Keyword)); List <string> newKeywords = AutoKeywordHandler.NewKeywords(AutoKeywordConvertions, null, null, null, null, null, keywordTags); DataGridViewHandler.SetCellToolTipText(dataGridView, columnIndex, rowIndex, "Running AutoCorrect will add these keywords", newKeywords); //Updated default cell status with new staus DataGridViewGenericCellStatus dataGridViewGenericCellStatus = new DataGridViewGenericCellStatus(DataGridViewHandler.GetCellStatus(dataGridView, columnIndex, rowIndex)); dataGridViewGenericCellStatus.MetadataBrokerType |= metadataBrokerType; if (fileEntryAttribute.FileEntryVersion != FileEntryVersion.CompatibilityFixedAndAutoUpdated && fileEntryAttribute.FileEntryVersion != FileEntryVersion.MetadataToSave) { if (dataGridViewGenericCellStatus.SwitchState == SwitchStates.Undefine) { dataGridViewGenericCellStatus.SwitchState = (dataGridViewGenericCellStatus.MetadataBrokerType & MetadataBrokerType.ExifTool) == MetadataBrokerType.ExifTool ? SwitchStates.On : SwitchStates.Off; } } else { dataGridViewGenericCellStatus.SwitchState = (dataGridViewGenericCellStatus.MetadataBrokerType & MetadataBrokerType.ExifTool) == MetadataBrokerType.ExifTool ? SwitchStates.On : SwitchStates.Off; DataGridViewGenericRow dataGridViewGenericRow = DataGridViewHandler.GetRowDataGridViewGenericRow(dataGridView, rowIndex); if (dataGridViewGenericRow != null && dataGridViewGenericRow.ReadWriteAccess == ReadWriteAccess.AllowCellReadAndWrite) { dataGridViewGenericRow.ReadWriteAccess = ReadWriteAccess.ForceCellToReadOnly; for (int columnIndexUpdate = 0; columnIndexUpdate < DataGridViewHandler.GetColumnCount(dataGridView); columnIndexUpdate++) { DataGridViewHandler.SetCellReadOnlyDependingOfStatus(dataGridView, columnIndexUpdate, rowIndex, dataGridViewGenericCellStatus); } } } DataGridViewHandler.SetCellStatus(dataGridView, columnIndex, rowIndex, dataGridViewGenericCellStatus, false); } } //If updated, check if any keyword are removed from the list int keywordsStarts = DataGridViewHandler.GetRowHeaderItemStarts(dataGridView, headerKeywords); int keywordsEnds = DataGridViewHandler.GetRowHeaderItemsEnds(dataGridView, headerKeywords); for (int rowIndex = keywordsStarts; rowIndex <= keywordsEnds; rowIndex++) { DataGridViewGenericCellStatus dataGridViewGenericCellStatus = DataGridViewHandler.GetCellStatus(dataGridView, columnIndex, rowIndex); if ((dataGridViewGenericCellStatus.MetadataBrokerType & metadataBrokerType) == metadataBrokerType) { DataGridViewGenericRow dataGridViewGenericRow = DataGridViewHandler.GetRowDataGridViewGenericRow(dataGridView, rowIndex); if (!metadata.PersonalKeywordTags.Contains(new KeywordTag(dataGridViewGenericRow.RowName))) { if ((dataGridViewGenericCellStatus.MetadataBrokerType & metadataBrokerType) == MetadataBrokerType.ExifTool && dataGridViewGenericCellStatus.SwitchState == SwitchStates.On) { dataGridViewGenericCellStatus.SwitchState = SwitchStates.Undefine; } dataGridViewGenericCellStatus.MetadataBrokerType &= ~metadataBrokerType; //Remove flag if line deleted DataGridViewHandler.SetCellStatus(dataGridView, columnIndex, rowIndex, dataGridViewGenericCellStatus, false); } } } }
private static int AddRowKeywords(DataGridView dataGridView, int columnIndex, DataGridViewGenericRow dataGridViewGenericDataRow, object value, DataGridViewGenericCellStatus dataGridViewGenericCellStatusDefaults, bool sort) { int rowIndex = DataGridViewHandler.AddRow(dataGridView, columnIndex, dataGridViewGenericDataRow, value, dataGridViewGenericCellStatusDefaults, sort); return(rowIndex); }
private static int AddRow(DataGridView dataGridView, int columnIndex, DataGridViewGenericRow dataGridViewGenericDataRow, bool sort) { return(DataGridViewHandler.AddRow(dataGridView, columnIndex, dataGridViewGenericDataRow, sort)); }
private void dataGridViewDate_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (isDataGridViewDate_CellValueChanging) { return; //To avoid loop and stack overflow } if (GlobalData.IsApplicationClosing) { return; } //if (ClipboardUtility.IsClipboardActive) return; //if (GlobalData.IsDataGridViewCutPasteDeleteFindReplaceInProgress) return; if (e.ColumnIndex < 0) { return; } if (e.RowIndex < 0) { return; } DataGridView dataGridView = ((DataGridView)sender); //if (!dataGridView.Enabled) return; if (DataGridViewHandler.GetIsPopulatingFile(dataGridView)) { return; } if (DataGridViewHandler.GetIsPopulating(dataGridView)) { return; } //if (IsPopulatingAnything("Date Cell value changed")) return; DataGridViewGenericRow gridViewGenericDataRow = DataGridViewHandler.GetRowDataGridViewGenericRow(dataGridView, e.RowIndex); if (gridViewGenericDataRow == null) { return; } if (!gridViewGenericDataRow.HeaderName.Equals(DataGridViewHandlerDate.headerMedia)) { return; } isDataGridViewDate_CellValueChanging = true; if (gridViewGenericDataRow.RowName.Equals(DataGridViewHandlerDate.tagMediaDateTaken)) //headerMedia, tagMediaDateTaken { string dataTimeString = DataGridViewHandler.GetCellValueNullOrStringTrim(dataGridView, e.ColumnIndex, e.RowIndex); DateTimeOffset?dateTimeZoneResult = TimeZoneLibrary.ParseExcatDateTimeOffsetAsUTC(dataTimeString); if (dateTimeZoneResult != null) //If date and time has +00:00 offset { DateTime?dateTimeLocal = TimeZoneLibrary.ParseDateTimeAsLocal(dataTimeString.Substring(0, TimeZoneLibrary.AllowedDateTimeFormatsWithoutTimeZone[0].Length)); DataGridViewHandler.AddRow(dataGridView, e.ColumnIndex, new DataGridViewGenericRow(DataGridViewHandlerDate.headerMedia, DataGridViewHandlerDate.tagMediaDateTaken), TimeZoneLibrary.ToStringSortable(dateTimeLocal), false, false); DataGridViewHandler.AddRow(dataGridView, e.ColumnIndex, new DataGridViewGenericRow(DataGridViewHandlerDate.headerMedia, DataGridViewHandlerDate.tagGPSLocationDateTime), TimeZoneLibrary.ToStringW3CDTF_UTC(((DateTimeOffset)dateTimeZoneResult).UtcDateTime), false, false); } else { DateTime?dateTime = TimeZoneLibrary.ParseDateTimeAsLocal(dataTimeString); if (dateTime != null) { DataGridViewHandler.AddRow(dataGridView, e.ColumnIndex, new DataGridViewGenericRow(DataGridViewHandlerDate.headerMedia, DataGridViewHandlerDate.tagMediaDateTaken), TimeZoneLibrary.ToStringSortable((DateTime)dateTime), false, false); } else if (string.IsNullOrEmpty(dataTimeString)) { DataGridViewHandler.AddRow(dataGridView, e.ColumnIndex, new DataGridViewGenericRow(DataGridViewHandlerDate.headerMedia, DataGridViewHandlerDate.tagMediaDateTaken), "", false, false); } else { DataGridViewHandler.AddRow(dataGridView, e.ColumnIndex, new DataGridViewGenericRow(DataGridViewHandlerDate.headerMedia, DataGridViewHandlerDate.tagMediaDateTaken), "Error", false, false); } } } if (gridViewGenericDataRow.RowName.Equals(DataGridViewHandlerDate.tagGPSLocationDateTime)) //headerMedia, tagGPSLocationDateTime { string dataTimeString = DataGridViewHandler.GetCellValueNullOrStringTrim(dataGridView, e.ColumnIndex, e.RowIndex); DateTime?dateTime = TimeZoneLibrary.ParseDateTimeAsUTC(dataTimeString); if (dateTime != null) { DataGridViewHandler.AddRow(dataGridView, e.ColumnIndex, new DataGridViewGenericRow(DataGridViewHandlerDate.headerMedia, DataGridViewHandlerDate.tagGPSLocationDateTime), TimeZoneLibrary.ToStringW3CDTF_UTC((DateTime)dateTime), false, false); } else if (string.IsNullOrEmpty(dataTimeString)) { DataGridViewHandler.AddRow(dataGridView, e.ColumnIndex, new DataGridViewGenericRow(DataGridViewHandlerDate.headerMedia, DataGridViewHandlerDate.tagGPSLocationDateTime), "", false, false); } else { DataGridViewHandler.AddRow(dataGridView, e.ColumnIndex, new DataGridViewGenericRow(DataGridViewHandlerDate.headerMedia, DataGridViewHandlerDate.tagGPSLocationDateTime), "Error", false, false); } } DataGridViewHandlerDate.PopulateTimeZone(dataGridView, e.ColumnIndex, null); UpdateGoodleHistoryCoordinateAndNearBy(e.ColumnIndex); isDataGridViewDate_CellValueChanging = false; }
private void SaveRename() { if (GlobalData.IsApplicationClosing) { return; } try { if (IsFileInAnyQueueLock(imageListView1.SelectedItems)) { DataGridViewHandlerRename.RenameVaribale = Properties.Settings.Default.RenameVariable; using (new WaitCursor()) { DataGridView dataGridView = dataGridViewRename; int columnIndex = DataGridViewHandler.GetColumnIndexFirstFullFilePath(dataGridView, DataGridViewHandlerRename.headerNewFilename, false); if (columnIndex == -1) { return; } for (int rowIndex = 0; rowIndex < DataGridViewHandler.GetRowCountWithoutEditRow(dataGridView); rowIndex++) { DataGridViewGenericCell cellGridViewGenericCell = DataGridViewHandler.GetCellDataGridViewGenericCellCopy(dataGridView, columnIndex, rowIndex); if (!cellGridViewGenericCell.CellStatus.CellReadOnly) { DataGridViewGenericRow dataGridViewGenericRow = DataGridViewHandler.GetRowDataGridViewGenericRow(dataGridView, rowIndex); #region Get Old filename from grid string oldFilename = dataGridViewGenericRow.RowName; string oldDirectory = dataGridViewGenericRow.HeaderName; string oldFullFilename = FileHandler.CombinePathAndName(oldDirectory, oldFilename); #endregion AddQueueRenameMediaFilesLock(oldFullFilename, DataGridViewHandlerRename.RenameVaribale); } } } } else { Dictionary <string, string> renameSuccess; Dictionary <string, RenameToNameAndResult> renameFailed; HashSet <string> directoriesCreated; DataGridViewHandlerRename.Write(dataGridViewRename, out renameSuccess, out renameFailed, out directoriesCreated, checkBoxRenameShowFullPath.Checked); UpdateImageViewListeAfterRename(imageListView1, renameSuccess, renameFailed, true); foreach (string newDirector in directoriesCreated) { GlobalData.DoNotTrigger_TreeViewFolder_BeforeAndAfterSelect = true; TreeViewFolderBrowserHandler.RefreshFolderWithName(treeViewFolderBrowser1, newDirector, true); GlobalData.DoNotTrigger_TreeViewFolder_BeforeAndAfterSelect = false; } ImageListView_SelectionChanged_Action_ImageListView_DataGridView(false); } } catch (Exception ex) { Logger.Error(ex, "Was not able to rename files"); KryptonMessageBox.Show("Was not able to rename files.\r\n" + ex.Message, "Rename files failed.", MessageBoxButtons.OK, MessageBoxIcon.Error, showCtrlCopy: true); } }
private static int AddRowRegion(DataGridView dataGridView, MetadataBrokerType metadataBrokerType, Metadata metadata, int columnIndex, DataGridViewGenericRow dataGridViewGenericRow, RegionStructure regionStructureToAdd, DataGridViewGenericCellStatus dataGridViewGenericCellStatusDefaults) { #region Find Row to Edit or Where to add bool rowFound = false; int lastHeaderRowFound = -1; bool rowBlankFound = false; int firstBlankFound = -1; int rowIndexRowFound = -1; int startSearchRow = 0; for (int rowIndex = startSearchRow; rowIndex < DataGridViewHandler.GetRowCountWithoutEditRow(dataGridView); rowIndex++) { DataGridViewGenericRow dataGridViewGenericRowCheck = DataGridViewHandler.GetRowDataGridViewGenericRow(dataGridView, rowIndex); if (!dataGridViewGenericRowCheck.IsHeader && !dataGridViewGenericRow.IsHeader && //Is row dataGridViewGenericRowCheck.HeaderName == dataGridViewGenericRow.HeaderName && dataGridViewGenericRowCheck.RowName == dataGridViewGenericRow.RowName) { //Check if region match RegionStructure regionStructureInCell = DataGridViewHandler.GetCellValue(dataGridView, columnIndex, rowIndex) as RegionStructure; if (regionStructureToAdd != null && regionStructureInCell != null) { if (metadata != null && metadata.MediaHeight != null && metadata.MediaWidth != null) { Size imageSize = new Size((int)metadata.MediaWidth, (int)metadata.MediaHeight); Rectangle mediaRectangleToAdd = regionStructureToAdd.GetImageRegionPixelRectangle(imageSize); Rectangle mediaRectangleCell = regionStructureInCell.GetImageRegionPixelRectangle(imageSize); if (RegionStructure.RectangleEqual(mediaRectangleToAdd, mediaRectangleCell)) { rowFound = true; rowIndexRowFound = rowIndex; break; // return rowIndex; } } } if (regionStructureInCell == null) { rowBlankFound = true; if (firstBlankFound == -1) { firstBlankFound = rowIndex; } } } #region Sorting if (dataGridViewGenericRow.IsHeader && //A normal row is add (not header) //dataGridViewGenericRowCheck.IsHeader && //If header, then check if same header name dataGridViewGenericRow.HeaderName.CompareTo(dataGridViewGenericRowCheck.HeaderName) >= 0) { lastHeaderRowFound = rowIndex; //Remember head row found } //Add sorted if (!dataGridViewGenericRow.IsHeader && //A normal row is add (not header) dataGridViewGenericRowCheck.IsHeader && //If header, then check if same header name dataGridViewGenericRowCheck.HeaderName == dataGridViewGenericRow.HeaderName) { lastHeaderRowFound = rowIndex; //Remember head row found } if (!dataGridViewGenericRow.IsHeader && //A normal row is add (not header) !dataGridViewGenericRowCheck.IsHeader && //If header, then check if same header name dataGridViewGenericRowCheck.HeaderName == dataGridViewGenericRow.HeaderName && dataGridViewGenericRow.RowName.CompareTo(dataGridViewGenericRowCheck.RowName) >= 0) { lastHeaderRowFound = rowIndex; //If lower or eaual, remeber last } #endregion } #endregion #region Update row or Add int rowIndexUsed; if (rowFound) //Found row and cell with correct region { rowIndexUsed = rowIndexRowFound; RegionStructure regionStructureInCell = DataGridViewHandler.GetCellRegionStructure(dataGridView, columnIndex, rowIndexUsed); if (regionStructureInCell == null || regionStructureInCell?.Thumbnail == null || (metadata.Broker == MetadataBrokerType.ExifTool && regionStructureToAdd.Thumbnail != null)) { DataGridViewHandler.SetCellValue(dataGridView, columnIndex, rowIndexUsed, regionStructureToAdd, false); //Prioritize ExifTool } } else if (rowBlankFound) //Found row and but no cell with correct region { rowIndexUsed = firstBlankFound; RegionStructure regionStructureInCell = DataGridViewHandler.GetCellRegionStructure(dataGridView, columnIndex, rowIndexUsed); if (regionStructureInCell == null || regionStructureInCell?.Thumbnail == null || (metadata.Broker == MetadataBrokerType.ExifTool && regionStructureToAdd.Thumbnail != null)) { DataGridViewHandler.SetCellValue(dataGridView, columnIndex, rowIndexUsed, regionStructureToAdd, false); //Prioritize ExifTool } } else //No postion found, add on sorted location { //lastHeaderRowFound rowIndexUsed = DataGridViewHandler.AddRow(dataGridView, columnIndex, dataGridViewGenericRow, DataGridViewHandler.GetFavoriteList(dataGridView), regionStructureToAdd, dataGridViewGenericCellStatusDefaults, lastHeaderRowFound, true, true, true); } #endregion SetCellDefault(dataGridView, metadataBrokerType, columnIndex, rowIndexUsed); //No DirtyFlagSet DataGridViewHandler.SetCellRowHeight(dataGridView, rowIndexUsed, DataGridViewHandler.GetCellRowHeight(dataGridView)); #region Delete from suggestion DataGridViewHandler.DeleteRow(dataGridView, headerPeopleSuggestion, regionStructureToAdd.Name); DataGridViewHandler.DeleteRow(dataGridView, headerPeopleMostUsed, regionStructureToAdd.Name); #endregion return(rowIndexUsed); }
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); }