Example #1
0
        public static void Start(BaseUserPage pageWithPointerEventsToRegister)
        {
            if (pageWithPointerEventsToRegister == null)
            {
                return;
            }

            pageWithPointerEventsToRegister.PointerPressed  += page_PointerPressed;
            pageWithPointerEventsToRegister.PointerMoved    += page_PointerMoved;
            pageWithPointerEventsToRegister.PointerReleased += page_PointerReleased;


            _gr = new Windows.UI.Input.GestureRecognizer();
            _gr.CrossSliding                += gr_CrossSliding;
            _gr.Dragging                    += gr_Dragging;
            _gr.Holding                     += gr_Holding;
            _gr.ManipulationCompleted       += gr_ManipulationCompleted;
            _gr.ManipulationInertiaStarting += gr_ManipulationInertiaStarting;
            _gr.ManipulationStarted         += gr_ManipulationStarted;
            _gr.ManipulationUpdated         += gr_ManipulationUpdated;
            _gr.RightTapped                 += gr_RightTapped;
            _gr.Tapped         += gr_Tapped;
            _gr.GestureSettings =
                Windows.UI.Input.GestureSettings.ManipulationRotate
                | Windows.UI.Input.GestureSettings.ManipulationTranslateX
                | Windows.UI.Input.GestureSettings.ManipulationTranslateY
                | Windows.UI.Input.GestureSettings.ManipulationScale
                | Windows.UI.Input.GestureSettings.ManipulationRotateInertia
                | Windows.UI.Input.GestureSettings.ManipulationScaleInertia
                | Windows.UI.Input.GestureSettings.ManipulationTranslateInertia
                | Windows.UI.Input.GestureSettings.Tap
                | Windows.UI.Input.GestureSettings.CrossSlide
            ;
        }
Example #2
0
        public EffectRenderer(Windows.UI.Xaml.UIElement rootForPointerEvents, Windows.UI.Xaml.UIElement rootOfLayout)
        {
            _root       = rootForPointerEvents;
            _rootParent = rootOfLayout;
            EnableClear = true;
            Show        = true;

            clock = new Stopwatch();

            gestureRecognizer = new Windows.UI.Input.GestureRecognizer();
            gestureRecognizer.GestureSettings = Windows.UI.Input.GestureSettings.ManipulationTranslateX |
                                                Windows.UI.Input.GestureSettings.ManipulationTranslateY |
                                                Windows.UI.Input.GestureSettings.ManipulationTranslateInertia;
            gestureRecognizer.ManipulationUpdated += gestureRecognizer_ManipulationUpdated;

            _root.PointerPressed  += _root_PointerPressed;
            _root.PointerReleased += _root_PointerReleased;
            //_root.PointerEntered += _root_PointerPressed;
            //_root.PointerExited += _root_PointerReleased;
            _root.PointerMoved        += _root_PointerMoved;
            _root.PointerWheelChanged += _root_PointerWheelChanged;
            angleX = 0.16f;
            angleY = 1.2f;

            clock.Start();
        }
Example #3
0
        public EffectRenderer(Windows.UI.Xaml.UIElement rootForPointerEvents, Windows.UI.Xaml.UIElement rootOfLayout)
        {
            _root = rootForPointerEvents;
            _rootParent = rootOfLayout;
            EnableClear = true;
            Show = true;

            clock = new Stopwatch();

            gestureRecognizer = new Windows.UI.Input.GestureRecognizer();
            gestureRecognizer.GestureSettings = Windows.UI.Input.GestureSettings.ManipulationTranslateX |
                Windows.UI.Input.GestureSettings.ManipulationTranslateY |
                Windows.UI.Input.GestureSettings.ManipulationTranslateInertia;
            gestureRecognizer.ManipulationUpdated += gestureRecognizer_ManipulationUpdated;

            _root.PointerPressed += _root_PointerPressed;
            _root.PointerReleased += _root_PointerReleased;
            //_root.PointerEntered += _root_PointerPressed;
            //_root.PointerExited += _root_PointerReleased;
            _root.PointerMoved += _root_PointerMoved;
            _root.PointerWheelChanged += _root_PointerWheelChanged;
            angleX = 0.16f;
            angleY = 1.2f;

            clock.Start();
        }
Example #4
0
 void OnRightTapped(Windows.UI.Input.GestureRecognizer sender, Windows.UI.Input.RightTappedEventArgs args)
 {
     if (_holdObj != null)
     {
         DoHolding(_holdObj);
     }
 }
Example #5
0
        public static void Start(BaseUserPage pageWithPointerEventsToRegister)
        {
            if (pageWithPointerEventsToRegister == null) return;

            pageWithPointerEventsToRegister.PointerPressed += page_PointerPressed;
            pageWithPointerEventsToRegister.PointerMoved += page_PointerMoved;
            pageWithPointerEventsToRegister.PointerReleased += page_PointerReleased;


            _gr = new Windows.UI.Input.GestureRecognizer();
            _gr.CrossSliding += gr_CrossSliding;
            _gr.Dragging += gr_Dragging;
            _gr.Holding += gr_Holding;
            _gr.ManipulationCompleted += gr_ManipulationCompleted;
            _gr.ManipulationInertiaStarting += gr_ManipulationInertiaStarting;
            _gr.ManipulationStarted += gr_ManipulationStarted;
            _gr.ManipulationUpdated += gr_ManipulationUpdated;
            _gr.RightTapped += gr_RightTapped;
            _gr.Tapped += gr_Tapped;
            _gr.GestureSettings = 
                Windows.UI.Input.GestureSettings.ManipulationRotate 
                | Windows.UI.Input.GestureSettings.ManipulationTranslateX 
                | Windows.UI.Input.GestureSettings.ManipulationTranslateY 
                | Windows.UI.Input.GestureSettings.ManipulationScale 
                | Windows.UI.Input.GestureSettings.ManipulationRotateInertia 
                | Windows.UI.Input.GestureSettings.ManipulationScaleInertia 
                | Windows.UI.Input.GestureSettings.ManipulationTranslateInertia 
                | Windows.UI.Input.GestureSettings.Tap
                | Windows.UI.Input.GestureSettings.CrossSlide
                ;


        }
Example #6
0
        private void OnManipulationUpdated(Windows.UI.Input.GestureRecognizer sender, Windows.UI.Input.ManipulationUpdatedEventArgs args)
        {
            // Because of the way we process pointer events, all coordinates are expressed
            // in the coordinate system of the reference of the manipulation target.
            // args.Position stores the position of the pivot of this manipulation
            // args.Delta stores the deltas (Translation, Rotation in degrees, and Scale)

            var filteredArgs = new FilterManipulationEventArgs(args);

            if (OnFilterManipulation != null)
            {
                OnFilterManipulation(this, filteredArgs);
            }

            // Update the transform
            // filteredArgs.Pivot indicates the position of the pivot of this manipulation
            // filteredArgs.Delta indicates the deltas (Translation, Rotation in degrees, and Scale)
            this._previousTransform.Matrix  = _transform.Value;
            this._deltaTransform.CenterX    = filteredArgs.Pivot.X;
            this._deltaTransform.CenterY    = filteredArgs.Pivot.Y;
            this._deltaTransform.Rotation   = filteredArgs.Delta.Rotation;
            this._deltaTransform.ScaleX     = _deltaTransform.ScaleY = filteredArgs.Delta.Scale;
            this._deltaTransform.TranslateX = filteredArgs.Delta.Translation.X;
            this._deltaTransform.TranslateY = filteredArgs.Delta.Translation.Y;
        }
Example #7
0
        public static void Stop(BaseUserPage pageWithPointerEventsToUnRegister)
        {
            if (pageWithPointerEventsToUnRegister == null)
            {
                return;
            }

            if (_gr != null)
            {
                _gr.CrossSliding                -= gr_CrossSliding;
                _gr.Dragging                    -= gr_Dragging;
                _gr.Holding                     -= gr_Holding;
                _gr.ManipulationCompleted       -= gr_ManipulationCompleted;
                _gr.ManipulationInertiaStarting -= gr_ManipulationInertiaStarting;
                _gr.ManipulationStarted         -= gr_ManipulationStarted;
                _gr.ManipulationUpdated         -= gr_ManipulationUpdated;
                _gr.RightTapped                 -= gr_RightTapped;
                _gr.Tapped -= gr_Tapped;

                pageWithPointerEventsToUnRegister.PointerPressed  -= page_PointerPressed;
                pageWithPointerEventsToUnRegister.PointerMoved    -= page_PointerMoved;
                pageWithPointerEventsToUnRegister.PointerReleased -= page_PointerReleased;

                _gr = null;
            }
        }
Example #8
0
 static void gr_Tapped(Windows.UI.Input.GestureRecognizer sender, Windows.UI.Input.TappedEventArgs args)
 {
     if (OnGestureRaised != null)
     {
         OnGestureRaised(sender, new CustomGestureArgs()
         {
             TappedEventArgs = args
         });
     }
 }
Example #9
0
 static void gr_ManipulationCompleted(Windows.UI.Input.GestureRecognizer sender, Windows.UI.Input.ManipulationCompletedEventArgs args)
 {
     if (OnGestureRaised != null)
     {
         OnGestureRaised(sender, new CustomGestureArgs()
         {
             ManipulationCompletedArgs = args
         });
     }
 }
Example #10
0
 void OnHolding(Windows.UI.Input.GestureRecognizer sender, Windows.UI.Input.HoldingEventArgs args)
 {
     if (args.HoldingState == Windows.UI.Input.HoldingState.Started)
     {
         if (_holdObj != null)
         {
             DoHolding(_holdObj);
         }
         gestRec.CompleteGesture();
     }
 }
Example #11
0
 void OnTapped(Windows.UI.Input.GestureRecognizer sender, Windows.UI.Input.TappedEventArgs args)
 {
     if (_holdObj != null)
     {
         sectionListBox.SelectedItem = (_holdObj as TextBlock).DataContext;
         if (args.TapCount >= 2)
         {
             sectionListBox_DoubleTapped(null, null);
         }
     }
 }
Example #12
0
        internal InputProcessor(Windows.UI.Xaml.FrameworkElement element, Windows.UI.Xaml.Controls.Canvas reference)
        {
            this._target = element;
            this._reference = reference;

            // Setup pointer event handlers for the element.
            this._target.PointerCanceled += OnPointerCanceled;
            this._target.PointerMoved += OnPointerMoved;
            this._target.PointerPressed += OnPointerPressed;
            this._target.PointerReleased += OnPointerReleased;
            this._target.PointerWheelChanged += OnPointerWheelChanged;

            // Create the gesture recognizer
            this._gestureRecognizer = new Windows.UI.Input.GestureRecognizer();
            this._gestureRecognizer.GestureSettings = Windows.UI.Input.GestureSettings.None;
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="element">
        /// Manipulation target.
        /// </param>
        /// <param name="reference">
        /// Element that contains the coordinate space used for expressing transformations
        /// during manipulations, usually the parent element of Target in the UI tree.
        /// </param>
        /// <remarks>
        /// Transformations during manipulations cannot be expressed in the coordinate space of the manipulation target.
        /// Thus <paramref name="element"/> and <paramref name="reference"/> must be different. Usually <paramref name="reference"/>
        /// will be an ancestor of <paramref name="element"/> in the UI tree.
        /// </remarks>
        internal InputProcessor(Windows.UI.Xaml.FrameworkElement element, Windows.UI.Xaml.Controls.Canvas reference)
        {
            this._target    = element;
            this._reference = reference;

            // Setup pointer event handlers for the element.
            // They are used to feed the gesture recognizer.
            this._target.PointerCanceled     += OnPointerCanceled;
            this._target.PointerMoved        += OnPointerMoved;
            this._target.PointerPressed      += OnPointerPressed;
            this._target.PointerReleased     += OnPointerReleased;
            this._target.PointerWheelChanged += OnPointerWheelChanged;

            // Create the gesture recognizer
            this._gestureRecognizer = new Windows.UI.Input.GestureRecognizer();
            this._gestureRecognizer.GestureSettings = Windows.UI.Input.GestureSettings.None;
        }
Example #14
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="element">
        /// Manipulation target.
        /// </param>
        /// <param name="reference">
        /// Element that contains the coordinate space used for expressing transformations
        /// during manipulations, usually the parent element of Target in the UI tree.
        /// </param>
        /// <remarks>
        /// Transformations during manipulations cannot be expressed in the coordinate space of the manipulation target.
        /// Thus <paramref name="element"/> and <paramref name="reference"/> must be different. Usually <paramref name="reference"/>
        /// will be an ancestor of <paramref name="element"/> in the UI tree.
        /// </remarks>
        internal InputProcessor(Windows.UI.Xaml.FrameworkElement element, Windows.UI.Xaml.Controls.Canvas reference)
        {
            _target    = element;
            _reference = reference;


            _target.AddHandler(UIElement.PointerCanceledEvent, new PointerEventHandler(OnPointerCanceled), true);
            _target.AddHandler(UIElement.PointerCaptureLostEvent, new PointerEventHandler(OnPointerCaptureLost), true);
            _target.AddHandler(UIElement.PointerReleasedEvent, new PointerEventHandler(OnPointerReleased), true);
            _target.AddHandler(UIElement.PointerExitedEvent, new PointerEventHandler(OnPointerExited), true);
            _target.AddHandler(UIElement.PointerMovedEvent, new PointerEventHandler(OnPointerMoved), true);
            _target.AddHandler(UIElement.PointerPressedEvent, new PointerEventHandler(OnPointerPressed), true);
            _target.AddHandler(UIElement.PointerWheelChangedEvent, new PointerEventHandler(OnPointerWheelChanged), true);

            // Create the gesture recognizer
            _gestureRecognizer = new Windows.UI.Input.GestureRecognizer();
            _gestureRecognizer.GestureSettings = Windows.UI.Input.GestureSettings.None;
        }
Example #15
0
        public MainPage()
        {
            this.DataContext = this;
            this.ViewModel = new MyTabViewModel();
            UIChanger = new MyUIChanger();
            this.InitializeComponent();
#if STORETOOLKIT
            AppBarButton RenderButton = new AppBarButton() { Icon = new SymbolIcon(Symbol.Camera), Label = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("Render/Label") };
            RenderButton.Click += RenderPngs_Click;
            (this.BottomAppBar as CommandBar).PrimaryCommands.Add(RenderButton);
#endif
#if WINDOWS_PHONE_APP
            this.NavigationCacheMode = NavigationCacheMode.Required;
#endif
            gestRec = new Windows.UI.Input.GestureRecognizer();
            gestRec.GestureSettings = Windows.UI.Input.GestureSettings.HoldWithMouse | Windows.UI.Input.GestureSettings.Hold | Windows.UI.Input.GestureSettings.Tap | Windows.UI.Input.GestureSettings.DoubleTap | Windows.UI.Input.GestureSettings.RightTap;
            gestRec.Holding += OnHolding;
            gestRec.RightTapped += OnRightTapped;
            gestRec.Tapped += OnTapped;
        }
Example #16
0
 void gestureRecognizer_Holding(Windows.UI.Input.GestureRecognizer sender, Windows.UI.Input.HoldingEventArgs args)
 {
     if (Hold != null && CanHolding)
     {
         if (args.HoldingState == Windows.UI.Input.HoldingState.Started)
         {
             PressProgressBar.Visibility = Visibility.Visible;
             if (!_isAnimateBegin)
             {
                 _isAnimateBegin = true;
                 PressStoryBoard.Begin();
             }
         }
         else
         {
             _isAnimateBegin = false;
             PressStoryBoard.Stop();
             PressProgressBar.Visibility = Visibility.Collapsed;
         }
     }
 }
        private void OnManipulationUpdated(Windows.UI.Input.GestureRecognizer sender, Windows.UI.Input.ManipulationUpdatedEventArgs args)
        {
            _deltaTransform.TranslateX = args.Delta.Translation.X;
            _deltaTransform.TranslateY = args.Delta.Translation.Y;

            _target.SetValue(Windows.UI.Xaml.Controls.Canvas.TopProperty, 0);
            _target.SetValue(Windows.UI.Xaml.Controls.Canvas.LeftProperty, 0);


            // Because of the way we process pointer events, all coordinates are expressed
            // in the coordinate system of the reference of the manipulation target.
            // args.Position stores the position of the pivot of this manipulation
            // args.Delta stores the deltas (Translation, Rotation in degrees, and Scale)

            var filteredArgs = new FilterManipulationEventArgs(args);

            OnFilterManipulation?.Invoke(this, filteredArgs);

            // Update the transform
            // filteredArgs.Pivot indicates the position of the pivot of this manipulation
            // filteredArgs.Delta indicates the deltas (Translation, Rotation in degrees, and Scale)
            _previousTransform.Matrix  = _transform.Value;
            _deltaTransform.CenterX    = filteredArgs.Pivot.X;
            _deltaTransform.CenterY    = filteredArgs.Pivot.Y;
            _deltaTransform.Rotation   = filteredArgs.Delta.Rotation;
            _deltaTransform.TranslateX = filteredArgs.Delta.Translation.X;
            _deltaTransform.TranslateY = filteredArgs.Delta.Translation.Y;

            if (ZoomBehavior == Controls.ZoomType.Resize)
            {
                _target.Height = _target.ActualHeight * filteredArgs.Delta.Scale;
                _target.Width  = _target.ActualWidth * filteredArgs.Delta.Scale;
            }
            else if (ZoomBehavior == Controls.ZoomType.Scale)
            {
                _deltaTransform.ScaleX = _deltaTransform.ScaleY = filteredArgs.Delta.Scale;
            }
        }
Example #18
0
        public static void Stop(BaseUserPage pageWithPointerEventsToUnRegister)
        {
            if (pageWithPointerEventsToUnRegister == null) return;

            if (_gr != null)
            {
                _gr.CrossSliding -= gr_CrossSliding;
                _gr.Dragging -= gr_Dragging;
                _gr.Holding -= gr_Holding;
                _gr.ManipulationCompleted -= gr_ManipulationCompleted;
                _gr.ManipulationInertiaStarting -= gr_ManipulationInertiaStarting;
                _gr.ManipulationStarted -= gr_ManipulationStarted;
                _gr.ManipulationUpdated -= gr_ManipulationUpdated;
                _gr.RightTapped -= gr_RightTapped;
                _gr.Tapped -= gr_Tapped;

                pageWithPointerEventsToUnRegister.PointerPressed -= page_PointerPressed;
                pageWithPointerEventsToUnRegister.PointerMoved -= page_PointerMoved;
                pageWithPointerEventsToUnRegister.PointerReleased -= page_PointerReleased;

                _gr = null;
            }
        }
Example #19
0
 void gestureRecognizer_CrossSliding(Windows.UI.Input.GestureRecognizer sender, Windows.UI.Input.CrossSlidingEventArgs args)
 {
     Debug.WriteLine("ok");
     if (args.ToString() == "Horizontal") //Left or right
     {
         Debug.WriteLine("Left");
         if (_isSettingsOpen)
         {
             VisualStateManager.GoToState(this, "OpeningSettings", true);
             _isSettingsOpen = false;
         }
     }
     else //Left
     {
         // Add code for Left swipe handling
         Debug.WriteLine("Right");
         if (!_isSettingsOpen)
         {
             VisualStateManager.GoToState(this, "ClosingSettings", true);
             _isSettingsOpen = true;
         }
     }
 }
Example #20
0
        public MainPage()
        {
            this.DataContext = this;
            this.ViewModel   = new MyTabViewModel();
            UIChanger        = new MyUIChanger();
            this.InitializeComponent();
#if STORETOOLKIT
            AppBarButton RenderButton = new AppBarButton()
            {
                Icon = new SymbolIcon(Symbol.Camera), Label = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("Render/Label")
            };
            RenderButton.Click += RenderPngs_Click;
            (this.BottomAppBar as CommandBar).PrimaryCommands.Add(RenderButton);
#endif
#if WINDOWS_PHONE_APP
            this.NavigationCacheMode = NavigationCacheMode.Required;
#endif
            gestRec = new Windows.UI.Input.GestureRecognizer();
            gestRec.GestureSettings = Windows.UI.Input.GestureSettings.HoldWithMouse | Windows.UI.Input.GestureSettings.Hold | Windows.UI.Input.GestureSettings.Tap | Windows.UI.Input.GestureSettings.DoubleTap | Windows.UI.Input.GestureSettings.RightTap;
            gestRec.Holding        += OnHolding;
            gestRec.RightTapped    += OnRightTapped;
            gestRec.Tapped         += OnTapped;
        }
        public WordForWordUC()
        {
            this.DataContext = this;
            this.ViewModel = new VirtualizingWrapPanelAdapter();
            UIChanger = new MyUIChanger();
            this.InitializeComponent();

            MainGrid.SizeChanged += OnSizeChanged;
#if WINDOWS_APP
            AppBarButton BackButton = new AppBarButton() { Icon = new SymbolIcon(Symbol.Back), Label = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("Back/Label") };
            BackButton.Click += Back_Click;
            (this.BottomAppBar as CommandBar).PrimaryCommands.Add(BackButton);
#endif
#if STORETOOLKIT
            AppBarButton RenderButton = new AppBarButton() { Icon = new SymbolIcon(Symbol.Camera), Label = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("Render/Label") };
            RenderButton.Click += RenderPngs_Click;
            (this.BottomAppBar as CommandBar).PrimaryCommands.Add(RenderButton);
#endif
            gestRec = new Windows.UI.Input.GestureRecognizer();
            gestRec.GestureSettings = Windows.UI.Input.GestureSettings.HoldWithMouse | Windows.UI.Input.GestureSettings.Hold | Windows.UI.Input.GestureSettings.RightTap | Windows.UI.Input.GestureSettings.Tap;
            gestRec.Holding += OnHolding;
            gestRec.RightTapped += OnRightTapped;
            gestRec.Tapped += OnTapped;
        }
Example #22
0
 void gestureRecognizer_ManipulationUpdated(Windows.UI.Input.GestureRecognizer sender, Windows.UI.Input.ManipulationUpdatedEventArgs args)
 {
     UpdateAngle((float)args.Delta.Translation.X, (float)args.Delta.Translation.Y);
 }
Example #23
0
 static void gr_RightTapped(Windows.UI.Input.GestureRecognizer sender, Windows.UI.Input.RightTappedEventArgs args)
 {
     //Debug.WriteLine("gr_RightTapped");
 }
Example #24
0
 private void gestureRecognizer_Tapped(Windows.UI.Input.GestureRecognizer sender, Windows.UI.Input.TappedEventArgs args)
 {
     Click?.Invoke(this, EventArgs.Empty);
 }
Example #25
0
 static void gr_ManipulationInertiaStarting(Windows.UI.Input.GestureRecognizer sender, Windows.UI.Input.ManipulationInertiaStartingEventArgs args)
 {
     //if (OnGestureRaised != null) OnGestureRaised(sender, new CustomGestureArgs() { ManipulationInertiaStartingArgs = args });
 }
Example #26
0
 static void gr_CrossSliding(Windows.UI.Input.GestureRecognizer sender, Windows.UI.Input.CrossSlidingEventArgs args)
 {
     //Debug.WriteLine("gr_CrossSliding");
 }