public static Task<BrushAnimator> CreateAsync(Uri sourceUri, RepeatBehavior repeatBehavior, IProgress<int> progress = null) { return CreateAsyncCore( sourceUri, progress, (stream, metadata) => new BrushAnimator(stream, sourceUri, metadata, repeatBehavior)); }
public static Task<ImageAnimator> CreateAsync(Uri sourceUri, RepeatBehavior repeatBehavior, IProgress<int> progress, Image image) { return CreateAsyncCore( sourceUri, progress, (stream, metadata) => new ImageAnimator(stream, sourceUri, metadata, repeatBehavior, image)); }
internal static async Task<Animator> CreateAsync(Image image, Uri sourceUri, RepeatBehavior repeatBehavior = default(RepeatBehavior)) { var loader = new UriLoader(); var stream = await loader.GetStreamFromUriAsync(sourceUri); try { return await CreateAsync(stream, sourceUri, repeatBehavior, image); } catch { stream?.Dispose(); throw; } }
private Animator(Stream sourceStream, Uri sourceUri, GifDataStream metadata, RepeatBehavior repeatBehavior, Image image) { _sourceStream = sourceStream; _sourceUri = sourceUri; _metadata = metadata; _image = image; _palettes = CreatePalettes(metadata); _bitmap = CreateBitmap(metadata); var desc = metadata.Header.LogicalScreenDescriptor; _stride = 4 * ((desc.Width * 32 + 31) / 32); _previousBackBuffer = new byte[desc.Height * _stride]; _indexStreamBuffer = CreateIndexStreamBuffer(metadata, _sourceStream); _timingManager = CreateTimingManager(metadata, repeatBehavior); }
/// <summary> /// Indicates whether the two specified Windows.UI.Xaml.Media.Animation.RepeatBehavior /// values are equal. /// </summary> /// <param name="repeatBehavior1">The first value to compare.</param> /// <param name="repeatBehavior2">The second value to compare.</param> /// <returns> /// true if both the type and repeat behavior of repeatBehavior1 are equal to /// that of repeatBehavior2; otherwise, false. /// </returns> public static bool Equals(RepeatBehavior repeatBehavior1, RepeatBehavior repeatBehavior2) { return(repeatBehavior1 == repeatBehavior2); }
public static Task <ImageAnimator> CreateAsync(Stream sourceStream, RepeatBehavior repeatBehavior, Image image) { return(CreateAsyncCore( sourceStream, metadata => new ImageAnimator(sourceStream, null, metadata, repeatBehavior, image))); }
private static async Task<Animator> CreateAsync(Stream sourceStream, Uri sourceUri, RepeatBehavior repeatBehavior, Image image) { var stream = sourceStream.AsBuffered(); var metadata = await GifDataStream.ReadAsync(stream); return new Animator(stream, sourceUri, metadata, repeatBehavior, image); }
public TimingManager(RepeatBehavior repeatBehavior) { RepeatBehavior = repeatBehavior; }
public static void AddClock(ImageSource source, RepeatBehavior repeatBehavior, AnimationClock clock) { var key = new CacheKey(source, repeatBehavior); _clockCache[key] = clock; }
public ParallelTimeline(Nullable <TimeSpan> beginTime, Duration duration, RepeatBehavior repeatBehavior) : base(beginTime, duration, repeatBehavior) { }
public bool Equals (RepeatBehavior repeatBehavior) { return Equals (this, repeatBehavior); }
public bool Equals(RepeatBehavior repeatBehavior);
internal MultiplyFrameImageExDisplaySource(ImageExSource source, RepeatBehavior repeatBehavior, double speedRatio) { if (source == null) { throw new ArgumentNullException(nameof(source)); } _frames = source.Frames; if (_frames == null || _frames.Length <= 1) { throw new ArgumentException("This source is a single frame source."); } Width = source.Width; Height = source.Height; _animationFrameBridge = new AnimationBridge <SKBitmap>(); _animationFrameBridge.ValueChanged += AnimationFrameBridge_ValueChanged; var storyboard = new Storyboard(); var animation = new ObjectAnimationUsingKeyFrames { SpeedRatio = speedRatio }; if (repeatBehavior == default) { var repetitionCount = source.RepetitionCount; if (repetitionCount == -1) { animation.RepeatBehavior = RepeatBehavior.Forever; } else if (repetitionCount > 0) { animation.RepeatBehavior = new RepeatBehavior(repetitionCount); } } else { animation.RepeatBehavior = repeatBehavior; } var frameCount = _frames.Length; var totalDuration = 0; for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) { var frame = _frames[frameIndex]; var bitmap = frame.Bitmap; var duration = frame.Duration; animation.KeyFrames.Add(new DiscreteObjectKeyFrame { Value = bitmap, KeyTime = TimeSpan.FromMilliseconds(totalDuration) }); totalDuration += duration; } animation.Duration = TimeSpan.FromMilliseconds(totalDuration); Storyboard.SetTarget(animation, _animationFrameBridge); Storyboard.SetTargetProperty(animation, nameof(_animationFrameBridge.Value)); storyboard.Children.Add(animation); _animation = animation; _storyboard = storyboard; }
public IAnimation SetRepeatBehavior(RepeatBehavior repeatBehavior) { RepeatBehavior = repeatBehavior; return(this); }
protected Timeline(Nullable <TimeSpan> beginTime, Duration duration, RepeatBehavior repeatBehavior) { _beginTime = beginTime; _duration = duration; _repeatBehavior = repeatBehavior; }
internal static Task <Animator> CreateAsync(Image image, Stream sourceStream, RepeatBehavior repeatBehavior = default(RepeatBehavior)) { return(Animator.CreateAsync(sourceStream, null, repeatBehavior, image)); }
internal static async Task <Animator> CreateAsync(Image image, Uri sourceUri, CancellationToken cancellationToken, RepeatBehavior repeatBehavior = default(RepeatBehavior)) { UriLoader loader = new UriLoader(); // ISSUE: reference to a compiler-generated field loader.DownloadProgressChanged += Animator.DownloadProgressChanged; try { Stream stream = await loader.GetStreamFromUriAsync(sourceUri, cancellationToken); try { return(await Animator.CreateAsync(stream, sourceUri, repeatBehavior, image)); } catch { Stream stream1 = stream; if (stream1 != null) { // ISSUE: explicit non-virtual call stream1.Dispose(); } throw; } } catch (TaskCanceledException) { } // ISSUE: reference to a compiler-generated field loader.DownloadProgressChanged -= Animator.DownloadProgressChanged; return(null); }
private BrushAnimator(Stream sourceStream, Uri sourceUri, GifDataStream metadata, RepeatBehavior repeatBehavior) : base(sourceStream, sourceUri, metadata, repeatBehavior) { Brush = new ImageBrush { ImageSource = Bitmap }; }
private static async void InitAnimationAsync(Image image, Stream stream, RepeatBehavior repeatBehavior, int seqNum) { if (!CheckDesignMode(image, null, stream)) return; try { var animator = await ImageAnimator.CreateAsync(stream, repeatBehavior, image); await SetAnimatorCoreAsync(image, animator); // Check that the source hasn't changed while we were loading the animation if (GetSeqNum(image) != seqNum) { animator.Dispose(); return; } OnLoaded(image); } catch (InvalidSignatureException) { var bmp = new BitmapImage(); #if WPF bmp.BeginInit(); bmp.StreamSource = stream; bmp.EndInit(); #elif WINRT bmp.SetSource(stream.AsRandomAccessStream()); #elif SILVERLIGHT bmp.SetSource(stream); #endif image.Source = bmp; OnLoaded(image); } catch(Exception ex) { OnError(image, ex, AnimationErrorKind.Loading); } }
public static bool Equals(RepeatBehavior repeatBehavior1, RepeatBehavior repeatBehavior2);
public GUIAnimation(GUIAnimation a) : base(a._parentControlId, a._controlId, a._positionX, a._positionY, a._width, a._height) { _animating = false; _isFirstRender = true; _iterationCount = 0; _startTick = 0; _hidePngAnimations = false; _triggerList = a._triggerList.GetRange(0, a._triggerList.Count); _easing = a._easing; _fillBehavior = a._fillBehavior; _horizontalAlignment = a._horizontalAlignment; _textureNames = a._textureNames; _rate = a._rate; _duration = a._duration; _repeatBehavior = a._repeatBehavior; _verticalAlignment = a._verticalAlignment; _triggerNames = a._triggerNames; InitTriggerList(); }
public static Storyboard CreateTranslateAnimation(DependencyObject dependencyObject, TranslateAxes axis, double defaultValue, double startValue, double endValue, EasingFunctionBase easingFunctionIn, EasingFunctionBase easingFunctionOut, double duration, double staggerDelay, bool autoReverse, bool repeatForever, RepeatBehavior repeatBehavior) { if (null == dependencyObject) { return(null); } // total duration double totalDuration = duration + staggerDelay; // create the storyboard Storyboard storyboard = new Storyboard() { Duration = TimeSpan.FromMilliseconds(totalDuration), AutoReverse = autoReverse, RepeatBehavior = (repeatForever) ? RepeatBehavior.Forever : repeatBehavior }; // need a translate transform to animate TranslateTransform translateTransform = FindOrCreateTranslateTransform(dependencyObject); if (null != translateTransform) { // set the default value for the transform translateTransform.X = (TranslateAxes.Horizontal == axis) ? defaultValue : 0; translateTransform.Y = (TranslateAxes.Vertical == axis) ? defaultValue : 0; // create default easing CubicEase easeIn = new CubicEase() { EasingMode = EasingMode.EaseIn }; CubicEase easeOut = new CubicEase() { EasingMode = EasingMode.EaseOut }; string propertyName = (TranslateAxes.Horizontal == axis) ? "X" : "Y"; DoubleAnimationUsingKeyFrames daKeyFrames = CreateEasingKeyFrames(translateTransform, propertyName, defaultValue, startValue, endValue, easeIn, easeOut, duration, staggerDelay); storyboard.Children.Add(daKeyFrames); Storyboard.SetTarget(daKeyFrames, translateTransform); Storyboard.SetTargetProperty(daKeyFrames, propertyName); } return(storyboard); }
public ImageAnimator(Stream sourceStream, Uri sourceUri, GifDataStream metadata, RepeatBehavior repeatBehavior, Image image) : base(sourceStream, sourceUri, metadata, repeatBehavior) { ErrorSource = image; }
public static Storyboard CreateEasingAnimation(DependencyObject dependencyObject, string propertyName, double defaultValue, double startValue, double endValue, double duration, double staggerDelay, bool autoReverse, bool repeatForever, RepeatBehavior repeatBehavior) { // create default easing CubicEase easeIn = new CubicEase() { EasingMode = EasingMode.EaseIn }; CubicEase easeOut = new CubicEase() { EasingMode = EasingMode.EaseOut }; return(CreateEasingAnimation(dependencyObject, propertyName, defaultValue, startValue, endValue, easeIn, easeOut, duration, staggerDelay, autoReverse, repeatForever, repeatBehavior)); }
internal static Task<Animator> CreateAsync(Image image, Stream sourceStream, RepeatBehavior repeatBehavior = default(RepeatBehavior)) { return CreateAsync(sourceStream, null, repeatBehavior, image); }
public static Storyboard CreateInOutAnimation(DependencyObject dependencyObject, string propertyName, double defaultValue, double startValue, double endValue, double durationIn, double durationOut, double staggerDelayIn, double restEnd, double staggerDelayOut, bool autoReverse, bool repeatForever, RepeatBehavior repeatBehavior) { // total duration double totalDuration = staggerDelayIn + durationIn + restEnd + staggerDelayOut + durationOut; // create the storyboard Storyboard storyboard = new Storyboard() { Duration = TimeSpan.FromMilliseconds(totalDuration), AutoReverse = autoReverse, RepeatBehavior = (repeatForever) ? RepeatBehavior.Forever : repeatBehavior }; // add frame collection to the storyboard storyboard.Children.Add( CreateInOutKeyFrames(dependencyObject, propertyName, defaultValue, startValue, endValue, durationIn, durationOut, staggerDelayIn, restEnd, staggerDelayOut)); // set the target of the storyboard Storyboard.SetTarget(storyboard, dependencyObject); Storyboard.SetTargetProperty(storyboard, propertyName); return(storyboard); }
// // How do we support "null" values, should the caller take care of that? // // The caller is responsible for calling value_free_value on the returned Value public static Value FromObject(object v, bool box_value_types) { Value value = new Value(); unsafe { if (box_value_types && (v is ValueType || v is string)) { value.boxed_valuetype = GCHandle.ToIntPtr(GCHandle.Alloc(v)); } if (v is IEasingFunction && !(v is EasingFunctionBase)) { v = new EasingFunctionWrapper(v as IEasingFunction); } if (v is INativeEventObjectWrapper) { INativeEventObjectWrapper dov = (INativeEventObjectWrapper)v; if (dov.NativeHandle == IntPtr.Zero) { throw new Exception(String.Format( "Object {0} has not set its native property", dov.GetType())); } NativeMethods.event_object_ref(dov.NativeHandle); value.k = dov.GetKind(); value.u.p = dov.NativeHandle; } else if (v is DependencyProperty) { value.k = Kind.DEPENDENCYPROPERTY; value.u.p = ((DependencyProperty)v).Native; } else if (v is int || (v.GetType().IsEnum&& Enum.GetUnderlyingType(v.GetType()) == typeof(int))) { value.k = Deployment.Current.Types.TypeToKind(v.GetType()); value.u.i32 = (int)v; } else if (v is byte || (v.GetType().IsEnum&& Enum.GetUnderlyingType(v.GetType()) == typeof(byte))) { value.k = Deployment.Current.Types.TypeToKind(v.GetType()); value.u.i32 = (byte)v; } else if (v is bool) { value.k = Kind.BOOL; value.u.i32 = ((bool)v) ? 1 : 0; } else if (v is double) { value.k = Kind.DOUBLE; value.u.d = (double)v; } else if (v is float) { value.k = Kind.FLOAT; value.u.f = (float)v; } else if (v is long) { value.k = Kind.INT64; value.u.i64 = (long)v; } else if (v is TimeSpan) { TimeSpan ts = (TimeSpan)v; value.k = Kind.TIMESPAN; value.u.i64 = ts.Ticks; } else if (v is ulong) { value.k = Kind.UINT64; value.u.ui64 = (ulong)v; } else if (v is uint) { value.k = Kind.UINT32; value.u.ui32 = (uint)v; } else if (v is char) { value.k = Kind.CHAR; value.u.ui32 = (uint)(char)v; } else if (v is string) { value.k = Kind.STRING; value.u.p = StringToIntPtr((string)v); } else if (v is Rect) { Rect rect = (Rect)v; value.k = Kind.RECT; value.u.p = Marshal.AllocHGlobal(sizeof(Rect)); Marshal.StructureToPtr(rect, value.u.p, false); // Unmanaged and managed structure layout is equal. } else if (v is Size) { Size size = (Size)v; value.k = Kind.SIZE; value.u.p = Marshal.AllocHGlobal(sizeof(Size)); Marshal.StructureToPtr(size, value.u.p, false); // Unmanaged and managed structure layout is equal. } else if (v is CornerRadius) { CornerRadius corner = (CornerRadius)v; value.k = Kind.CORNERRADIUS; value.u.p = Marshal.AllocHGlobal(sizeof(CornerRadius)); Marshal.StructureToPtr(corner, value.u.p, false); // Unmanaged and managed structure layout is equal. } else if (v is AudioFormat) { AudioFormat f = (AudioFormat)v; value.k = Kind.AUDIOFORMAT; value.u.p = Marshal.AllocHGlobal(sizeof(UnmanagedAudioFormat)); UnmanagedAudioFormat *format = (UnmanagedAudioFormat *)value.u.p; format->bitsPerSample = f.BitsPerSample; format->channels = f.Channels; format->samplesPerSecond = f.SamplesPerSecond; format->waveFormat = f.WaveFormat; } else if (v is VideoFormat) { VideoFormat f = (VideoFormat)v; value.k = Kind.VIDEOFORMAT; value.u.p = Marshal.AllocHGlobal(sizeof(UnmanagedVideoFormat)); UnmanagedVideoFormat *format = (UnmanagedVideoFormat *)value.u.p; format->framesPerSecond = f.FramesPerSecond; format->height = f.PixelHeight; format->width = f.PixelWidth; format->stride = f.Stride; format->pixelFormat = f.PixelFormat; } else if (v is Point) { Point pnt = (Point)v; value.k = Kind.POINT; value.u.p = Marshal.AllocHGlobal(sizeof(Point)); Marshal.StructureToPtr(pnt, value.u.p, false); // Unmanaged and managed structure layout is equal. } else if (v is Thickness) { Thickness thickness = (Thickness)v; value.k = Kind.THICKNESS; value.u.p = Marshal.AllocHGlobal(sizeof(Thickness)); Marshal.StructureToPtr(thickness, value.u.p, false); // Unmanaged and managed structure layout is equal. } else if (v is Color) { Color c = (Color)v; value.k = Kind.COLOR; value.u.p = Marshal.AllocHGlobal(sizeof(UnmanagedColor)); UnmanagedColor *color = (UnmanagedColor *)value.u.p; color->r = c.R / 255.0f; color->g = c.G / 255.0f; color->b = c.B / 255.0f; color->a = c.A / 255.0f; } else if (v is Matrix) { // hack around the fact that managed Matrix is a struct while unmanaged Matrix is a DO // i.e. the unmanaged and managed structure layouts ARE NOT equal return(FromObject(new UnmanagedMatrix((Matrix)v), box_value_types)); } else if (v is StylusPoint) { return(FromObject(new UnmanagedStylusPoint((StylusPoint)v), box_value_types)); } else if (v is Matrix3D) { // hack around the fact that managed Matrix3D is a struct while unmanaged Matrix3D is a DO // i.e. the unmanaged and managed structure layouts ARE NOT equal return(FromObject(new UnmanagedMatrix3D((Matrix3D)v), box_value_types)); } else if (v is Duration) { Duration d = (Duration)v; value.k = Kind.DURATION; value.u.p = Marshal.AllocHGlobal(sizeof(Duration)); Marshal.StructureToPtr(d, value.u.p, false); // Unmanaged and managed structure layout is equal. } else if (v is KeyTime) { KeyTime k = (KeyTime)v; value.k = Kind.KEYTIME; value.u.p = Marshal.AllocHGlobal(sizeof(KeyTime)); Marshal.StructureToPtr(k, value.u.p, false); // Unmanaged and managed structure layout is equal. } else if (v is RepeatBehavior) { RepeatBehavior d = (RepeatBehavior)v; value.k = Kind.REPEATBEHAVIOR; value.u.p = Marshal.AllocHGlobal(sizeof(RepeatBehavior)); Marshal.StructureToPtr(d, value.u.p, false); // Unmanaged and managed structure layout is equal. } else if (v is FontFamily) { FontFamily family = (FontFamily)v; value.k = Kind.FONTFAMILY; value.u.p = Marshal.AllocHGlobal(sizeof(UnmanagedFontFamily)); Marshal.StructureToPtr(family, value.u.p, false); // Unmanaged and managed structure layout is equal. } else if (v is FontSource) { FontSource source = (FontSource)v; value.k = Kind.FONTSOURCE; if (source.wrapper != null || source.typeface != null) { value.u.p = Marshal.AllocHGlobal(sizeof(UnmanagedFontSource)); UnmanagedFontSource *ufs = (UnmanagedFontSource *)value.u.p; ufs->type = source.type; switch (source.type) { case FontSourceType.ManagedStream: ManagedStreamCallbacks callbacks = source.wrapper.GetCallbacks(); ufs->source.stream = Marshal.AllocHGlobal(sizeof(UnmanagedStreamCallbacks)); Marshal.StructureToPtr(callbacks, ufs->source.stream, false); break; case FontSourceType.GlyphTypeface: ufs->source.typeface = source.typeface.Native; break; } } else { value.IsNull = true; } } else if (v is PropertyPath) { PropertyPath propertypath = (PropertyPath)v; value.k = Kind.PROPERTYPATH; value.u.p = Marshal.AllocHGlobal(sizeof(UnmanagedPropertyPath)); UnmanagedPropertyPath *upp = (UnmanagedPropertyPath *)value.u.p; upp->property = propertypath.NativeDP; if (upp->property == IntPtr.Zero) { upp->pathString = StringToIntPtr(propertypath.Path); upp->expandedPathString = StringToIntPtr(propertypath.ExpandedPath); } else { upp->pathString = IntPtr.Zero; upp->expandedPathString = IntPtr.Zero; } } else if (v is Uri) { Uri uri = (Uri)v; value.k = Kind.URI; value.u.p = UriHelper.ToNativeUri(uri); } else if (v is XmlLanguage) { XmlLanguage lang = (XmlLanguage)v; value.k = Kind.XMLLANGUAGE; value.u.p = StringToIntPtr(lang.IetfLanguageTag); } else if (v is Cursor) { Cursor c = (Cursor)v; value.k = Kind.CURSORTYPE; value.u.i32 = (int)c.cursor; } else if (v is GridLength) { GridLength gl = (GridLength)v; value.k = Kind.GRIDLENGTH; value.u.p = Marshal.AllocHGlobal(sizeof(GridLength)); Marshal.StructureToPtr(gl, value.u.p, false); // Unmanaged and managed structure layout is equal. } else if (v is FontStretch) { FontStretch stretch = (FontStretch)v; value.k = Kind.FONTSTRETCH; value.u.p = Marshal.AllocHGlobal(sizeof(UnmanagedFontStretch)); Marshal.StructureToPtr(stretch, value.u.p, false); // Unmanaged and managed structure layout is equal. } else if (v is FontStyle) { FontStyle style = (FontStyle)v; value.k = Kind.FONTSTYLE; value.u.p = Marshal.AllocHGlobal(sizeof(UnmanagedFontStyle)); Marshal.StructureToPtr(style, value.u.p, false); // Unmanaged and managed structure layout is equal. } else if (v is FontWeight) { FontWeight weight = (FontWeight)v; value.k = Kind.FONTWEIGHT; value.u.p = Marshal.AllocHGlobal(sizeof(UnmanagedFontWeight)); Marshal.StructureToPtr(weight, value.u.p, false); // Unmanaged and managed structure layout is equal. } else if (v is TextDecorationCollection) { value.k = Kind.TEXTDECORATIONS; value.u.i32 = (int)(v as TextDecorationCollection).Kind; } else if (v is Type) { Type t = v as Type; value.k = Kind.MANAGEDTYPEINFO; value.u.p = NativeMethods.managed_type_info_new(Deployment.Current.Types.TypeToKind(t)); } else if (v is Value) { throw new InvalidOperationException("You can not create a Mono.Value from a Mono.Value."); } else { //Console.WriteLine ("Do not know how to encode {0} yet, boxing it", v.GetType ()); // TODO: We probably need to marshal types that can animate as the // corresponding type (Point, Double, Color, etc). // TODO: We need to store the GCHandle somewhere so that we can free it, // or register a callback on the surface for the unmanaged code to call. GCHandle handle = GCHandle.Alloc(v); value.IsGCHandle = true; value.k = Deployment.Current.Types.TypeToKind(v.GetType()); value.u.p = GCHandle.ToIntPtr(handle); } } return(value); }
private static RepeatBehavior GetActualRepeatBehavior(GifDataStream metadata, RepeatBehavior repeatBehavior) { return(repeatBehavior == default ? GetRepeatBehaviorFromGif(metadata) : repeatBehavior); }
public ImageAnimator(Stream sourceStream, Uri sourceUri, GifDataStream metadata, RepeatBehavior repeatBehavior, Image image) : base(sourceStream, sourceUri, metadata, repeatBehavior) { _image = image; OnRepeatBehaviorChanged(); // in case the value has changed during creation }
internal Animator(Stream sourceStream, Uri sourceUri, GifDataStream metadata, RepeatBehavior repeatBehavior) { _sourceStream = sourceStream; _sourceUri = sourceUri; _isSourceStreamOwner = sourceUri != null; // stream opened from URI, should close it _metadata = metadata; _palettes = CreatePalettes(metadata); _bitmap = CreateBitmap(metadata); var desc = metadata.Header.LogicalScreenDescriptor; _stride = 4 * ((desc.Width * 32 + 31) / 32); _previousBackBuffer = new byte[desc.Height * _stride]; _indexStreamBuffer = CreateIndexStreamBuffer(metadata, _sourceStream); _timingManager = CreateTimingManager(metadata, repeatBehavior); }
/// <summary> /// Returns a value that indicates whether the specified Windows.UI.Xaml.Media.Animation.RepeatBehavior /// is equal to this Windows.UI.Xaml.Media.Animation.RepeatBehavior. /// </summary> /// <param name="repeatBehavior">The value to compare to this Windows.UI.Xaml.Media.Animation.RepeatBehavior.</param> /// <returns> /// true if both the type and repeat behavior of repeatBehavior are equal to /// this Windows.UI.Xaml.Media.Animation.RepeatBehavior; otherwise, false. /// </returns> public bool Equals(RepeatBehavior repeatBehavior) { return(this == repeatBehavior); }
protected BaseTransitionzExtension(double beginTime, double duration, T from, T to, EasingFunctionBase ease, EasingFunctionBase reverseEase, TransitionOn transitionOn, bool autoreverse, RepeatBehavior repeatBehavior) : this() { this.BeginTime = beginTime; this.Duration = duration; this.From = from; this.To = to; this.Ease = ease; this.ReverseEase = reverseEase; this.TransitionOn = transitionOn; this.AutoReverse = autoreverse; this.RepeatBehavior = repeatBehavior; }
/// <summary> /// Sets the value of the <c>RepeatBehavior</c> attached property for the specified object. /// </summary> /// <param name="obj">The element on which to set the property value.</param> /// <param name="value">The repeat behavior of the animated image.</param> public static void SetRepeatBehavior(Image obj, RepeatBehavior value) { obj.SetValue(RepeatBehaviorProperty, value); }
public static void AddAnimation(ImageSource source, RepeatBehavior repeatBehavior, ObjectAnimationUsingKeyFrames animation) { var key = new CacheKey(source, repeatBehavior); _animationCache[key] = animation; }
private static async void InitAnimationAsync(Image image, Uri sourceUri, RepeatBehavior repeatBehavior, int seqNum) { if (!CheckDesignMode(image, sourceUri, null)) return; try { var progress = new Progress<int>(percentage => OnDownloadProgress(image, percentage)); var animator = await ImageAnimator.CreateAsync(sourceUri, repeatBehavior, progress, image); // Check that the source hasn't changed while we were loading the animation if (GetSeqNum(image) != seqNum) { animator.Dispose(); return; } await SetAnimatorCoreAsync(image, animator); OnLoaded(image); } catch (InvalidSignatureException) { image.Source = new BitmapImage(sourceUri); OnLoaded(image); } catch(Exception ex) { OnError(image, ex, AnimationErrorKind.Loading); } }
public static void RemoveAnimation(ImageSource source, RepeatBehavior repeatBehavior, ObjectAnimationUsingKeyFrames animation) { var key = new CacheKey(source, repeatBehavior); _animationCache.Remove(key); }
public static void SetRepeatBehavior(DependencyObject obj, RepeatBehavior value) { obj.SetValue(RepeatBehaviorProperty, value); }
public CacheKey(ImageSource source, RepeatBehavior repeatBehavior) { _source = source; _repeatBehavior = repeatBehavior; }
public static bool Equals (RepeatBehavior repeatBehavior1, RepeatBehavior repeatBehavior2) { if (repeatBehavior1.kind != repeatBehavior2.kind) return false; switch (repeatBehavior1.kind) { case RepeatBehaviorKind.Count: return repeatBehavior1.count == repeatBehavior2.count; case RepeatBehaviorKind.TimeSpan: return repeatBehavior1.duration == repeatBehavior2.duration; case RepeatBehaviorKind.Forever: return true; default: return false; } }
public TimingManager(RepeatBehavior repeatBehavior) { _repeatBehavior = repeatBehavior; }
private BrushAnimator(Stream sourceStream, Uri sourceUri, GifDataStream metadata, RepeatBehavior repeatBehavior) : base(sourceStream, sourceUri, metadata, repeatBehavior) { Brush = new ImageBrush {ImageSource = Bitmap}; }
private Storyboard CreateFadingStoryBoard(System.Windows.Controls.Control target, double fromValue, double toValue, TimeSpan timespan, RepeatBehavior behavior) { // new TimeSpan(0, 0, 0, 0, 500); // fromValue = 1 // toValue = 0 DoubleAnimation fading = new DoubleAnimation(fromValue, toValue, timespan.Duration()); Storyboard.SetTarget(fading, target); Storyboard.SetTargetProperty(fading, new PropertyPath($"({target.GetType().Name}.Opacity)")); var result = new Storyboard() { AutoReverse = true }; if (behavior != null) { result.RepeatBehavior = behavior; } result.Children.Add(fading); return(result); }
public static Task<BrushAnimator> CreateAsync(Stream sourceStream, RepeatBehavior repeatBehavior) { return CreateAsyncCore( sourceStream, metadata => new BrushAnimator(sourceStream, null, metadata, repeatBehavior)); }
public static Task<ImageAnimator> CreateAsync(Stream sourceStream, RepeatBehavior repeatBehavior, Image image) { return CreateAsyncCore( sourceStream, metadata => new ImageAnimator(sourceStream, null, metadata, repeatBehavior, image)); }
private static async void InitAnimationAsync(Image image, Uri sourceUri, RepeatBehavior repeatBehavior) { if (!CheckDesignMode(image, sourceUri, null)) return; try { var animator = await Animator.CreateAsync(sourceUri, repeatBehavior); SetAnimatorCore(image, animator); OnLoaded(image); } catch (InvalidSignatureException) { image.Source = new BitmapImage(sourceUri); OnLoaded(image); } catch(Exception ex) { OnError(image, ex, AnimationErrorKind.Loading); } }
public OpacityParamsExtension(double beginTime, double duration, double from, double to, EasingFunctionBase ease, EasingFunctionBase reverseEase, TransitionOn transitionOn, bool autoReverse, RepeatBehavior repeatBehavior) : base(beginTime, duration, from, to, ease, reverseEase, transitionOn, autoReverse, repeatBehavior) { }
private TimingManager CreateTimingManager(GifDataStream metadata, RepeatBehavior repeatBehavior) { var actualRepeatBehavior = repeatBehavior == default(RepeatBehavior) ? GetRepeatBehavior(metadata) : repeatBehavior; var manager = new TimingManager(actualRepeatBehavior); foreach (var frame in metadata.Frames) { manager.Add(GetFrameDelay(frame)); } manager.Completed += TimingManagerCompleted; return manager; }
private static async void InitAnimationAsync(Image image, Stream stream, RepeatBehavior repeatBehavior) { if (!CheckDesignMode(image, null, stream)) return; try { var animator = await Animator.CreateAsync(stream, repeatBehavior); SetAnimatorCore(image, animator); OnLoaded(image); } catch (InvalidSignatureException) { var bmp = new BitmapImage(); #if WPF bmp.BeginInit(); bmp.StreamSource = stream; bmp.EndInit(); #elif WINRT bmp.SetSource(stream.AsRandomAccessStream()); #endif image.Source = bmp; OnLoaded(image); } catch(Exception ex) { OnError(image, ex, AnimationErrorKind.Loading); } }
internal static Task<Animator> CreateAsync(Stream sourceStream, RepeatBehavior repeatBehavior = default(RepeatBehavior), Image image = null) { return CreateAsync(sourceStream, null, repeatBehavior, image); }
protected Timeline(Nullable<TimeSpan> beginTime, Duration duration, RepeatBehavior repeatBehavior) { _beginTime = beginTime; _duration = duration; _repeatBehavior = repeatBehavior; }
public PulseAnimation() { RepeatBehavior = new RepeatBehavior(2); Duration = TimeSpan.FromMilliseconds(400); }