Example #1
0
        private void Image_SrcImagePreview_MouseLeave(object sender, RoutedEventArgs e)
        {
            System.Windows.Controls.Image imageControl = sender as System.Windows.Controls.Image;

            double          h1         = imageControl.Height;
            double          h2         = 64;
            DoubleAnimation animHeight = new DoubleAnimation();

            animHeight.Duration     = new Duration(TimeSpan.FromSeconds(0.3));
            animHeight.From         = h1;
            animHeight.To           = h2;
            animHeight.FillBehavior = FillBehavior.HoldEnd;

            double          w1        = imageControl.Width;
            double          w2        = 64;
            DoubleAnimation animWidth = new DoubleAnimation();

            animWidth.Duration     = new Duration(TimeSpan.FromSeconds(0.3));
            animWidth.From         = w1;
            animWidth.To           = w2;
            animWidth.FillBehavior = FillBehavior.HoldEnd;

            imageControl.BeginAnimation(System.Windows.Controls.Image.HeightProperty, animHeight);
            imageControl.BeginAnimation(System.Windows.Controls.Image.WidthProperty, animWidth);
        }
Example #2
0
        private void NewParticlesImage(IAdornmentLayer adornmentLayer, IWpfTextView view)
        {
            var particles = new Image();

            particles.UpdateSource(GetParticlesImage());
            adornmentLayer.AddAdornment(AdornmentPositioningBehavior.ViewportRelative, null, null, particles, null);
            particlesList.Add(particles);

            try
            {
                var top  = view.Caret.Top;
                var left = view.Caret.Left;
                particles.BeginAnimation(Canvas.TopProperty, GetParticlesTopAnimation(top));
                particles.BeginAnimation(Canvas.LeftProperty, GetParticlesLeftAnimation(left));
                var opacityAnimation = GetParticlesOpacityAnimation();
                opacityAnimation.Completed += (sender, e) =>
                {
                    particles.Visibility = Visibility.Hidden;
                    adornmentLayer.RemoveAdornment(particles);
                    particlesList.Remove(particles);
                };
                particles.BeginAnimation(UIElement.OpacityProperty, opacityAnimation);
            }
            catch
            {
                adornmentLayer.RemoveAdornment(particles);
                particlesList.Remove(particles);
            }
        }
Example #3
0
        private void Image_MouseLeave(object sender, MouseEventArgs e)
        {
            System.Windows.Controls.Image img = (System.Windows.Controls.Image)sender;
            DoubleAnimation animation         = new DoubleAnimation(0, TimeSpan.FromSeconds(2));

            img.BeginAnimation(System.Windows.Controls.Image.OpacityProperty, animation);
        }
Example #4
0
        public MainWindow()
        {
            InitializeComponent();
            onstart();
            //初始化Emgucv和接收摄像头图像的Mat
            CvInvoke.UseOpenCL = true;
            capframe           = new Mat();
            cap = new Capture();
            cap.SetCaptureProperty(CapProp.Fps, 30);
            cap.SetCaptureProperty(CapProp.FrameHeight, 720);
            cap.SetCaptureProperty(CapProp.FrameWidth, 960);
            cap.ImageGrabbed += Cap_ImageGrabbed;
            cap.Stop();
            history = new List <BitmapImage>();

            this.Loaded += new RoutedEventHandler(MainWindow_Loaded);

            slider.ValueChanged += Slider_ValueChanged;

            LunboList = new List <BitmapImage>();
            int imagelistnum = 4;

            for (int i = 1; i <= imagelistnum; i++)
            {
                LunboList.Add(new BitmapImage(new Uri(@"..\..\images\showlist\" + i.ToString() + ".jpg", UriKind.Relative)));
            }

            timer = new System.Timers.Timer(1000 * 3);
            int lunboinedx = 0;

            timer.Elapsed += delegate
            {
                lunboinedx++;
                Dispatcher.Invoke(DispatcherPriority.Normal, (Action) delegate()
                {
                    if (lunboinedx == 1000)
                    {
                        lunbo.Children.Clear();
                        lunboinedx = 0;
                    }
                    var tt     = new System.Windows.Controls.Image();
                    tt.Source  = LunboList[lunboinedx % imagelistnum];
                    tt.Height  = 200;
                    tt.Width   = 267;
                    tt.Stretch = Stretch.Fill;
                    tt.Margin  = new Thickness(1320, 0, -267, 0);
                    lunbo.Children.Add(tt);
                    ThicknessAnimation anim = new ThicknessAnimation();
                    anim.From     = new Thickness(1593, 0, -267, 0);
                    anim.To       = new Thickness(-1868, 0, 0, 0);
                    anim.Duration = TimeSpan.FromSeconds(15);
                    tt.BeginAnimation(MarginProperty, anim);
                });
            };
            timer.Start();
        }
Example #5
0
        private void NewParticleImage(IAdornmentLayer adornmentLayer, IWpfTextView view, bool isPartyMode)
        {
            try
            {
                var particles = new Image();
                particles.UpdateSource(GetParticleImage());
                adornmentLayer.AddAdornment(AdornmentPositioningBehavior.ViewportRelative, null, null, particles, null);
                particlesList.Add(particles);

                try
                {
                    var top = isPartyMode
                        ? RandomUtils.Random.Next((int)view.ViewportTop, (int)view.ViewportBottom)
                        : view.Caret.Top;
                    var left = isPartyMode
                        ? RandomUtils.Random.Next((int)view.ViewportLeft, (int)view.ViewportRight)
                        : view.Caret.Left;
                    particles.BeginAnimation(Canvas.TopProperty, GetParticleTopAnimation(top));
                    particles.BeginAnimation(Canvas.LeftProperty, GetParticleLeftAnimation(left));
                    var opacityAnimation = GetParticleOpacityAnimation();
                    opacityAnimation.Completed += (sender, e) =>
                    {
                        particles.Visibility = Visibility.Hidden;
                        adornmentLayer.RemoveAdornment(particles);
                        particlesList.Remove(particles);
                    };
                    particles.BeginAnimation(UIElement.OpacityProperty, opacityAnimation);
                }
                catch
                {
                    adornmentLayer.RemoveAdornment(particles);
                    particlesList.Remove(particles);
                }
            }
            catch
            {
            }
        }
Example #6
0
        public static void ChangeSource(
            this System.Windows.Controls.Image image, ImageSource source, TimeSpan fadeOutTime, TimeSpan fadeInTime)
        {
            var fadeInAnimation = new DoubleAnimation(1d, fadeInTime);

            if (image.Source != null)
            {
                var fadeOutAnimation = new DoubleAnimation(0d, fadeOutTime);

                fadeOutAnimation.Completed += (o, e) =>
                {
                    image.Source = source;
                    image.BeginAnimation(System.Windows.Controls.Image.OpacityProperty, fadeInAnimation);
                };

                image.BeginAnimation(System.Windows.Controls.Image.OpacityProperty, fadeOutAnimation);
            }
            else
            {
                image.Opacity = 0d;
                image.Source  = source;
                image.BeginAnimation(System.Windows.Controls.Image.OpacityProperty, fadeInAnimation);
            }
        }
Example #7
0
        private async Task <DoubleAnimation> StartNextPhotoAnimation(DoubleAnimation animation, Image animatedImage, bool completionFlag = false)
        {
            var photoindex = CurrentIndex;

            animatedImage.Source = await GetNextPhotoBitmap();

            //var photo = new Image { Source = await GetNextPhotoBitmap() };

            var bi = animatedImage.Source as BitmapImage;

            Debug.Assert(bi != null);
            var photoWidth  = bi.Width;
            var photoHeight = bi.Height;

            animation.Duration = new Duration(TimeSpan.FromSeconds(_random.Next(MinAnimateTimeSecs, MaxAnimateTimeSecs)));
            animation.From     = -photoHeight;                // y start
            animation.To       = _canvasHeight + photoHeight; // y finish

            // Completion handler - remove the image, start the next handler
            EventHandler handler = null;

            handler = async(s, e) =>
            {
                animation.Completed -= handler;
                ScreensaverCanvas.Children.Remove(animatedImage);
                await StartNextPhotoAnimation(animation, animatedImage, true);
            };
            animation.Completed += handler;

            double xStart = _random.Next(0, (int)_canvasWidth - (int)photoWidth);;

            _logger.Debug("{0} Dur {1} ({2},{3}) From {4} - {5}  xStart {6} Canvas({7}, {8}) {9}", photoindex, animation.Duration, (int)photoWidth, (int)photoHeight, (int)animation.From, (int)animation.To, (int)xStart, (int)_canvasWidth, (int)_canvasHeight, completionFlag);
            Canvas.SetLeft(animatedImage, xStart);

            // photo.Stretch = Stretch.UniformToFill;
            //animatedImage.Name = "Photo" + CurrentIndex;

            ScreensaverCanvas.Children.Add(animatedImage);
            animatedImage.BeginAnimation(Canvas.TopProperty, animation, HandoffBehavior.SnapshotAndReplace);

            return(animation);
        }
        private async Task<DoubleAnimation> StartNextPhotoAnimation(DoubleAnimation animation, Image animatedImage, bool completionFlag = false)
        {
            var photoindex = CurrentIndex;

            animatedImage.Source = await GetNextPhotoBitmap();
            //var photo = new Image { Source = await GetNextPhotoBitmap() };

            var bi = animatedImage.Source as BitmapImage;
            Debug.Assert(bi != null);
            var photoWidth = bi.Width;
            var photoHeight = bi.Height;

            animation.Duration = new Duration(TimeSpan.FromSeconds(_random.Next(MinAnimateTimeSecs, MaxAnimateTimeSecs)));
            animation.From = -photoHeight;                // y start
            animation.To = _canvasHeight + photoHeight;    // y finish

            // Completion handler - remove the image, start the next handler
            EventHandler handler = null;
            handler = async (s, e) =>
            {
                animation.Completed -= handler;
                ScreensaverCanvas.Children.Remove(animatedImage);
                await StartNextPhotoAnimation(animation, animatedImage, true);
            };
            animation.Completed += handler;

            double xStart = _random.Next(0, (int)_canvasWidth - (int)photoWidth); ;

            _logger.Debug("{0} Dur {1} ({2},{3}) From {4} - {5}  xStart {6} Canvas({7}, {8}) {9}", photoindex, animation.Duration, (int)photoWidth, (int)photoHeight, (int)animation.From, (int)animation.To, (int)xStart, (int)_canvasWidth, (int)_canvasHeight, completionFlag);
            Canvas.SetLeft(animatedImage, xStart);

            // photo.Stretch = Stretch.UniformToFill;
            //animatedImage.Name = "Photo" + CurrentIndex;

            ScreensaverCanvas.Children.Add(animatedImage);
            animatedImage.BeginAnimation(Canvas.TopProperty, animation, HandoffBehavior.SnapshotAndReplace);

            return animation;
        }