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 createShadow(Point fromInkableScene) { InkableScene inkableScene = MainViewController.Instance.InkableScene; if (inkableScene != null && DataContext != null) { _currentFromInkableScene = fromInkableScene; _shadow = new AttributeGroupView(); _shadow.DataContext = new InputGroupViewModel() { AttributeOperationModel = (DataContext as InputGroupViewModel).AttributeOperationModel, IsShadow = true }; _shadow.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); _shadow.Width = this.ActualWidth; _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); (DataContext as InputGroupViewModel).FireMoved(bounds, (DataContext as InputGroupViewModel).AttributeOperationModel); } }
private void OperationTypeModelDropped(object sender, OperationTypeModelEventArgs e) { var width = OperationViewModel.WIDTH; var height = OperationViewModel.HEIGHT; var size = new Vec(width, height); var position = (Pt) new Vec(e.Bounds.Center.X, e.Bounds.Center.Y) - size / 2.0; var operationTypeModel = sender as OperationTypeModel; OperationViewModel operationViewModel = null; if (operationTypeModel.OperationType == OperationType.Histogram) { operationViewModel = CreateDefaultHistogramOperationViewModel(null, position); } else if (operationTypeModel.OperationType == OperationType.Example) { operationViewModel = CreateDefaultExampleOperationViewModel(position); } if (operationViewModel != null) { var operationContainerView = new OperationContainerView(); operationViewModel.Size = size; operationContainerView.DataContext = operationViewModel; InkableScene.Add(operationContainerView); } }
private void addAttachmentViews(OperationViewModel visModel) { foreach (var attachmentViewModel in visModel.AttachementViewModels) { var attachmentView = new AttachmentView { DataContext = attachmentViewModel }; InkableScene.Add(attachmentView); } }
public OperationContainerView CopyOperationViewModel(OperationViewModel operationViewModel, Pt?centerPoint) { var newOperationContainerView = new OperationContainerView(); var newOperationViewModel = OperationViewModelFactory.CopyOperationViewModel(operationViewModel); addAttachmentViews(newOperationViewModel); OperationViewModels.Add(newOperationViewModel); if (centerPoint.HasValue) { newOperationViewModel.Position = (Pt)centerPoint - operationViewModel.Size / 2.0; } newOperationContainerView.DataContext = newOperationViewModel; InkableScene.Add(newOperationContainerView); return(newOperationContainerView); }
public void createShadow(Point fromInkableScene) { InkableScene inkableScene = MainViewController.Instance.InkableScene; if (inkableScene != null) { _shadow = new CreateLinkMenuItemView(); _shadow.DataContext = new CreateLinkMenuItemViewModel(); _shadow.Width = this.ActualWidth; _shadow.Height = this.ActualHeight; _shadow.RenderTransform = new TranslateTransform() { X = fromInkableScene.X - _shadow.Width / 2.0, Y = fromInkableScene.Y - _shadow.Height }; inkableScene.Add(_shadow); _shadow.SendToFront(); } }
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); } }
private void AttributeTransformationViewModelDropped(object sender, AttributeTransformationViewModelEventArgs e) { IGeometry mainPageBounds = e.Bounds.GetPolygon(); var hits = new List <AttributeTransformationViewModelEventHandler>(); foreach (var element in InkableScene.GetDescendants().OfType <AttributeTransformationViewModelEventHandler>()) { var geom = element.BoundsGeometry; if ((geom != null) && mainPageBounds.Intersects(geom)) { hits.Add(element); } } var width = OperationViewModel.WIDTH; var height = OperationViewModel.HEIGHT; var size = new Vec(width, height); var position = (Pt) new Vec(e.Bounds.Center.X, e.Bounds.Center.Y) - size / 2.0; var orderderHits = hits.OrderBy(fe => (fe.BoundsGeometry.Centroid.GetVec() - e.Bounds.Center.GetVec()).LengthSquared).ToList(); foreach (var element in InkableScene.GetDescendants().OfType <AttributeTransformationViewModelEventHandler>()) { element.AttributeTransformationViewModelDropped( sender as AttributeTransformationViewModel, e, (hits.Count() > 0) && (orderderHits[0] == element)); } if (!hits.Any()) { var operationContainerView = new OperationContainerView(); var histogramOperationViewModel = CreateDefaultHistogramOperationViewModel(e.AttributeTransformationModel.AttributeModel, position); histogramOperationViewModel.Size = size; operationContainerView.DataContext = histogramOperationViewModel; InkableScene.Add(operationContainerView); } }
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; } }
private void InkableSceneInkCollectedEvent(object sender, InkCollectedEventArgs e) { var recognizedGestures = _gesturizer.Recognize(e.InkStroke.Clone()); foreach (var recognizedGesture in recognizedGestures.ToList()) { if (recognizedGesture is ConnectGesture) { var connect = recognizedGesture as ConnectGesture; if (connect.FilterConsumerOperationViewModel == null) { connect.CreateConsumer(e.InkStroke.Clone()); } FilterLinkViewController.Instance.CreateFilterLinkViewModel(connect.FilterProviderOperationViewModel, connect.FilterConsumerOperationViewModel); } else if (recognizedGesture is HitGesture) { var hitGesture = recognizedGesture as HitGesture; foreach (var hitScribbable in hitGesture.HitScribbables) { if (hitScribbable is InkStroke) { InkableScene.Remove(hitScribbable as InkStroke); } else if (hitScribbable is OperationContainerView) { RemoveOperationViewModel(hitScribbable as OperationContainerView); } else if (hitScribbable is FilterLinkView) { var models = (hitScribbable as FilterLinkView).GetLinkModelsToRemove(e.InkStroke.Geometry); foreach (var model in models) { FilterLinkViewController.Instance.RemoveFilterLinkViewModel(model); } } else if (hitScribbable is MenuItemView) { var model = (hitScribbable as MenuItemView).DataContext as MenuItemViewModel; model.FireDeleted(); } } } } if (!e.InkStroke.IsErase && !recognizedGestures.Any()) { var allScribbables = new List <IScribbable>(); IScribbleHelpers.GetScribbablesRecursive(allScribbables, InkableScene.Elements.OfType <IScribbable>().ToList()); var inkStroke = e.InkStroke.GetResampled(20); var inkStrokeLine = inkStroke.GetLineString(); var consumed = false; foreach (var existingScribbable in allScribbables) { var geom = existingScribbable.Geometry; if (geom != null) { if (inkStrokeLine.Intersects(geom)) { consumed = existingScribbable.Consume(e.InkStroke); if (consumed) { break; } } } } if (!consumed) { InkableScene.Add(e.InkStroke); } } }