void mainPointerManager_Moved(object sender, PointerManagerEvent e)
        {
            if (e.NumActiveContacts == 1)
            {
                GeneralTransform gt           = this.TransformToVisual(MainViewController.Instance.InkableScene);
                Point            currentPoint = gt.TransformPoint(e.CurrentContacts[e.TriggeringPointer.PointerId].Position);

                Vec delta = gt.TransformPoint(e.StartContacts[e.TriggeringPointer.PointerId].Position).GetVec() - currentPoint.GetVec();

                if (delta.Length > 10 && _shadow == null)
                {
                    createShadow(currentPoint);
                }

                if (_shadow != null)
                {
                    InkableScene inkableScene = MainViewController.Instance.InkableScene;
                    _shadow.RenderTransform = new TranslateTransform()
                    {
                        X = currentPoint.X - _shadow.Width / 2.0,
                        Y = currentPoint.Y - _shadow.Height
                    };
                    if (inkableScene != null)
                    {
                        inkableScene.Add(_shadow);
                    }
                }

                _mainPointerManagerPreviousPoint = currentPoint;
            }
        }
        public void Released(FrameworkElement sender, PointerManagerEvent e, bool isRightMouse)
        {
            if (_movingStarted)
            {
                _movingStarted = false;
            }
            else if (_tapStart.ElapsedMilliseconds < 300)
            {
                var trans = sender.TransformToVisual(MainViewController.Instance.InkableScene);
                if (e.CurrentContacts.ContainsKey(e.TriggeringPointer.PointerId))
                {
                    _renderer.StartSelection(trans.TransformPoint(e.CurrentContacts[e.TriggeringPointer.PointerId].Position));
                    var used = _renderer.EndSelection();

                    OperationViewModel model = (DataContext as OperationViewModel);
                    if (!used)
                    {
                        foreach (var avm in model.AttachementViewModels)
                        {
                            //avm.ActiveStopwatch.Restart();
                        }
                    }
                }
            }
            _fingerDown = false;

            if (isRightMouse)
            {
                MainViewController.Instance.RemoveOperationViewModel(this);
            }
        }
        void mainPointerManager_Removed(object sender, PointerManagerEvent e)
        {
            if (!(DataContext as AttributeTransformationViewModel).IsDraggable)
            {
                return;
            }
            if (_shadow == null &&
                _manipulationStartTime + TimeSpan.FromSeconds(0.5).Ticks > DateTime.Now.Ticks)
            {
                if ((DataContext as AttributeTransformationViewModel).IsMenuEnabled && InputFieldViewModelTapped != null)
                {
                    Debug.WriteLine("--TAPP");
                    InputFieldViewModelTapped(this, new EventArgs());
                }
            }

            if (_shadow != null)
            {
                InkableScene inkableScene = MainViewController.Instance.InkableScene;

                Rct bounds = _shadow.GetBounds(inkableScene);
                (DataContext as AttributeTransformationViewModel).FireDropped(bounds,
                                                                              new AttributeTransformationModel((DataContext as AttributeTransformationViewModel).AttributeTransformationModel.AttributeModel)
                {
                    AggregateFunction = (DataContext as AttributeTransformationViewModel).AttributeTransformationModel.AggregateFunction
                });

                inkableScene.Remove(_shadow);
                _shadow = null;
            }

            _manipulationStartTime = 0;
        }
        void mainPointerManager_Removed(object sender, PointerManagerEvent e)
        {
            var menuItemModel = (DataContext as MenuItemViewModel);
            var sliderModel   = menuItemModel.MenuItemComponentViewModel as SliderMenuItemComponentViewModel;

            sliderModel.FinalValue = sliderModel.Value;
        }
Exemplo n.º 5
0
 private void mainPointerManager_Removed(object sender, PointerManagerEvent e)
 {
     if (e.NumActiveContacts == 1)
     {
         var gt = MainViewController.Instance.InkableScene.TransformToVisual(this);
         _mainPointerManagerPreviousPoint = gt.TransformPoint(e.CurrentContacts.Values.ToList()[0].Position);
     }
 }
 private void mainPointerManager_Added(object sender, PointerManagerEvent e)
 {
     if (e.NumActiveContacts == 1)
     {
         GeneralTransform gt = this.TransformToVisual(MainViewController.Instance.InkableScene);
         _mainPointerManagerPreviousPoint = gt.TransformPoint(e.CurrentContacts[e.TriggeringPointer.PointerId].Position);
     }
 }
        public void Pressed(FrameworkElement sender, PointerManagerEvent e)
        {
            _tapStart.Restart();
            var trans = sender.TransformToVisual(MainViewController.Instance.InkableScene);

            _previousPoint = trans.TransformPoint(e.CurrentContacts[e.TriggeringPointer.PointerId].Position);
            _initialPoint  = _previousPoint;
            _movingStarted = false;
            _fingerDown    = true;
        }
        void resizePointerManager_Added(object sender, PointerManagerEvent e)
        {
            if (e.NumActiveContacts == 1)
            {
                GeneralTransform gt = resizeGrid.TransformToVisual(MainViewController.Instance.InkableScene);
                _resizePointerManagerPreviousPoint = gt.TransformPoint(e.CurrentContacts[e.TriggeringPointer.PointerId].Position);

                //OperationViewModel model = (DataContext as OperationViewModel);
                //model.AttachementViewModels.ForEach(avm => avm.Value.IsDisplayed = true);
            }
        }
Exemplo n.º 9
0
        private void mainPointerManager_Moved(object sender, PointerManagerEvent e)
        {
            if (e.NumActiveContacts == 1)
            {
                var gt           = MainViewController.Instance.InkableScene.TransformToVisual(this);
                var currentPoint = gt.TransformPoint(e.CurrentContacts[e.TriggeringPointer.PointerId].Position);

                var delta = _mainPointerManagerPreviousPoint.GetVec() - currentPoint.GetVec();

                var xform  = MainViewController.Instance.InkableScene.RenderTransform as MatrixTransform;
                Mat matrix = xform.Matrix;
                //Point center = e.Position;
                //matrix = Mat.Translate(-center.X, -center.Y) * matrix;
                //matrix = Mat.Scale(delta.Scale, delta.Scale) * matrix;
                //matrix = Mat.Translate(+center.X, +center.Y) * matrix;
                matrix = Mat.Translate(-delta.X, -delta.Y) * matrix;
                MainViewController.Instance.InkableScene.RenderTransform = new MatrixTransform
                {
                    Matrix = matrix
                };

                _mainPointerManagerPreviousPoint = currentPoint;
            }
            else if (e.NumActiveContacts == 2)
            {
                var gt = MainViewController.Instance.InkableScene.TransformToVisual(this);
                var p1 = gt.TransformPoint(e.CurrentContacts.Values.ToList()[0].Position);
                var p2 = gt.TransformPoint(e.CurrentContacts.Values.ToList()[1].Position);

                var currentPoint  = ((p1.GetVec() + p2.GetVec()) / 2.0).GetWindowsPoint();
                var currentLength = (p1.GetVec() - p2.GetVec()).Length;

                var s = currentLength / _length;

                var delta = _mainPointerManagerPreviousPoint.GetVec() - currentPoint.GetVec();

                var xform  = MainViewController.Instance.InkableScene.RenderTransform as MatrixTransform;
                Mat matrix = xform.Matrix;
                matrix =
                    Mat.Translate(currentPoint.X, currentPoint.Y) *
                    Mat.Scale(s, s) *
                    Mat.Translate(-currentPoint.X, -currentPoint.Y) *
                    matrix;
                MainViewController.Instance.InkableScene.RenderTransform = new MatrixTransform
                {
                    Matrix = matrix
                };

                _mainPointerManagerPreviousPoint = currentPoint;
                _length = currentLength;
            }
        }
        void mainPointerManager_Moved(object sender, PointerManagerEvent e)
        {
            if (e.NumActiveContacts == 1)
            {
                var menuItemModel = (DataContext as MenuItemViewModel);
                var sliderModel   = menuItemModel.MenuItemComponentViewModel as SliderMenuItemComponentViewModel;

                Pt     pos = e.CurrentContacts[e.TriggeringPointer.PointerId].Position;
                double x   = Math.Min(Math.Max(pos.X, 0), menuItemModel.TargetSize.X) / menuItemModel.TargetSize.X;
                sliderModel.Value = Math.Round(x * (sliderModel.MaxValue - sliderModel.MinValue) + sliderModel.MinValue);
                //updateRendering();
            }
        }
        void resizePointerManager_Moved(object sender, PointerManagerEvent e)
        {
            if (e.NumActiveContacts == 1)
            {
                GeneralTransform gt           = resizeGrid.TransformToVisual(MainViewController.Instance.InkableScene);
                Point            currentPoint = gt.TransformPoint(e.CurrentContacts[e.TriggeringPointer.PointerId].Position);

                Vec delta = _resizePointerManagerPreviousPoint.GetVec() - currentPoint.GetVec();
                OperationViewModel model = (DataContext as OperationViewModel);
                model.Size = new Vec(Math.Max(model.Size.X - delta.X, OperationViewModel.MIN_WIDTH), Math.Max(model.Size.Y - delta.Y, OperationViewModel.MIN_HEIGHT));
                _resizePointerManagerPreviousPoint = currentPoint;
            }
        }
        private void mainPointerManager_Added(object sender, PointerManagerEvent e)
        {
            if (!(DataContext as AttributeTransformationViewModel).IsDraggable)
            {
                return;
            }

            if (e.NumActiveContacts == 1)
            {
                GeneralTransform gt = this.TransformToVisual(MainViewController.Instance.InkableScene);
                _mainPointerManagerPreviousPoint = gt.TransformPoint(e.CurrentContacts[e.TriggeringPointer.PointerId].Position);
                _manipulationStartTime           = DateTime.Now.Ticks;
            }
        }
 void _pointerManager_Removed(object sender, PointerManagerEvent e)
 {
     if (e.NumActiveContacts < 2)
     {
         _inertiaHandler.InertiaActive = true;
         if (e.NumActiveContacts < 1 && _oneFingerListener != null)
         {
             _oneFingerListener.Released(_frameworkElement, e, e.IsRightMouse);
         }
     }
     if (scrollPointer != null && e.TriggeringPointer.PointerId == scrollPointer.PointerId)
     {
         scrollPointer = null;
     }
 }
        public void Moved(FrameworkElement sender, PointerManagerEvent e)
        {
            var trans        = sender.TransformToVisual(MainViewController.Instance.InkableScene);
            var currentPoint = trans.TransformPoint(e.CurrentContacts[e.TriggeringPointer.PointerId].Position);

            if (((_initialPoint.GetVec() - currentPoint.GetVec()).Length2 > 100 || _movingStarted) &&
                _tapStart.ElapsedMilliseconds > 50)
            {
                _movingStarted = true;
                Vec delta = _previousPoint.GetVec() - currentPoint.GetVec();
                OperationViewModel model = (DataContext as OperationViewModel);
                model.Position -= delta;
            }
            _previousPoint = currentPoint;
        }
 void _pointerManager_Added(object sender, PointerManagerEvent e)
 {
     if (e.NumActiveContacts == 1 && _oneFingerListener != null)
     {
         var tt = e.CurrentContacts[e.TriggeringPointer.PointerId].Position;
         _oneFingerListener.Pressed(_frameworkElement, e);
     }
     else if (e.NumActiveContacts == 2 && _scrollViewer != null)
     {
         scrollPointer                 = e.TriggeringPointer;
         _startPoint                   = e.CurrentContacts[scrollPointer.PointerId].Position;
         _previousPoint                = _startPoint;
         _startVerticalOffset          = _scrollViewer.VerticalOffset;
         _inertiaHandler.InertiaActive = false;
     }
 }
        private void mainPointerManager_Added(object sender, PointerManagerEvent e)
        {
            var model = ((AttributeTransformationMenuItemViewModel)((MenuItemViewModel)DataContext).MenuItemComponentViewModel);

            if (!model.CanDrag)
            {
                return;
            }

            if (e.NumActiveContacts == 1)
            {
                GeneralTransform gt = this.TransformToVisual(MainViewController.Instance.InkableScene);
                _mainPointerManagerPreviousPoint = gt.TransformPoint(e.CurrentContacts[e.TriggeringPointer.PointerId].Position);
                _manipulationStartTime           = DateTime.Now.Ticks;
            }
        }
Exemplo n.º 17
0
 private void mainPointerManager_Added(object sender, PointerManagerEvent e)
 {
     if (e.NumActiveContacts == 1)
     {
         var gt = MainViewController.Instance.InkableScene.TransformToVisual(this);
         _mainPointerManagerPreviousPoint =
             gt.TransformPoint(e.CurrentContacts[e.TriggeringPointer.PointerId].Position);
     }
     else if (e.NumActiveContacts == 2)
     {
         var gt = MainViewController.Instance.InkableScene.TransformToVisual(this);
         var p1 = gt.TransformPoint(e.CurrentContacts.Values.ToList()[0].Position);
         var p2 = gt.TransformPoint(e.CurrentContacts.Values.ToList()[1].Position);
         _mainPointerManagerPreviousPoint = ((p1.GetVec() + p2.GetVec()) / 2.0).GetWindowsPoint();
         _length = (p1.GetVec() - p2.GetVec()).Length;
     }
 }
Exemplo n.º 18
0
        void mainPointerManager_Removed(object sender, PointerManagerEvent e)
        {
            if (_shadow == null &&
                _manipulationStartTime + TimeSpan.FromSeconds(0.5).Ticks > DateTime.Now.Ticks)
            {
                // tapp
            }

            if (_shadow != null)
            {
                InkableScene inkableScene = MainViewController.Instance.InkableScene;

                Rct bounds = _shadow.GetBounds(inkableScene);
                (DataContext as InputGroupViewModel).FireDropped(bounds, (DataContext as InputGroupViewModel).AttributeOperationModel);

                inkableScene.Remove(_shadow);
                _shadow = null;
            }

            _manipulationStartTime = 0;
        }
        void mainPointerManager_Removed(object sender, PointerManagerEvent e)
        {
            var model = ((AttributeTransformationMenuItemViewModel)((MenuItemViewModel)DataContext).MenuItemComponentViewModel);

            if (!model.CanDrag)
            {
                return;
            }
            if (_shadow == null &&
                _manipulationStartTime + TimeSpan.FromSeconds(0.5).Ticks > DateTime.Now.Ticks)
            {
                var attrModel =
                    ((AttributeTransformationMenuItemViewModel)
                     ((MenuItemViewModel)DataContext).MenuItemComponentViewModel);
                if (attrModel != null && attrModel.TappedTriggered != null)
                {
                    attrModel.TappedTriggered();
                }
            }

            if (_shadow != null)
            {
                InkableScene inkableScene = MainViewController.Instance.InkableScene;

                Rct bounds = _shadow.GetBounds(inkableScene);

                model.AttributeTransformationViewModel.FireDropped(bounds,
                                                                   new AttributeTransformationModel(model.AttributeTransformationViewModel.AttributeTransformationModel.AttributeModel)
                {
                    AggregateFunction = model.AttributeTransformationViewModel.AttributeTransformationModel.AggregateFunction
                });

                inkableScene.Remove(_shadow);
                _shadow = null;
            }

            _manipulationStartTime = 0;
        }
        void mainPointerManager_Moved(object sender, PointerManagerEvent e)
        {
            var model = ((AttributeTransformationMenuItemViewModel)((MenuItemViewModel)DataContext).MenuItemComponentViewModel);

            if (e.NumActiveContacts == 1 && model.CanDrag)
            {
                GeneralTransform gt           = this.TransformToVisual(MainViewController.Instance.InkableScene);
                Point            currentPoint = gt.TransformPoint(e.CurrentContacts[e.TriggeringPointer.PointerId].Position);

                Vec delta = gt.TransformPoint(e.StartContacts[e.TriggeringPointer.PointerId].Position).GetVec() - currentPoint.GetVec();

                if (delta.Length > 10 && _shadow == null)
                {
                    createShadow(currentPoint);
                }

                if (_shadow != null)
                {
                    InkableScene inkableScene = MainViewController.Instance.InkableScene;
                    _shadow.RenderTransform = new TranslateTransform()
                    {
                        X = currentPoint.X - _shadow.Width / 2.0,
                        Y = currentPoint.Y - _shadow.Height
                    };
                    if (inkableScene != null)
                    {
                        inkableScene.Add(_shadow);

                        Rct bounds = _shadow.GetBounds(inkableScene);
                        model.AttributeTransformationViewModel.FireMoved(bounds, model.AttributeTransformationViewModel.AttributeTransformationModel);
                    }
                }

                _mainPointerManagerPreviousPoint = currentPoint;
            }
        }
        void _pointerManager_Moved(object sender, PointerManagerEvent e)
        {
            if (e.NumActiveContacts == 1 && _oneFingerListener != null)
            {
                _oneFingerListener.Moved(_frameworkElement, e);
            }
            else if (_scrollViewer != null && e.NumActiveContacts == 2 && scrollPointer != null && e.CurrentPointers.Contains(scrollPointer) && e.TriggeringPointer.PointerId == scrollPointer.PointerId)
            {
                _oneFingerListener.TwoFingerMoved();

                Point  currentPoint = e.CurrentContacts[scrollPointer.PointerId].Position;
                double yDelta       = _startPoint.Y - currentPoint.Y;
                _scrollViewer.ChangeView(0, yDelta + _startVerticalOffset, 1);

                _inertiaHandler.InertiaActive = false;
                _inertiaHandler.ScrollTarget  = new Point(0, yDelta + _startVerticalOffset);
                if (_previousPoint.Y - currentPoint.Y != 0)
                {
                    _inertiaHandler.Velocity = new Vec(0, _previousPoint.Y - currentPoint.Y);
                }

                _previousPoint = currentPoint;
            }
        }
        void mainPointerManager_Removed(object sender, PointerManagerEvent e)
        {
            if (_shadow != null)
            {
                InkableScene inkableScene = MainViewController.Instance.InkableScene;

                Rct bounds = _shadow.GetBounds(inkableScene);

                /*model.AttributeTransformationViewModel.FireDropped(bounds,
                 *  new AttributeTransformationModel(model.AttributeTransformationViewModel.AttributeTransformationModel.AttributeModel)
                 *  {
                 *      AggregateFunction = model.AttributeTransformationViewModel.AttributeTransformationModel.AggregateFunction
                 *  });
                 */
                inkableScene.Remove(_shadow);
                _shadow = null;

                var model = ((MenuItemViewModel)this.DataContext).MenuItemComponentViewModel as CreateLinkMenuItemViewModel;
                if (model != null)
                {
                    model.FireCreateLinkEvent(bounds);
                }
            }
        }
 void resizePointerManager_Removed(object sender, PointerManagerEvent e)
 {
     //OperationViewModel model = (DataContext as OperationViewModel);
     //model.AttachementViewModels.ForEach(avm => avm.Value.IsDisplayed = false);
 }