/// <summary>
 /// Initializes a new instance of the <see cref="LayoutPlaceholderNodeStateView"/> class.
 /// </summary>
 /// <param name="controllerView">The controller view to which this object belongs.</param>
 /// <param name="state">The child node state.</param>
 public LayoutPlaceholderNodeStateView(LayoutControllerView controllerView, ILayoutPlaceholderNodeState state)
     : base(controllerView, state)
 {
     CellOrigin     = RegionHelper.InvalidOrigin;
     CellSize       = RegionHelper.InvalidSize;
     ActualCellSize = RegionHelper.InvalidSize;
 }
        /// <summary>
        /// Handler called every time a state is moved in the controller.
        /// </summary>
        /// <param name="operation">Details of the operation performed.</param>
        private protected override void OnStateMoved(WriteableMoveNodeOperation operation)
        {
            base.OnStateMoved(operation);

            ILayoutPlaceholderNodeState State = ((LayoutMoveNodeOperation)operation).State;

            Debug.Assert(State != null);
            Debug.Assert(StateViewTable.ContainsKey(State));
        }
        private protected virtual void MeasureCells()
        {
            ILayoutPlaceholderNodeState RootState     = Controller.RootState;
            ILayoutNodeStateView        RootStateView = (ILayoutNodeStateView)StateViewTable[RootState];

            RootStateView.MeasureCells(null, null, Measure.Floating);

            InternalViewSize = RootStateView.CellSize;

            Debug.Assert(RegionHelper.IsFixed(InternalViewSize));
        }
        /// <summary>
        /// Handler called every time a block state is inserted in the controller.
        /// </summary>
        /// <param name="operation">Details of the operation performed.</param>
        private protected override void OnBlockStateInserted(IWriteableInsertBlockOperation operation)
        {
            base.OnBlockStateInserted(operation);

            ILayoutBlockState BlockState = ((ILayoutInsertBlockOperation)operation).BlockState;

            Debug.Assert(BlockState != null);
            Debug.Assert(BlockStateViewTable.ContainsKey(BlockState));

            Debug.Assert(StateViewTable.ContainsKey(BlockState.PatternState));
            Debug.Assert(StateViewTable.ContainsKey(BlockState.SourceState));

            Debug.Assert(BlockState.StateList.Count == 1);

            ILayoutPlaceholderNodeState ChildState = ((ILayoutInsertBlockOperation)operation).ChildState;

            Debug.Assert(ChildState == BlockState.StateList[0]);
            Debug.Assert(ChildState.ParentIndex == ((ILayoutInsertBlockOperation)operation).BrowsingIndex);
            Debug.Assert(StateViewTable.ContainsKey(ChildState));
        }
        private protected virtual void ArrangeCells()
        {
            ILayoutPlaceholderNodeState RootState     = Controller.RootState;
            ILayoutNodeStateView        RootStateView = (ILayoutNodeStateView)StateViewTable[RootState];

            Point ViewOrigin;

            if (ShowLineNumber)
            {
                Measure Width = MeasureLineNumberWidth();
                ViewOrigin = new Point(Width, Measure.Zero);
            }
            else
            {
                ViewOrigin = Point.Origin;
            }

            RootStateView.ArrangeCells(ViewOrigin);

            Debug.Assert(Point.IsEqual(RootStateView.CellOrigin, ViewOrigin));
        }