コード例 #1
0
 /// <summary>
 /// the event handler for CargoChanged Annotation event
 /// internally it calls the store AnnotationModified delegate
 /// </summary>
 /// <param name="sender">annotation that changed</param>
 /// <param name="args">args describing the change</param>
 private void OnCargoChanged(object sender, AnnotationResourceChangedEventArgs args)
 {
     _currentAnnotations[args.Annotation.Id].Dirty = true;
     _cargoChanged(sender, args);
 }
コード例 #2
0
        /// <summary>
        ///     Should be called when any annotation's cargo changes.
        ///     This will fire the CargoChanged event and cause a flush
        ///     if AutoFlush is true.
        /// </summary>
        /// <param name="args">the args for the event</param>
        protected virtual void OnCargoChanged(AnnotationResourceChangedEventArgs args)
        {
            AnnotationResourceChangedEventHandler cargoChanged = null;

            // Ignore null resources added to an annotation
            if (args.Resource == null)
                return;
            
            lock (SyncRoot)
            {
                cargoChanged = CargoChanged;
            }

            if (AutoFlush)
            {
                Flush();
            }

            if (cargoChanged != null)
            {
                cargoChanged(this, args);
            }
        }
コード例 #3
0
ファイル: AnnotationService.cs プロジェクト: JianwenSun/cc
        /// <summary>
        ///     Called when an anchor on any attached annotation changes.
        ///     We need to handle these changes by updating the set of
        ///     attached annotations and firing any necessary events.
        /// </summary>
        /// <param name="sender">the annotation whose anchor changed</param>
        /// <param name="args">args describing the action and which anchor was changed</param>
        private void OnAnchorChanged(object sender, AnnotationResourceChangedEventArgs args)
        {
            VerifyAccess();

            // Ignore null resources added to an annotation
            if (args.Resource == null)
                return;

            AttachedAnnotationChangedEventArgs newArgs = null;

            switch (args.Action)
            {
                case AnnotationAction.Added:
                    newArgs = AnchorAdded(args.Annotation, args.Resource);
                    break;

                case AnnotationAction.Removed:
                    newArgs = AnchorRemoved(args.Annotation, args.Resource);
                    break;

                case AnnotationAction.Modified:
                    newArgs = AnchorModified(args.Annotation, args.Resource);
                    break;

                default:
                    Invariant.Assert(false, "Unknown AnnotationAction.");
                    break;
            }

            if (newArgs != null)
            {
                AttachedAnnotationChanged(this, newArgs);
            }
        }
コード例 #4
0
ファイル: XmlStreamStore.cs プロジェクト: sjyanxin/WPFSource
        /// <summary> 
        ///     Used as CargoChanged event handler for all annotations
        ///     handed out by the map. 
        /// </summary>
        /// <param name="sender">annotation that sent the event</param>
        /// <param name="e">args for the event</param>
        private void HandleCargoChanged(object sender, AnnotationResourceChangedEventArgs e) 
        {
            lock (SyncRoot) 
            { 
                _dirty = true;
            } 

            OnCargoChanged(e);
        }
コード例 #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); 
            }
 
        } 
コード例 #6
0
        // A registered handler for a bubble listening to the annotation store update event.
        //     obj  -   The sender of the event
        //     args -   event arguement
        private void OnAnnotationUpdated(object obj, AnnotationResourceChangedEventArgs args)
        {
            Debug.Assert(_attachedAnnotation != null && _attachedAnnotation.Annotation == args.Annotation);

            if (!InternalLocker.IsLocked(LockHelper.LockFlag.AnnotationChanged))
            {
                SNCAnnotation sncAnnotation = new SNCAnnotation(args.Annotation);
                _sncAnnotation = sncAnnotation;
                UpdateSNCWithAnnotation(SNCAnnotation.AllValues);
                IsDirty = true;
            }
        }