- 
                Notifications
    You must be signed in to change notification settings 
- Fork 280
GrayscaleEffect
        闫驚鏵(Jinhua  Yan) edited this page Jul 3, 2023 
        ·
        1 revision
      
        <wd:Window.Effect>
        <wd:GrayscaleEffect x:Name="grayscaleEffect" Factor="1"/>
    </wd:Window.Effect>private void Grayscale_Click(object sender, RoutedEventArgs e)
        {
            if(grayscaleEffect.Factor == 1)
            {
                menuItemGrayscale.Header = "关闭灰度";
                Create(0);
            }
               
            else
            {
                menuItemGrayscale.Header = "开启灰度";
                Create(1);
            }
        }
        void Create(double to)
        {
            var sineEase = new SineEase() { EasingMode = EasingMode.EaseOut };
            var doubleAnimation = new DoubleAnimation
            {
                To = to,
                Duration = TimeSpan.FromMilliseconds(1000),
                EasingFunction = sineEase
            };
            grayscaleEffect.BeginAnimation(GrayscaleEffect.FactorProperty, doubleAnimation);
        }