// Token: 0x06007BDF RID: 31711 RVA: 0x0022D34B File Offset: 0x0022B54B
 internal AttachedAnnotation(LocatorManager manager, Annotation annotation, AnnotationResource anchor, object attachedAnchor, AttachmentLevel attachmentLevel, DependencyObject parent)
 {
     this._annotation     = annotation;
     this._anchor         = anchor;
     this._locatorManager = manager;
     this.Update(attachedAnchor, attachmentLevel, parent);
 }
Exemple #2
0
        // ------------------ _annStore_StoreContentChanged -------------------
        void _annStore_StoreContentChanged(object sender, StoreContentChangedEventArgs e)
        {
            if (e.Action == StoreContentAction.Deleted)
            {
                return;
            }
            Annotation ann = e.Annotation;

            if (ann.Cargos.Count > 0)
            {
                AnnotationResource annResource = ann.Cargos[0] as AnnotationResource;
                if (annResource.Name == "Highlight")
                {
                    AddBookmarkOrComment(BookmarkList, ann);
                }
                else
                {
                    AddBookmarkOrComment(CommentsList, ann);
                }
            }
            else
            {
                AddBookmarkOrComment(CommentsList, ann);
            }
        }
        // Token: 0x0600785B RID: 30811 RVA: 0x002248A0 File Offset: 0x00222AA0
        private static void GetCargoAndRoot(SNCAnnotation annotation, XmlToken token, out AnnotationResource cargo, out XmlElement root, out bool newCargo, out bool newRoot)
        {
            Invariant.Assert(annotation != null, "Annotation is null.");
            Invariant.Assert((token & (XmlToken.MetaData | XmlToken.Left | XmlToken.Top | XmlToken.XOffset | XmlToken.YOffset | XmlToken.Width | XmlToken.Height | XmlToken.IsExpanded | XmlToken.Author | XmlToken.Text | XmlToken.Ink | XmlToken.ZOrder)) > (XmlToken)0, "No token specified.");
            string cargoName = SNCAnnotation.GetCargoName(token);

            newRoot  = false;
            newCargo = false;
            cargo    = annotation.FindCargo(cargoName);
            if (cargo != null)
            {
                root = SNCAnnotation.FindRootXmlElement(token, cargo);
                if (root == null)
                {
                    newRoot = true;
                    XmlDocument xmlDocument = new XmlDocument();
                    root = xmlDocument.CreateElement(SNCAnnotation.GetXmlName(token), "http://schemas.microsoft.com/windows/annotations/2003/11/base");
                    return;
                }
            }
            else
            {
                newCargo = true;
                cargo    = new AnnotationResource(cargoName);
                XmlDocument xmlDocument2 = new XmlDocument();
                root = xmlDocument2.CreateElement(SNCAnnotation.GetXmlName(token), "http://schemas.microsoft.com/windows/annotations/2003/11/base");
                cargo.Contents.Add(root);
            }
        }
Exemple #4
0
        /// <summary>
        ///     Create an instance of AttachedAnnotation with a specified parent.  Takes an optional
        ///     parent for the attached annotation.  This is useful when the parent is known before
        ///     hand and not available through the normal means (such as in printing).
        /// </summary>
        /// <param name="manager">the LocatorManager providing processors for this anchored annotation</param>
        /// <param name="annotation">the annotation itself</param>
        /// <param name="anchor">the annotation's anchor represented by the attached anchor</param>
        /// <param name="attachedAnchor">the attached anchor itself</param>
        /// <param name="attachmentLevel">the level of the attached anchor</param>
        /// <param name="parent">parent of the selection</param>
        internal AttachedAnnotation(LocatorManager manager, Annotation annotation, AnnotationResource anchor, Object attachedAnchor, AttachmentLevel attachmentLevel, DependencyObject parent)
        {
            Debug.Assert(manager != null, "LocatorManager can not be null");
            Debug.Assert(annotation != null, "Annotation can not be null");
            Debug.Assert(anchor != null, "Anchor can not be null");
            Debug.Assert(attachedAnchor != null, "AttachedAnchor can not be null");

            _annotation     = annotation;
            _anchor         = anchor;
            _locatorManager = manager;
            Update(attachedAnchor, attachmentLevel, parent);
        }
        // Token: 0x06007860 RID: 30816 RVA: 0x00224AE8 File Offset: 0x00222CE8
        private static XmlElement FindRootXmlElement(XmlToken token, AnnotationResource cargo)
        {
            XmlElement result = null;
            string     value  = string.Empty;

            if (token <= XmlToken.YOffset)
            {
                if (token <= XmlToken.Left)
                {
                    if (token != XmlToken.MetaData && token != XmlToken.Left)
                    {
                        goto IL_77;
                    }
                }
                else if (token != XmlToken.Top && token != XmlToken.XOffset && token != XmlToken.YOffset)
                {
                    goto IL_77;
                }
            }
            else if (token <= XmlToken.IsExpanded)
            {
                if (token != XmlToken.Width && token != XmlToken.Height && token != XmlToken.IsExpanded)
                {
                    goto IL_77;
                }
            }
            else
            {
                if (token == XmlToken.Text || token == XmlToken.Ink)
                {
                    value = SNCAnnotation.GetXmlName(token);
                    goto IL_77;
                }
                if (token != XmlToken.ZOrder)
                {
                    goto IL_77;
                }
            }
            value = SNCAnnotation.GetXmlName(XmlToken.MetaData);
IL_77:
            foreach (XmlElement xmlElement in cargo.Contents)
            {
                if (xmlElement.Name.Equals(value))
                {
                    result = xmlElement;
                    break;
                }
            }
            return(result);
        }
        // Token: 0x06007861 RID: 30817 RVA: 0x00224BB8 File Offset: 0x00222DB8
        private static object FindContent(XmlToken token, AnnotationResource cargo)
        {
            object     result     = null;
            XmlElement xmlElement = SNCAnnotation.FindRootXmlElement(token, cargo);

            if (xmlElement != null)
            {
                if (token <= XmlToken.Width)
                {
                    if (token <= XmlToken.Top)
                    {
                        if (token != XmlToken.Left && token != XmlToken.Top)
                        {
                            return(result);
                        }
                    }
                    else if (token != XmlToken.XOffset && token != XmlToken.YOffset && token != XmlToken.Width)
                    {
                        return(result);
                    }
                }
                else if (token <= XmlToken.IsExpanded)
                {
                    if (token != XmlToken.Height && token != XmlToken.IsExpanded)
                    {
                        return(result);
                    }
                }
                else
                {
                    if (token == XmlToken.Text || token == XmlToken.Ink)
                    {
                        return(xmlElement);
                    }
                    if (token != XmlToken.ZOrder)
                    {
                        return(result);
                    }
                }
                return(xmlElement.GetAttributeNode(SNCAnnotation.GetXmlName(token), "http://schemas.microsoft.com/windows/annotations/2003/11/base"));
            }
            return(result);
        }
        // Token: 0x0600785A RID: 30810 RVA: 0x00224848 File Offset: 0x00222A48
        private object FindData(XmlToken token)
        {
            object obj = null;

            if (this._cachedXmlElements.ContainsKey(token))
            {
                obj = this._cachedXmlElements[token];
            }
            else
            {
                AnnotationResource annotationResource = this.FindCargo(SNCAnnotation.GetCargoName(token));
                if (annotationResource != null)
                {
                    obj = SNCAnnotation.FindContent(token, annotationResource);
                    if (obj != null)
                    {
                        this._cachedXmlElements.Add(token, obj);
                    }
                }
            }
            return(obj);
        }
 // Token: 0x06007BDE RID: 31710 RVA: 0x0022D33B File Offset: 0x0022B53B
 internal AttachedAnnotation(LocatorManager manager, Annotation annotation, AnnotationResource anchor, object attachedAnchor, AttachmentLevel attachmentLevel) : this(manager, annotation, anchor, attachedAnchor, attachmentLevel, null)
 {
 }
        // Token: 0x06007862 RID: 30818 RVA: 0x00224C48 File Offset: 0x00222E48
        private void UpdateContent(StickyNoteControl snc, bool updateAnnotation, XmlToken token)
        {
            Invariant.Assert(snc != null, "Sticky Note Control is null.");
            Invariant.Assert((token & (XmlToken.Text | XmlToken.Ink)) > (XmlToken)0, "No token specified.");
            StickyNoteContentControl content = snc.Content;

            if (content == null)
            {
                return;
            }
            if ((token == XmlToken.Ink && content.Type != StickyNoteType.Ink) || (token == XmlToken.Text && content.Type != StickyNoteType.Text))
            {
                return;
            }
            XmlElement xmlElement = null;

            if (updateAnnotation)
            {
                AnnotationResource annotationResource = null;
                bool flag  = false;
                bool flag2 = false;
                if (!content.IsEmpty)
                {
                    SNCAnnotation.GetCargoAndRoot(this, token, out annotationResource, out xmlElement, out flag2, out flag);
                    content.Save(xmlElement);
                }
                else
                {
                    string cargoName = SNCAnnotation.GetCargoName(token);
                    annotationResource = this.FindCargo(cargoName);
                    if (annotationResource != null)
                    {
                        this._annotation.Cargos.Remove(annotationResource);
                        this._cachedXmlElements.Remove(token);
                    }
                }
                if (flag)
                {
                    Invariant.Assert(xmlElement != null, "XmlElement should have been created.");
                    Invariant.Assert(annotationResource != null, "Cargo should have been retrieved.");
                    annotationResource.Contents.Add(xmlElement);
                }
                if (flag2)
                {
                    Invariant.Assert(annotationResource != null, "Cargo should have been created.");
                    this._annotation.Cargos.Add(annotationResource);
                    return;
                }
            }
            else
            {
                XmlElement xmlElement2 = (XmlElement)this.FindData(token);
                if (xmlElement2 != null)
                {
                    content.Load(xmlElement2);
                    return;
                }
                if (!content.IsEmpty)
                {
                    content.Clear();
                }
            }
        }