internal IEnumerable <SceneElement> GetAttachedElements(AnnotationSceneNode annotation) { ExceptionChecks.CheckNullArgument <AnnotationSceneNode>(annotation, "annotation"); List <SceneElement> list = new List <SceneElement>(); if (annotation.IsInDocument) { if (annotation.Parent != annotation.ViewModel.RootNode) { SceneElement sceneElement = annotation.Parent as SceneElement; if (sceneElement != null) { list.Add(sceneElement); } } IEnumerable <SceneElement> collection = Enumerable.Select(Enumerable.Where(Enumerable.Select(this.referenceSub.PathNodes, pathNode => new { pathNode = pathNode, referenceInfo = pathNode.Info }), param0 => { if (param0.referenceInfo.ReferencedAnnotations.Contains(annotation)) { return(param0.referenceInfo.ReferenceOwner != annotation.ViewModel.RootNode); } return(false); }), param0 => param0.referenceInfo.ReferenceOwner); list.AddRange(collection); } return((IEnumerable <SceneElement>)list); }
public AnnotationSceneNode Create(SceneElement owner, bool forceAnnotationsVisible) { ExceptionChecks.CheckNullArgument <SceneElement>(owner, "owner"); return(this.Create((IEnumerable <SceneElement>) new SceneElement[1] { owner }, forceAnnotationsVisible)); }
public void CopyToClipboardAsText(AnnotationSceneNode annotation) { ExceptionChecks.CheckNullArgument <AnnotationSceneNode>(annotation, "annotation"); this.CopyToClipboardAsText((IEnumerable <AnnotationSceneNode>) new AnnotationSceneNode[1] { annotation }); }
public IEnumerable <AnnotationSceneNode> GetAttachedAnnotations(SceneElement element) { ExceptionChecks.CheckNullArgument <SceneElement>(element, "element"); if (element == element.ViewModel.RootNode) { return(Enumerable.Empty <AnnotationSceneNode>()); } return(Enumerable.Union <AnnotationSceneNode>(Enumerable.Cast <AnnotationSceneNode>((IEnumerable)element.GetCollectionForProperty(AnnotationManagerSceneNode.AnnotationsProperty)), this.GetReferencedAnnotations(element))); }
private List <AnnotationSceneNode> ComputeReferencedAnnotations(IEnumerable <string> references) { ExceptionChecks.CheckNullArgument <IEnumerable <string> >(references, "referencesString"); return(Enumerable.ToList <AnnotationSceneNode>(Enumerable.Distinct <AnnotationSceneNode>(Enumerable.Select(Enumerable.Where(Enumerable.Join(this.Annotations, references, (Func <AnnotationSceneNode, string>)(annotation => annotation.Id), (Func <string, string>)(annoId => annoId), (annotation, annoId) => new { annotation = annotation, annoId = annoId }), param0 => param0.annotation.IsAttached), param0 => param0.annotation)))); }
public void CopyToClipboardAsText(IEnumerable <AnnotationSceneNode> annotations) { ExceptionChecks.CheckNullArgument <IEnumerable <AnnotationSceneNode> >(annotations, "annotations"); ExceptionChecks.CheckEmptyListArgument <AnnotationSceneNode>(annotations, "annotations"); FlowDocument flowDoc = this.GenerateFlowDocument(annotations); DataObject dataObj = new DataObject(); this.SaveFlowDocIntoDataObject(flowDoc, dataObj, DataFormats.Rtf); this.SaveFlowDocIntoDataObject(flowDoc, dataObj, DataFormats.Text); Clipboard.SetDataObject((object)dataObj); }
private static void SetAnnotationReferences(SceneElement element, IEnumerable <string> ids) { ExceptionChecks.CheckNullArgument <SceneElement>(element, "element"); ExceptionChecks.CheckNullArgument <IEnumerable <string> >(ids, "ids"); if (!Enumerable.Any <string>(ids)) { element.ClearValue(AnnotationSceneNode.ReferencesProperty); } else { element.SetValue(AnnotationSceneNode.ReferencesProperty, (object)string.Join(", ", Enumerable.ToArray <string>(ids))); } }
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 static void AddAnnotationReference(SceneElement element, AnnotationSceneNode annotation) { ExceptionChecks.CheckNullArgument <SceneElement>(element, "element"); ExceptionChecks.CheckNullArgument <AnnotationSceneNode>(annotation, "annotation"); string str = annotation.Id; if (string.IsNullOrEmpty(str)) { str = AnnotationUtils.SetAnnotationId(annotation); } IEnumerable <string> referencedAnnotationIds = AnnotationUtils.GetReferencedAnnotationIds(element); AnnotationUtils.SetAnnotationReferences(element, EnumerableExtensions.AppendItem <string>(referencedAnnotationIds, str)); }
public FlowDocument GenerateFlowDocument(IEnumerable <RawAnnotation> annotations) { ExceptionChecks.CheckNullArgument <IEnumerable <RawAnnotation> >(annotations, "annotations"); ExceptionChecks.CheckEmptyListArgument <RawAnnotation>(annotations, "annotations"); FlowDocument flowDocument = new FlowDocument(); foreach (RawAnnotation annotation in annotations) { flowDocument.Blocks.Add((Block) new CopyAnnotationTextTemplate(annotation)); flowDocument.Blocks.Add((Block) new Section((Block) new Paragraph())); } flowDocument.Blocks.Remove(Enumerable.Last <Block>((IEnumerable <Block>)flowDocument.Blocks)); return(flowDocument); }
public AnnotationSceneNode Create(IEnumerable <SceneElement> targets, bool forceAnnotationsVisible) { ExceptionChecks.CheckNullArgument <IEnumerable <SceneElement> >(targets, "targets"); ExceptionChecks.CheckEmptyListArgument <SceneElement>(targets, "targets"); if (forceAnnotationsVisible) { this.ShowAnnotations = true; } AnnotationSceneNode annotation = this.designerContext.ActiveSceneViewModel.AnnotationEditor.CreateAnnotation(targets); if (Enumerable.Any <SceneElement>(annotation.AttachedElements) && this.ShowAnnotations) { this.MakeVisible(annotation, targets); } return(annotation); }
public void Delete(IEnumerable <AnnotationSceneNode> annotations) { ExceptionChecks.CheckNullArgument <IEnumerable <AnnotationSceneNode> >(annotations, "annotations"); ExceptionChecks.CheckEmptyListArgument <AnnotationSceneNode>(annotations, "annotations"); SceneViewModel viewModel = Enumerable.First <AnnotationSceneNode>(annotations).ViewModel; if (Enumerable.Any <AnnotationSceneNode>(annotations, (Func <AnnotationSceneNode, bool>)(anno => anno.ViewModel != viewModel))) { throw new ArgumentException("All of the annotations must be from the same document!", "annotations"); } using (SceneEditTransaction editTransaction = viewModel.CreateEditTransaction(StringTable.DeleteAnnotationsInDocumentUndoUnit)) { this.DeleteCore(annotations); editTransaction.Commit(); } }
public static void SetSerialNumber(AnnotationSceneNode annotation) { ExceptionChecks.CheckNullArgument <AnnotationSceneNode>(annotation, "annotation"); string authorInitials = annotation.AuthorInitials; IEnumerable <int> source = Enumerable.Select <AnnotationSceneNode, int>(Enumerable.Where <AnnotationSceneNode>(annotation.ViewModel.AnnotationEditor.GetAnnotationsWithoutCache(), (Func <AnnotationSceneNode, bool>)(anno => { if (anno != annotation) { return(StringComparer.CurrentCultureIgnoreCase.Equals(anno.AuthorInitials, authorInitials)); } return(false); })), (Func <AnnotationSceneNode, int>)(anno => anno.SerialNumber)); int num = 1; if (Enumerable.Any <int>(source)) { num = Enumerable.Max(source) + 1; } annotation.SerialNumber = num; }
public static bool RemoveAnnotationReference(SceneElement element, AnnotationSceneNode annotation) { ExceptionChecks.CheckNullArgument <SceneElement>(element, "element"); ExceptionChecks.CheckNullArgument <AnnotationSceneNode>(annotation, "annotation"); string annotationId = annotation.Id; if (string.IsNullOrEmpty(annotationId)) { return(false); } List <string> list = Enumerable.ToList <string>(AnnotationUtils.GetReferencedAnnotationIds(element)); IEnumerable <string> enumerable = Enumerable.Where <string>((IEnumerable <string>)list, (Func <string, bool>)(id => id.Equals(annotationId, StringComparison.OrdinalIgnoreCase))); if (!Enumerable.Any <string>(enumerable)) { return(false); } AnnotationUtils.SetAnnotationReferences(element, Enumerable.Except <string>((IEnumerable <string>)list, enumerable)); return(true); }
public IEnumerable <RawAnnotation> GetAnnotations(SceneDocument sceneDoc) { ExceptionChecks.CheckNullArgument <SceneDocument>(sceneDoc, "sceneDoc"); if (sceneDoc.DocumentRoot == null || sceneDoc.DocumentRoot.RootNode == null) { return(Enumerable.Empty <RawAnnotation>()); } return((IEnumerable <RawAnnotation>)Enumerable.ToList <RawAnnotation>(Enumerable.Select <DocumentCompositeNode, RawAnnotation>(Enumerable.OfType <DocumentCompositeNode>((IEnumerable)sceneDoc.DocumentRoot.RootNode.SelectDescendantNodes(PlatformTypes.Annotation)), (Func <DocumentCompositeNode, RawAnnotation>)(anno => new RawAnnotation() { Id = this.GetPrimitiveProperty <string>(anno, AnnotationSceneNode.IdProperty, AnnotationDefaults.Id), Text = this.GetPrimitiveProperty <string>(anno, AnnotationSceneNode.TextProperty, AnnotationDefaults.Text), Top = this.GetPrimitiveProperty <double>(anno, AnnotationSceneNode.TopProperty, AnnotationDefaults.Top), Left = this.GetPrimitiveProperty <double>(anno, AnnotationSceneNode.LeftProperty, AnnotationDefaults.Left), Author = this.GetPrimitiveProperty <string>(anno, AnnotationSceneNode.AuthorProperty, AnnotationDefaults.Author), AuthorInitials = this.GetPrimitiveProperty <string>(anno, AnnotationSceneNode.AuthorInitialsProperty, AnnotationDefaults.AuthorInitials), SerialNumber = this.GetPrimitiveProperty <int>(anno, AnnotationSceneNode.SerialNumberProperty, AnnotationDefaults.SerialNumber), VisibleAtRuntime = this.GetPrimitiveProperty <bool>(anno, AnnotationSceneNode.VisibleAtRuntimeProperty, AnnotationDefaults.VisibleAtRuntime), Timestamp = this.GetPrimitiveProperty <DateTime>(anno, AnnotationSceneNode.TimestampProperty, AnnotationDefaults.Timestamp) })))); }
private AnnotationVisual CreateAnnotationVisual(AnnotationSceneNode annotation) { ExceptionChecks.CheckNullArgument <AnnotationSceneNode>(annotation, "annotation"); if (this.AnnotationLayer == null) { return((AnnotationVisual)null); } AnnotationVisual annotationVisual1 = Enumerable.FirstOrDefault <AnnotationVisual>(Enumerable.Cast <AnnotationVisual>((IEnumerable)this.AnnotationLayer.Children), (Func <AnnotationVisual, bool>)(v => v.Annotation == annotation)); if (annotationVisual1 != null) { return(annotationVisual1); } AnnotationVisual annotationVisual2 = new AnnotationVisual(new AnnotationViewModel(annotation) { ShowVisibleAtRuntime = annotation.ProjectContext.IsCapabilitySet(PlatformCapability.SupportPrototyping) }); annotationVisual2.Visibility = Visibility.Hidden; this.AnnotationLayer.Children.Add((UIElement)annotationVisual2); this.AnnotationLayer.UpdateLayout(); return(annotationVisual2); }
public static string SetAnnotationId(AnnotationSceneNode annotation) { ExceptionChecks.CheckNullArgument <AnnotationSceneNode>(annotation, "annotation"); Func <string, int> ParseOrZero = (Func <string, int>)(s => { int result; if (!int.TryParse(s, out result)) { return(0); } return(result); }); IEnumerable <AnnotationSceneNode> annotations = annotation.ViewModel.AnnotationEditor.Annotations; int num = 1; if (Enumerable.Any <AnnotationSceneNode>(annotations)) { num = Enumerable.Max(Enumerable.Select <AnnotationSceneNode, int>(annotations, (Func <AnnotationSceneNode, int>)(anno => ParseOrZero(anno.Id)))) + 1; } string str = num.ToString((IFormatProvider)CultureInfo.CurrentCulture); annotation.Id = str; return(str); }
private IEnumerable <AnnotationSceneNode> GetReferencedAnnotations(SceneElement element) { ExceptionChecks.CheckNullArgument <SceneElement>(element, "element"); return((IEnumerable <AnnotationSceneNode>)Enumerable.FirstOrDefault <List <AnnotationSceneNode> >(Enumerable.Select <SceneNodeSubscription <object, AnnotationEditor.ReferenceInfo> .PathNodeInfo, List <AnnotationSceneNode> >(Enumerable.Where <SceneNodeSubscription <object, AnnotationEditor.ReferenceInfo> .PathNodeInfo>(this.referenceSub.PathNodes, (Func <SceneNodeSubscription <object, AnnotationEditor.ReferenceInfo> .PathNodeInfo, bool>)(pathNode => pathNode.Info.ReferenceOwner == element)), (Func <SceneNodeSubscription <object, AnnotationEditor.ReferenceInfo> .PathNodeInfo, List <AnnotationSceneNode> >)(pathNode => pathNode.Info.ReferencedAnnotations))) ?? Enumerable.Empty <AnnotationSceneNode>()); }
public static IEnumerable <string> GetReferencedAnnotationIds(SceneElement element) { ExceptionChecks.CheckNullArgument <SceneElement>(element, "element"); return(AnnotationUtils.ParseAnnotationReferences(element.GetLocalOrDefaultValue(AnnotationSceneNode.ReferencesProperty) as string ?? string.Empty)); }
public bool IsSelected(AnnotationSceneNode annotation) { ExceptionChecks.CheckNullArgument <AnnotationSceneNode>(annotation, "annotation"); return(this.SelectedAnnotation == annotation); }
private FlowDocument GenerateFlowDocument(IEnumerable <AnnotationSceneNode> annotations) { ExceptionChecks.CheckNullArgument <IEnumerable <AnnotationSceneNode> >(annotations, "annotations"); ExceptionChecks.CheckEmptyListArgument <AnnotationSceneNode>(annotations, "annotations"); return(this.GenerateFlowDocument(Enumerable.Select <AnnotationSceneNode, RawAnnotation>(annotations, (Func <AnnotationSceneNode, RawAnnotation>)(annotation => new RawAnnotation(annotation))))); }