private static void OnRenderFocusedChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) { ListBoxChrome listBoxChrome = (ListBoxChrome)o; listBoxChrome._localResources = (ListBoxChrome.LocalResources)null; listBoxChrome.InvalidateVisual(); }
protected override void OnRender(DrawingContext dc) { Rect bounds = new Rect(0.0, 0.0, this.ActualWidth, this.ActualHeight); Thickness borderThickness = this.BorderThickness; double num1 = borderThickness.Left + borderThickness.Right; double num2 = borderThickness.Top + borderThickness.Bottom; bool flag = borderThickness.Left == 1.0 && borderThickness.Right == 1.0 && borderThickness.Top == 1.0 && borderThickness.Bottom == 1.0; double num3 = num1 != 0.0 || num2 != 0.0 ? 1.0 : 0.0; double num4 = 2.0 * num3; if (bounds.Width > num1 && bounds.Height > num2) { Rect rectangle = new Rect(bounds.Left + borderThickness.Left, bounds.Top + borderThickness.Top, bounds.Width - num1, bounds.Height - num2); Brush background = this.Background; if (background != null) { dc.DrawRectangle(background, (Pen)null, rectangle); } if (bounds.Width > num1 + num4 && bounds.Height > num2 + num4) { rectangle = new Rect(bounds.Left + borderThickness.Left + num3, bounds.Top + borderThickness.Top + num3, bounds.Width - num1 - num4, bounds.Height - num2 - num4); Brush backgroundOverlay = this.BackgroundOverlay; if (backgroundOverlay != null) { dc.DrawRoundedRectangle(backgroundOverlay, (Pen)null, rectangle, 1.0, 1.0); } } } if (num3 <= 0.0 || bounds.Width < num1 || bounds.Height < num2) { return; } if (flag) { Rect rectangle = new Rect(bounds.Left + 0.5, bounds.Top + 0.5, bounds.Width - 1.0, bounds.Height - 1.0); Pen borderPen = ListBoxChrome.GetBorderPen(this.BorderBrush); Pen borderOverlayPen = this.BorderOverlayPen; if (borderPen != null) { dc.DrawRoundedRectangle((Brush)null, borderPen, rectangle, 1.0, 1.0); } if (borderOverlayPen == null) { return; } dc.DrawRoundedRectangle((Brush)null, borderOverlayPen, rectangle, 1.0, 1.0); } else { Geometry borderGeometry = ListBoxChrome.GetBorderGeometry(borderThickness, bounds); if (this.BorderBrush == null) { return; } dc.DrawGeometry(this.BorderBrush, (Pen)null, borderGeometry); } }
private static void OnRenderMouseOverChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) { ListBoxChrome listBoxChrome = (ListBoxChrome)o; if (listBoxChrome.RenderFocused) { return; } if (listBoxChrome.Animates) { if ((bool)e.NewValue) { if (listBoxChrome._localResources == null) { listBoxChrome._localResources = new ListBoxChrome.LocalResources(); listBoxChrome.InvalidateVisual(); } DoubleAnimation doubleAnimation = new DoubleAnimation(1.0, new Duration(TimeSpan.FromSeconds(0.3))); listBoxChrome.BorderOverlayPen.Brush.BeginAnimation(Brush.OpacityProperty, (AnimationTimeline)doubleAnimation); } else if (listBoxChrome._localResources == null) { listBoxChrome.InvalidateVisual(); } else { Duration duration = new Duration(TimeSpan.FromSeconds(0.2)); DoubleAnimation doubleAnimation = new DoubleAnimation(); doubleAnimation.Duration = duration; listBoxChrome.BorderOverlayPen.Brush.BeginAnimation(Brush.OpacityProperty, (AnimationTimeline)doubleAnimation); } } else { listBoxChrome._localResources = (ListBoxChrome.LocalResources)null; listBoxChrome.InvalidateVisual(); } }