void automation_ToolTip(object sender, AnnToolTipEventArgs e) { if (e.AnnotationObject != null) { AnnTextObject text = e.AnnotationObject as AnnTextObject; string toolTipText = string.Empty; if (text != null) { toolTipText = text.Text; } else { AnnPolyRulerObject ruler = e.AnnotationObject as AnnPolyRulerObject; if (ruler != null) { if (ruler.MeasurementUnit == AnnUnit.Pixel) { LeadLengthD lengthInUnits = ruler.GetRulerLength(1); double lengthInPixels = Automation.Container.Mapper.LengthFromContainerCoordinates(lengthInUnits, AnnFixedStateOperations.Scrolling | AnnFixedStateOperations.Zooming); toolTipText = string.Format("{0} {1}", Math.Round(lengthInPixels, 2), ruler.UnitsAbbreviation[AnnUnit.Pixel]); } else { toolTipText = ruler.GetRulerLengthAsString(Automation.Container.Mapper.CalibrationScale); } } else { AnnRichTextObject richText = e.AnnotationObject as AnnRichTextObject; if (richText != null) { toolTipText = richText.ToString(); } else { AnnStickyNoteObject stickyNote = e.AnnotationObject as AnnStickyNoteObject; if (stickyNote != null) { toolTipText = stickyNote.Metadata[AnnObject.ContentMetadataKey]; } else { AnnAutomationObject annAutomationObject = MainForm.ManagerHelper.AutomationManager.FindObjectById(e.AnnotationObject.Id); toolTipText = annAutomationObject.Name; } } } } MainForm.ManagerHelper.SetToolTip(_viewer, toolTipText); } else { MainForm.ManagerHelper.SetToolTip(null, string.Empty); } }
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); */ }