Beispiel #1
0
 private void CoreWindow_PointerPressed(CoreWindow sender, PointerEventArgs args)
 {
     try
     {
         interactionSource.TryRedirectForManipulation(args.CurrentPoint);
     }
     catch
     {
     }
 }
Beispiel #2
0
 private void rootGrid_PointerPressed(object sender, PointerRoutedEventArgs e)
 {
     if (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Touch)
     {
         _source.TryRedirectForManipulation(e.GetCurrentPoint(rootGrid));
     }
 }
Beispiel #3
0
 private void Blur_PointerPressed(object sender, PointerRoutedEventArgs e)
 {
     if (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Touch)
     {
         _interactionSource.TryRedirectForManipulation(e.GetCurrentPoint(Window.Current.Content));
     }
 }
 private void Pointer_Pressed(object sender, PointerRoutedEventArgs e)
 {
     if (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Touch)
     {
         interactionSource.TryRedirectForManipulation(e.GetCurrentPoint(RootContainer));
     }
 }
        private void InitializeComposition()
        {
            _containerVisual = ElementCompositionPreview.GetElementVisual(pnlRoot);
            _compositor      = _containerVisual.Compositor;

            _tracker = InteractionTracker.CreateWithOwner(_compositor, this);

            //_cubicBezierEasingFunction = _compositor.CreateCubicBezierEasingFunction(new Vector2(0.8f, 1.0f), new Vector2(0.0f, 1.0f));
            _cubicBezierEasingFunction = _compositor.CreateCubicBezierEasingFunction(new Vector2(.17f, .67f), new Vector2(1f, 1f));

            _containerVisual.Size = new Vector2((float)pnlRoot.ActualWidth, (float)pnlRoot.ActualHeight);
            _props = _compositor.CreatePropertySet();

            VisualInteractionSource interactionSource = VisualInteractionSource.Create(_containerVisual);

            interactionSource.PositionXSourceMode = InteractionSourceMode.EnabledWithInertia;
            _tracker.InteractionSources.Add(interactionSource);

            pnlRoot.PointerPressed += (s, a) =>
            {
                // Capture the touch manipulation to the InteractionTracker for automatic handling
                if (a.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Touch)
                {
                    try
                    {
                        interactionSource.TryRedirectForManipulation(a.GetCurrentPoint(s as UIElement));
                    }
                    catch (UnauthorizedAccessException)
                    {
                        // Ignoring the failed redirect to prevent app crashing
                    }
                }
            };
        }
Beispiel #6
0
 private void OnImagePointerPressed(object sender, PointerRoutedEventArgs e)
 {
     if (e.Pointer.PointerDeviceType == PointerDeviceType.Touch)
     {
         visualInteractionSource.TryRedirectForManipulation(e.GetCurrentPoint(null));
         infoProvider.UpdateIsInteractingForRefresh(true);
     }
 }
Beispiel #7
0
 private void Root_PointerPressed(object sender, PointerRoutedEventArgs e)
 {
     if (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Touch)
     {
         // Tell the system to use the gestures from this pointer point (if it can).
         _interactionSource.TryRedirectForManipulation(e.GetCurrentPoint(Root));
     }
 }
Beispiel #8
0
        private void Root_OnPointerPressed(object sender, PointerRoutedEventArgs e)
        {
            if (e.Pointer.PointerDeviceType != PointerDeviceType.Touch)
            {
                return;
            }

            _interactionSource.TryRedirectForManipulation(e.GetCurrentPoint(Root));
        }
Beispiel #9
0
 public void NotifyPointerPressed(PointerEventArgs args)
 {
     try
     {
         interactionSource.TryRedirectForManipulation(args.CurrentPoint);
     }
     catch (Exception)
     {
     }
 }
 private void Content_PointerPressed(object sender, PointerRoutedEventArgs e)
 {
     if (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Touch)
     {
         try
         {
             interactionSource.TryRedirectForManipulation(e.GetCurrentPoint(maingrid));
         }
         catch (Exception) { }
     }
 }
Beispiel #11
0
 private void OnPointerPressed(object sender, PointerRoutedEventArgs e)
 {
     if (e.Pointer.PointerDeviceType != Windows.Devices.Input.PointerDeviceType.Mouse)
     {
         try
         {
             _interactionSource.TryRedirectForManipulation(e.GetCurrentPoint(this));
         }
         catch { }
     }
 }
 private void CoreWindow_PointerPressed(Windows.UI.Core.CoreWindow sender, Windows.UI.Core.PointerEventArgs args)
 {
     try
     {
         interactionSource.TryRedirectForManipulation(args.CurrentPoint);
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
     }
 }
 private void Window_PointerPressed(object sender, PointerRoutedEventArgs e)
 {
     try
     {
         // Tell the system to use the gestures from this pointer point (if it can).
         _interactionSource.TryRedirectForManipulation(e.GetCurrentPoint(null));
     }
     catch (Exception)
     {
         // Ignoring the failed redirect to prevent app crashing
     }
 }
Beispiel #14
0
 private void spContent_PointerPressed(object sender, PointerRoutedEventArgs e)
 {
     if (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Touch && interactionSource != null)
     {
         try
         {
             interactionSource.TryRedirectForManipulation(e.GetCurrentPoint(spContent));
         }
         catch (UnauthorizedAccessException) { }
         isGdInfoHideDef = null;
     }
 }
 private void root_PointerPressed(object sender, PointerRoutedEventArgs e)
 {
     if (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Touch)
     {
         _source.TryRedirectForManipulation(e.GetCurrentPoint(main));
         _direction = -_direction;
     }
     else
     {
         _tracker.TryUpdatePositionWithAdditionalVelocity(new Vector3(0f, 1000f * _direction, 0f));
         _direction = -_direction;
     }
 }
 private void OnPointerPressed(object sender, PointerRoutedEventArgs e)
 {
     if (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Touch || e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Pen)
     {
         try
         {
             _interactionSource.TryRedirectForManipulation(e.GetCurrentPoint(this));
         }
         catch (Exception)
         {
             // Ignoring the failed redirect to prevent app crashing
         }
     }
 }
Beispiel #17
0
 private void OnPointerPressed(object sender, PointerRoutedEventArgs e)
 {
     if (e.Pointer.PointerDeviceType == PointerDeviceType.Touch)
     {
         try
         {
             _interactionSource.TryRedirectForManipulation(e.GetCurrentPoint(Root));
         }
         catch (Exception)
         {
             // Catch unauthorized input.
         }
     }
 }
Beispiel #18
0
 private void MainGrid_PointerPressed(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
 {
     if (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Touch)
     {
         try
         {
             _interactionSource.TryRedirectForManipulation(e.GetCurrentPoint(MainGrid));
         }
         catch (UnauthorizedAccessException)
         {
             // Ignoring the failed redirect to prevent app crashing
         }
     }
 }
Beispiel #19
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            LayoutRoot   = (Grid)GetTemplateChild("LayoutRoot");
            ITRoot       = (Grid)GetTemplateChild("ITRoot");
            Layer        = (Border)GetTemplateChild("Layer");
            ModalContent = (StackPanel)GetTemplateChild("ModalContent");
            TitleBar     = (Grid)GetTemplateChild("TitleBar");
            CloseButton  = (Button)GetTemplateChild("CloseButton");

            DebugText1 = (TextBlock)GetTemplateChild("DebugText1");
            DebugText2 = (TextBlock)GetTemplateChild("DebugText2");
            DebugText3 = (TextBlock)GetTemplateChild("DebugText3");

            Resize();
            Window.Current.SizeChanged += (a, b) => { Resize(b.Size); };
            Loaded += (a, b) => {
                Resize(); // resize popup and layoutroot
                SetupModal();
                _tracker.TryUpdatePosition(new Vector3(0, _tracker.MinPosition.Y + 1, 0));
                OpenHalf();
            };
            ITRoot.PointerPressed += (a, b) => {
                try {
                    _is.TryRedirectForManipulation(b.GetCurrentPoint(this));
                } catch (Exception ex) {
                    Debug.WriteLine("TryRedirectForManipulation: " + ex.ToString());
                }
            };
            ITRoot.PointerWheelChanged += (a, b) => {
                var   o = b.GetCurrentPoint(a as UIElement);
                int   z = o.Properties.MouseWheelDelta;
                float d = (float)z * 1.5f;
                DebugText3.Text = $"Wheel: {z}\nDelta: {d}";
                if (d != 0 && _tracker.Position.Y >= _tracker.MinPosition.Y + StartHeight && _tracker.Position.Y <= _tracker.MaxPosition.Y)
                {
                    if (_tracker.Position.Y == _tracker.MaxPosition.Y && d < 0)
                    {
                        return;
                    }
                    _tracker.TryUpdatePositionWithAnimation(GetScrollKFA(new Vector3(0, _tracker.Position.Y - d, 0)));
                }
            };
            CloseButton.Click += (a, b) => {
                Hide();
            };
            WasShowed = true;
        }
 private void Window_PointerPressed(object sender, PointerRoutedEventArgs e)
 {
     if (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Touch)
     {
         try
         {
             // Tell the system to use the gestures from this pointer point (if it can).
             _interactionSource.TryRedirectForManipulation(e.GetCurrentPoint(null));
         }
         catch (UnauthorizedAccessException)
         {
             // Ignoring the failed redirect to prevent app crashing
         }
     }
 }
Beispiel #21
0
        private async void OnCardChromeHolding(object sender, HoldingRoutedEventArgs e)
        {
            if (e.PointerDeviceType == PointerDeviceType.Touch && e.HoldingState == HoldingState.Started)
            {
                // To create a continuous video playing experience, let's pause it here.
                _mediaElement.Pause();

                // Record the location as we want to resume from here on another device.
                _mediaPlayedPosition = _mediaElement.Position;

                // We don't want to visually move the video player. Instead, we want to create the illusion that
                // a "copy" of it is being dragged down to another device. So here we use RenderTargetBitmap to
                // create such visual.
                var bitmap = new RenderTargetBitmap();
                await bitmap.RenderAsync(Card);

                MediaCopy.Source = bitmap;

                MediaContainer.IsHitTestVisible = false;

                // Create animations to show that a "copy" of the video player is popped up and ready to be dragged up.
                Card.Fade(0.3f).Start();
                MediaCopy
                .Fade(0.7f, 1)
                .Then()
                .Scale(0.975f, 0.975f, (float)Card.ActualWidth / 2, (float)Card.ActualHeight / 2, 300d)
                .Then()
                .Offset(offsetY: -24.0f, duration: 400d)
                .Start();

                // Create an animation that changes the offset of the "copy" based on the manipulation progress.
                _mediaCopyVisual = VisualExtensions.GetVisual(MediaCopy);
                var progressExpressionNode = _progress.GetReference().GetScalarProperty("Progress");
                _mediaCopyVisual.StartAnimation("Offset.Y", progressExpressionNode * -_maxDistance);

                try
                {
                    // Let InteractionTracker to handle the swipe gesture.
                    _interactionSource.TryRedirectForManipulation(_pressedPoint);

                    // Send the card json and media played position over using Remote Sessions API.
                    await RomeShare.SendMediaDataAsync(_cardJson, _mediaPlayedPosition, MediaUrl);
                }
                catch (UnauthorizedAccessException) { }
            }
        }
 private void Root_PointerPressed(object sender, PointerRoutedEventArgs e)
 {
     if (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse)
     {
         _tracker.TryUpdatePositionWithAdditionalVelocity(new Vector3(0.0f, 1000.0f, 0.0f));
     }
     else
     {
         try
         {
             _interactionSource.TryRedirectForManipulation(e.GetCurrentPoint(Root));
         }
         catch (Exception)
         {
             //catch to avoid app crash based on unauthorized input
         }
     }
 }
Beispiel #23
0
 private void ContentBorder_PointerPressed(object sender, PointerRoutedEventArgs e)
 {
     if (IsRedirectForManipulationEnable)
     {
         if (m_source != null)
         {
             if (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Touch)
             {
                 //Mobile RengeBase导致VisualInteractionSource.TryRedirectForManipulation出错
                 //if (e.OriginalSource is Rectangle rect && rect.Name.Contains("TrackRect"))
                 //{
                 //    return;
                 //}
                 if (ContentBorder.CapturePointer(e.Pointer))
                 {
                     ContentBorder.ReleasePointerCapture(e.Pointer);
                     m_source.TryRedirectForManipulation(e.GetCurrentPoint(ContentBorder));
                 }
             }
         }
     }
 }
Beispiel #24
0
        private void ConfigureInteractionTracker()
        {
            if (InfoContent == null)
            {
                return;
            }
            if (HittestContent == null)
            {
                return;
            }

            // Configure hittestVisual size for the interaction (size needs to be explicitly set in order for the hittesting to work correctly due to XAML-COMP interop policy)
            _hittestVisual.Size = new Vector2((float)HittestContent.ActualWidth, (float)HittestContent.ActualHeight);

            _props = _compositor.CreatePropertySet();

            Visual infoVisual  = ElementCompositionPreview.GetElementVisual(InfoContent);
            Visual photoVisual = ElementCompositionPreview.GetElementVisual(PhotoContent);

            photoVisual.Size = new Vector2((float)PhotoContent.ActualWidth, (float)PhotoContent.ActualHeight);

            photoVisual.CenterPoint = new Vector3((float)PhotoContent.ActualWidth * .5f, (float)PhotoContent.ActualHeight * .5f, 0f);
            infoVisual.CenterPoint  = new Vector3((float)InfoContent.ActualWidth * .5f, (float)InfoContent.ActualHeight * .5f, 0f);

            VisualInteractionSource interactionSource = VisualInteractionSource.Create(_hittestVisual);

            //Configure for y-direction panning
            interactionSource.PositionYSourceMode = InteractionSourceMode.EnabledWithInertia;

            //Create tracker and associate interaction source
            _tracker.InteractionSources.Add(interactionSource);

            //Configure tracker boundaries
            _tracker.MaxPosition = new Vector3((float)HittestContent.ActualHeight);

            SpriteVisual shadowVisual = _compositor.CreateSpriteVisual();

            shadowVisual.Size = photoVisual.Size;
            ElementCompositionPreview.SetElementChildVisual(InfoContainer, shadowVisual);

            ConfigureAnimations(photoVisual, infoVisual, shadowVisual);

            ConfigureRestingPoints();

            HittestContent.PointerPressed += (s, a) =>
            {
                // Capture the touch manipulation to the InteractionTracker for automatic handling
                if (a.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Touch)
                {
                    try
                    {
                        interactionSource.TryRedirectForManipulation(a.GetCurrentPoint(s as UIElement));
                    }
                    catch (UnauthorizedAccessException)
                    {
                        // Ignoring the failed redirect to prevent app crashing
                    }
                }
                // Update the InteractionTracker's position to change between min and max for other input types
                else
                {
                    float direction = 1;
                    if (_isExpanded)
                    {
                        direction = -1;
                    }
                    _tracker.TryUpdatePositionWithAdditionalVelocity(new Vector3(0f, direction * 1000f, 0f));
                }
            };
        }