Ejemplo n.º 1
0
        // Token: 0x06007C8D RID: 31885 RVA: 0x00230668 File Offset: 0x0022E868
        private void AddComponent(IAttachedAnnotation attachedAnnotation, IAnnotationComponent component, bool reorder)
        {
            UIElement uielement = attachedAnnotation.Parent as UIElement;

            if (component.PresentationContext != null)
            {
                return;
            }
            AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(uielement);

            if (adornerLayer != null)
            {
                this.AddToAttachedAnnotations(attachedAnnotation, component);
                component.AddAttachedAnnotation(attachedAnnotation);
                AdornerPresentationContext.HostComponent(adornerLayer, component, uielement, reorder);
                return;
            }
            if (PresentationSource.FromVisual(uielement) == null)
            {
                return;
            }
            throw new InvalidOperationException(SR.Get("NoPresentationContextForGivenElement", new object[]
            {
                uielement
            }));
        }
 // Token: 0x06007C6A RID: 31850 RVA: 0x0022FD71 File Offset: 0x0022DF71
 public override void AddToHost(IAnnotationComponent component)
 {
     if (component == null)
     {
         throw new ArgumentNullException("component");
     }
     AdornerPresentationContext.HostComponent(this._adornerLayer, component, component.AnnotatedElement, false);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Add an attached annotation to a component and add the component to the adorner layer
        /// if the annotation component is not already in a presentation context.
        /// </summary>
        /// <param name="attachedAnnotation">the attachedAnnotation we are to add to the component</param>
        /// <param name="component">the component we are to add to the adorner layer</param>
        /// <param name="reorder">if true - the z-order must be reevaluated</param>
        private void AddComponent(IAttachedAnnotation attachedAnnotation, IAnnotationComponent component, bool reorder)
        {
            UIElement annotatedElement = attachedAnnotation.Parent as UIElement; // casted from DependencyObject

            Debug.Assert(annotatedElement != null, "the annotatedElement should inherit from UIElement");

            // if annotation component is already in presentation context, nothing else to do
            if (component.PresentationContext != null)
            {
                return;
            }

            // otherwise host in the appropriate adorner layer
            AdornerLayer layer = AdornerLayer.GetAdornerLayer(annotatedElement); // note, GetAdornerLayer requires UIElement

            if (layer == null)
            {
                if (PresentationSource.FromVisual(annotatedElement) == null)
                {
                    // The annotated element is no longer part of the application tree.
                    // This probably means we are out of [....] - trying to add an annotation
                    // for an element that has already gone away.  Bug # 1580288 tracks
                    // the need to figure this out.
                    return;
                }

                throw new InvalidOperationException(SR.Get(SRID.NoPresentationContextForGivenElement, annotatedElement));
            }

            // add to the attachedAnnotations
            this.AddToAttachedAnnotations(attachedAnnotation, component);

            // let the annotation component know about the attached annotation
            // call add before adding to adorner layer so the component can be initialized
            component.AddAttachedAnnotation(attachedAnnotation); // this might cause recursion in modify if annotation component adds to annotation

            AdornerPresentationContext.HostComponent(layer, component, annotatedElement, reorder);
        }
Ejemplo n.º 4
0
        // Token: 0x06007CE0 RID: 31968 RVA: 0x00231F28 File Offset: 0x00230128
        private void RegisterAnchor()
        {
            TextAnchor textAnchor = this._attachedAnnotation.AttachedAnchor as TextAnchor;

            if (textAnchor == null)
            {
                throw new ArgumentException(SR.Get("InvalidAttachedAnchor"));
            }
            ITextContainer textContainer = textAnchor.Start.TextContainer;

            this.HighlightAnchor.AddAttachedAnnotation(this._attachedAnnotation);
            this.UpdateGeometry();
            AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this.AnnotatedElement);

            if (adornerLayer == null)
            {
                throw new InvalidOperationException(SR.Get("NoPresentationContextForGivenElement", new object[]
                {
                    this.AnnotatedElement
                }));
            }
            AdornerPresentationContext.HostComponent(adornerLayer, this, this.AnnotatedElement, false);
            this._selection = textContainer.TextSelection;
            if (this._selection != null)
            {
                this._uiParent = (PathNode.GetParent(textContainer.Parent) as UIElement);
                this.RegisterComponent();
                if (this._uiParent != null)
                {
                    this._uiParent.GotKeyboardFocus  += this.OnContainerGotFocus;
                    this._uiParent.LostKeyboardFocus += this.OnContainerLostFocus;
                    if (this.HighlightAnchor.IsSelected(this._selection))
                    {
                        this.SetSelected(true);
                    }
                }
            }
        }