public static ColorAnimationUsingKeyFrames BlinkAnimation(Color startColor)
        {
            var toRed = new DiscreteColorKeyFrame
            {
                KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(100)),
                Value   = Colors.Red
            };
            var keepRed = new DiscreteColorKeyFrame
            {
                KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(500)),
                Value   = Colors.Red
            };
            var back = new LinearColorKeyFrame
            {
                KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(1500)),
                Value   = startColor
            };

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

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

            return(colorAnimationUsingKeyFrames);
        }
        public static ColorAnimationUsingKeyFrames FreeAnimation(Color startColor)
        {
            // mutued from XAML example at https://docs.microsoft.com/en-us/uwp/api/Windows.UI.Xaml.Media.Animation.ColorAnimation

            var linearColorKeyFrame = new LinearColorKeyFrame
            {
                KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(2000)),
                Value   = Colors.Red
            };
            var discreteColorKeyFrame = new DiscreteColorKeyFrame
            {
                KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(2500)),
                Value   = Colors.Yellow
            };
            var splineColorKeyFrame = new SplineColorKeyFrame
            {
                KeyTime   = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(4500)),
                Value     = startColor,
                KeySpline = new KeySpline {
                    ControlPoint1 = new Point(0.6, 0.0), ControlPoint2 = new Point(0.9, 0.0)
                }
            };

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

            colorKeyFrameCollection.Add(linearColorKeyFrame);
            colorKeyFrameCollection.Add(discreteColorKeyFrame);
            colorKeyFrameCollection.Add(splineColorKeyFrame);

            return(colorAnimationUsingKeyFrames);
        }
Пример #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);
        }
        private void OnListViewContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args)
        {
            if (args.ItemContainer != null && !args.InRecycleQueue && args.Phase == 0)
            {
                var colorAnimation = new ColorAnimationUsingKeyFrames
                {
                    // 'cause the new item comes in with an animation of which duration is about 300s, we add a little delay here to only
                    // animate the color after it appears.
                    BeginTime = TimeSpan.FromMilliseconds(300)
                };
                var keyFrame1 = new LinearColorKeyFrame {
                    KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0)), Value = Colors.White
                };
                var keyFrame2 = new LinearColorKeyFrame {
                    KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(400)), Value = Colors.LightGray
                };
                var keyFrame3 = new LinearColorKeyFrame {
                    KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(1200)), Value = Colors.White
                };
                colorAnimation.KeyFrames.Add(keyFrame1);
                colorAnimation.KeyFrames.Add(keyFrame2);
                colorAnimation.KeyFrames.Add(keyFrame3);

                ListView.Background = new SolidColorBrush(Colors.Transparent);
                Storyboard.SetTarget(colorAnimation, args.ItemContainer);
                Storyboard.SetTargetProperty(colorAnimation, "(Control.Background).(SolidColorBrush.Color)");

                var storyboard = new Storyboard();
                storyboard.Children.Add(colorAnimation);
                storyboard.Begin();
            }
        }
Пример #5
0
        private void ColorAnimation(ListViewItem item)
        {
            var colorAnimation = new ColorAnimationUsingKeyFrames
            {
                BeginTime = TimeSpan.FromMilliseconds(300)
            };
            var keyFrame1 = new LinearColorKeyFrame
            {
                KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0)),
                Value   = Colors.White
            };
            var keyFrame2 = new LinearColorKeyFrame
            {
                KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(400)),
                Value   = Colors.Red
            };
            var keyFrame3 = new LinearColorKeyFrame
            {
                KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(1200)),
                Value   = Colors.White
            };

            colorAnimation.KeyFrames.Add(keyFrame1);
            colorAnimation.KeyFrames.Add(keyFrame2);
            colorAnimation.KeyFrames.Add(keyFrame3);

            Storyboard.SetTarget(colorAnimation, item);
            Storyboard.SetTargetProperty(colorAnimation, "(Control.Background).(SolidColorBrush.Color)");

            var storyboard = new Storyboard();

            storyboard.Children.Add(colorAnimation);
            storyboard.Begin();
        }
Пример #6
0
        /// <summary>
        /// Change the Edges thickness when alligned Vertex pressed
        /// </summary>
        /// <param name="ellipse">The Ellipese pressed</param>
        /// <param name="increase">Variable indicating whether to increase or decrease the thickness</param>
        void ChangeEdgeThickness(VertexControl ellipse, bool increase)
        {
            // Change Edge thickness according to number of aligned Vertices selected
            System.Windows.Shapes.Line line;
            // Iterate through all the edges connected to clicked vertex
            foreach (var item in vertexEdges[ellipse.VertexID])
            {
                // if edge wasn't selected before - add it to list
                if (!(thickerEdges.ContainsKey(item)))
                {
                    thickerEdges.Add(item, new List <string>());
                }

                // get the edge instance on the canvas
                line            = (System.Windows.Shapes.Line)canvas1.FindName(item);
                line.Visibility = Visibility.Collapsed;

                if (increase)
                {
                    // foreach edge holds the two verteces connected to it (as known for now)
                    thickerEdges[item].Add(ellipse.VertexID);

                    #region Story Board
                    SolidColorBrush myAnimatedBrush = new SolidColorBrush();
                    Storyboard      colorStoryboard = new Storyboard();
                    Storyboard.SetTargetProperty(colorStoryboard, new PropertyPath("Color"));//(SolidColorBrush.ColorProperty));
                    Storyboard.SetTarget(colorStoryboard, myAnimatedBrush);
                    ColorAnimationUsingKeyFrames caukf = new ColorAnimationUsingKeyFrames();
                    // caukf.BeginTime = new TimeSpan(0, 0, 0, 0);

                    LinearColorKeyFrame lckf0 = new LinearColorKeyFrame();
                    lckf0.KeyTime = KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 0, 900));
                    lckf0.Value   = Colors.Red;

                    LinearColorKeyFrame lckf1 = new LinearColorKeyFrame();
                    lckf1.KeyTime = KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 0, 1900));
                    lckf1.Value   = Colors.White;

                    LinearColorKeyFrame lckf2 = new LinearColorKeyFrame();
                    lckf2.KeyTime = KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 0, 1900));
                    lckf2.Value   = Colors.Red;

                    LinearColorKeyFrame lckf3 = new LinearColorKeyFrame();
                    lckf3.KeyTime = KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 0, 2300));
                    lckf3.Value   = Colors.White;

                    caukf.KeyFrames.Add(lckf0);
                    caukf.KeyFrames.Add(lckf1);
                    //caukf.KeyFrames.Add(lckf2);
                    //caukf.KeyFrames.Add(lckf3);

                    colorStoryboard.Children.Add(caukf);
                    colorStoryboard.Begin();
                    #endregion

                    line.Stroke = myAnimatedBrush;

                    // increase Edge thickness
                    if (line.StrokeThickness == 4)
                    {
                        line.StrokeThickness += 5;
                    }
                }
                else// The edge's thickness needs to be decreased (the vertex was unselected)
                {
                    // Holds all the thick Edges
                    List <string> EdgeVerticesList = thickerEdges[item];
                    List <string> copy             = new List <string>();

                    if ((line.StrokeThickness > 4))
                    {
                        foreach (string s in EdgeVerticesList)
                        {
                            if (s != ellipse.VertexID)
                            {
                                copy.Add(s);
                            }
                        }

                        thickerEdges[item] = copy;

                        if (copy.Count == 0)
                        {
                            line.StrokeThickness -= 5;
                            // line.Stroke = new SolidColorBrush(Colors.White);
                        }
                    }
                }
                line.Visibility = Visibility.Visible;
            }

            // Check if graph solved correctly
            bool solved_correctly = true;
            foreach (var item in m_line_list)// Iterate on all edges and check thier thickness
            {
                if (item.StrokeThickness <= 4)
                {
                    solved_correctly = false;
                }
            }
            // Write conclusion for graph solution to the DB

            client.SolvedProblemGraphAsync((int)i_storage["userID"], solved_correctly, DateTime.Now);
        }