public static ObjectAnimationUsingKeyFrames GetAnimation(ImageSource source, RepeatBehavior repeatBehavior)
 {
     var key = new CacheKey(source, repeatBehavior);
     ObjectAnimationUsingKeyFrames animation;
     _animationCache.TryGetValue(key, out animation);
     return animation;
 }
        public static Storyboard OpacityAnimation(this UIElement element, double beginTimeInSeconds, double durationInSeconds, double fromOpacity, double toOpacity
           , EasingFunctionBase easingFunction = null, Storyboard sb = null, RepeatBehavior? repeatBehavior = null, bool autoReverse = false)
        {
            if (sb == null) sb = new Storyboard();

            Storyboard.SetTarget(sb, element);

            DoubleAnimation opacityAnim = new DoubleAnimation();

            opacityAnim.BeginTime = TimeSpan.FromSeconds(beginTimeInSeconds);
            opacityAnim.From = fromOpacity;
            opacityAnim.To = toOpacity;
            opacityAnim.EasingFunction = easingFunction;

            Storyboard.SetTargetProperty(opacityAnim, new PropertyPath(UIElement.OpacityProperty));
            Storyboard.SetTarget(opacityAnim, element);

            if (repeatBehavior.HasValue)
            {
                opacityAnim.RepeatBehavior = repeatBehavior.Value;
            }

            sb.AutoReverse = autoReverse;
            sb.Children.Add(opacityAnim);

            return sb;
        }
 public static void IncrementReferenceCount(ImageSource source, RepeatBehavior repeatBehavior)
 {
     var cacheKey = new CacheKey(source, repeatBehavior);
     int count;
     _referenceCount.TryGetValue(cacheKey, out count);
     count++;
     _referenceCount[cacheKey] = count;
 }
Example #4
0
		public void Defaults ()
		{
			RepeatBehavior rb = new RepeatBehavior ();
			Assert.IsTrue (rb.HasCount, "HasCount");
			Assert.IsFalse (rb.HasDuration, "HasCount");

			Assert.AreEqual (0.0, rb.Count, "Count");
			Assert.Throws<InvalidOperationException> (delegate {
				Assert.AreEqual (TimeSpan.Zero, rb.Duration, "Duration");
			}, "Duration");

			Assert.AreEqual ("0x", rb.ToString (), "ToString");
		}
 public static void DecrementReferenceCount(ImageSource source, RepeatBehavior repeatBehavior)
 {
     var cacheKey = new CacheKey(source, repeatBehavior);
     int count;
     _referenceCount.TryGetValue(cacheKey, out count);
     if (count > 0)
     {
         count--;
         _referenceCount[cacheKey] = count;
     }
     if (count == 0)
     {
         _animationCache.Remove(cacheKey);
         _referenceCount.Remove(cacheKey);
     }
 }
Example #6
0
 /// <summary>  
 /// Y方向移动动画(需要移动的对象、移动时间、相对控件原始位置的起始位置、相对控件原始位置的结束位置)(提升效率)Timeline.DesiredFrameRateProperty.OverrideMetadata(typeof(Timeline), new FrameworkPropertyMetadata { DefaultValue = 20 });  
 /// </summary>  
 /// <param name="myFrameworkElement">需要移动的对象</param>  
 /// <param name="aTime">移动时间</param>  
 /// <param name="dFrom">相对控件原始位置的-起始位置</param>  
 /// <param name="dTo">相对控件原始位置的-结束位置</param>  
 /// <param name="RBehavior">动画是否循环</param>  
 /// <param name="wind">动画移动所在窗口(推荐this)</param>  
 /// <returns>返回动画对象</returns>  
 public static Storyboard InDouble_Y_Animation(FrameworkElement myFrameworkElement, TimeSpan aTime, double dFrom, double dTo, RepeatBehavior RForever, Window wind)
 {
     myFrameworkElement.RenderTransform = new TranslateTransform();
     DependencyProperty[] propertyChain = new DependencyProperty[]
     {
         DataGrid.RenderTransformProperty,
         TranslateTransform.YProperty
     };
     Storyboard myStoryboard = new Storyboard();
     DoubleAnimation InDoubleAnimation = new DoubleAnimation();
     InDoubleAnimation.From = dFrom;
     InDoubleAnimation.To = dTo;
     InDoubleAnimation.Duration = aTime;
     Storyboard.SetTargetName(InDoubleAnimation, myFrameworkElement.Name);
     Storyboard.SetTargetProperty(InDoubleAnimation, new PropertyPath("(0).(1)", propertyChain));
     myStoryboard.Children.Add(InDoubleAnimation);
     myStoryboard.RepeatBehavior = RForever;
     myStoryboard.Begin(wind);
     return myStoryboard;
 }
        public static Storyboard ScaleAnimation(this UIElement element, double beginTimeInSeconds, double durationInSeconds, double fromScaleX, double fromScaleY, double toScaleX, double toScaleY
            , EasingFunctionBase easingFunction = null, Storyboard sb = null, RepeatBehavior? repeatBehavior = null, bool autoReverse = false)
        {
            if (sb == null) sb = new Storyboard();

            Storyboard.SetTarget(sb, element);

            int? transformGroupIndex;
            string scaleXProp, scaleYProp;

            var scaleTransform = element.FindTransform<ScaleTransform>(out transformGroupIndex);

            if (scaleTransform == null) throw new Exception("No scale transformation found on target element.");

            if (transformGroupIndex.HasValue)
            {
                scaleXProp = "(UIElement.RenderTransform).(TransformGroup.Children)[" + transformGroupIndex + "].(ScaleTransform.ScaleX)";
                scaleYProp = "(UIElement.RenderTransform).(TransformGroup.Children)[" + transformGroupIndex + "].(ScaleTransform.ScaleY)";
            }
            else
            {
                scaleXProp = "(UIElement.RenderTransform).(ScaleTransform.ScaleX)";
                scaleYProp = "(UIElement.RenderTransform).(ScaleTransform.ScaleY)";
            }

            DoubleAnimationUsingKeyFrames scaleXAnim = Util.CreateDoubleAnimationUsingKeyFrames(scaleXProp, beginTimeInSeconds, new AnimationKeyFrame(fromScaleX, 0, easingFunction), new AnimationKeyFrame(toScaleX, durationInSeconds, easingFunction));
            DoubleAnimationUsingKeyFrames scaleYAnim = Util.CreateDoubleAnimationUsingKeyFrames(scaleYProp, beginTimeInSeconds, new AnimationKeyFrame(fromScaleY, 0, easingFunction), new AnimationKeyFrame(toScaleY, durationInSeconds, easingFunction));

            if (repeatBehavior.HasValue)
            {
                scaleXAnim.RepeatBehavior = scaleYAnim.RepeatBehavior = repeatBehavior.Value;
            }
            sb.AutoReverse = autoReverse;

            sb.Children.Add(scaleXAnim);
            sb.Children.Add(scaleYAnim);

            return sb;
        }
Example #8
0
		public void DoubleConstructor ()
		{
			RepeatBehavior rb = new RepeatBehavior (1.0);
			Assert.IsTrue (rb.HasCount, "HasCount");
			Assert.IsFalse (rb.HasDuration, "HasCount");

			Assert.AreEqual (1.0, rb.Count, "Count");
			Assert.Throws<InvalidOperationException> (delegate {
				Assert.AreEqual (TimeSpan.Zero, rb.Duration, "Duration");
			}, "Duration");

			Assert.AreEqual ("1x", rb.ToString (), "ToString");

			Assert.Throws<ArgumentOutOfRangeException> (delegate {
				rb = new RepeatBehavior (-0.1);
			}, "Negative");
			Assert.Throws<ArgumentOutOfRangeException> (delegate {
				rb = new RepeatBehavior (Double.MinValue);
			}, "MinValue");
			Assert.Throws<ArgumentOutOfRangeException> (delegate {
				rb = new RepeatBehavior (Double.NegativeInfinity);
			}, "NegativeInfinity");

			Assert.Throws<ArgumentOutOfRangeException> (delegate {
				rb = new RepeatBehavior (Double.PositiveInfinity);
			}, "PositiveInfinity");
			Assert.Throws<ArgumentOutOfRangeException> (delegate {
				rb = new RepeatBehavior (Double.NaN);
			}, "NaN");

			rb = new RepeatBehavior (Double.MaxValue);
			Assert.IsTrue (rb.HasCount, "HasCount-Max");
			Assert.IsFalse (rb.HasDuration, "HasDuration-Max");
			Assert.AreEqual (Double.MaxValue, rb.Count, "Count-Max");
			Assert.AreEqual ("1.79769313486232E+308x", rb.ToString (), "ToString");
			Assert.IsFalse (rb.Equals (RepeatBehavior.Forever), "Max!=Forever");
		}
Example #9
0
		public void RepeatBehaviorDurationToStringIFormattable ()
		{
			RepeatBehavior rb = new RepeatBehavior (TimeSpan.Zero);
			RepeatBehaviorFormatter.CallCount = 0;
			IFormattable f = (rb as IFormattable);
			Assert.AreEqual ("00:00:00", f.ToString (null, null), "null,null");
			Assert.AreEqual (0, RepeatBehaviorFormatter.CallCount, "CallCount-a");
			Assert.AreEqual ("00:00:00", f.ToString (null, new RepeatBehaviorFormatter ()), "null,RepeatBehaviorFormatter");
			Assert.AreEqual (0, RepeatBehaviorFormatter.CallCount, "CallCount-b");
			Assert.AreEqual ("00:00:00", f.ToString ("e", null), "e,null");
			Assert.AreEqual (0, RepeatBehaviorFormatter.CallCount, "CallCount-c");
			Assert.AreEqual ("00:00:00", f.ToString (String.Empty, new RepeatBehaviorFormatter ()), "Empty,RepeatBehaviorFormatter");
			Assert.AreEqual (0, RepeatBehaviorFormatter.CallCount, "CallCount-d");
		}
Example #10
0
		public void RepeatBehaviorCountToStringIFormattable ()
		{
			RepeatBehavior rb = new RepeatBehavior (Double.MaxValue);
			RepeatBehaviorFormatter.CallCount = 0;
			IFormattable f = (rb as IFormattable);
			Assert.AreEqual ("1.79769313486232E+308x", f.ToString (null, null), "null,null");
			Assert.AreEqual (0, RepeatBehaviorFormatter.CallCount, "CallCount-a");
			Assert.AreEqual ("[1.79769313486232E+308]x", f.ToString (null, new RepeatBehaviorFormatter ()), "null,RepeatBehaviorFormatter");
			Assert.AreEqual (1, RepeatBehaviorFormatter.CallCount, "CallCount-b");
			Assert.AreEqual ("1.797693e+308x", f.ToString ("e", null), "e,null");
			Assert.AreEqual (1, RepeatBehaviorFormatter.CallCount, "CallCount-c");
			Assert.AreEqual ("[1.79769313486232E+308]x", f.ToString (String.Empty, new RepeatBehaviorFormatter ()), "Empty,RepeatBehaviorFormatter");
			Assert.AreEqual (2, RepeatBehaviorFormatter.CallCount, "CallCount-d");
		}
 extern public static bool Equals(RepeatBehavior repeatBehavior1, RepeatBehavior repeatBehavior2);
 /// <summary>
 /// Creates a new MediaTimeline.
 /// </summary>
 /// <param name="beginTime">The value for the BeginTime property</param>
 /// <param name="duration">The value for the Duration property</param>
 /// <param name="repeatBehavior">The value for the RepeatBehavior property</param>
 public MediaTimeline(Nullable<TimeSpan> beginTime, Duration duration, RepeatBehavior repeatBehavior)
     : this()
 {
     BeginTime = beginTime;
     Duration = duration;
     RepeatBehavior = repeatBehavior;
 }
Example #13
0
		protected TimelineGroup (TimeSpan? beginTime, Duration duration, RepeatBehavior repeatBehavior)
			: base (beginTime, duration, repeatBehavior)
		{
		}
 public CacheKey(ImageSource source, RepeatBehavior repeatBehavior)
 {
     _source = source;
     _repeatBehavior = repeatBehavior;
 }
Example #15
0
 public static Storyboard ScaleUniformAnimation(this UIElement element, double beginTimeInSeconds, double durationInSeconds, double fromScale, double toScale, EasingFunctionBase easingFunction = null, Storyboard sb = null, RepeatBehavior? repeatBehavior = null, bool autoReverse = false)
 {
     return element.ScaleAnimation(beginTimeInSeconds, durationInSeconds, fromScale, fromScale, toScale, toScale, easingFunction, sb, repeatBehavior, autoReverse);
 }
Example #16
0
        public static Storyboard XYAnimation(this UIElement element, double beginTimeInSeconds, double durationInSeconds, double? toX = null, double? toY = null
            , EasingFunctionBase easingFunction = null, Storyboard sb = null, RepeatBehavior? repeatBehavior = null, bool autoReverse = false)
        {
            if (sb == null) sb = new Storyboard();

            Storyboard.SetTarget(sb, element);

            int? transformGroupIndex;
            string xProp, yProp;

            var translateTransform = element.FindTransform<TranslateTransform>(out transformGroupIndex);

            if (translateTransform == null) throw new Exception("No translate transformation found on target element.");

            if (transformGroupIndex.HasValue)
            {
                xProp = "(UIElement.RenderTransform).(TransformGroup.Children)[" + transformGroupIndex + "].(TranslateTransform.X)";
                yProp = "(UIElement.RenderTransform).(TransformGroup.Children)[" + transformGroupIndex + "].(TranslateTransform.Y)";
            }
            else
            {
                xProp = "(UIElement.RenderTransform).(TransformGroup.X)";
                yProp = "(UIElement.RenderTransform).(TransformGroup.Y)";
            }

            if (toX.HasValue)
            {
                DoubleAnimation xAnim = new DoubleAnimation();
                sb.Children.Add(xAnim);

                xAnim.BeginTime = TimeSpan.FromSeconds(beginTimeInSeconds);
                xAnim.Duration = TimeSpan.FromSeconds(durationInSeconds);
                xAnim.To = toX.Value;

                Storyboard.SetTargetProperty(xAnim, new PropertyPath(xProp));
                Storyboard.SetTarget(xAnim, element);

                if (repeatBehavior.HasValue)
                {
                    xAnim.RepeatBehavior = repeatBehavior.Value;
                }
            }

            if (toY.HasValue)
            {
                DoubleAnimation yAnim = new DoubleAnimation();
                sb.Children.Add(yAnim);

                yAnim.BeginTime = TimeSpan.FromSeconds(beginTimeInSeconds);
                yAnim.Duration = TimeSpan.FromSeconds(durationInSeconds);
                yAnim.To = toY.Value;

                Storyboard.SetTargetProperty(yAnim, new PropertyPath(yProp));
                Storyboard.SetTarget(yAnim, element);

                if (repeatBehavior.HasValue)
                {
                    yAnim.RepeatBehavior = repeatBehavior.Value;
                }
            }

            sb.AutoReverse = autoReverse;

            return sb;
        }
Example #17
0
 public object ConvertFrom(XamlNamespaces namespaces, Uri sourceUri, object value)
 {
     return(RepeatBehavior.Parse(value.ToString().Trim()));
 }
Example #18
0
 protected TimelineGroup(Nullable <TimeSpan> beginTime, System.Windows.Duration duration, RepeatBehavior repeatBehavior)
 {
 }
 public ParallelTimeline(Nullable <TimeSpan> beginTime, System.Windows.Duration duration, RepeatBehavior repeatBehavior)
 {
 }
 public ParallelTimeline(Nullable<TimeSpan> beginTime, System.Windows.Duration duration, RepeatBehavior repeatBehavior)
 {
 }
 public static void AddAnimation(ImageSource source, RepeatBehavior repeatBehavior, ObjectAnimationUsingKeyFrames animation)
 {
     var key = new CacheKey(source, repeatBehavior);
     _animationCache[key] = animation;
 }
 public static void RemoveAnimation(ImageSource source, RepeatBehavior repeatBehavior, ObjectAnimationUsingKeyFrames animation)
 {
     var key = new CacheKey(source, repeatBehavior);
     _animationCache.Remove(key);
 }
Example #23
0
		public MediaTimeline (TimeSpan? beginTimme, Duration duration, RepeatBehavior repeatBehavior)
		{
		}
Example #24
0
		protected Timeline (Nullable<TimeSpan> beginTime,
				    Duration duration,
				    RepeatBehavior repeatBehavior)
		{
			throw new NotImplementedException ();
		}
Example #25
0
 /// <summary>
 /// Creates a ParallelTimeline with the specified BeginTime, Duration and RepeatBehavior.
 /// </summary>
 /// <param name="beginTime">
 /// The scheduled BeginTime for this ParallelTimeline.
 /// </param>
 /// <param name="duration">
 /// The simple Duration of this ParallelTimeline.
 /// </param>
 /// <param name="repeatBehavior">
 /// The RepeatBehavior for this ParallelTimeline.
 /// </param>
 public ParallelTimeline(TimeSpan?beginTime, Duration duration, RepeatBehavior repeatBehavior)
     : base(beginTime, duration, repeatBehavior)
 {
 }
 protected Timeline(Nullable<TimeSpan> beginTime, System.Windows.Duration duration, RepeatBehavior repeatBehavior)
 {
 }
Example #27
0
 /// <summary>
 /// Creates a TimelineGroup with the specified BeginTime, Duration and RepeatBehavior.
 /// </summary>
 /// <param name="beginTime">
 /// The scheduled BeginTime for this TimelineGroup.
 /// </param>
 /// <param name="duration">
 /// The simple Duration of this TimelineGroup.
 /// </param>
 /// <param name="repeatBehavior">
 /// The RepeatBehavior for this TimelineGroup.
 /// </param>
 protected TimelineGroup(Nullable <TimeSpan> beginTime, Duration duration, RepeatBehavior repeatBehavior)
     : base(beginTime, duration, repeatBehavior)
 {
 }
 extern public bool Equals(RepeatBehavior repeatBehavior);
 /// <summary>
 /// Creates a TimelineGroup with the specified BeginTime, Duration and RepeatBehavior.
 /// </summary>
 /// <param name="beginTime">
 /// The scheduled BeginTime for this TimelineGroup.
 /// </param>
 /// <param name="duration">
 /// The simple Duration of this TimelineGroup.
 /// </param>
 /// <param name="repeatBehavior">
 /// The RepeatBehavior for this TimelineGroup.
 /// </param>
 protected TimelineGroup(Nullable<TimeSpan> beginTime, Duration duration, RepeatBehavior repeatBehavior)
     : base(beginTime, duration, repeatBehavior)
 {
 }
Example #30
0
		public void RepeatBehaviorCountToStringIFormatProvider ()
		{
			RepeatBehavior rb = new RepeatBehavior (2);
			RepeatBehaviorFormatter.CallCount = 0;
			Assert.AreEqual ("2x", rb.ToString (null), "null");
			Assert.AreEqual (0, RepeatBehaviorFormatter.CallCount, "CallCount-a");
			Assert.AreEqual ("[2]x", rb.ToString (new RepeatBehaviorFormatter ()), "RepeatBehaviorFormatter");
			// 1 time: one per double (1), no call for 'x'
			Assert.AreEqual (1, RepeatBehaviorFormatter.CallCount, "CallCount");
		}
Example #31
0
 /// <summary>
 /// Indicates whether the specified RepeatBehaviors are equal to each other.
 /// </summary>
 /// <param name="repeatBehavior1"></param>
 /// <param name="repeatBehavior2"></param>
 /// <returns>true if repeatBehavior1 and repeatBehavior2 are equal; otherwise false.</returns>
 public static bool Equals(RepeatBehavior repeatBehavior1, RepeatBehavior repeatBehavior2)
 {
     return(repeatBehavior1.Equals(repeatBehavior2));
 }
Example #32
0
		public void RepeatBehaviorDurationToStringIFormatProvider ()
		{
			RepeatBehavior rb = new RepeatBehavior (TimeSpan.MaxValue);
			RepeatBehaviorFormatter.CallCount = 0;
			Assert.AreEqual ("10675199.02:48:05.4775807", rb.ToString (null), "null");
			Assert.AreEqual (0, RepeatBehaviorFormatter.CallCount, "CallCount-a");
			Assert.AreEqual ("10675199.02:48:05.4775807", rb.ToString (new RepeatBehaviorFormatter ()), "RepeatBehaviorFormatter");
			// unused
			Assert.AreEqual (0, RepeatBehaviorFormatter.CallCount, "CallCount");
		}
Example #33
0
		public ParallelTimeline (TimeSpan? beginTime, Duration duration, RepeatBehavior repeatBehavior)
			: base (beginTime, duration, repeatBehavior)
		{
		}
Example #34
0
 protected Timeline(Nullable <TimeSpan> beginTime,
                    Duration duration,
                    RepeatBehavior repeatBehavior)
 {
     throw new NotImplementedException();
 }
Example #35
0
        /// <summary>  
        /// 缩放匀速动画 (提升效率)Timeline.DesiredFrameRateProperty.OverrideMetadata(typeof(Timeline), new FrameworkPropertyMetadata { DefaultValue = 20 });  
        /// </summary>  
        /// <param name="sender">缩放控件</param>  
        /// <param name="scaleXF">缩放X开始值</param>  
        /// <param name="scaleXT">缩放X结束值</param>  
        /// <param name="scaleYF">缩放Y开始值</param>  
        /// <param name="scaleYT">缩放Y结束值</param>  
        /// <param name="aTime">动画持续时间</param>  
        /// <param name="RBehavior">动画是否循环</param>  
        /// <param name="wind">动画移动所在窗口(推荐this)</param>  
        /// <returns>返回动画对象</returns>  
        public static Storyboard ScaleTransformAnimation(UIElement sender, double scaleXF, double scaleXT, double scaleYF, double scaleYT, TimeSpan aTime, RepeatBehavior RForever, Window wind)
        {
            DoubleAnimationUsingKeyFrames dba_SacleX = new DoubleAnimationUsingKeyFrames();
            dba_SacleX.KeyFrames.Add(new EasingDoubleKeyFrame(scaleXF, TimeSpan.FromSeconds(0)));
            dba_SacleX.KeyFrames.Add(new EasingDoubleKeyFrame(scaleXT, aTime));

            DoubleAnimationUsingKeyFrames dba_SacleY = new DoubleAnimationUsingKeyFrames();
            dba_SacleY.KeyFrames.Add(new EasingDoubleKeyFrame(scaleYF, TimeSpan.FromSeconds(0)));
            dba_SacleY.KeyFrames.Add(new EasingDoubleKeyFrame(scaleYT, aTime));

            Storyboard mystoryboard = new Storyboard();
            Storyboard.SetTarget(dba_SacleX, sender);
            sender.RenderTransform = new ScaleTransform();
            Storyboard.SetTargetProperty(dba_SacleX, new PropertyPath("(UIElement.RenderTransform).(ScaleTransform.ScaleX)"));
            mystoryboard.Children.Add(dba_SacleX);
            Storyboard.SetTarget(dba_SacleY, sender);
            Storyboard.SetTargetProperty(dba_SacleY, new PropertyPath("(UIElement.RenderTransform).(ScaleTransform.ScaleY)"));
            mystoryboard.Children.Add(dba_SacleY);
            mystoryboard.RepeatBehavior = RForever;
            mystoryboard.Begin(wind);
            return mystoryboard;
        }
Example #36
0
		public void TimeSpanConstructor ()
		{
			RepeatBehavior rb = new RepeatBehavior (TimeSpan.Zero);
			Assert.IsFalse (rb.HasCount, "HasCount");
			Assert.IsTrue (rb.HasDuration, "HasDuration");

			Assert.Throws<InvalidOperationException> (delegate {
				Assert.AreEqual (0, rb.Count, "Count");
			}, "Count");
			Assert.AreEqual (TimeSpan.Zero, rb.Duration, "Duration");

			Assert.AreEqual (TimeSpan.Zero.ToString (), rb.ToString (), "ToString");

			Assert.Throws<ArgumentOutOfRangeException> (delegate {
				rb = new RepeatBehavior (new TimeSpan (-1));
			}, "Negative");
			Assert.Throws<ArgumentOutOfRangeException> (delegate {
				rb = new RepeatBehavior (TimeSpan.MinValue);
			}, "MinValue");

			rb = new RepeatBehavior (TimeSpan.MaxValue);
			Assert.IsFalse (rb.HasCount, "HasCount-Max");
			Assert.IsTrue (rb.HasDuration, "HasDuration-Max");
			Assert.AreEqual (TimeSpan.MaxValue, rb.Duration, "Duration");
			Assert.AreEqual ("10675199.02:48:05.4775807", rb.ToString (), "ToString");
			Assert.IsFalse (rb.Equals (RepeatBehavior.Forever), "Max!=Forever");
		}
Example #37
0
 protected TimelineGroup(TimeSpan?beginTime, Duration duration, RepeatBehavior repeatBehavior)
     : base(beginTime, duration, repeatBehavior)
 {
 }
Example #38
0
        public void UpdateServerStatus( bool online )
        {
            if (online)
            {
                Application.Current.Dispatcher.BeginInvoke((Action) delegate
                {
                    LServerStatus.Content = "Running";
                    UpdateConsole(DateTime.Now.ToString("HH:mm:ss") + " Server - Running");
                    UpdateConsole(DateTime.Now.ToString("HH:mm:ss") + " Server - Listening on Port: " + Server.CurrentServiceHost.Description.Endpoints[0].ListenUri.Port);
                    LServerStatus.Foreground = Brushes.LimeGreen;

                    var myDoubleAnimation = new DoubleAnimation();
                    RegisterName(LServerStatus.Name, LServerStatus);
                    myDoubleAnimation.From = 1.0;
                    myDoubleAnimation.To = 0.0;
                    myDoubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(1));
                    myDoubleAnimation.AutoReverse = true;
                    myDoubleAnimation.RepeatBehavior = RepeatBehavior.Forever;
                    _myStoryboard = new Storyboard();
                    _myStoryboard.Children.Add(myDoubleAnimation);
                    Storyboard.SetTargetName(myDoubleAnimation, LServerStatus.Name);
                    Storyboard.SetTargetProperty(myDoubleAnimation, new PropertyPath(OpacityProperty));
                    _myStoryboard.Begin(this);
                });
            }
            else
            {
                Application.Current.Dispatcher.BeginInvoke((Action) delegate
                {
                    LServerStatus.Content = "Shutdown";
                    LServerStatus.Foreground = Brushes.Red;
                    UpdateConsole(DateTime.Now.ToString("HH:mm:ss") + " Server successfully Shutdown");
                    SwitchServerState();
                    LbUserOnline.Items.Clear();
                    TbChatPane.Clear();
                    var rb = new RepeatBehavior(0);
                    _myStoryboard.RepeatBehavior = rb;
                    _myStoryboard.Begin(this);
                });
            }
        }
Example #39
0
 public static Timeline Repeat(this Timeline timeline, RepeatBehavior repeat)
 {
     timeline.RepeatBehavior = repeat;
     return(timeline);
 }