public static void UpdateWindowCommandsForFlyout(this MetroWindow window, Flyout flyout) { var currentTheme = GetCurrentTheme(window); window.ChangeAllWindowCommandsBrush(window.OverrideDefaultWindowCommandsBrush, currentTheme); window.ChangeAllWindowButtonCommandsBrush(window.OverrideDefaultWindowCommandsBrush ?? flyout.Foreground, currentTheme, flyout.Theme, flyout.Position); }
public static void ResetAllWindowCommandsBrush(this MetroWindow window) { var currentTheme = GetCurrentTheme(window); window.ChangeAllWindowCommandsBrush(window.OverrideDefaultWindowCommandsBrush, currentTheme); window.ChangeAllWindowButtonCommandsBrush(window.OverrideDefaultWindowCommandsBrush, currentTheme); }
public static void UpdateWindowCommandsForFlyout(this MetroWindow window, Flyout flyout) { var currentAppTheme = ThemeManager.DetectTheme(window) ?? (Application.Current.MainWindow is MetroWindow metroWindow ? ThemeManager.DetectTheme(metroWindow) : null) ?? ThemeManager.DetectTheme(Application.Current); window.ChangeAllWindowCommandsBrush(window.OverrideDefaultWindowCommandsBrush, currentAppTheme); window.ChangeAllWindowButtonCommandsBrush(window.OverrideDefaultWindowCommandsBrush ?? flyout.Foreground, currentAppTheme, flyout.Theme, flyout.Position); }
public static void ResetAllWindowCommandsBrush(this MetroWindow window) { var currentAppTheme = ThemeManager.DetectTheme(window) ?? (Application.Current.MainWindow is MetroWindow metroWindow ? ThemeManager.DetectTheme(metroWindow) : null) ?? ThemeManager.DetectTheme(Application.Current); window.ChangeAllWindowCommandsBrush(window.OverrideDefaultWindowCommandsBrush, currentAppTheme); window.ChangeAllWindowButtonCommandsBrush(window.OverrideDefaultWindowCommandsBrush, currentAppTheme); }
public static void ResetAllWindowCommandsBrush(this MetroWindow window) { if (window.OverrideDefaultWindowCommandsBrush == null) { window.InvokeCommandButtons(x => x.ClearValue(Control.ForegroundProperty)); window.WindowButtonCommands.ClearValue(Control.ForegroundProperty); } else { window.ChangeAllWindowCommandsBrush(window.OverrideDefaultWindowCommandsBrush); } }
/// <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); } if (topFlyout == null && leftFlyout != null) { window.ResetAllWindowCommandsBrush(); } var rightFlyout = allOpenFlyouts .Where(x => x.Position == Position.Right) .OrderByDescending(Panel.GetZIndex) .FirstOrDefault(); if (rightFlyout != null) { window.UpdateWindowCommandsForFlyout(rightFlyout); } } }
public static void HandleWindowCommandsForFlyouts(this MetroWindow window, IEnumerable <Flyout> flyouts, Brush resetBrush = null) { IEnumerable <Flyout> flyouts1 = from x in flyouts where x.IsOpen select x; if (!flyouts1.Any <Flyout>((Flyout x) => x.Position != Position.Bottom)) { if (resetBrush != null) { window.ChangeAllWindowCommandsBrush(resetBrush, Position.Top); } else { window.ResetAllWindowCommandsBrush(); } } Flyout flyout = ( from x in flyouts1 where x.Position == Position.Top select x).OrderByDescending <Flyout, int>(new Func <Flyout, int>(Panel.GetZIndex)).FirstOrDefault <Flyout>(); if (flyout != null) { window.UpdateWindowCommandsForFlyout(flyout); return; } Flyout flyout1 = ( from x in flyouts1 where x.Position == Position.Left select x).OrderByDescending <Flyout, int>(new Func <Flyout, int>(Panel.GetZIndex)).FirstOrDefault <Flyout>(); if (flyout1 != null) { window.UpdateWindowCommandsForFlyout(flyout1); } Flyout flyout2 = ( from x in flyouts1 where x.Position == Position.Right select x).OrderByDescending <Flyout, int>(new Func <Flyout, int>(Panel.GetZIndex)).FirstOrDefault <Flyout>(); if (flyout2 != null) { window.UpdateWindowCommandsForFlyout(flyout2); } }
public static void UpdateWindowCommandsForFlyout(this MetroWindow window, Flyout flyout) { Brush brush = null; if (flyout.Theme == FlyoutTheme.Accent) { brush = (Brush)flyout.FindResource("IdealForegroundColorBrush"); } else if (flyout.ActualTheme == Theme.Light) { brush = (Brush)ThemeManager.LightResource["BlackBrush"]; } else if (flyout.ActualTheme == Theme.Dark) { brush = (Brush)ThemeManager.DarkResource["BlackBrush"]; } window.ChangeAllWindowCommandsBrush(brush); }
/// <summary> /// Adapts the WindowCommands to the theme of the first opened, topmost && && (top || right) flyout /// </summary> /// <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 flyout = flyouts .Where(x => x.IsOpen && (x.Position == Position.Right || x.Position == Position.Top)) .OrderByDescending(Panel.GetZIndex) .FirstOrDefault(); if (flyout != null) { window.UpdateWindowCommandsForFlyout(flyout); } else if (resetBrush == null) { window.ResetAllWindowCommandsBrush(); } else { window.ChangeAllWindowCommandsBrush(resetBrush); } }
public static void UpdateWindowCommandsForFlyout(this MetroWindow window, Flyout flyout) { Brush brush = flyout.Foreground; window.ChangeAllWindowCommandsBrush(brush, flyout.Position); }
public static void ResetAllWindowCommandsBrush(this MetroWindow window) { window.ChangeAllWindowCommandsBrush(window.OverrideDefaultWindowCommandsBrush); }