Exemplo n.º 1
0
        private void Touch_FrameReported(object sender, TouchFrameEventArgs e)
        {
            if (_manipulationStartedArgs == null)
            {
                Touch.FrameReported -= Touch_FrameReported;
                return;
            }

            var point = e.GetPrimaryTouchPoint(null);

            if (point.Action == TouchAction.Up)
            {
                Touch.FrameReported -= Touch_FrameReported;
                return;
            }

            var manipulationPoint = e.GetPrimaryTouchPoint(_manipulationStartedArgs.ManipulationContainer);
            var length            = Math.Pow(manipulationPoint.Position.X - _manipulationStartedArgs.ManipulationOrigin.X, 2.0)
                                    + Math.Pow(manipulationPoint.Position.Y - _manipulationStartedArgs.ManipulationOrigin.Y, 2.0);

            if (length > 30.0 * 30.0)
            {
                Touch.FrameReported -= Touch_FrameReported;
                return;
            }

            if (_startTime.HasValue && _startTime.Value.AddSeconds(0.5) <= DateTime.Now)
            {
                Touch.FrameReported -= Touch_FrameReported;
                VirtPanel.DisableVerticalScrolling();

                _loadedStoryboard = EmojiControl.GetScaleStoryboard(_fromItem, 0.85, 1.0);

                Preview.Visibility = Visibility.Visible;
                var stickerImage = _fromItem as Image;
                if (stickerImage != null)
                {
                    PreviewImage.Source = stickerImage.Source;

                    var stickerItem = stickerImage.DataContext as TLStickerItem;
                    if (stickerItem != null)
                    {
                        Image.DataContext = stickerItem;
                    }
                }

                var grid = Preview;
                grid.Children.Remove(PreviewGrid);

                Execute.BeginOnUIThread(() =>
                {
                    PreviewGrid.RenderTransform = new CompositeTransform();
                    PreviewGrid.Opacity         = 0.0;
                    grid.Children.Add(PreviewGrid);
                });
            }
        }
Exemplo n.º 2
0
        private void StickerPanel_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
        {
            var fromItem = _fromItem;

            _startTime = null;
            _fromItem  = null;

            if (_storyboard != null)
            {
                _storyboard.SkipToFill();
            }

            VirtPanel.EnableVerticalScrolling();
            Preview.Visibility = Visibility.Collapsed;

            var st = EmojiControl.GetScaleStoryboard(_lastMouseEnter ?? fromItem, 1.0, 1.0);

            if (st != null)
            {
                Execute.BeginOnUIThread(st.Begin);
            }
        }
Exemplo n.º 3
0
        private void StickerPanel_MouseEnter(object sender, MouseEventArgs e)
        {
            if (Preview.Visibility == Visibility.Collapsed)
            {
                return;
            }

            //DebugText.Text = sender.GetHashCode().ToString();

            var st1 = EmojiControl.GetScaleStoryboard(_lastMouseEnter ?? _fromItem, 1.0, 1.0);

            _lastMouseEnter = e.OriginalSource as FrameworkElement;

            var stickerImage = e.OriginalSource as Image;

            if (stickerImage != null)
            {
                PreviewImage.Source = stickerImage.Source;

                var stickerItem = stickerImage.DataContext as TLStickerItem;
                if (stickerItem != null)
                {
                    Image.DataContext = stickerItem;
                }
                PreviewGrid.DataContext = Image.DataContext;
            }

            var duration       = .5;
            var easingFunction = new ElasticEase {
                Oscillations = 1, Springiness = 10.0, EasingMode = EasingMode.EaseOut
            };
            var storyboard = new Storyboard();

            var doubleAnimation = new DoubleAnimation();

            doubleAnimation.From           = 0.0;
            doubleAnimation.To             = 0.0;
            doubleAnimation.Duration       = new Duration(TimeSpan.FromSeconds(duration));
            doubleAnimation.EasingFunction = easingFunction;
            Storyboard.SetTarget(doubleAnimation, PreviewGrid);
            Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("(UIElement.RenderTransform).(CompositeTransform.TranslateX)"));
            storyboard.Children.Add(doubleAnimation);

            var doubleAnimation2 = new DoubleAnimation();

            doubleAnimation2.From           = 0.0; //position.Y;
            doubleAnimation2.To             = 0.0;
            doubleAnimation2.Duration       = new Duration(TimeSpan.FromSeconds(duration));
            doubleAnimation2.EasingFunction = easingFunction;
            Storyboard.SetTarget(doubleAnimation2, PreviewGrid);
            Storyboard.SetTargetProperty(doubleAnimation2, new PropertyPath("(UIElement.RenderTransform).(CompositeTransform.TranslateY)"));
            storyboard.Children.Add(doubleAnimation2);

            var doubleAnimation3 = new DoubleAnimation();

            doubleAnimation3.From           = 1.0;
            doubleAnimation3.To             = 1.0;
            doubleAnimation3.Duration       = new Duration(TimeSpan.FromSeconds(duration));
            doubleAnimation3.EasingFunction = easingFunction;
            Storyboard.SetTarget(doubleAnimation3, PreviewGrid);
            Storyboard.SetTargetProperty(doubleAnimation3, new PropertyPath("Opacity"));
            storyboard.Children.Add(doubleAnimation3);

            var doubleAnimation4 = new DoubleAnimation();

            doubleAnimation4.From           = 2.4;
            doubleAnimation4.To             = 2.6;
            doubleAnimation4.Duration       = new Duration(TimeSpan.FromSeconds(duration));
            doubleAnimation4.EasingFunction = easingFunction;
            Storyboard.SetTarget(doubleAnimation4, PreviewGrid);
            Storyboard.SetTargetProperty(doubleAnimation4, new PropertyPath("(UIElement.RenderTransform).(CompositeTransform.ScaleY)"));
            storyboard.Children.Add(doubleAnimation4);

            var doubleAnimation5 = new DoubleAnimation();

            doubleAnimation5.From           = 2.4;
            doubleAnimation5.To             = 2.6;
            doubleAnimation5.Duration       = new Duration(TimeSpan.FromSeconds(duration));
            doubleAnimation5.EasingFunction = easingFunction;
            Storyboard.SetTarget(doubleAnimation5, PreviewGrid);
            Storyboard.SetTargetProperty(doubleAnimation5, new PropertyPath("(UIElement.RenderTransform).(CompositeTransform.ScaleX)"));
            storyboard.Children.Add(doubleAnimation5);

            storyboard.Begin();

            _storyboard = storyboard;

            var st2 = EmojiControl.GetScaleStoryboard(_lastMouseEnter, 0.85, 1.0);

            if (st1 != null || st2 != null)
            {
                Execute.BeginOnUIThread(() =>
                {
                    if (st1 != null)
                    {
                        st1.Begin();
                    }
                    if (st2 != null)
                    {
                        st2.Begin();
                    }
                });
            }
        }