Ejemplo n.º 1
0
        public ImageAnnotationAdorner(
            ImageAnnotation imageAnnotation,
            Image adornedImage,
            Style annotationStyle,
            Style annotationEditorStyle,
            Point location)
            : base(adornedImage)
        {
            _location = location;

            _control = new ImageAnnotationControl(imageAnnotation, annotationStyle, annotationEditorStyle);

            base.AddLogicalChild(_control);
            base.AddVisualChild(_control);
        }
        public ImageAnnotationControl(
            ImageAnnotation imageAnnotation,
            Style annotationStyle,
            Style annotationEditorStyle)
        {
            InitializeComponent();

            if (imageAnnotation == null)
                throw new ArgumentNullException("imageAnnotation");

            _imageAnnotation = imageAnnotation;

            // Establish a binding between the ImageAnnotation's Text
            // and our Content property so that changes in either
            // property will update the other.
            Binding binding = new Binding("Text");
            binding.Source = _imageAnnotation;
            binding.Mode = BindingMode.TwoWay;
            this.SetBinding(ContentControl.ContentProperty, binding);

            // Allow this control to be focused,
            // so that we can steal focus from the
            // TextBox used to edit the annotation.
            base.Focusable = true;

            // Prevent the control from having a focus rect.
            base.FocusVisualStyle = null;

            if (annotationStyle != null)
            {
                base.Resources.Add("STYLE_Annotation", annotationStyle);
            }

            if (annotationEditorStyle != null)
            {
                base.Resources.Add("STYLE_AnnotationEditor", annotationEditorStyle);
            }

            this.IsInEditMode = true;
        }