private static void OnMenuItemMouseEnter(object sender, MouseEventArgs e)
        {
            var menuItem   = (MenuItem)sender;
            var isTopLevel = menuItem.Role == MenuItemRole.TopLevelHeader || menuItem.Role == MenuItemRole.TopLevelItem;

            var dic              = new Dictionary <DependencyProperty, Brush>();
            var hoverBackground  = isTopLevel ? GetTopLevelItemHoverBackground(menuItem) : GetSubmenuItemHoverBackground(menuItem);
            var hoverForeground  = isTopLevel ? GetTopLevelItemHoverForeground(menuItem) : GetSubmenuItemHoverForeground(menuItem);
            var hoverBorderBrush = isTopLevel ? GetTopLevelItemHoverBorderBrush(menuItem) : GetSubmenuItemHoverBorderBrush(menuItem);

            if (hoverBackground != null)
            {
                dic.Add(MenuItem.BackgroundProperty, hoverBackground);
            }
            if (hoverForeground != null)
            {
                dic.Add(MenuItem.ForegroundProperty, hoverForeground);
            }
            if (hoverBorderBrush != null)
            {
                dic.Add(MenuItem.BorderBrushProperty, hoverBorderBrush);
            }
            if (dic.Any())
            {
                UIElementUtils.BeginStoryboard(menuItem, dic);
            }
        }
        private static void OnMenuItemMouseLeave(object sender, MouseEventArgs e)
        {
            var menuItem   = (MenuItem)sender;
            var isTopLevel = menuItem.Role == MenuItemRole.TopLevelHeader || menuItem.Role == MenuItemRole.TopLevelItem;

            var hoverBackground  = isTopLevel ? GetTopLevelItemHoverBackground(menuItem) : GetSubmenuItemHoverBackground(menuItem);
            var hoverForeground  = isTopLevel ? GetTopLevelItemHoverForeground(menuItem) : GetSubmenuItemHoverForeground(menuItem);
            var hoverBorderBrush = isTopLevel ? GetTopLevelItemHoverBorderBrush(menuItem) : GetSubmenuItemHoverBorderBrush(menuItem);

            var list = new List <DependencyProperty>();

            if (hoverBackground != null)
            {
                list.Add(MenuItem.BackgroundProperty);
            }
            if (hoverForeground != null)
            {
                list.Add(MenuItem.ForegroundProperty);
            }
            if (hoverBorderBrush != null)
            {
                list.Add(MenuItem.BorderBrushProperty);
            }
            if (list.Any())
            {
                UIElementUtils.BeginStoryboard(menuItem, list);
            }
        }
Exemple #3
0
        private static void OnToggleButtonMouseLeave(object sender, RoutedEventArgs e)
        {
            var button           = sender as ToggleButton;
            var hoverBackground  = GetHoverBackground(button);
            var hoverForeground  = GetHoverForeground(button);
            var hoverBorderBrush = GetHoverBorderBrush(button);

            var list = new List <DependencyProperty>();

            if (hoverBackground != null)
            {
                list.Add(ToggleButton.BackgroundProperty);
            }
            if (hoverForeground != null)
            {
                list.Add(ToggleButton.ForegroundProperty);
            }
            if (hoverBorderBrush != null)
            {
                list.Add(ToggleButton.BorderBrushProperty);
            }
            if (list.Any())
            {
                UIElementUtils.BeginStoryboard(button, list);
            }
        }
Exemple #4
0
        private static void OnToggleButtonMouseEnter(object sender, RoutedEventArgs e)
        {
            var button           = sender as ToggleButton;
            var hoverBackground  = GetHoverBackground(button);
            var hoverForeground  = GetHoverForeground(button);
            var hoverBorderBrush = GetHoverBorderBrush(button);

            var dic = new Dictionary <DependencyProperty, Brush>();

            if (hoverBackground != null)
            {
                dic.Add(ToggleButton.BackgroundProperty, hoverBackground);
            }
            if (hoverForeground != null)
            {
                dic.Add(ToggleButton.ForegroundProperty, hoverForeground);
            }
            if (hoverBorderBrush != null)
            {
                dic.Add(ToggleButton.BorderBrushProperty, hoverBorderBrush);
            }
            if (dic.Any())
            {
                UIElementUtils.BeginStoryboard(button, dic);
            }
        }
Exemple #5
0
        private static void OnPasswordBoxLostFocus(object sender, RoutedEventArgs e)
        {
            var passwordBox   = sender as PasswordBox;
            var fcBorderBrush = GetFocusedBorderBrush(passwordBox);
            var fcForeground  = GetFocusedForeground(passwordBox);

            if (fcBorderBrush == null && fcForeground == null)
            {
                return;
            }

            var list = new List <DependencyProperty>();

            if (fcBorderBrush != null)
            {
                list.Add(PasswordBox.BorderBrushProperty);
            }
            if (fcForeground != null)
            {
                list.Add(PasswordBox.ForegroundProperty);
            }

            UIElementUtils.BeginStoryboard(passwordBox, list);
        }
Exemple #6
0
        private static void OnPasswordBoxGotFocus(object sender, RoutedEventArgs e)
        {
            var passwordBox   = sender as PasswordBox;
            var fcBorderBrush = GetFocusedBorderBrush(passwordBox);
            var fcForeground  = GetFocusedForeground(passwordBox);

            if (fcBorderBrush == null && fcForeground == null)
            {
                return;
            }

            var dic = new Dictionary <DependencyProperty, Brush>();

            if (fcBorderBrush != null)
            {
                dic.Add(PasswordBox.BorderBrushProperty, fcBorderBrush);
            }
            if (fcForeground != null)
            {
                dic.Add(PasswordBox.ForegroundProperty, fcForeground);
            }

            UIElementUtils.BeginStoryboard(passwordBox, dic);
        }