private ModelBase GetBoundModel(object dataItem) { // Attempt get to the data-bound model (if there's any). var nodeModel = dataItem as NodeModel; var noteModel = dataItem as NoteModel; var annotationModel = dataItem as AnnotationModel; if (null == nodeModel && (null == noteModel) && (null == annotationModel)) { var nodeViewModel = dataItem as NodeViewModel; if (null != nodeViewModel) nodeModel = nodeViewModel.NodeModel; else { NoteViewModel noteViewModel = dataItem as NoteViewModel; if (null != noteViewModel) noteModel = noteViewModel.Model; else { AnnotationViewModel annotationViewModel = dataItem as AnnotationViewModel; if (null != annotationViewModel) annotationModel = annotationViewModel.AnnotationModel; } } } if (null != nodeModel) return nodeModel; else if (null != noteModel) return noteModel; return annotationModel; }
public void Draw(TContext context, AnnotationViewModel annotation) { if (annotation.SurfacePoints.Count == 0) { return; // nothing happens } AnnotationPoint p1, p2; p1 = annotation.SurfacePoints[0]; p2 = annotation.SurfacePoints.Count == 1 ? p1 : annotation.SurfacePoints[1]; switch (annotation.Type) { case AnnotationType.AdHoc: DrawAdHoc(context, annotation.SurfacePoints); break; case AnnotationType.Ellipse: DrawEllipse(context, p1, p2); break; case AnnotationType.Line: DrawLine(context, p1, p2); break; case AnnotationType.Rectangle: DrawRectangle(context, p1, p2); break; } }
protected void OnAnnotationViewModelAdded(AnnotationViewModel annotation) { var ev = AnnotationAdded; if (ev != null) { ev(this, new AnnotationViewModelAddedEventsArgs(annotation)); } }
public IActionResult Delete(Guid id) { var annotationViewModel = new AnnotationViewModel { Id = id }; var annotationCommand = _mapper.Map <DeleteAnnotationCommand>(annotationViewModel); _mediator.SendCommand(annotationCommand); return(Response(annotationCommand)); }
private void WrapUpMove() { _currentBuilder = null; _currentAnnotation = null; ReleaseMouseCapture(); IsEditing = false; CurrentAnnotationType = null; }
private void HookupAnnotationsModel() { AnnotationViewModel.WhenAny(v => v.Annotations, v => v.Value). ObserveOn(RxApp.MainThreadScheduler) .Subscribe(_ => SetNeedsDisplay()); if (AnnotationViewModel is AgentAnnotationViewModel) { var vm = (AgentAnnotationViewModel)AnnotationViewModel; vm.AnnotationTools.WhenAny(p => p.Type, p => p.Value) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(p => Toggle(p != null)); } }
private void ContextMenuInitial(Point p, double padding) { ContextMenu Menu = new ContextMenu(); var AnnotationModel = new AnnotationViewModel(); Menu.DataContext = AnnotationModel; AnnotationModel.UpdateTagCollection += (tagItem, tagEnum) => { var mode = DataContext as ContentPageViewModel; mode.UpdateTagCollections(tagItem, tagEnum); }; AnnotationModel.AddAnnotation += async(annStatue) => { switch (annStatue) { case AnnotationStatue.Highlight: await InvokeScript(ContentWebView, "insertTagAtRange();"); break; case AnnotationStatue.Note: await InvokeScript(ContentWebView, "insertNodeAtRange();"); break; } await InvokeScript(ContentWebView, "highlightSelectedText();"); }; Menu.ContextMenuClick += (s) => { switch (s) { case ContextMenuStatue.LegalDefine: var contentPageViewModel = DataContext as ContentPageViewModel; double PaddingLeft = LeftSidePanelGrid.Visibility == Visibility.Visible ? 368 : 48; string countryCode = HtmlHelper.GetTOCCountryCode(contentPageViewModel.SelectedContent); DictionaryDialog DictinaryMenu = new DictionaryDialog(countryCode, ContentMenuPosition, PaddingLeft); DictinaryMenu.Show(SelectContent); break; case ContextMenuStatue.Copy: HtmlHelper.Copy(SelectContent); break; } }; Menu.Show(p, padding); }
void AnnotationCanvas_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { if (CurrentAnnotationType == null) { return; } this.CaptureMouse(); IsEditing = true; var p = e.GetPosition(this); var vm = DataContext as AgentAnnotationViewModel; _currentBuilder = vm.CreateBuilder(CurrentAnnotationType.Value); _currentAnnotation = vm.CreateAnnotationViewModel(_currentBuilder.Annotation); vm.AddInProgressAnnotation(_currentAnnotation); _currentBuilder.OnNextPoint(ConvertPoint(p)); }
public AnnotationViewModelAddedEventsArgs(AnnotationViewModel annotation) { Annotation = annotation; }