private IEnumerable <SynchronizationKey> GetNewKeys() { foreach (var detailColumn in m_detailColumnManager.Columns) { var masterColumn = default(ColumnBase); if (!DataGridItemPropertyMapHelper.TryGetMasterColumn(m_itemPropertyMap, m_masterColumnManager.Columns, detailColumn, out masterColumn)) { masterColumn = null; } yield return(new SynchronizationKey(masterColumn, detailColumn, m_detailConfiguration)); } }
private void SetMainColumn() { if (!this.IsSynchronizationReady || !this.AreDetailsFlatten) { return; } Debug.Assert(m_detailColumnManager != null); var detailColumns = m_detailColumnManager.Columns; var detailColumn = default(ColumnBase); var mainColumn = m_masterColumnManager.Columns.MainColumn; if (mainColumn != null) { if (!DataGridItemPropertyMapHelper.TryGetDetailColumn(m_itemPropertyMap, detailColumns, mainColumn, out detailColumn)) { detailColumn = null; } } detailColumns.MainColumn = detailColumn; }
private void UpdateTargetPosition() { var detailConfig = this.DetailConfiguration; var dataGridControl = detailConfig.DataGridControl; if (dataGridControl == null) { return; } var masterColumn = this.MasterColumn; var masterColumnManager = DataGridControl.GetDataGridContext(dataGridControl).ColumnManager; var masterColumnLocation = masterColumnManager.GetColumnLocationFor(masterColumn); if (masterColumnLocation == null) { return; } var detailColumn = this.DetailColumn; var detailColumnManager = detailConfig.ColumnManager; var detailColumnLocation = detailColumnManager.GetColumnLocationFor(detailColumn); if (detailColumnLocation == null) { return; } var map = detailConfig.ItemPropertyMap; var previousMasterLocation = masterColumnLocation.GetPreviousSiblingOrCousin(); Debug.Assert(previousMasterLocation != null); switch (previousMasterLocation.Type) { case LocationType.Start: case LocationType.Splitter: { for (var previousDetailLocation = detailColumnLocation.GetPreviousSiblingOrCousin(); previousDetailLocation != null; previousDetailLocation = previousDetailLocation.GetPreviousSiblingOrCousin()) { // The detail column is at the appropriate location. if (previousDetailLocation.Type == previousMasterLocation.Type) { return; } if (previousDetailLocation.Type != LocationType.Column) { break; } ColumnBase unused; if (DataGridItemPropertyMapHelper.TryGetMasterColumn(map, masterColumnManager.Columns, ((ColumnHierarchyManager.IColumnLocation)previousDetailLocation).Column, out unused)) { break; } } } break; case LocationType.Column: { var previousMasterColumn = ((ColumnHierarchyManager.IColumnLocation)previousMasterLocation).Column; for (var previousDetailLocation = detailColumnLocation.GetPreviousSiblingOrCousin(); previousDetailLocation != null; previousDetailLocation = previousDetailLocation.GetPreviousSiblingOrCousin()) { if (previousDetailLocation.Type != LocationType.Column) { break; } ColumnBase targetMasterColumn; if (DataGridItemPropertyMapHelper.TryGetMasterColumn(map, masterColumnManager.Columns, ((ColumnHierarchyManager.IColumnLocation)previousDetailLocation).Column, out targetMasterColumn)) { // The detail column is at the appropriate location. if (previousMasterColumn == targetMasterColumn) { return; } } } } break; default: // Unexpected location. throw new NotSupportedException(); } var nextMasterLocation = masterColumnLocation.GetNextSiblingOrCousin(); Debug.Assert(nextMasterLocation != null); switch (nextMasterLocation.Type) { case LocationType.Splitter: case LocationType.Orphan: { for (var nextDetailLocation = detailColumnLocation.GetNextSiblingOrCousin(); nextDetailLocation != null; nextDetailLocation = nextDetailLocation.GetNextSiblingOrCousin()) { // The detail column is at the appropriate location. if (nextDetailLocation.Type == nextMasterLocation.Type) { return; } if (nextDetailLocation.Type != LocationType.Column) { break; } ColumnBase unused; if (DataGridItemPropertyMapHelper.TryGetMasterColumn(map, masterColumnManager.Columns, ((ColumnHierarchyManager.IColumnLocation)nextDetailLocation).Column, out unused)) { break; } } } break; case LocationType.Column: { var nextMasterColumn = ((ColumnHierarchyManager.IColumnLocation)nextMasterLocation).Column; for (var nextDetailLocation = detailColumnLocation.GetNextSiblingOrCousin(); nextDetailLocation != null; nextDetailLocation = nextDetailLocation.GetNextSiblingOrCousin()) { if (nextDetailLocation.Type != LocationType.Column) { break; } ColumnBase targetMasterColumn; if (DataGridItemPropertyMapHelper.TryGetMasterColumn(map, masterColumnManager.Columns, ((ColumnHierarchyManager.IColumnLocation)nextDetailLocation).Column, out targetMasterColumn)) { // The detail column is at the appropriate location. if (nextMasterColumn == targetMasterColumn) { return; } } } } break; default: // Unexpected location. throw new NotSupportedException(); } // If we get here, it means that the column is really not at the appropriate location. for (var pivotMasterLocation = previousMasterLocation; pivotMasterLocation != null; pivotMasterLocation = pivotMasterLocation.GetPreviousSiblingOrCousin()) { if (pivotMasterLocation.Type == LocationType.Column) { ColumnBase pivotDetailColumn; if (!DataGridItemPropertyMapHelper.TryGetDetailColumn(map, detailColumnManager.Columns, ((ColumnHierarchyManager.IColumnLocation)pivotMasterLocation).Column, out pivotDetailColumn)) { continue; } var pivotDetailLocation = (pivotDetailColumn != null) ? detailColumnManager.GetColumnLocationFor(pivotDetailColumn) : null; if (pivotDetailLocation == null) { continue; } Debug.Assert(detailColumnLocation.CanMoveAfter(pivotDetailLocation)); detailColumnLocation.MoveAfter(pivotDetailLocation); } else { switch (pivotMasterLocation.Type) { case LocationType.Start: { var pivotDetailLocation = detailColumnManager.GetLevelMarkersFor(detailColumnManager.Columns).Start; if (!detailColumnLocation.CanMoveAfter(pivotDetailLocation)) { throw new NotSupportedException(); } detailColumnLocation.MoveAfter(pivotDetailLocation); } break; case LocationType.Splitter: { var pivotDetailLocation = detailColumnManager.GetLevelMarkersFor(detailColumnManager.Columns).Splitter; if (!detailColumnLocation.CanMoveAfter(pivotDetailLocation)) { throw new NotSupportedException(); } detailColumnLocation.MoveAfter(pivotDetailLocation); } break; default: // Unexpected location. throw new NotSupportedException(); } } // The detail column is now at the appropriate location. return; } }