public static Timeline EaseAnimation(Color startColor)
        {
            // docs https://docs.microsoft.com/en-us/windows/uwp/graphics/key-frame-and-easing-function-animations#easing-functions

            var toRed = new EasingColorKeyFrame
            {
                KeyTime        = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(500)),
                Value          = Colors.Red,
                EasingFunction = new BounceEase {
                    Bounces = 1, EasingMode = EasingMode.EaseIn
                }
            };
            var back = new EasingColorKeyFrame
            {
                KeyTime        = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(2000)),
                Value          = startColor,
                EasingFunction = new SineEase {
                    EasingMode = EasingMode.EaseIn
                }
            };

            var colorAnimationUsingKeyFrames = new ColorAnimationUsingKeyFrames();
            ColorKeyFrameCollection colorKeyFrameCollection = colorAnimationUsingKeyFrames.KeyFrames;

            colorKeyFrameCollection.Add(toRed);
            colorKeyFrameCollection.Add(back);

            return(colorAnimationUsingKeyFrames);
        }
Пример #2
0
        private void Bd_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Border border = sender as Border;

            //colorAnimation.From = Colors.Transparent;
            //SolidColorBrush color = Application.Current.FindResource("Accent.LightBrush") as SolidColorBrush;
            //_colorAnimation.To = Colors.Transparent;
            //_colorAnimation.Duration = TimeSpan.FromSeconds(0.5);
            //Storyboard storyBoard = new Storyboard();
            //Storyboard.SetTargetName(border, "myColorAnimation");
            //Storyboard.SetTargetProperty(_colorAnimation, new PropertyPath("(Border.Background).(SolidColorBrush.Color)"));
            //storyBoard.Children.Add(_colorAnimation);
            //storyBoard.Begin(border);
            if (Convert.ToBoolean(border.Tag))
            {
                return;
            }


            EasingColorKeyFrame color1 = new EasingColorKeyFrame(_mouseOverColor.Color, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)));
            EasingColorKeyFrame color2 = new EasingColorKeyFrame(_staticBackground.Color, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.3)));

            _caukf.KeyFrames.Add(color1);
            _caukf.KeyFrames.Add(color2);
            Storyboard storyBoard = new Storyboard();

            Storyboard.SetTargetName(border, "myCaukf");
            Storyboard.SetTargetProperty(_caukf, new PropertyPath("(Border.Background).(SolidColorBrush.Color)"));
            storyBoard.Children.Add(_caukf);
            storyBoard.Begin(border);
        }
Пример #3
0
        private static ColorKeyFrame CreateColorKeyFrmas(KeyFrames <Color> Model)
        {
            ColorKeyFrame frame = null;

            switch (Model.Type)
            {
            case KeyFramesType.Spline: frame = new SplineColorKeyFrame()
            {
                    KeySpline = Model.Spline
            }; break;

            case KeyFramesType.Linear: frame = new LinearColorKeyFrame(); break;

            case KeyFramesType.Easing: frame = new EasingColorKeyFrame()
            {
                    EasingFunction = Model.EasingFunction
            }; break;

            case KeyFramesType.Discrete: frame = new DiscreteColorKeyFrame(); break;

            default: break;
            }
            frame.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(Model.KeyTime));
            frame.Value   = Model.Value;
            return(frame);
        }
Пример #4
0
        private void Bd_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
        {
            /*
             * <MultiTrigger>
             *                          <MultiTrigger.Conditions>
             *                              <Condition Property="IsSelected" Value="False"/>
             *                              <Condition Property="IsMouseOver" Value="True"/>
             *                          </MultiTrigger.Conditions>
             *                          <MultiTrigger.EnterActions>
             *                              <BeginStoryboard>
             *                                  <Storyboard >
             *                                      <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="Background.(SolidColorBrush.Color)" Storyboard.TargetName="Bd">
             *
             *                                          <EasingColorKeyFrame KeyTime="0" Value="Transparent"></EasingColorKeyFrame>
             *                                          <EasingColorKeyFrame KeyTime="0:0:1" Value="{Binding Source={StaticResource mouseovercolor} }"></EasingColorKeyFrame>
             *
             *
             *                                      </ColorAnimationUsingKeyFrames>
             *                                  </Storyboard>
             *                              </BeginStoryboard>
             *                          </MultiTrigger.EnterActions>
             *                          <!--<Setter  Property="Background" Value="{StaticResource Item.MouseOver.Background}"></Setter>-->
             *                          <Setter Property="TextElement.Foreground" TargetName="cp" Value="{StaticResource Item.MouseOver.ForegroundColor}"/>
             *                      </MultiTrigger>
             */
            Border border = sender as Border;

            if (Convert.ToBoolean(border.Tag))
            {
                return;
            }
            _mouseOverColor   = _mouseOverColor ?? Application.Current.FindResource("Item.MouseOver.Background") as SolidColorBrush;
            _staticBackground = _staticBackground ?? Application.Current.FindResource("ListBox.Static.Background") as SolidColorBrush;


            //colorAnimation.From = Colors.Transparent;
            //SolidColorBrush color= Application.Current.FindResource("Item.MouseOver.Background") as SolidColorBrush;
            //colorAnimation.To = color.Color;
            //colorAnimation.Duration = TimeSpan.FromSeconds(0.5);
            //Storyboard storyBoard = new Storyboard();
            //Storyboard.SetTargetName(border, "myColorAnimation");
            //Storyboard.SetTargetProperty(colorAnimation, new PropertyPath("(Border.Background).(SolidColorBrush.Color)"));
            //storyBoard.Children.Add(colorAnimation);
            //storyBoard.Begin(border);


            EasingColorKeyFrame color1 = new EasingColorKeyFrame(_staticBackground.Color, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)));
            EasingColorKeyFrame color2 = new EasingColorKeyFrame(_mouseOverColor.Color, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.3)));

            _caukf.KeyFrames.Add(color1);
            _caukf.KeyFrames.Add(color2);
            Storyboard storyBoard = new Storyboard();

            Storyboard.SetTargetName(border, "myCaukf");
            Storyboard.SetTargetProperty(_caukf, new PropertyPath("(Border.Background).(SolidColorBrush.Color)"));
            storyBoard.Children.Add(_caukf);
            storyBoard.Begin(border);
        }
Пример #5
0
        public override void CreateStoryboard()
        {
            ColorAnimationUsingKeyFrames dau = new ColorAnimationUsingKeyFrames();

            EasingColorKeyFrame fromk = null;

            if (FromColor.HasValue)
            {
                fromk = new EasingColorKeyFrame(FromColor.Value, TimeSpan.FromMilliseconds(AniTime(0)));
                dau.KeyFrames.Add(fromk);
            }

            EasingColorKeyFrame tok = null;

            if (ToColor.HasValue)
            {
                tok = new EasingColorKeyFrame(ToColor.Value, TimeSpan.FromMilliseconds(AniTime(1)));
                dau.KeyFrames.Add(tok);
            }


            if (AniEasingFunction != null)
            {
                if (fromk != null)
                {
                    fromk.EasingFunction = AniEasingFunction;
                }
                if (tok != null)
                {
                    tok.EasingFunction = AniEasingFunction;
                }
            }
            else if (CirDefault != null)
            {
                if (fromk != null)
                {
                    fromk.EasingFunction = CirDefault;
                }
                if (tok != null)
                {
                    tok.EasingFunction = CirDefault;
                }
            }

            //Storyboard.SetTargetName(dau, ElementName);
            Storyboard.SetTarget(dau, Element);
            Storyboard.SetTargetProperty(dau, AniPropertyPath);
            Story.Children.Add(dau);
        }
Пример #6
0
        public void addColorAnimation(String control, Color value, int duration)
        {
            ColorAnimationUsingKeyFrames anim = new ColorAnimationUsingKeyFrames();
            EasingColorKeyFrame          eckf = new EasingColorKeyFrame();

            eckf.Value     = value;
            eckf.KeyTime   = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(duration));
            anim.BeginTime = TimeSpan.FromSeconds(beginTime);
            beginTime     += duration;
            if (duration > 0)
            {
                animTimer.Add(beginTime);
            }
            Storyboard.SetTargetName(anim, control);
            Storyboard.SetTargetProperty(anim, new PropertyPath(SolidColorBrush.ColorProperty));
            sb.Children.Add(anim);
        }
        public static ColorAnimationUsingKeyFrames AddEasingKeyFrame(
            this ColorAnimationUsingKeyFrames animation,
            double seconds, Color value,
            EasingFunctionBase easingFunction = null)
        {
            var keyFrame = new EasingColorKeyFrame
            {
                KeyTime        = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(seconds)),
                Value          = value,
                EasingFunction = easingFunction
            };

            animation.KeyFrames.Add(keyFrame);
#if NETFX_CORE || WINDOWS_81_PORTABLE
            animation.EnableDependentAnimation = true;
#endif
            return(animation);
        }
        /// <summary>
        /// Called when the control template is applied.
        /// </summary>
        public override void OnApplyTemplate()
        {
            PART_FindTextBox         = GetTemplateChild("PART_FindTextBox") as TextBox;
            PART_ReplaceTextBox      = GetTemplateChild("PART_ReplaceTextBox") as TextBox;
            PART_FindButton          = GetTemplateChild("PART_FindButton") as Button;
            PART_PreviousMatchButton = GetTemplateChild("PART_PreviousMatchButton") as Button;
            PART_ReplaceButton       = GetTemplateChild("PART_ReplaceButton") as Button;
            PART_ReplaceAllButton    = GetTemplateChild("PART_ReplaceAllButton") as Button;
            PART_NextMatchButton     = GetTemplateChild("PART_NextMatchButton") as Button;
            PART_OptionsButton       = GetTemplateChild("PART_OptionsButton") as ToggleButton;
            PART_OptionsList         = GetTemplateChild("PART_OptionsList") as ListView;
            PART_HistoryList         = GetTemplateChild("PART_HistoryList") as ListView;
            PART_OptionsPopup        = GetTemplateChild("PART_OptionsPopup") as Popup;

            if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))//Blend uses a StandinPopup class so PART_OptionsPopup will be null
            {
                PART_OptionsPopup.CustomPopupPlacementCallback += (Size popupSize, Size targetSize, Point offset) =>
                                                                  new[] { new CustomPopupPlacement()
                                                                          {
                                                                              Point = new Point(targetSize.Width - popupSize.Width, targetSize.Height)
                                                                          } }
            }
            ;

            easingColorKeyFrameEnd = GetTemplateChild("PART_EasingColorKeyFrameEnd") as EasingColorKeyFrame;
            if (easingColorKeyFrameEnd != null)
            {
                easingColorKeyFrameEnd.Value = NoHitsBorderBrushColor;
            }
            //UpdateStates(false);
            VisualStateManager.GoToState(this, "NoQuery", false);
            VisualStateManager.GoToState(this, "Blur_NoQuery", true);



            base.OnApplyTemplate();
        }