Exemplo n.º 1
0
 private void UpdatePendingAnimationDurations(System.Windows.Duration duration)
 {
     foreach (var item in scrollStepQueue)
     {
         item.Duration = duration;
     }
 }
Exemplo n.º 2
0
        public void AnimateHeader(Color First, Color Second, Double DurationSecs = 0.3)
        {
            var duration        = new Duration(TimeSpan.FromSeconds(DurationSecs));
            var firstAnimation  = new ColorAnimation();
            var secondAnimation = new ColorAnimation();

            var sb = new Storyboard();

            sb.Children.Add(firstAnimation);
            sb.Children.Add(secondAnimation);
            firstAnimation.Duration        = duration;
            firstAnimation.To              = First;
            firstAnimation.RepeatBehavior  = new RepeatBehavior(1);
            secondAnimation.Duration       = duration;
            secondAnimation.To             = Second;
            secondAnimation.RepeatBehavior = new RepeatBehavior(1);

            Storyboard.SetTarget(firstAnimation, xHeader);
            Storyboard.SetTargetProperty(firstAnimation, new PropertyPath("Foreground.(GradientBrush.GradientStops)[0].(GradientStop.Color)"));
            Storyboard.SetTarget(secondAnimation, xHeader);
            Storyboard.SetTargetProperty(secondAnimation, new PropertyPath("Foreground.(GradientBrush.GradientStops)[1].(GradientStop.Color)"));
            var rsName = RandomResourceKey();

            Resources.Add(rsName, sb);
            sb.Completed += (o, s) => { Resources.Remove(rsName); };
            sb.Begin();
        }
 /// <summary>
 /// Create animation with duration
 /// </summary>
 /// <param name="Duration">Duration of animation</param>
 public FadeAnimate(System.Windows.Duration Duration)
     : base()
 {
     this.From     = From;
     this.To       = To;
     this.Duration = Duration;
 }
Exemplo n.º 4
0
		public static int Compare (Duration t1,
					   Duration t2)
		{
			if (t1.durationType == DurationType.Forever) {
				return (t2.durationType == DurationType.Forever ? 0 : -1);
			}
			else if (t1.durationType == DurationType.Automatic) {
			}
			else if (t1.durationType == DurationType.Timespan) {
				
			}
			

			switch (t1.durationType) {
			case DurationType.Forever:
			case DurationType.Automatic:
			case DurationType.Timespan:
				break;
			}

			if (t1.IsForever && t2.IsForever)
				return 0;
			else if (t1.IsAutomatic && t2.IsAutomatic)
				return 0;
			else
				return (int)(t2.TimeSpan - t1.TimeSpan).Ticks;
		}
Exemplo n.º 5
0
		public Duration Add (Duration duration)
		{
			if (duration.IsForever || this.IsForever)
				return new Duration (DurationType.Forever);
			else if (duration.IsAutomatic || this.IsAutomatic)
				return new Duration (DurationType.Automatic);
			else
				return new Duration (timeSpan + duration.timeSpan);
		}
Exemplo n.º 6
0
 /// <summary>
 /// Create a new Track record
 /// </summary>
 /// <param name="trackNumber"></param>
 /// <param name="trackLength"></param>
 /// <param name="album"></param>
 /// <param name="artists"></param>
 /// <param name="title"></param>
 /// <param name="fileName"></param>
 public Track(int trackNumber, IList<Artist> artists, Album album, Duration trackLength, string title,
              string fileName)
 {
     TrackNumber = trackNumber;
     Artists = artists;
     Album = album;
     TrackLength = trackLength;
     Title = title;
     FileName = fileName;
 }
Exemplo n.º 7
0
 public ReportField()
 {
     // This object supports the animation of values as columns are modified.  Since the animation takes a finite amount of
     // time to transition from one value to another, the commands to modify this object are queued up and handled in the
     // order in which they were recieved.
     this.commandTable = new Dictionary <IAnimatable, Queue <CommandArgumentPair> >();
     this.animationMap = new Dictionary <AnimationClock, IAnimatable>();
     this.duration     = new Duration(TimeSpan.FromMilliseconds(ReportField.defaultDuration));
     this.typeList     = new List <Type>();
 }
Exemplo n.º 8
0
 private void timer_Tick(object sender, EventArgs e)
 {
     if (_player.Source != null)
     {
         System.Windows.Duration duration = _player.NaturalDuration;
         txtEllapsedTime.Text = _player.Position.ToString(@"hh\:mm\:ss");;
         TimeSpan ts;
         if (duration.HasTimeSpan)
         {
             ts = _player.NaturalDuration.TimeSpan;
             double   total   = ts.TotalSeconds;
             TimeSpan now     = _player.Position;
             double   current = now.TotalSeconds;
             double   percent = ((current * sliderProgress.Maximum / total));
             if (!isDragging)
             {
                 sliderProgress.Value = percent;
             }
         }
     }
 }
Exemplo n.º 9
0
        public void SetVerticalOffset(double offset)
        {
            ScrollDirection direction = DoubleUtil.GreaterThan(VerticalOffset, offset) ? ScrollDirection.Down : ScrollDirection.Up;

            // if we are chaging the direction of scroll, remove all queued animations and stop current anim
            if (scrollStepQueue.Count > 0 && scrollStepQueue.Peek().Direction != direction)
            {
                scrollStepQueue.Clear();
                //StopCurrentScrollAnimation(); // this doesn't look good
            }

            var duration = new System.Windows.Duration(TimeSpan.FromMilliseconds((double)500 / Math.Max(1, Math.Min(scrollStepQueue.Count, 3))));

            UpdatePendingAnimationDurations(duration);
            Debug.WriteLine($"{scrollStepQueue.Count}, {duration.TimeSpan}");
            scrollStepQueue.Enqueue(new ScrollStep()
            {
                Offset    = scrollLine * (int)direction,
                Direction = direction,
                Duration  = duration
            });

            ExecuteNextAnimationInQueue();
        }
Exemplo n.º 10
0
 /// <summary>
 /// Returns the specified instance of Duration.
 /// </summary>
 /// <param name="duration"></param>
 /// <returns>Returns duration.</returns>
 public static Duration Plus(Duration duration)
 {
     return(duration);
 }
Exemplo n.º 11
0
 /// <summary>
 /// Indicates whether the specified Durations are equal.
 /// </summary>
 /// <param name="t1"></param>
 /// <param name="t2"></param>
 /// <returns>true if t1 equals t2; otherwise false.</returns>
 public static bool Equals(Duration t1, Duration t2)
 {
     return(t1.Equals(t2));
 }
Exemplo n.º 12
0
 public FadeAnimationStrategy(Duration duration)
 {
     _duration = duration;
 }
Exemplo n.º 13
0
 /// <summary>
 /// Indicates whether the specified Durations are equal.
 /// </summary>
 /// <param name="t1"></param>
 /// <param name="t2"></param>
 /// <returns>true if t1 equals t2; otherwise false.</returns>
 public static bool Equals(Duration t1, Duration t2)
 {
     return t1.Equals(t2);
 }
Exemplo n.º 14
0
 /// <summary>
 /// Subtracts the specified Duration from this instance. 
 /// </summary>
 /// <param name="duration"></param>
 /// <returns>A Duration whose value is the result of the value of this instance minus the value of duration.</returns>
 public Duration Subtract(Duration duration)
 {
     return this - duration;
 }
Exemplo n.º 15
0
 /// <summary>
 /// Adds the specified Duration to this instance.
 /// </summary>
 /// <param name="duration"></param>
 /// <returns>A Duration that represents the value of this instance plus the value of duration.</returns>
 public Duration Add(Duration duration)
 {
     return this + duration;
 }
Exemplo n.º 16
0
 /// <summary>
 /// Indicates whether the specified Duration is equal to this Duration.
 /// </summary>
 /// <param name="duration"></param>
 /// <returns>true if duration is equal to this instance; otherwise false.</returns>
 public bool Equals(Duration duration)
 {
     if (HasTimeSpan)
     {
         if (duration.HasTimeSpan)
         {
             return _timeSpan == duration._timeSpan;
         }
         else
         {
             return false;
         }
     }
     else
     {
         return _durationType == duration._durationType;
     }
 }
Exemplo n.º 17
0
        /// <summary>
        /// Compares one Duration value to another.
        /// </summary>
        /// <param name="t1"></param>
        /// <param name="t2"></param>
        /// <returns>
        /// A negative value, zero or a positive value, respectively, if t1 is
        /// less than, equal or greater than t2.
        /// 
        /// Duration.Automatic is a special case and has the following return values:
        /// 
        ///  -1 if t1 is Automatic and t2 is not Automatic
        ///   0 if t1 and t2 are Automatic
        ///   1 if t1 is not Automatic and t2 is Automatic
        /// 
        /// This mirrors Double.CompareTo()'s treatment of Double.NaN
        /// </returns>
        public static int Compare(Duration t1, Duration t2)
        {

            if (t1._durationType == DurationType.Automatic)
            {
                if (t2._durationType == DurationType.Automatic)
                {
                    return 0;
                }
                else
                {
                    return -1;
                }
            }
            else if (t2._durationType == DurationType.Automatic)
            {
                return 1;
            }
            else // Neither are Automatic, do a standard comparison
            {
                if (t1 < t2)
                {
                    return -1;
                }
                else if (t1 > t2)
                {
                    return 1;
                }
                else  // Neither is greater than the other
                {
                    return 0;
                }
            }
        }
Exemplo n.º 18
0
 /// <summary>
 /// Returns the specified instance of Duration.
 /// </summary>
 /// <param name="duration"></param>
 /// <returns>Returns duration.</returns>
 public static Duration Plus(Duration duration)
 {
     return duration;
 }
 public SlideAnimationStrategy()
 {
     _duration = 500.MilliSeconds();
 }
Exemplo n.º 20
0
 /// <summary>
 /// Subtracts the specified Duration from this instance.
 /// </summary>
 /// <param name="duration"></param>
 /// <returns>A Duration whose value is the result of the value of this instance minus the value of duration.</returns>
 public Duration Subtract(Duration duration)
 {
     return(this - duration);
 }
Exemplo n.º 21
0
		public static bool Equals (Duration t1,
					   Duration t2)
		{
			throw new NotImplementedException ();
		}
Exemplo n.º 22
0
 /// <summary>
 /// Adds the specified Duration to this instance.
 /// </summary>
 /// <param name="duration"></param>
 /// <returns>A Duration that represents the value of this instance plus the value of duration.</returns>
 public Duration Add(Duration duration)
 {
     return(this + duration);
 }
Exemplo n.º 23
0
		public static Duration Plus (Duration duration)
		{
			throw new NotImplementedException ();
		}
Exemplo n.º 24
0
 protected virtual void OnDurationChanged(Duration oldDuration, Duration newDuration)
 {
 }
Exemplo n.º 25
0
		public bool Equals (Duration duration)
		{
			throw new NotImplementedException ();
		}