Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }