示例#1
0
        /// <summary>
        /// Remove an attached annotation from the component
        /// </summary>
        /// <param name="attachedAnnotation">The attached annotation to be removed from the component</param>
        public void RemoveAttachedAnnotation(IAttachedAnnotation attachedAnnotation)
        {
            if (attachedAnnotation == null)
            {
                throw new ArgumentNullException("attachedAnnotation");
            }

            if (attachedAnnotation != _attachedAnnotation)
            {
                throw new ArgumentException(SR.Get(SRID.InvalidAttachedAnnotation), "attachedAnnotation");
            }

            Invariant.Assert(_range != null, "null highlight range");

            //fire trace event
            EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordAnnotation, EventTrace.Event.RemoveAttachedHighlightBegin);

            //check input data and retrieve the TextContainer
            ITextContainer textContainer = CheckInputData(attachedAnnotation);

            Invariant.Assert(textContainer.Highlights != null, "textContainer.Highlights is null");

            //get AnnotationHighlightLayer in the textContainer
            AnnotationHighlightLayer highlightLayer = textContainer.Highlights.GetLayer(typeof(HighlightComponent)) as AnnotationHighlightLayer;

            Invariant.Assert(highlightLayer != null, "AnnotationHighlightLayer is not initialized");

            //unregister of cargo changes
            _attachedAnnotation.Annotation.CargoChanged -= new AnnotationResourceChangedEventHandler(OnAnnotationUpdated);

            highlightLayer.RemoveRange(this);

            //highlight is removed - remove the attached annotation and the data
            _attachedAnnotation = null;

            //fire trace event
            EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordAnnotation, EventTrace.Event.RemoveAttachedHighlightEnd);
        }
        // Token: 0x06007CBA RID: 31930 RVA: 0x00231370 File Offset: 0x0022F570
        public void RemoveAttachedAnnotation(IAttachedAnnotation attachedAnnotation)
        {
            if (attachedAnnotation == null)
            {
                throw new ArgumentNullException("attachedAnnotation");
            }
            if (attachedAnnotation != this._attachedAnnotation)
            {
                throw new ArgumentException(SR.Get("InvalidAttachedAnnotation"), "attachedAnnotation");
            }
            Invariant.Assert(this._range != null, "null highlight range");
            EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordAnnotation, EventTrace.Event.RemoveAttachedHighlightBegin);
            ITextContainer textContainer = this.CheckInputData(attachedAnnotation);

            Invariant.Assert(textContainer.Highlights != null, "textContainer.Highlights is null");
            AnnotationHighlightLayer annotationHighlightLayer = textContainer.Highlights.GetLayer(typeof(HighlightComponent)) as AnnotationHighlightLayer;

            Invariant.Assert(annotationHighlightLayer != null, "AnnotationHighlightLayer is not initialized");
            this._attachedAnnotation.Annotation.CargoChanged -= this.OnAnnotationUpdated;
            annotationHighlightLayer.RemoveRange(this);
            this._attachedAnnotation = null;
            EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordAnnotation, EventTrace.Event.RemoveAttachedHighlightEnd);
        }