コード例 #1
0
        private void InitFromUri(Uri uri)
        {
            if (uri == null)
            {
                _gifDecoder = null;
                _animation = null;
                _animationIsWorking = false;

                return;
            }

            var decoder = BitmapDecoder.Create(uri, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
            _gifDecoder = decoder as GifBitmapDecoder;
            if (_gifDecoder != null)
            {
                _animation = new Int32Animation(0, _gifDecoder.Frames.Count - 1,
                                            new Duration(new TimeSpan(0, 0, 0, _gifDecoder.Frames.Count/10,
                                                                      (int) ((_gifDecoder.Frames.Count/10.0 - _gifDecoder.Frames.Count/10)*1000))))
                {
                    RepeatBehavior = RepeatBehavior.Forever
                };

            }
            else
            {
                _animation = null;
                _animationIsWorking = false;
            }

            Source = decoder.Frames[0];
        }
コード例 #2
0
ファイル: Animation.cs プロジェクト: podlipensky/sharpcanvas
        private string sample28(ICanvasRenderingContext2D ctx)
        {
            Thread.Sleep(interval);
            dragon = new FlyingDragon(surface);
            // Create the animation targetting the StrokeDashOffset property
            var anima = new Int32Animation
                            {
                                Duration = new Duration(TimeSpan.FromSeconds(20)),
                                FillBehavior = FillBehavior.Stop,
                                From = 0,
                                By = 1,
                                To = 1000
                            };
            // DesiredFrameRate can help reduce CPU cost and improve smoothness.
            // It can also cause beating if used improperly. Use with caution!
            //Timeline.DesiredFrameRateProperty.OverrideMetadata(typeof(Timeline), new FrameworkPropertyMetadata { DefaultValue = 120 });
            Timeline.SetDesiredFrameRate(anima, 20); // 20 fps

            // Final per-figure setup
            Storyboard.SetTarget(anima, dragon);
            //Storyboard.SetDesiredFrameRate(anima, 10);
            Storyboard.SetTargetProperty(anima, new PropertyPath(FlyingDragon.IndexProperty));
            storyboard.Children.Add(anima);
            // Begin the animation
            storyboard.Begin();

            IsStarted = true;
            return string.Empty;
        }
コード例 #3
0
ファイル: AnimatedLoader.cs プロジェクト: StevenThuriot/Nova
        /// <summary>
        ///     Initializes a new instance of the <see cref="AnimatedLoader" /> class.
        /// </summary>
        public AnimatedLoader()
        {
            Visibility = Visibility.Hidden;
            IsVisibleChanged += LoaderVisibilityChanged;

            var imageSource = Application.Current.Resources["LoaderImage"] as ImageSource;
            var loaderUri = imageSource == null
                                ? new Uri("pack://application:,,,/Nova;component/Resources/loader.gif", UriKind.Absolute)
                                : new Uri(imageSource.ToString(), UriKind.Absolute);

            _gifBitmapDecoder = new GifBitmapDecoder(loaderUri, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);

            var seconds = _gifBitmapDecoder.Frames.Count/10;
            var milliseconds = (int) (((_gifBitmapDecoder.Frames.Count/10.0) - (_gifBitmapDecoder.Frames.Count/10.0))*1000d);

            var timespan = new TimeSpan(0, 0, 0, seconds, milliseconds);
            var duration = new Duration(timespan);

            _animation = new Int32Animation(0, _gifBitmapDecoder.Frames.Count - 1, duration)
                {
                    RepeatBehavior = RepeatBehavior.Forever
                };

            Source = _gifBitmapDecoder.Frames[0];
            Height = Source.Height;
            Width = Source.Width;
        }
コード例 #4
0
ファイル: Int32Animation.cs プロジェクト: beda2280/wpf-1
        private static void AnimationFunction_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Int32Animation a = (Int32Animation)d;

            a._isAnimationFunctionValid = false;
            a.PropertyChanged(e.Property);
        }
コード例 #5
0
ファイル: GifImage.cs プロジェクト: SneakyMax/Rosette
 private void GifImage_Initialized(object sender, EventArgs e)
 {
     gifDecoder = new GifBitmapDecoder(Uri, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
     animation = new Int32Animation(0, gifDecoder.Frames.Count - 1, new Duration(new TimeSpan(0, 0, 0, gifDecoder.Frames.Count / 10, (int)((gifDecoder.Frames.Count / 10.0 - gifDecoder.Frames.Count / 10) * 1000))));
     animation.RepeatBehavior = RepeatBehavior.Forever;
     Source = gifDecoder.Frames[0];
 }
コード例 #6
0
 public GifImage(Uri uri)
 {
     gf = new GifBitmapDecoder(uri, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
     anim = new Int32Animation(0, gf.Frames.Count - 1, new Duration(new TimeSpan(0, 0, 0, gf.Frames.Count / 10, (int)((gf.Frames.Count / 10.0 - gf.Frames.Count / 10) * 1000))));
     anim.RepeatBehavior = RepeatBehavior.Forever;
     Source = gf.Frames[0];
 }
コード例 #7
0
ファイル: GifImage.cs プロジェクト: poma/SshConnect
 protected override void OnInitialized(EventArgs e)
 {
     gf = new GifBitmapDecoder(new Uri(Uri, UriKind.RelativeOrAbsolute), BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
     anim = new Int32Animation(0, gf.Frames.Count - 1, new Duration(new TimeSpan(0, 0, 0, gf.Frames.Count / (int)fps,
         (int)((gf.Frames.Count / (double)fps - gf.Frames.Count / (int)fps) * 1000))));
     anim.RepeatBehavior = RepeatBehavior.Forever;
     Source = gf.Frames[0];
 }
コード例 #8
0
ファイル: GifImage.cs プロジェクト: AntonLapshin/hcprojects
 public GifImage()
 {
     Uri uri = new Uri("pack://application:,,,/AssortmentManagement;component/Images/load.gif");
     gf = new GifBitmapDecoder(uri, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
     anim = new Int32Animation(0, gf.Frames.Count - 1, new Duration(new TimeSpan(0, 0, 0, gf.Frames.Count / 10, (int)((gf.Frames.Count / 10.0 - gf.Frames.Count / 10) * 1000))));
     anim.RepeatBehavior = RepeatBehavior.Forever;
     Source = gf.Frames[0];           
 }
コード例 #9
0
        private void Initialize()
        {
            _gifDecoder = FASTBuildMonitorControl.GetGifBitmapDecoder(GifSource);
            _animation = new Int32Animation(0, _gifDecoder.Frames.Count - 1, new Duration(new TimeSpan(0, 0, 0, _gifDecoder.Frames.Count / 10, (int)((_gifDecoder.Frames.Count / 10.0 - _gifDecoder.Frames.Count / 10) * 1000))));
            _animation.RepeatBehavior = RepeatBehavior.Forever;
            this.Source = _gifDecoder.Frames[0];

            _isInitialized = true;
        }
コード例 #10
0
ファイル: GifImage.cs プロジェクト: roundedsquare/Houhou-SRS
        private void Initialize()
        {
            _gifDecoder = new GifBitmapDecoder(new Uri("pack://application:,,," + this.GifSource), BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
            _animation = new Int32Animation(0, _gifDecoder.Frames.Count - 1, new Duration(new TimeSpan(0, 0, 0, _gifDecoder.Frames.Count / 10, (int)((_gifDecoder.Frames.Count / 10.0 - _gifDecoder.Frames.Count / 10) * 1000))));
            _animation.RepeatBehavior = RepeatBehavior.Forever;
            this.Source = _gifDecoder.Frames[0];

            _isInitialized = true;
        }
コード例 #11
0
ファイル: GifImage.cs プロジェクト: flq/TheDailyTweeter
 private void onInitialized(object sender, EventArgs e)
 {
     gf = new GifBitmapDecoder(new Uri(GifUri), BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
     var millisecondPerFrame = 1000.0 / Convert.ToDouble(FramesPerSecond);
     anim = new Int32Animation(0, gf.Frames.Count - 1, TimeSpan.FromMilliseconds(millisecondPerFrame * gf.Frames.Count))
     {
         RepeatBehavior = RepeatBehavior.Forever
     };
     Source = gf.Frames[0];
 }
コード例 #12
0
ファイル: GifImage.cs プロジェクト: dustyburwell/jell
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);

             var stream = Application.GetResourceStream(new Uri(Source.ToString()));
             m_gf = new GifBitmapDecoder(stream.Stream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
             m_anim = new Int32Animation(0, m_gf.Frames.Count - 1, new Duration(new TimeSpan(0, 0, 0, m_gf.Frames.Count / 10, (int)((m_gf.Frames.Count / 10.0 - m_gf.Frames.Count / 10) * 1000))));
             m_anim.RepeatBehavior = RepeatBehavior.Forever;
             Source = m_gf.Frames[0];
        }
コード例 #13
0
 protected override void OnInitialized(EventArgs e)
 {
     decoder = new GifBitmapDecoder(Uri, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
     animation = new Int32Animation(0, decoder.Frames.Count - 1,
                                    new Duration(new TimeSpan(0, 0, 0, decoder.Frames.Count / 10, (int) ((decoder.Frames.Count / 10.0 - decoder.Frames.Count / 10) * 1000))))
     {
         RepeatBehavior = RepeatBehavior.Forever
     };
     Source = decoder.Frames[0];
 }
コード例 #14
0
ファイル: GifImage.cs プロジェクト: ukionik/VDesktopeNew
        private void Initialize()
        {
            if (!DesignerProperties.GetIsInDesignMode(this))
            {
                _gifDecoder = new GifBitmapDecoder(new Uri("pack://application:,,,/OAuth;component/" + GifSource), BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
                _animation = new Int32Animation(0, _gifDecoder.Frames.Count - 1, new Duration(new TimeSpan(0, 0, 0, _gifDecoder.Frames.Count / 10, (int)((_gifDecoder.Frames.Count / 10.0 - _gifDecoder.Frames.Count / 10) * 1000)))) { RepeatBehavior = RepeatBehavior.Forever };
                Source = _gifDecoder.Frames[0];

                _isInitialized = true;
            }
        }
コード例 #15
0
 public void setGifSource(string url)
 {
     // initialize the gifDecoder
     _gifDecoder = new GifBitmapDecoder(new Uri(url), BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
     // initialize the animation
     _animation = new Int32Animation(0, _gifDecoder.Frames.Count - 1, new Duration(new TimeSpan(0, 0, 0, _gifDecoder.Frames.Count / 10, (int)((_gifDecoder.Frames.Count / 10.0 - _gifDecoder.Frames.Count / 10) * 1000))));
     // repeat forever
     _animation.RepeatBehavior = RepeatBehavior.Forever;
     // set the image source
     this.Source = _gifDecoder.Frames[0];
     this.StartAnimation();
 }
コード例 #16
0
 private void RefreshGif()
 {
     if (string.IsNullOrEmpty(_gifSource?.ToString())) return;
     _gf = new GifBitmapDecoder(_gifSource, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
     _anim = new Int32Animation(0,
         _gf.Frames.Count - 1,
         new Duration(TimeSpan.FromSeconds(_gf.Frames.Count/FramesPerSecond)))
     {
         RepeatBehavior = RepeatBehavior.Forever
     };
     Source = _gf.Frames[0];
 }
コード例 #17
0
ファイル: GifImage.cs プロジェクト: AlexKrainov/DownLoadVK
        private void GifSourceChanged(string newSource)
        {
            if (_animation != null)
                BeginAnimation(FrameIndexProperty, null);

            _decoder = new GifBitmapDecoder(new Uri(newSource), BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
            Source = _decoder.Frames[0];

            int count = _decoder.Frames.Count;
            _animation = new Int32Animation(0, count - 1, new Duration(new TimeSpan(0, 0, 0, count / 10, (int)((count / 10.0 - count / 10) * 1000))));
            _animation.RepeatBehavior = RepeatBehavior.Forever;
            BeginAnimation(FrameIndexProperty, _animation);
        }
コード例 #18
0
        internal ExplosionImage()
        {
            var random = new Random();
            particles = new List<Particle>();
            for (var i = 0; i < random.Next(10, 20); i++)
            {
                particles.Add(new Particle(new Point(Width / 2, Height / 2), random));
            }

            boundsRect = new Rect(0, 0, Width, Height);
            boundsDrawing = new GeometryDrawing();
            boundsDrawing.Brush = new SolidColorBrush(Color.FromArgb(0, 255, 255, 255));
            boundsDrawing.Geometry = new RectangleGeometry(boundsRect);

            var frameAnimation = new Int32Animation();
            frameAnimation.Duration = new Duration(TimeSpan.FromSeconds(5));
            frameAnimation.To = (int)frameAnimation.Duration.TimeSpan.TotalMilliseconds;
            frameAnimation.Completed += FrameAnimation_Completed;
            BeginAnimation(FrameProperty, frameAnimation);
        }
コード例 #19
0
        /// <summary>
        /// Starts frame animation only if frames count is bigger than 1.
        /// </summary>
        /// <param name="image"></param>
        private static void StartFramesAnimation(this Image image)
        {
            BitmapFrame bitmapFrame = image.Source as BitmapFrame;
            if(bitmapFrame != null)
            {
                int framesCount = bitmapFrame.Decoder.Frames.Count;

                if(framesCount > 1)
                {
                    Int32Animation gifAnimation =
                        new Int32Animation(
                            0, // "From" value
                            framesCount - 1, // "To" value
                            new Duration(TimeSpan.FromMilliseconds(MILLISCONDS_PER_FRAME * framesCount))
                        );

                    gifAnimation.RepeatBehavior = RepeatBehavior.Forever;

                    image.BeginAnimation(CurrentFrameIndexProperty, gifAnimation, HandoffBehavior.SnapshotAndReplace);
                }
            }
        }
コード例 #20
0
        /// <summary>
        ///   Initializes this instance.
        /// </summary>
        private void Initialize()
        {
            if (string.IsNullOrEmpty(this.GifSource))
            {
                // this.GifSource = "/LoadTariffs;component/Resources/Images/Windows8loader.gif";
                this.GifSource = "/Umehluko.Tools.UI;component/Resources/Images/Windows8loader.gif";
            }

            this._gifDecoder = new GifBitmapDecoder(
                new Uri("pack://application:,,," + this.GifSource), 
                BitmapCreateOptions.PreservePixelFormat, 
                BitmapCacheOption.Default);

            this._animation = new Int32Animation(
                0, 
                this._gifDecoder.Frames.Count - 1, 
                new Duration(
                    new TimeSpan(
                        0, 
                        0, 
                        0, 
                        this._gifDecoder.Frames.Count / 10, 
                        (int)((this._gifDecoder.Frames.Count / 10.0 - this._gifDecoder.Frames.Count / 10) * 1000))))
                                  {
                                      RepeatBehavior
                                          =
                                          RepeatBehavior
                                          .Forever
                                  };

            this.Source = this._gifDecoder.Frames[0];

            this._isInitialized = true;
        }
コード例 #21
0
 private void SetZIndex(IAnimatable image, TimeSpan beginTime, int value)
 {
     Int32Animation animation = new Int32Animation(value, new Duration(new TimeSpan(0))) { BeginTime = beginTime };
     image.BeginAnimation(Panel.ZIndexProperty, animation);
 }
コード例 #22
0
        private void Initialize()
        {
            if (string.IsNullOrEmpty(GifSource)) {
            StopAnimation();
            return;
             }

             _gifDecoder = new GifBitmapDecoder(new Uri("pack://application:,,," + this.GifSource), BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
             _animation = new Int32Animation(0, 5 * (_gifDecoder.Frames.Count) - 1, new Duration(new TimeSpan(0, 0, 0, _gifDecoder.Frames.Count / 10, (int)((_gifDecoder.Frames.Count / 10.0 - _gifDecoder.Frames.Count / 10) * 1000))));
             _animation.RepeatBehavior = RepeatBehavior.Forever;
             this.Source = _gifDecoder.Frames[0];
             _isInitialized = true;

             if (AutoStart) {
            StartAnimation();
             }
        }
コード例 #23
0
ファイル: GifImage.cs プロジェクト: Mizipzor/TeamCityDesktop
 private void Initialize()
 {
     decoder = new GifBitmapDecoder(
         new Uri("pack://application:,,," + GifSource),
         BitmapCreateOptions.PreservePixelFormat,
         BitmapCacheOption.Default);
     int frameCount = decoder.Frames.Count;
     animation = new Int32Animation(
         0,
         decoder.Frames.Count - 1,
         new Duration(new TimeSpan(0, 0, 0, 0, frameCount * 100)))
         {RepeatBehavior = RepeatBehavior.Forever};
     Source = decoder.Frames[0];
     isInitialized = true;
     if (AutoStart && Visibility == Visibility.Visible)
     {
         StartAnimation();
     }
 }
コード例 #24
0
        /// <summary>
        /// The animate.
        /// </summary>
        private void Animate()
        {
            try
            {
                if (this.storyboard != null)
                {
                    this.storyboard.Stop();
                    this.storyboard.Remove();
                }

                this.PreviousSelectedIndex = -1;
                this.PreviousSelectedItem = null;
                this.SelectedIndexProxy = 0;

                if ((this.ItemsSource != null) && (this.content != null))
                {
                    int count = this.ItemsSource.Cast<object>().Count();

                    this.storyboard = new Storyboard();
                    Int32Animation intAnimation = new Int32Animation()
                    {
                        Duration = this.Duration,
                        FillBehavior = System.Windows.Media.Animation.FillBehavior.HoldEnd,
                        From = 0,
                        To = count - 1
                    };
                    Storyboard.SetTarget(intAnimation, this);
                    Storyboard.SetTargetProperty(intAnimation, new PropertyPath("SelectedIndexProxy"));
                    this.storyboard.Children.Add(intAnimation);

                    this.IsFlipping = true;
                    this.storyboard.Completed += this.OnFlippingCompleted;
                    this.storyboard.Begin();
                }
            }
            catch
            {
            }
        }
コード例 #25
0
    void Initialize()
    {
        gifDecoder = new GifBitmapDecoder(new Uri(GifSource), BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
        animation = new Int32Animation(0, gifDecoder.Frames.Count - 1, new Duration(new TimeSpan(0, 0, 0, gifDecoder.Frames.Count/10, (int) ((gifDecoder.Frames.Count/10.0 - gifDecoder.Frames.Count/10)*1000))))
            {
                RepeatBehavior = RepeatBehavior.Forever
            };
        Source = gifDecoder.Frames[0];

        isInitialized = true;
    }
コード例 #26
0
ファイル: AnimatedImage.cs プロジェクト: SLaks/LibraryBrowser
        private void ClearAnimation()
        {
            if (Animation != null)
                BeginAnimation(FrameIndexProperty, null);

            Animation = null;
            this.Frames = null;
        }
コード例 #27
0
ファイル: AnimatedImage.cs プロジェクト: SLaks/LibraryBrowser
        private void PrepareAnimation()
        {
            Animation = new Int32Animation(0, this.Frames.Count - 1, new Duration(TimeSpan.FromMilliseconds(Frames.Count * 100))) {
                RepeatBehavior = RepeatBehavior.Forever
            };

            base.Source = this.Frames[0];
            BeginAnimation(FrameIndexProperty, Animation);
        }
コード例 #28
-1
        private void PrepareAnimation(System.Windows.Media.Imaging.BitmapImage aBitmapImage)
        {
            System.Diagnostics.Debug.Assert(aBitmapImage != null);

            if (aBitmapImage.UriSource != null)
            {
                Decoder = new GifBitmapDecoder(
                    aBitmapImage.UriSource,
                    BitmapCreateOptions.PreservePixelFormat,
                    BitmapCacheOption.Default);
            }
            else
            {
                aBitmapImage.StreamSource.Position = 0;
                Decoder = new GifBitmapDecoder(
                    aBitmapImage.StreamSource,
                    BitmapCreateOptions.PreservePixelFormat,
                    BitmapCacheOption.Default);
            }

            Animation =
                new Int32Animation(
                    0,
                    Decoder.Frames.Count - 1,
                    new Duration(
                        new TimeSpan(
                            0,
                            0,
                            0,
                            Decoder.Frames.Count / 10,
                            (int)((Decoder.Frames.Count / 10.0 - Decoder.Frames.Count / 10) * 1000))))
                {
                    RepeatBehavior = RepeatBehavior.Forever
                };

            base.Source = Decoder.Frames[0];
            BeginAnimation(FrameIndexProperty, Animation);
            IsAnimationWorking = true;
        }
コード例 #29
-1
		private void Initialize()
		{
			_gifDecoder = new GifBitmapDecoder(new Uri("pack://application:,,," + this.GifSource), BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
			_animation = new Int32Animation(0, _gifDecoder.Frames.Count - 1,
				new Duration(
					TimeSpan.FromMilliseconds(
						((ushort)(_gifDecoder.Frames[0].Metadata as BitmapMetadata).GetQuery("/grctlext/Delay")) * 10 * _gifDecoder.Frames.Count)))
			{
				RepeatBehavior = RepeatBehavior.Forever
			};

			this.Source = _gifDecoder.Frames[0];

			_isInitialized = true;
		}