private static bool MoveColumnUnder(ColumnHierarchyManager columnsLayout, ColumnCollection columns, ColumnBase current, ColumnBase parent)
        {
            Debug.Assert(columnsLayout != null);

            var currentLocation = columnsLayout.GetColumnLocationFor(current);

            if (currentLocation == null)
            {
                return(false);
            }

            var pivotLocation = default(ColumnHierarchyManager.ILocation);

            // Move the column under the orphan section.
            if (parent == null)
            {
                var columnCollection = current.ContainingCollection;
                if (columnCollection == null)
                {
                    return(false);
                }

                var mergedColumnCollection = default(ColumnCollection);

                if (columnCollection == columns)
                {
                    mergedColumnCollection = null;
                }

                if (mergedColumnCollection == null)
                {
                    return(false);
                }

                var levelMarkers = columnsLayout.GetLevelMarkersFor(mergedColumnCollection);
                if (levelMarkers == null)
                {
                    return(false);
                }

                pivotLocation = levelMarkers.Orphan;
            }
            else
            {
                pivotLocation = columnsLayout.GetColumnLocationFor(parent);
            }

            if (pivotLocation == null)
            {
                return(false);
            }

            if (!currentLocation.CanMoveUnder(pivotLocation))
            {
                return(false);
            }

            currentLocation.MoveUnder(pivotLocation);
            return(true);
        }
        private static bool MoveColumnBefore(ColumnHierarchyManager columnsLayout, ColumnBase current, ColumnBase next)
        {
            Debug.Assert(columnsLayout != null);

            var currentLocation = columnsLayout.GetColumnLocationFor(current);

            if (currentLocation == null)
            {
                return(false);
            }

            var pivotLocation = columnsLayout.GetColumnLocationFor(next);

            if (pivotLocation == null)
            {
                return(false);
            }

            if (!currentLocation.CanMoveBefore(pivotLocation))
            {
                return(false);
            }

            currentLocation.MoveBefore(pivotLocation);
            return(true);
        }
 internal static void RemoveListener(ColumnHierarchyManager source, IWeakEventListener listener)
 {
     ColumnsLayoutChangingEventManager.CurrentManager.ProtectedRemoveListener(source, listener);
 }