示例#1
0
        private void automation_ToolTip(object sender, AnnToolTipEventArgs e)
        {
            var imageViewer = _documentViewer.View.ImageViewer;

            if (e.AnnotationObject == null)
            {
                _automationManagerHelper.SetToolTip(null, string.Empty);
                return;
            }

            // If text, show the text value
            var textObject = e.AnnotationObject as AnnTextObject;

            if (textObject != null)
            {
                _automationManagerHelper.SetToolTip(imageViewer, textObject.Text);
                return;
            }

            // If ruler, show its length
            var rulerObject = e.AnnotationObject as AnnPolyRulerObject;

            if (rulerObject != null)
            {
                _automationManagerHelper.SetToolTip(imageViewer, rulerObject.GetRulerLengthAsString(1));
                return;
            }

            // If it has content, show that
            if (e.AnnotationObject.Metadata.ContainsKey(AnnObject.ContentMetadataKey))
            {
                var content = e.AnnotationObject.Metadata[AnnObject.ContentMetadataKey];
                _automationManagerHelper.SetToolTip(imageViewer, content);
                return;
            }

            // Optionally show its name ...

            /*
             * var automationObject = _automationManagerHelper.AutomationManager.FindObjectById(e.AnnotationObject.Id);
             * _automationManagerHelper.SetToolTip(imageViewer, automationObject.Name);
             */
        }