/// <summary>
 /// Detirmines the size of the client area for the secondary element, based on the overall area allocated to it
 /// </summary>
 /// <param name="totalSecondaryArea">The total secondary area.</param>
 /// <param name="parentPanel">The parent panel.</param>
 /// <returns>The client size (area usable by the contained element, which excludes areas needed for header information)</returns>
 public Rect GetSecondaryClientArea(Rect totalSecondaryArea, PrimarySecondaryHorizontalPanel parentPanel)
 {
     if (IgnoreIconSizeForLayout)
     {
         return(new Rect(totalSecondaryArea.X, totalSecondaryArea.Y, totalSecondaryArea.Width, totalSecondaryArea.Height));
     }
     return(new Rect(totalSecondaryArea.X, totalSecondaryArea.Y + ExpandCollapseIconSize.Height + 4, totalSecondaryArea.Width, totalSecondaryArea.Height - ExpandCollapseIconSize.Height - 4));
 }
        /// <summary>
        /// Called when a click on the panel background happens
        /// </summary>
        /// <param name="location">The location of the click.</param>
        /// <param name="currentPrimaryArea">The current primary area.</param>
        /// <param name="currentSecondaryArea">The current secondary area.</param>
        /// <param name="parentPanel">The parent panel.</param>
        /// <returns>True if the click event has been handled and no further processing is needed</returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public bool Click(Point location, Rect currentPrimaryArea, Rect currentSecondaryArea, PrimarySecondaryHorizontalPanel parentPanel)
        {
            if (location.Y > ExpandCollapseIconSize.Height + 4)
            {
                return(false);
            }

            if (parentPanel.IsSecondaryElementCollapsed)
            {
                if (parentPanel.SecondaryAreaLocation == SecondaryAreaLocation.Left)
                {
                    if (location.X <= ExpandCollapseIconSize.Width)
                    {
                        parentPanel.IsSecondaryElementCollapsed = !parentPanel.IsSecondaryElementCollapsed;
                        return(true);
                    }
                }
                else
                {
                    if (location.X >= parentPanel.ActualWidth - ExpandCollapseIconSize.Width)
                    {
                        parentPanel.IsSecondaryElementCollapsed = !parentPanel.IsSecondaryElementCollapsed;
                        return(true);
                    }
                }
            }
            else
            {
                if (location.X >= currentSecondaryArea.Left && location.X <= currentSecondaryArea.Right)
                {
                    parentPanel.IsSecondaryElementCollapsed = !parentPanel.IsSecondaryElementCollapsed;
                    return(true);
                }
            }
            return(false);
        }
 /// <summary>
 /// Returns the minimum width of a collapsed secondary area
 /// </summary>
 /// <param name="parentPanel">The parent panel.</param>
 /// <returns>Minimum width of the area</returns>
 public double GetMinimumCollapsedAreaWidth(PrimarySecondaryHorizontalPanel parentPanel)
 {
     return(ExpandCollapseIconSize.Width);
 }
 /// <summary>
 /// Renders additional graphical elements
 /// </summary>
 /// <param name="dc">The dc.</param>
 /// <param name="currentPrimaryArea">The current primary area.</param>
 /// <param name="currentSecondaryArea">The current secondary area.</param>
 /// <param name="parentPanel">The parent panel.</param>
 public void Render(DrawingContext dc, Rect currentPrimaryArea, Rect currentSecondaryArea, PrimarySecondaryHorizontalPanel parentPanel)
 {
     if (parentPanel.CanCollapseSecondary)
     {
         if (parentPanel.IsSecondaryElementCollapsed)
         {
             if (CollapsedSecondaryAreaIconProperty != null)
             {
                 dc.DrawRectangle(CollapsedSecondaryAreaIcon, null, new Rect(new Point(parentPanel.ActualWidth - ExpandCollapseIconSize.Width + IconMargin.Left, IconMargin.Top), new Size(ExpandCollapseIconSize.Width - IconMargin.Left - IconMargin.Right, ExpandCollapseIconSize.Height - IconMargin.Top - IconMargin.Bottom)));
             }
         }
         else
         {
             if (ExpandedSecondaryAreaIcon != null)
             {
                 dc.DrawRectangle(ExpandedSecondaryAreaIcon, null, new Rect(new Point(currentSecondaryArea.X + IconMargin.Left, IconMargin.Top), new Size(ExpandCollapseIconSize.Width - IconMargin.Left - IconMargin.Right, ExpandCollapseIconSize.Height - IconMargin.Top - IconMargin.Bottom)));
             }
         }
     }
 }
 /// <summary>
 /// Detirmines the size of the client area for the primary element, based on the overall area allocated to it
 /// </summary>
 /// <param name="totalPrimaryArea">The total primary area.</param>
 /// <param name="parentPanel">The parent panel.</param>
 /// <returns>The client size (area usable by the contained element, which excludes areas needed for header information)</returns>
 public Rect GetPrimaryClientArea(Rect totalPrimaryArea, PrimarySecondaryHorizontalPanel parentPanel)
 {
     return(totalPrimaryArea);
 }
 /// <summary>
 /// Renders additional graphical elements
 /// </summary>
 /// <param name="dc">The dc.</param>
 /// <param name="currentPrimaryArea">The current primary area.</param>
 /// <param name="currentSecondaryArea">The current secondary area.</param>
 /// <param name="parentPanel">The parent panel.</param>
 public void Render(DrawingContext dc, Rect currentPrimaryArea, Rect currentSecondaryArea, PrimarySecondaryHorizontalPanel parentPanel)
 {
     if (parentPanel.CanCollapseSecondary)
     {
         if (parentPanel.IsSecondaryElementCollapsed)
         {
             if (CollapsedSecondaryAreaIconProperty != null)
                 dc.DrawRectangle(CollapsedSecondaryAreaIcon, null, new Rect(new Point(parentPanel.ActualWidth - ExpandCollapseIconSize.Width + IconMargin.Left, IconMargin.Top), new Size(ExpandCollapseIconSize.Width - IconMargin.Left - IconMargin.Right, ExpandCollapseIconSize.Height - IconMargin.Top - IconMargin.Bottom)));
         }
         else
         {
             if (ExpandedSecondaryAreaIcon != null)
                 dc.DrawRectangle(ExpandedSecondaryAreaIcon, null, new Rect(new Point(currentSecondaryArea.X + IconMargin.Left, IconMargin.Top), new Size(ExpandCollapseIconSize.Width - IconMargin.Left - IconMargin.Right, ExpandCollapseIconSize.Height - IconMargin.Top - IconMargin.Bottom)));
         }
     }
 }
 /// <summary>
 /// Detirmines the size of the client area for the secondary element, based on the overall area allocated to it
 /// </summary>
 /// <param name="totalSecondaryArea">The total secondary area.</param>
 /// <param name="parentPanel">The parent panel.</param>
 /// <returns>The client size (area usable by the contained element, which excludes areas needed for header information)</returns>
 public Rect GetSecondaryClientArea(Rect totalSecondaryArea, PrimarySecondaryHorizontalPanel parentPanel)
 {
     if (IgnoreIconSizeForLayout)
         return new Rect(totalSecondaryArea.X, totalSecondaryArea.Y, totalSecondaryArea.Width, totalSecondaryArea.Height);
     return new Rect(totalSecondaryArea.X, totalSecondaryArea.Y + ExpandCollapseIconSize.Height + 4, totalSecondaryArea.Width, totalSecondaryArea.Height - ExpandCollapseIconSize.Height - 4);
 }
 /// <summary>
 /// Detirmines the size of the client area for the primary element, based on the overall area allocated to it
 /// </summary>
 /// <param name="totalPrimaryArea">The total primary area.</param>
 /// <param name="parentPanel">The parent panel.</param>
 /// <returns>The client size (area usable by the contained element, which excludes areas needed for header information)</returns>
 public Rect GetPrimaryClientArea(Rect totalPrimaryArea, PrimarySecondaryHorizontalPanel parentPanel)
 {
     return totalPrimaryArea;
 }
 /// <summary>
 /// Returns the minimum width of a collapsed secondary area
 /// </summary>
 /// <param name="parentPanel">The parent panel.</param>
 /// <returns>Minimum width of the area</returns>
 public double GetMinimumCollapsedAreaWidth(PrimarySecondaryHorizontalPanel parentPanel)
 {
     return ExpandCollapseIconSize.Width;
 }
        /// <summary>
        /// Called when a click on the panel background happens
        /// </summary>
        /// <param name="location">The location of the click.</param>
        /// <param name="currentPrimaryArea">The current primary area.</param>
        /// <param name="currentSecondaryArea">The current secondary area.</param>
        /// <param name="parentPanel">The parent panel.</param>
        /// <returns>True if the click event has been handled and no further processing is needed</returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public bool Click(Point location, Rect currentPrimaryArea, Rect currentSecondaryArea, PrimarySecondaryHorizontalPanel parentPanel)
        {
            if (location.Y > ExpandCollapseIconSize.Height + 4) return false;

            if (parentPanel.IsSecondaryElementCollapsed)
            {
                if (parentPanel.SecondaryAreaLocation == SecondaryAreaLocation.Left)
                {
                    if (location.X <= ExpandCollapseIconSize.Width)
                    {
                        parentPanel.IsSecondaryElementCollapsed = !parentPanel.IsSecondaryElementCollapsed;
                        return true;
                    }
                }
                else
                {
                    if (location.X >= parentPanel.ActualWidth - ExpandCollapseIconSize.Width)
                    {
                        parentPanel.IsSecondaryElementCollapsed = !parentPanel.IsSecondaryElementCollapsed;
                        return true;
                    }
                }
            }
            else
            {
                if (location.X >= currentSecondaryArea.Left && location.X <= currentSecondaryArea.Right)
                {
                    parentPanel.IsSecondaryElementCollapsed = !parentPanel.IsSecondaryElementCollapsed;
                    return true;
                }
            }
            return false;
        }