// Token: 0x06007CBC RID: 31932 RVA: 0x00231444 File Offset: 0x0022F644 public void Activate(bool active) { if (this._active == active) { return; } if (this._attachedAnnotation == null) { throw new InvalidOperationException(SR.Get("NoAttachedAnnotationToModify")); } TextAnchor textAnchor = this._attachedAnnotation.AttachedAnchor as TextAnchor; Invariant.Assert(textAnchor != null, "AttachedAnchor is not a text anchor"); ITextContainer textContainer = textAnchor.Start.TextContainer; Invariant.Assert(textContainer != null, "TextAnchor does not belong to a TextContainer"); AnnotationHighlightLayer annotationHighlightLayer = textContainer.Highlights.GetLayer(typeof(HighlightComponent)) as AnnotationHighlightLayer; Invariant.Assert(annotationHighlightLayer != null, "AnnotationHighlightLayer is not initialized"); annotationHighlightLayer.ActivateRange(this, active); this._active = active; if (active) { this.HighlightBrush = new SolidColorBrush(this._selectedBackground); return; } this.HighlightBrush = new SolidColorBrush(this._background); }
/// <summary> /// Sets highlight color to active/inactive /// <param name="active">true - activate, false = deactivate</param> /// </summary> public void Activate(bool active) { //return if the state is unchanged if (_active == active) { return; } //get the highlight layer if (_attachedAnnotation == null) { throw new InvalidOperationException(SR.Get(SRID.NoAttachedAnnotationToModify)); } TextAnchor textAnchor = _attachedAnnotation.AttachedAnchor as TextAnchor; Invariant.Assert(textAnchor != null, "AttachedAnchor is not a text anchor"); //this should be in a fixed or flow textcontainer ITextContainer textContainer = textAnchor.Start.TextContainer; Invariant.Assert(textContainer != null, "TextAnchor does not belong to a TextContainer"); //get AnnotationHighlightLayer in the textContainer AnnotationHighlightLayer highlightLayer = textContainer.Highlights.GetLayer(typeof(HighlightComponent)) as AnnotationHighlightLayer; Invariant.Assert(highlightLayer != null, "AnnotationHighlightLayer is not initialized"); highlightLayer.ActivateRange(this, active); _active = active; if (active) { HighlightBrush = new SolidColorBrush(_selectedBackground); } else { HighlightBrush = new SolidColorBrush(_background); } }