// 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);
        }
        // Token: 0x06007CC9 RID: 31945 RVA: 0x00231834 File Offset: 0x0022FA34
        private void OnAnnotationUpdated(object sender, AnnotationResourceChangedEventArgs args)
        {
            Invariant.Assert(this._attachedAnnotation != null && this._attachedAnnotation.Annotation == args.Annotation, "_attachedAnnotation is different than the input one");
            Invariant.Assert(this._range != null, "The highlight range is null");
            TextAnchor textAnchor = this._attachedAnnotation.AttachedAnchor as TextAnchor;

            Invariant.Assert(textAnchor != null, "wrong anchor type of the saved attached annotation");
            ITextContainer textContainer = textAnchor.Start.TextContainer;

            Invariant.Assert(textContainer != null, "TextAnchor does not belong to a TextContainer");
            Color color;
            Color color2;

            this.GetColors(args.Annotation, out color, out color2);
            if (!this._background.Equals(color) || !this._selectedBackground.Equals(color2))
            {
                Invariant.Assert(textContainer.Highlights != null, "textContainer.Highlights is null");
                AnnotationHighlightLayer annotationHighlightLayer = textContainer.Highlights.GetLayer(typeof(HighlightComponent)) as AnnotationHighlightLayer;
                if (annotationHighlightLayer == null)
                {
                    throw new InvalidDataException(SR.Get("MissingAnnotationHighlightLayer"));
                }
                this._background         = color;
                this._selectedBackground = color2;
                annotationHighlightLayer.ModifiedRange(this);
            }
        }
        // Token: 0x06007CB9 RID: 31929 RVA: 0x00231278 File Offset: 0x0022F478
        public void AddAttachedAnnotation(IAttachedAnnotation attachedAnnotation)
        {
            if (this._attachedAnnotation != null)
            {
                throw new ArgumentException(SR.Get("MoreThanOneAttachedAnnotation"));
            }
            EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordAnnotation, EventTrace.Event.AddAttachedHighlightBegin);
            ITextContainer textContainer = this.CheckInputData(attachedAnnotation);
            TextAnchor     range         = attachedAnnotation.AttachedAnchor as TextAnchor;

            this.GetColors(attachedAnnotation.Annotation, out this._background, out this._selectedBackground);
            this._range = range;
            Invariant.Assert(textContainer.Highlights != null, "textContainer.Highlights is null");
            AnnotationHighlightLayer annotationHighlightLayer = textContainer.Highlights.GetLayer(typeof(HighlightComponent)) as AnnotationHighlightLayer;

            if (annotationHighlightLayer == null)
            {
                annotationHighlightLayer = new AnnotationHighlightLayer();
                textContainer.Highlights.AddLayer(annotationHighlightLayer);
            }
            this._attachedAnnotation = attachedAnnotation;
            this._attachedAnnotation.Annotation.CargoChanged += this.OnAnnotationUpdated;
            annotationHighlightLayer.AddRange(this);
            this.HighlightBrush   = new SolidColorBrush(this._background);
            base.IsHitTestVisible = false;
            EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordAnnotation, EventTrace.Event.AddAttachedHighlightEnd);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Add an attached annotation to the component. The attached anchor will be used to add
        /// a highlight to the appropriate TextContainer
        /// </summary>
        /// <param name="attachedAnnotation">The attached annotation to be added to the component</param>
        public void AddAttachedAnnotation(IAttachedAnnotation attachedAnnotation)
        {
            if (_attachedAnnotation != null)
            {
                throw new ArgumentException(SR.Get(SRID.MoreThanOneAttachedAnnotation));
            }

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

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

            TextAnchor textAnchor = attachedAnnotation.AttachedAnchor as TextAnchor;

            //Get highlight Colors from the cargo. For undefined Colors the default values are used
            GetColors(attachedAnnotation.Annotation, out _background, out _selectedBackground);
            _range = textAnchor;

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

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

            if (highlightLayer == null)
            {
                highlightLayer = new AnnotationHighlightLayer();
                textContainer.Highlights.AddLayer(highlightLayer);
            }

            //save the attached annotation
            _attachedAnnotation = attachedAnnotation;

            //register for cargo changes
            _attachedAnnotation.Annotation.CargoChanged += new AnnotationResourceChangedEventHandler(OnAnnotationUpdated);

            //add this highlight range
            highlightLayer.AddRange(this);
            HighlightBrush   = new SolidColorBrush(_background);
            IsHitTestVisible = false;

            //fire trace event
            EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordAnnotation, EventTrace.Event.AddAttachedHighlightEnd);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Called when the Annotation cargo changes
        /// </summary>
        /// <param name="sender">the sender</param>
        /// <param name="args">event arguments</param>
        private void OnAnnotationUpdated(object sender, AnnotationResourceChangedEventArgs args)
        {
            Invariant.Assert(_attachedAnnotation != null && _attachedAnnotation.Annotation == args.Annotation, "_attachedAnnotation is different than the input one");
            Invariant.Assert(_range != null, "The highlight range is null");

            //get text container
            TextAnchor textAnchor = _attachedAnnotation.AttachedAnchor as TextAnchor;

            Invariant.Assert(textAnchor != null, "wrong anchor type of the saved attached annotation");

            //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 highlight Colors from the cargo and update the highlight layer
            Color background, activeBackground;

            GetColors(args.Annotation, out background, out activeBackground);

            if (!_background.Equals(background) ||
                !_selectedBackground.Equals(activeBackground))
            {
                //modify the highlight
                Invariant.Assert(textContainer.Highlights != null, "textContainer.Highlights is null");

                //get AnnotationHighlightLayer in the textContainer
                AnnotationHighlightLayer highlightLayer = textContainer.Highlights.GetLayer(typeof(HighlightComponent)) as AnnotationHighlightLayer;
                if (highlightLayer == null)
                {
                    throw new InvalidDataException(SR.Get(SRID.MissingAnnotationHighlightLayer));
                }

                //change the colors and invalidate
                _background         = background;
                _selectedBackground = activeBackground;
                highlightLayer.ModifiedRange(this);
            }
        }
Exemplo n.º 6
0
        /// <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);
            }
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Add an attached annotation to the component. The attached anchor will be used to add
        /// a highlight to the appropriate TextContainer
        /// </summary> 
        /// <param name="attachedAnnotation">The attached annotation to be added to the component</param>
        public void AddAttachedAnnotation(IAttachedAnnotation attachedAnnotation) 
        { 
            if (_attachedAnnotation != null)
            { 
                throw new ArgumentException(SR.Get(SRID.MoreThanOneAttachedAnnotation));
            }

            //fire trace event 
            EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordAnnotation, EventTrace.Event.AddAttachedHighlightBegin);
 
            //check input data and retrieve the TextContainer 
            ITextContainer textContainer = CheckInputData(attachedAnnotation);
 
            TextAnchor textAnchor = attachedAnnotation.AttachedAnchor as TextAnchor;

            //Get highlight Colors from the cargo. For undefined Colors the default values are used
            GetColors(attachedAnnotation.Annotation, out _background, out _selectedBackground); 
            _range = textAnchor;
 
            Invariant.Assert(textContainer.Highlights != null, "textContainer.Highlights is null"); 

            //get or create AnnotationHighlightLayer in the textContainer 
            AnnotationHighlightLayer highlightLayer = textContainer.Highlights.GetLayer(typeof(HighlightComponent)) as AnnotationHighlightLayer;
            if (highlightLayer == null)
            {
                highlightLayer = new AnnotationHighlightLayer(); 
                textContainer.Highlights.AddLayer(highlightLayer);
            } 
 
            //save the attached annotation
            _attachedAnnotation = attachedAnnotation; 

            //register for cargo changes
            _attachedAnnotation.Annotation.CargoChanged += new AnnotationResourceChangedEventHandler(OnAnnotationUpdated);
 
            //add this highlight range
            highlightLayer.AddRange(this); 
            HighlightBrush = new SolidColorBrush(_background); 
            IsHitTestVisible = false;
 
            //fire trace event
            EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordAnnotation, EventTrace.Event.AddAttachedHighlightEnd);

        }