private void ActionMarkRows() { DataGridView dataGridView = DataGridViewLocationHistory; dataGridView.ClearSelection(); HashSet <FileEntry> files = DataGridViewHandler.GetSelectFileEntries(ActiveDataGridView, ActiveDataGridViewSelectedFilesMode); for (int columnIndex = 0; columnIndex < DataGridViewHandler.GetColumnCount(DataGridViewDateTime); columnIndex++) { DataGridViewGenericColumn dataGridViewGenericColumn = DataGridViewHandler.GetColumnDataGridViewGenericColumn(DataGridViewDateTime, columnIndex); if (dataGridViewGenericColumn != null) { if (files.Contains(dataGridViewGenericColumn.FileEntryAttribute.FileEntry)) { DateTime?dataTimeTaken = DataGridViewHandlerDate.GetUserInputDateTaken(DataGridViewDateTime, columnIndex, null); DateTime?dataTimeLocationUtc = DataGridViewHandlerDate.GetUserInputLocationDate(DataGridViewDateTime, columnIndex, null); DateTime?dateTimeSuggestionFromGPSDateTime = DataGridViewHandlerDate.GetSuggestionFromGPSDate(DataGridViewDateTime, columnIndex, null); FindAndSelect(dataTimeTaken, dataTimeLocationUtc, dateTimeSuggestionFromGPSDateTime); } } } if (dataGridView.SelectedRows.Count > 0) { selectedRowsSorted.Clear(); foreach (DataGridViewRow dataGridViewRow in dataGridView.SelectedRows) { selectedRowsSorted.Add(dataGridViewRow.Index); } selectedRowsSorted.Sort(); SetRowVisbible(visibleRowIndex); SetButtonStatus(enabledPreviousNext: selectedRowsSorted.Count > 0); } else { selectedRowsSorted.Clear(); SetButtonStatus(enabledPreviousNext: selectedRowsSorted.Count > 0); } Properties.Settings.Default.LocationAnalyticsZoomLevel = (byte)comboBoxMapZoomLevel.SelectedIndex; GetLocationAndShow(MapProvider.OpenStreetMap); selectionChanged = false; }
public static void PopulateGoogleHistoryCoordinateAndNearby(DataGridView dataGridViewMap, DataGridView dataGridViewDate, int columnIndexMap, int timeZoneShift, int accepedIntervalSecound) { #region Check if Aggegated DataGridViewGenericColumn dataGridViewGenericColumn = DataGridViewHandler.GetColumnDataGridViewGenericColumn(dataGridViewMap, columnIndexMap); if (dataGridViewGenericColumn == null) { return; } #endregion #region Get Metadata Metadata metadata = dataGridViewGenericColumn.Metadata; if (metadata == null) { DataGridViewHandler.SetCellValue(dataGridViewMap, columnIndexMap, headerGoogleLocations, tagGoogleCoordinateUTC, "No metadata loaded"); return; } #endregion DateTime?dateTaken = DataGridViewHandlerDate.GetUserInputDateTaken(dataGridViewDate, null, dataGridViewGenericColumn.FileEntryAttribute); DateTime?locationDate = DataGridViewHandlerDate.GetUserInputLocationDate(dataGridViewDate, null, dataGridViewGenericColumn.FileEntryAttribute); if (dateTaken == null) { dateTaken = metadata.MediaDateTaken; } if (locationDate == null) { locationDate = metadata.LocationDateTime; } PopulateGoogleHistoryCoordinate( dataGridViewMap, columnIndexMap, timeZoneShift, accepedIntervalSecound, dateTaken, locationDate, metadata); PopulateNearbyCoordinate( dataGridViewMap, columnIndexMap, timeZoneShift, accepedIntervalSecound, (DateTime)metadata.FileDate, dateTaken, locationDate); }
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 kryptonRibbonGroupButtonHomeDateAndTimeMinus60m_Click(object sender, EventArgs e) { DataGridView dataGridView = dataGridViewDate; DataGridViewHandlerDate.AdjustSelectedCell(dataGridView, -60); }
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; }
private void ShowFormLocationHistoryAnalytics(DataGridView dataGridViewLocationHistory, DataGridView dataGridViewDate, DataGridView dataGridViewActive) { using (new WaitCursor()) { SetButtonStatus(false); List <DateTime> datesFound = new List <DateTime>(); DateTime? dateTimeFrom = null; DateTime? dateTimeTo = null; if (DataGridViewHandler.GetIsAgregated(dataGridViewActive)) { //ShowFormLocationHistoryAnalyticsInit(); PopulateMetadataLocationsClear(dataGridViewLocationHistory); foreach (int columnIndex in DataGridViewHandler.GetColumnSelected(dataGridViewActive)) { DataGridViewGenericColumn dataGridViewGenericColumn = DataGridViewHandler.GetColumnDataGridViewGenericColumn(dataGridViewActive, columnIndex); if (dataGridViewGenericColumn != null) { DateTime?date = DataGridViewHandlerDate.GetUserInputDateTaken(dataGridViewDate, null, dataGridViewGenericColumn.FileEntryAttribute); if (date != null) { AddDatesFound((DateTime)date, ref datesFound); if (dateTimeFrom == null || date < dateTimeFrom) { dateTimeFrom = date; } if (dateTimeTo == null || date > dateTimeTo) { dateTimeTo = date; } } date = DataGridViewHandlerDate.GetUserInputLocationDate(dataGridViewDate, null, dataGridViewGenericColumn.FileEntryAttribute); if (date != null) { AddDatesFound((DateTime)date, ref datesFound); if (dateTimeFrom == null || date < dateTimeFrom) { dateTimeFrom = date; } if (dateTimeTo == null || date > dateTimeTo) { dateTimeTo = date; } } if (dataGridViewGenericColumn != null && dataGridViewGenericColumn.Metadata != null) { date = dataGridViewGenericColumn.Metadata.MediaDateTaken; if (date != null) { AddDatesFound((DateTime)date, ref datesFound); if (dateTimeFrom == null || date < dateTimeFrom) { dateTimeFrom = date; } if (dateTimeTo == null || date > dateTimeTo) { dateTimeTo = date; } } date = dataGridViewGenericColumn.Metadata.LocationDateTime; if (date != null) { AddDatesFound((DateTime)date, ref datesFound); if (dateTimeFrom == null || date < dateTimeFrom) { dateTimeFrom = date; } if (dateTimeTo == null || date > dateTimeTo) { dateTimeTo = date; } } //date = dataGridViewGenericColumn.Metadata.FileDateCreated; //if (date != null) //{ // if (dateTimeFrom == null || date < dateTimeFrom) dateTimeFrom = date; // if (dateTimeTo == null || date > dateTimeTo) dateTimeTo = date; //} //date = dataGridViewGenericColumn.Metadata.FileDateModified; //if (date != null) //{ // if (dateTimeFrom == null || date < dateTimeFrom) dateTimeFrom = date; // if (dateTimeTo == null || date > dateTimeTo) dateTimeTo = date; //} if (dataGridViewGenericColumn.Metadata.FileDateCreated != null && dataGridViewGenericColumn.Metadata.FileDateModified != null) { date = (dataGridViewGenericColumn.Metadata.FileDateCreated < dataGridViewGenericColumn.Metadata.FileDateModified ? dataGridViewGenericColumn.Metadata.FileDateCreated : dataGridViewGenericColumn.Metadata.FileDateModified); AddDatesFound((DateTime)date, ref datesFound); } } } } DateTime?dateTimeFoundFrom = null; DateTime?dateTimeFoundTo = null; for (int index = 0; index < datesFound.Count - 1; index++) { if (index == 0) { dateTimeFoundFrom = datesFound[index]; } if (datesFound[index].AddDays(1) != datesFound[index + 1]) { dateTimeFoundTo = datesFound[index]; } if (index == datesFound.Count - 2) { dateTimeFoundTo = datesFound[index + 1]; } if (dateTimeFoundFrom != null && dateTimeFoundTo == null) { dateTimeFoundTo = ((DateTime)dateTimeFoundFrom).AddDays(1); } if (dateTimeFoundFrom == null && dateTimeFoundTo != null) { dateTimeFoundFrom = ((DateTime)dateTimeFoundTo).AddDays(-1); } if (dateTimeFoundFrom != null && dateTimeFoundTo != null) { PopulateMetadataLocationsAdd(dataGridViewLocationHistory, (DateTime)dateTimeFoundFrom, ((DateTime)dateTimeFoundTo).AddDays(1).AddMilliseconds(-1), Properties.Settings.Default.LocationAnalyticsMinimumTimeInterval * 60, (float)Properties.Settings.Default.LocationAnalyticsMinimumDistance); dateTimeFoundFrom = datesFound[index + 1]; dateTimeFoundTo = null; } } } if (dateTimeFrom != null) { DefaultDateTimeFrom = new DateTime(((DateTime)dateTimeFrom).Year, ((DateTime)dateTimeFrom).Month, ((DateTime)dateTimeFrom).Day, 0, 0, 0, DateTimeKind.Utc); } if (dateTimeTo != null) { DefaultDateTimeTo = new DateTime(((DateTime)dateTimeTo).Year, ((DateTime)dateTimeTo).Month, ((DateTime)dateTimeTo).Day, 0, 0, 0, DateTimeKind.Utc).AddDays(1); } } }