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; } }
public void createShadow(Point fromInkableScene) { InkableScene inkableScene = MainViewController.Instance.InkableScene; var model = ((AttributeTransformationMenuItemViewModel)((MenuItemViewModel)DataContext).MenuItemComponentViewModel).AttributeTransformationViewModel; if (inkableScene != null && model != null) { _currentFromInkableScene = fromInkableScene; _shadow = new AttributeFieldView(); _shadow.DataContext = new AttributeTransformationViewModel(null, model.AttributeTransformationModel) { IsNoChrome = false, IsMenuEnabled = true, IsShadow = true }; _shadow.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); double add = model.IsNoChrome ? 30 : 0; //_shadow.Width = this.ActualWidth + add; //_shadow.Height = _shadow.DesiredSize.Height; _shadow.RenderTransform = new TranslateTransform() { X = fromInkableScene.X - _shadow.Width / 2.0, Y = fromInkableScene.Y - _shadow.Height }; inkableScene.Add(_shadow); _shadow.SendToFront(); Rct bounds = _shadow.GetBounds(inkableScene); model.FireMoved(bounds, model.AttributeTransformationModel); } }