private static void Element_Selected(object sender, RoutedEventArgs e) { var element = (FrameworkElement)sender; if (element.GetValue(SelectedShadowColorProperty) is Color selectedShadowColor) { var effect = GetEffect(element); if (effect == null) { effect = new DropShadowEffect() { Color = selectedShadowColor, ShadowDepth = ShadowHelper.GetShadowDepth(element), Direction = ShadowHelper.GetDirection(element), BlurRadius = ShadowHelper.GetBlurRadius(element), Opacity = 0, RenderingBias = ShadowHelper.GetRenderingBias(element), }; AnimationUtil.BeginDoubleAnimation(effect, DropShadowEffect.OpacityProperty, null, ShadowHelper.GetOpacity(element), GlobalSettings.Setting.AnimationDuration); SetEffect(element, effect); } else { AnimationUtil.BeginDoubleAnimation(effect, DropShadowEffect.OpacityProperty, null, ShadowHelper.GetOpacity(element), GlobalSettings.Setting.AnimationDuration); AnimationUtil.BeginColorAnimation(effect, DropShadowEffect.ColorProperty, null, selectedShadowColor, GlobalSettings.Setting.AnimationDuration); } } }
private static void Element_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e) { var element = (FrameworkElement)sender; var properties = new List <DependencyProperty>(); if (!GetHoverBackgroundLock((DependencyObject)sender) && element.GetValue(HoverBackgroundProperty) != null) { properties.Add(BackgroundProperty); } if (!GetHoverForegroundLock((DependencyObject)sender) && element.GetValue(HoverForegroundProperty) != null) { if (element is TextBox || element is PasswordBox) { properties.Add(Control.ForegroundProperty); } else { properties.Add(ForegroundProperty); } } if (!GetHoverBorderBrushLock((DependencyObject)sender) && element.GetValue(HoverBorderBrushProperty) != null) { properties.Add(BorderBrushProperty); } if (element.GetValue(HoverGlyphBrushProperty) != null) { properties.Add(GlyphBrushProperty); } if (element.GetValue(HoverToggleBrushProperty) != null) { properties.Add(ToggleBrushProperty); } if (element.GetValue(HoverRibbonLineBrushProperty) != null) { properties.Add(RibbonLineBrushProperty); } if (properties.Any()) { AnimationUtil.BeginBrushAnimationStoryboard(element, properties); } if (element.GetValue(HoverShadowColorProperty) is Color) { var effect = GetEffect(element); if (effect == null) { return; } var shadowColor = element.GetValue(ShadowColorProperty); if (shadowColor == null) { AnimationUtil.BeginDoubleAnimation(effect, DropShadowEffect.OpacityProperty, null, 0, GlobalSettings.Setting.AnimationDuration); } else { AnimationUtil.BeginColorAnimation(effect, DropShadowEffect.ColorProperty, null, (Color)shadowColor, GlobalSettings.Setting.AnimationDuration); } } }
protected override void OnUnchecked(RoutedEventArgs e) { base.OnUnchecked(e); if (CheckedToggleShadowColor is Color && ToggleShadowColor is Color shadowColor) { AnimationUtil.BeginColorAnimation(this, InternalToggleShadowColorProperty, null, shadowColor, TimeSpan.FromSeconds(0.2)); } }
private static void Element_GotFocus(object sender, RoutedEventArgs e) { var element = (FrameworkElement)sender; var propertyBrushes = new Dictionary <DependencyProperty, Brush>(); if (element.GetValue(FocusedBackgroundProperty) is Brush focusedBackground) { propertyBrushes.Add(BackgroundProperty, focusedBackground); } if (element.GetValue(FocusedForegroundProperty) is Brush focusedForeground) { if (element is TextBox || element is PasswordBox) { propertyBrushes.Add(Control.ForegroundProperty, focusedForeground); } propertyBrushes.Add(ForegroundProperty, focusedForeground); } if (element.GetValue(FocusedBorderBrushProperty) is Brush focusedBorderBrush) { propertyBrushes.Add(BorderBrushProperty, focusedBorderBrush); } if (element.GetValue(FocusedWatermarkBrushProperty) is Brush watermarkBrush) { propertyBrushes.Add(WatermarkBrushProperty, watermarkBrush); } if (propertyBrushes.Any()) { AnimationUtil.BeginBrushAnimationStoryboard(element, propertyBrushes); } if (element.GetValue(FocusedShadowColorProperty) is Color focusedShadowColor) { var effect = GetEffect(element); if (effect == null) { effect = new DropShadowEffect() { Color = focusedShadowColor, ShadowDepth = ShadowHelper.GetShadowDepth(element), Direction = ShadowHelper.GetDirection(element), BlurRadius = ShadowHelper.GetBlurRadius(element), Opacity = 0, RenderingBias = ShadowHelper.GetRenderingBias(element), }; AnimationUtil.BeginDoubleAnimation(effect, DropShadowEffect.OpacityProperty, null, ShadowHelper.GetOpacity(element), GlobalSettings.Setting.AnimationDuration); SetEffect(element, effect); } else { AnimationUtil.BeginDoubleAnimation(effect, DropShadowEffect.OpacityProperty, null, ShadowHelper.GetOpacity(element), GlobalSettings.Setting.AnimationDuration); AnimationUtil.BeginColorAnimation(effect, DropShadowEffect.ColorProperty, null, focusedShadowColor, GlobalSettings.Setting.AnimationDuration); } } }
private static void Element_LostFocus(object sender, RoutedEventArgs e) { var element = (FrameworkElement)sender; var properties = new List <DependencyProperty>(); if (element.GetValue(FocusedBackgroundProperty) != null) { properties.Add(BackgroundProperty); } if (element.GetValue(FocusedForegroundProperty) != null) { if (element is TextBox || element is PasswordBox) { properties.Add(Control.ForegroundProperty); } properties.Add(ForegroundProperty); } if (element.GetValue(FocusedBorderBrushProperty) != null) { properties.Add(BorderBrushProperty); } if (element.GetValue(FocusedWatermarkBrushProperty) != null) { properties.Add(WatermarkBrushProperty); } if (properties.Any()) { AnimationUtil.BeginBrushAnimationStoryboard(element, properties); } if (element.GetValue(FocusedShadowColorProperty) is Color) { var effect = GetEffect(element); if (effect == null) { return; } var shadowColor = element.GetValue(ShadowColorProperty); if (shadowColor == null) { AnimationUtil.BeginDoubleAnimation(effect, DropShadowEffect.OpacityProperty, null, 0, GlobalSettings.Setting.AnimationDuration); } else { AnimationUtil.BeginColorAnimation(effect, DropShadowEffect.ColorProperty, null, (Color)shadowColor, GlobalSettings.Setting.AnimationDuration); } } }
private static void Element_Unselected(object sender, RoutedEventArgs e) { var element = (FrameworkElement)sender; if (element.GetValue(SelectedShadowColorProperty) is Color) { var effect = GetEffect(element); if (effect == null) { return; } var shadowColor = element.GetValue(ShadowColorProperty); if (shadowColor == null) { AnimationUtil.BeginDoubleAnimation(effect, DropShadowEffect.OpacityProperty, null, 0, GlobalSettings.Setting.AnimationDuration); } else { AnimationUtil.BeginColorAnimation(effect, DropShadowEffect.ColorProperty, null, (Color)shadowColor, GlobalSettings.Setting.AnimationDuration); } } }
private static void Element_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e) { var element = (FrameworkElement)sender; var propertyBrushes = new Dictionary <DependencyProperty, Brush>(); if (!GetHoverBackgroundLock((DependencyObject)sender) && element.GetValue(HoverBackgroundProperty) is Brush hoverBackground) { propertyBrushes.Add(BackgroundProperty, hoverBackground); } if (!GetHoverForegroundLock((DependencyObject)sender) && element.GetValue(HoverForegroundProperty) is Brush hoverForeground) { if (element is TextBox || element is PasswordBox) { propertyBrushes.Add(Control.ForegroundProperty, hoverForeground); } else { propertyBrushes.Add(ForegroundProperty, hoverForeground); } } if (!GetHoverBorderBrushLock((DependencyObject)sender) && element.GetValue(HoverBorderBrushProperty) is Brush hoverBorderBrush) { propertyBrushes.Add(BorderBrushProperty, hoverBorderBrush); } if (element.GetValue(HoverGlyphBrushProperty) is Brush hoverGlyphBrush) { propertyBrushes.Add(GlyphBrushProperty, hoverGlyphBrush); } if (element.GetValue(HoverToggleBrushProperty) is Brush hoverToggleBrush) { propertyBrushes.Add(ToggleBrushProperty, hoverToggleBrush); } if (element.GetValue(HoverRibbonLineBrushProperty) is Brush hoverRibbonLineBrush) { propertyBrushes.Add(RibbonLineBrushProperty, hoverRibbonLineBrush); } if (propertyBrushes.Any()) { AnimationUtil.BeginBrushAnimationStoryboard(element, propertyBrushes); } if (element.GetValue(HoverShadowColorProperty) is Color hoverShadowColor) { var effect = GetEffect(element); if (effect == null) { effect = new DropShadowEffect() { Color = hoverShadowColor, ShadowDepth = ShadowHelper.GetShadowDepth(element), Direction = ShadowHelper.GetDirection(element), BlurRadius = ShadowHelper.GetBlurRadius(element), Opacity = 0, RenderingBias = ShadowHelper.GetRenderingBias(element), }; AnimationUtil.BeginDoubleAnimation(effect, DropShadowEffect.OpacityProperty, null, ShadowHelper.GetOpacity(element), GlobalSettings.Setting.AnimationDuration); SetEffect(element, effect); } else { AnimationUtil.BeginDoubleAnimation(effect, DropShadowEffect.OpacityProperty, null, ShadowHelper.GetOpacity(element), GlobalSettings.Setting.AnimationDuration); AnimationUtil.BeginColorAnimation(effect, DropShadowEffect.ColorProperty, null, hoverShadowColor, GlobalSettings.Setting.AnimationDuration); } } }