internal AnnotationSceneNode CreateAnnotation(IEnumerable <SceneElement> targets) { Artboard artboard = this.sceneViewModel.DefaultView.Artboard; SceneElement sceneElement = Enumerable.First <SceneElement>(targets); int num = Enumerable.Count <SceneElement>(targets); bool treatTopLeftAsCenter = num > 1 || sceneElement.Equals((object)sceneElement.ViewModel.RootNode); AnnotationSceneNode annotation; using (SceneEditTransaction editTransaction = sceneElement.ViewModel.CreateEditTransaction(StringTable.AddAnnotationUndoUnit)) { annotation = AnnotationManagerSceneNode.CreateAnnotation((SceneNode)sceneElement); foreach (SceneElement element in Enumerable.Skip <SceneElement>(targets, 1)) { AnnotationUtils.AddAnnotationReference(element, annotation); } Point point1; if (treatTopLeftAsCenter) { Rect rect = Rect.Empty; if (num > 1 || !sceneElement.Equals((object)annotation.ViewModel.RootNode)) { rect = artboard.GetElementListBounds(targets); } if (rect.IsEmpty) { rect = artboard.ArtboardBounds; } point1 = new Point(rect.Left + rect.Width / 2.0, rect.Top + rect.Height / 2.0); } else { point1 = artboard.GetElementBounds(sceneElement).TopRight; } Point point2 = RoundingHelper.RoundPosition(point1); annotation.Left = point2.X; annotation.Top = point2.Y; string authorName = this.AnnotationService.DesignerContext.AnnotationsOptionsModel.AuthorName; if (!string.IsNullOrEmpty(authorName)) { annotation.Author = authorName; } string authorInitials = this.AnnotationService.DesignerContext.AnnotationsOptionsModel.AuthorInitials; if (!string.IsNullOrEmpty(authorInitials)) { annotation.AuthorInitials = authorInitials; } AnnotationUtils.SetSerialNumber(annotation); editTransaction.Commit(); } this.CreateAnnotationVisual(annotation).Initialize(treatTopLeftAsCenter); return(annotation); }
private void DeleteCore(IEnumerable <AnnotationSceneNode> annotations) { ExceptionChecks.CheckNullArgument <IEnumerable <AnnotationSceneNode> >(annotations, "annotations"); ExceptionChecks.CheckEmptyListArgument <AnnotationSceneNode>(annotations, "annotations"); foreach (AnnotationSceneNode annotationSceneNode in Enumerable.ToList <AnnotationSceneNode>(annotations)) { foreach (SceneElement element in Enumerable.ToList <SceneElement>(annotationSceneNode.AttachedElements)) { AnnotationUtils.RemoveAnnotationReference(element, annotationSceneNode); } AnnotationManagerSceneNode.DeleteAnnotation(annotationSceneNode); } }
public void UnlinkAllAttachments(AnnotationSceneNode annotation) { IEnumerable <SceneElement> attachedElements = annotation.AttachedElements; if (!Enumerable.Any <SceneElement>(attachedElements)) { return; } SceneViewModel viewModel = annotation.ViewModel; using (SceneEditTransaction editTransaction = viewModel.CreateEditTransaction(StringTable.UnlinkAnnotationUndoUnit)) { EnumerableExtensions.ForEach <SceneElement>(attachedElements, (Action <SceneElement>)(element => AnnotationUtils.RemoveAnnotationReference(element, annotation))); AnnotationManagerSceneNode.SetAnnotationParent(annotation, viewModel.RootNode); editTransaction.Commit(); } }
public void UnlinkAttachment(AnnotationSceneNode annotation, SceneElement target) { SceneViewModel viewModel = annotation.ViewModel; using (SceneEditTransaction editTransaction = viewModel.CreateEditTransaction(StringTable.UnlinkAnnotationUndoUnit)) { bool flag = AnnotationUtils.RemoveAnnotationReference(target, annotation); if (target.Equals((object)annotation.Parent)) { flag = true; AnnotationManagerSceneNode.SetAnnotationParent(annotation, viewModel.RootNode); } if (!flag) { return; } editTransaction.Commit(); } }
private void SceneDocument_EditTransactionCompleting(object sender, EventArgs e) { SceneElement rootElement = this.sceneViewModel.RootNode as SceneElement; if (rootElement == null) { return; } Enumerable.ToList <AnnotationSceneNode>(Enumerable.Distinct <AnnotationSceneNode>(Enumerable.SelectMany <SceneElement, AnnotationSceneNode>(Enumerable.Select(Enumerable.Where(Enumerable.Select(Enumerable.Where <DocumentNodeChange>(this.sceneViewModel.Damage.CollapsedChangeList, (Func <DocumentNodeChange, bool>)(docChange => docChange.Action == DocumentNodeChangeAction.Remove)), docChange => new { docChange = docChange, element = this.sceneViewModel.GetSceneNode(docChange.OldChildNode) as SceneElement }), param0 => param0.element != null), param0 => param0.element), (Func <SceneElement, IEnumerable <AnnotationSceneNode> >)(elementDeleted => Enumerable.Cast <AnnotationSceneNode>((IEnumerable)this.annotationsSearchPath.Query((SceneNode)elementDeleted)))))).ForEach((Action <AnnotationSceneNode>)(annotation => AnnotationManagerSceneNode.CloneAnnotation(annotation, (SceneNode)rootElement))); }