/// <summary>
        /// Recalculates the layout if necessary.
        /// </summary>
        /// <param name="graphics">The graphics object which is used to measure the strings.</param>
        internal void UpdateLayout(Graphics graphics)
        {
            if (_layoutChanged)
            {
                _layoutChanged = false;

                // syncronize layout
                List <BehaviorNode> processedBehaviors = new List <BehaviorNode>();
                processedBehaviors.Add(_rootNodeLayout.RootBehavior);
                _rootNodeLayout.SynchronizeWithNode(processedBehaviors.AsReadOnly());

                // calculate the size of each node
                _rootNodeLayout.Node.UpdateFinalSize(graphics, _rootNodeLayout.RootBehavior);
                _rootNodeLayout.UpdateExtent();

                // calculate the total size of the branches
                _rootNodeLayout.CalculateLayoutSize(_padding);

                // align the branches
                _rootNodeLayout.Layout(_padding);

                // align the parents at the centre of their children
                _rootNodeLayout.UpdateLocation();
            }
        }
        /// <summary>
        /// Recalculates the layout if necessary.
        /// </summary>
        /// <param name="dc">The graphics object which is used to measure the strings.</param>
        internal void UpdateLayout(DrawingContext dc)
        {
            if (_layoutChanged)
            {
                _layoutChanged = false;

                // synchronize layout
                ProcessedBehaviors processedBehaviors = new ProcessedBehaviors();
                _rootNodeLayout.SynchronizeWithNode(processedBehaviors);

                // calculate the size of each node
                _rootNodeLayout.UpdateFinalSize(dc, _rootNodeLayout.RootBehavior);
                _rootNodeLayout.UpdateExtent();

                // calculate the total size of the branches
                _rootNodeLayout.CalculateLayoutSize(_padding);

                // align the branches
                _rootNodeLayout.Layout(_padding);

                // align the parents at the centre of their children
                _rootNodeLayout.UpdateLocation();
            }
        }