protected override System.Windows.Size MeasureOverride(System.Windows.Size availableSize)
        {
            PanelHelper helper = new PanelHelper(availableSize.Height);

            foreach (UIElement child in Children)
            {
                child.Measure(availableSize);
                helper.PlaceControl(child);
            }

            return(helper.DesiredSize);
        }
        /// <summary>
        /// Enables the dropping of OUs or MonitoredSystems inside the hierarchy.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        //private void DropHandler(object sender, DragEventArgs e)
        //{
        //    try
        //    {
        //        // Tuple: bool isOU, int ID/ouID, int ouID/parentID
        //        Tuple<bool, int, int> oldValues = (Tuple<bool, int, int>)e.Data.GetData(typeof(Tuple<bool, int, int>));

        //        // dropping a OU
        //        if (oldValues.Item1 == true)
        //        {
        //            // find out which element was hit
        //            var result = VisualTreeHelper.HitTest(this, e.GetPosition(sender as UIElement));

        //            DependencyObject parent = result.VisualHit;
        //            while (parent != null && !(parent.GetType().Equals(typeof(ExtendedTreeViewItem))))
        //            {
        //                parent = VisualTreeHelper.GetParent(parent);
        //            }

        //            // find the corresponding monitored system
        //            if (parent != null)
        //            {
        //                var monitoredSystem = (parent as ExtendedTreeViewItem).DataContext as MonitoredSystem;

        //                // move the monitored System
        //                if (monitoredSystem != null)
        //                {
        //                    // check if the old and new OU are different
        //                    if (!oldValues.Item3.Equals(monitoredSystem.OuID))
        //                    {
        //                        foreach (OrganizationalUnit current in DataModel.Instance.GetOrganizationalUnits(DataModel.Instance.Elements))
        //                        {
        //                            if (current.ID.Equals(oldValues.Item3))
        //                            {
        //                                current.ParentID = monitoredSystem.OuID;
        //                            }
        //                        }
        //                    }
        //                    LayoutManager.Instance.MoveBefore(oldValues.Item3, monitoredSystem.ID, true);
        //                    e.Handled = true;
        //                }
        //                else
        //                {
        //                    // find out the OUID of this panel
        //                    int OUID = -1;
        //                    foreach (UIElement child in Children)
        //                    {
        //                        if (child.GetType().Equals(typeof(Tile)))
        //                        {
        //                            OUID = (child as Tile).MonitoredSystem.OuID;
        //                            break;
        //                        }
        //                    }

        //                    // check if the old and new OU are different
        //                    if (OUID != -1 && !oldValues.Item3.Equals(OUID))
        //                    {
        //                        foreach (OrganizationalUnit current in DataModel.Instance.GetOrganizationalUnits(DataModel.Instance.Elements))
        //                        {
        //                            if (current.ID.Equals(oldValues.Item3))
        //                            {
        //                                current.ParentID = OUID;
        //                                e.Handled = true;
        //                            }
        //                        }
        //                    }
        //                }
        //            }
        //        }
        //        // dropping an MonitoredSystem
        //        else
        //        {
        //            // find out which element was hit
        //            var result = VisualTreeHelper.HitTest(this, e.GetPosition(sender as UIElement));

        //            DependencyObject parent = result.VisualHit;
        //            while (parent != null && !(parent.GetType().Equals(typeof(ExtendedTreeViewItem))))
        //            {
        //                parent = VisualTreeHelper.GetParent(parent);
        //            }

        //            // find the corresponding monitored system
        //            if (parent != null)
        //            {
        //                var monitoredSystem = (parent as TreeViewItem).DataContext as MonitoredSystem;

        //                // check if the OU has changed as well
        //                if (monitoredSystem != null && !oldValues.Item3.Equals(monitoredSystem.OuID))
        //                {
        //                    foreach (MonitoredSystem current in DataModel.Instance.GetMonitoredSystems(DataModel.Instance.Elements))
        //                    {
        //                        if (current.ID.Equals(oldValues.Item2))
        //                        {
        //                            current.OuID = monitoredSystem.OuID;
        //                        }
        //                    }
        //                }

        //                // move the monitored System
        //                if (monitoredSystem != null)
        //                {
        //                    LayoutManager.Instance.MoveBefore(oldValues.Item2, monitoredSystem.ID, false);
        //                    e.Handled = true;
        //                }
        //            }
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        Console.WriteLine("EXCEPTION: SpaceFillingPanel_DropHandler: " + ex.ToString());
        //    }
        //}

        protected override System.Windows.Size ArrangeOverride(System.Windows.Size finalSize)
        {
            PanelHelper helper = new PanelHelper(finalSize.Height);

            foreach (UIElement child in Children)
            {
                var offsetBefore = VisualTreeHelper.GetOffset(child);

                child.Arrange(helper.PlaceControl(child));

                var offsetAfter = VisualTreeHelper.GetOffset(child);

                TranslateTransform transform = new TranslateTransform();
                child.RenderTransform = transform;

                DoubleAnimation animation = new DoubleAnimation(offsetBefore.X - offsetAfter.X, 0, new Duration(new TimeSpan(0, 0, 0, 0, 800)));
                animation.EasingFunction = new ExponentialEase()
                {
                    EasingMode = System.Windows.Media.Animation.EasingMode.EaseOut
                };
                animation.AccelerationRatio = 0;
                animation.DecelerationRatio = 1;
                transform.BeginAnimation(TranslateTransform.XProperty, animation);

                DoubleAnimation animationY = new DoubleAnimation(offsetBefore.Y - offsetAfter.Y, 0, new Duration(new TimeSpan(0, 0, 0, 0, 800)));
                animationY.EasingFunction = new ExponentialEase()
                {
                    EasingMode = System.Windows.Media.Animation.EasingMode.EaseOut
                };
                animationY.AccelerationRatio = 0;
                animationY.DecelerationRatio = 1;
                transform.BeginAnimation(TranslateTransform.YProperty, animationY);
            }

            return(finalSize);
        }