Skip to content

Commit

Permalink
现在在快速切换窗口时可以正常还原笔刷了
Browse files Browse the repository at this point in the history
  • Loading branch information
wherewhere committed Jul 15, 2024
1 parent 6aa72de commit b670500
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
11 changes: 4 additions & 7 deletions MicaForUWP/Media/BackdropBlurBrush.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ namespace MicaForUWP.Media
#endif
public class BackdropBlurBrush : XamlCompositionBrushBase
{
private bool _isForce = true;

private CompositionEffectBrush brush;
private CompositionColorBrush fallback;
private ScalarKeyFrameAnimation tintOpacityFillAnimation;
Expand Down Expand Up @@ -492,9 +494,8 @@ private void SetCompositionFocus(bool isGotFocus)
if (BackgroundSource == BackgroundSource.Backdrop
|| CompositionBrush == null
|| brush == null) { return; }
isGotFocus = isGotFocus && PowerManager.EnergySaverStatus != EnergySaverStatus.On;
tintToFallBackAnimation.SetColorParameter("FallbackColor", FallbackColor);
if (isGotFocus)
if (_isForce = isGotFocus && PowerManager.EnergySaverStatus != EnergySaverStatus.On)
{
CompositionBrush = brush;
tintOpacityFillAnimation.Direction = AnimationDirection.Reverse;
Expand All @@ -514,13 +515,9 @@ private void SetCompositionFocus(bool isGotFocus)
brush.StartAnimation("Arithmetic.Source2Amount", tintOpacityFillAnimation);
brush.StartAnimation("Arithmetic.Source1Amount", hostOpacityZeroAnimation);
brush.StartAnimation("TintColor.Color", tintToFallBackAnimation);
scopedBatch.Completed += (s, a) => CompositionBrush = fallback;
scopedBatch.Completed += (s, a) => { if (!_isForce) { CompositionBrush = fallback; } };
scopedBatch.End();
}
else
{
CompositionBrush = fallback;
}
}
}
}
25 changes: 11 additions & 14 deletions MicaForUWP/Media/BackdropMicaBrush.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ namespace MicaForUWP.Media
#endif
public class BackdropMicaBrush : XamlCompositionBrushBase
{
private bool _isForce = true;

private CompositionEffectBrush brush;
private CompositionColorBrush fallback;
private ScalarKeyFrameAnimation tintOpacityFillAnimation;
Expand Down Expand Up @@ -545,22 +547,21 @@ await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
}
}

private void SetCompositionFocus(bool iIsGotFocus)
private void SetCompositionFocus(bool isGotFocus)
{
if (BackgroundSource == BackgroundSource.Backdrop
|| CompositionBrush == null
|| brush == null) { return; }
iIsGotFocus = iIsGotFocus && PowerManager.EnergySaverStatus != EnergySaverStatus.On;
tintToFallBackAnimation.SetColorParameter("FallbackColor", FallbackColor);
if (iIsGotFocus)
if (_isForce = isGotFocus && PowerManager.EnergySaverStatus != EnergySaverStatus.On)
{
CompositionBrush = brush;
tintOpacityFillAnimation.Direction = AnimationDirection.Reverse;
hostOpacityZeroAnimation.Direction = AnimationDirection.Reverse;
tintToFallBackAnimation.Direction = AnimationDirection.Reverse;
CompositionBrush.StartAnimation("TintOpacity.Opacity", tintOpacityFillAnimation);
CompositionBrush.StartAnimation("LuminosityOpacity.Opacity", hostOpacityZeroAnimation);
CompositionBrush.StartAnimation("TintColor.Color", tintToFallBackAnimation);
brush.StartAnimation("TintOpacity.Opacity", tintOpacityFillAnimation);
brush.StartAnimation("LuminosityOpacity.Opacity", hostOpacityZeroAnimation);
brush.StartAnimation("TintColor.Color", tintToFallBackAnimation);
}
else if (CompositionBrush == brush)
{
Expand All @@ -569,16 +570,12 @@ private void SetCompositionFocus(bool iIsGotFocus)
tintOpacityFillAnimation.Direction = AnimationDirection.Normal;
hostOpacityZeroAnimation.Direction = AnimationDirection.Normal;
tintToFallBackAnimation.Direction = AnimationDirection.Normal;
CompositionBrush.StartAnimation("TintOpacity.Opacity", tintOpacityFillAnimation);
CompositionBrush.StartAnimation("LuminosityOpacity.Opacity", hostOpacityZeroAnimation);
CompositionBrush.StartAnimation("TintColor.Color", tintToFallBackAnimation);
scopedBatch.Completed += (s, a) => CompositionBrush = fallback;
brush.StartAnimation("TintOpacity.Opacity", tintOpacityFillAnimation);
brush.StartAnimation("LuminosityOpacity.Opacity", hostOpacityZeroAnimation);
brush.StartAnimation("TintColor.Color", tintToFallBackAnimation);
scopedBatch.Completed += (s, a) => { if (!_isForce) { CompositionBrush = fallback; } };
scopedBatch.End();
}
else
{
CompositionBrush = fallback;
}
}
}
}

0 comments on commit b670500

Please sign in to comment.