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; }
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); } }
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 MainViewController(InkableScene inkableScene, MainPage mainPage) { InkableScene = inkableScene; MainPage = mainPage; // disable for cidr demo BrushableViewController.CreateInstance(OperationViewModels); ComparisonViewController.CreateInstance(OperationViewModels); MainModel = new MainModel(); AttributeTransformationViewModel.AttributeTransformationViewModelDropped += AttributeTransformationViewModelDropped; AttributeTransformationViewModel.AttributeTransformationViewModelMoved += AttributeTransformationViewModelMoved; InputGroupViewModel.InputGroupViewModelDropped += InputGroupViewModelDropped; InputGroupViewModel.InputGroupViewModelMoved += InputGroupViewModelMoved; OperationTypeModel.OperationTypeModelDropped += OperationTypeModelDropped; OperationTypeModel.OperationTypeModelMoved += OperationTypeModelMoved; InkableScene.InkCollectedEvent += InkableSceneInkCollectedEvent; OperationViewModels.CollectionChanged += OperationViewViewModels_CollectionChanged; _gesturizer.AddGesture(new ConnectGesture(InkableScene)); _gesturizer.AddGesture(new EraseGesture(InkableScene)); //_gesturizer.AddGesture(new ScribbleGesture(_root)); }
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; } }
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 UpdateJobStatus() { foreach (var current in OperationViewModels.ToArray()) { // check if we need to halt or resume the job var tg = InkableScene.TransformToVisual(MainPage); var tt = tg.TransformBounds(current.Bounds); if (!MainPage.GetBounds().IntersectsWith(tt) && MainModel.QueryExecuter.IsJobRunning(current.OperationModel)) { MainModel.QueryExecuter.HaltJob(current.OperationModel); } else if (MainPage.GetBounds().IntersectsWith(tt) && !MainModel.QueryExecuter.IsJobRunning(current.OperationModel)) { MainModel.QueryExecuter.ResumeJob(current.OperationModel); } } }
private void AttributeTransformationViewModelMoved(object sender, AttributeTransformationViewModelEventArgs e) { IGeometry mainPageBounds = e.Bounds.GetPolygon(); var hits = new List <AttributeTransformationViewModelEventHandler>(); var tt = InkableScene.GetDescendants().OfType <AttributeTransformationViewModelEventHandler>().ToList(); foreach (var element in tt) { var geom = element.BoundsGeometry; if ((geom != null) && mainPageBounds.Intersects(geom)) { hits.Add(element); } } var ops = InkableScene.GetDescendants().OfType <OperationContainerView>().ToList(); foreach (var element in ops) { var geom = element.Geometry; if ((geom != null) && (mainPageBounds.Distance(geom) < 100)) { foreach (var a in (element.DataContext as OperationViewModel).AttachementViewModels) { if (a.ShowOnAttributeMove) { a.ActiveStopwatch.Restart(); } } } } var orderderHits = hits.OrderBy(fe => (fe.BoundsGeometry.Centroid.GetVec() - e.Bounds.Center.GetVec()).LengthSquared).ToList(); foreach (var element in InkableScene.GetDescendants().OfType <AttributeTransformationViewModelEventHandler>()) { element.AttributeTransformationViewModelMoved( sender as AttributeTransformationViewModel, e, (hits.Count() > 0) && (orderderHits[0] == element)); } }
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; }
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(); } }
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); } }
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); } }
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 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); } } }
public static void CreateInstance(InkableScene root, MainPage mainPage) { Instance = new MainViewController(root, mainPage); Instance.LoadConfig(); }
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); } } }