Exemple #1
0
        private static void ChangeAllWindowButtonCommandsBrush(this MetroWindow window, Brush foregroundBrush, Metro.Theme currentAppTheme, FlyoutTheme flyoutTheme = FlyoutTheme.Adapt, Position position = Position.Top)
        {
            if (position == Position.Right || position == Position.Top)
            {
                if (foregroundBrush == null)
                {
                    window.WindowButtonCommands?.ClearValue(Control.ForegroundProperty);
                }

                // set the theme based on color lightness
                // otherwise set the theme based on current application or window theme
                var theme = currentAppTheme != null && currentAppTheme.Type == ThemeType.Dark
                    ? Theme.Dark
                    : Theme.Light;

                if (flyoutTheme == FlyoutTheme.Light)
                {
                    theme = Theme.Light;
                }
                else if (flyoutTheme == FlyoutTheme.Dark)
                {
                    theme = Theme.Dark;
                }
                else if (flyoutTheme == FlyoutTheme.Inverse)
                {
                    theme = theme == Theme.Light ? Theme.Dark : Theme.Light;
                }

                window.WindowButtonCommands?.SetValue(WindowButtonCommands.ThemeProperty, theme);

                // clear or set the foreground property
                if (foregroundBrush != null)
                {
                    window.WindowButtonCommands?.SetValue(Control.ForegroundProperty, foregroundBrush);
                }
            }
        }
Exemple #2
0
        private static void ChangeAllWindowCommandsBrush(this MetroWindow window, Brush foregroundBrush, Metro.Theme currentAppTheme)
        {
            if (foregroundBrush == null)
            {
                window.LeftWindowCommands?.ClearValue(Control.ForegroundProperty);
                window.RightWindowCommands?.ClearValue(Control.ForegroundProperty);
            }

            // set the theme based on current application or window theme
            var theme = currentAppTheme != null && currentAppTheme.Type == ThemeType.Dark
                ? Theme.Dark
                : Theme.Light;

            // set the theme to light by default
            window.LeftWindowCommands?.SetValue(WindowCommands.ThemeProperty, theme);
            window.RightWindowCommands?.SetValue(WindowCommands.ThemeProperty, theme);

            // clear or set the foreground property
            if (foregroundBrush != null)
            {
                window.LeftWindowCommands?.SetValue(Control.ForegroundProperty, foregroundBrush);
                window.RightWindowCommands?.SetValue(Control.ForegroundProperty, foregroundBrush);
            }
        }