/// <summary> /// Adapts the WindowCommands to the theme of the first opened, topmost && (top || right || left) flyout /// </summary> /// <param name="window">The MetroWindow</param> /// <param name="flyouts">All the flyouts! Or flyouts that fall into the category described in the summary.</param> /// <param name="resetBrush">An optional brush to reset the window commands brush to.</param> public static void HandleWindowCommandsForFlyouts(this MetroWindow window, IEnumerable <Flyout> flyouts, Brush resetBrush = null) { var allOpenFlyouts = flyouts.Where(x => x.IsOpen); var anyFlyoutOpen = allOpenFlyouts.Any(x => x.Position != Position.Bottom); if (!anyFlyoutOpen) { if (resetBrush == null) { window.ResetAllWindowCommandsBrush(); } else { window.ChangeAllWindowCommandsBrush(resetBrush); } } var topFlyout = allOpenFlyouts .Where(x => x.Position == Position.Top) .OrderByDescending(Panel.GetZIndex) .FirstOrDefault(); if (topFlyout != null) { window.UpdateWindowCommandsForFlyout(topFlyout); } else { var leftFlyout = allOpenFlyouts .Where(x => x.Position == Position.Left) .OrderByDescending(Panel.GetZIndex) .FirstOrDefault(); if (leftFlyout != null) { window.UpdateWindowCommandsForFlyout(leftFlyout); } var rightFlyout = allOpenFlyouts .Where(x => x.Position == Position.Right) .OrderByDescending(Panel.GetZIndex) .FirstOrDefault(); if (rightFlyout != null) { window.UpdateWindowCommandsForFlyout(rightFlyout); } } }
public static void UpdateWindowCommandsForFlyout(this MetroWindow window, Flyout flyout) { window.ChangeAllWindowCommandsBrush(flyout.Foreground, flyout.Position); }
public static void ResetAllWindowCommandsBrush(this MetroWindow window) { window.ChangeAllWindowCommandsBrush(window.OverrideDefaultWindowCommandsBrush); }