Exemple #1
0
        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);
            }
        }
        void AddStickyNoteProperties(List <PropertyDescriptor> properties, string category)
        {
            AnnStickyNoteObject annStickyNoteObject = _object as AnnStickyNoteObject;

            Attribute[] attribs = new Attribute[1] {
                new EditorAttribute(typeof(BitmapEditor), typeof(UITypeEditor))
            };

            object defaultValue = _resources.Images[annStickyNoteObject.DefaultPicture];

            properties.Add(new CustomPropertyDescriptor(_type.GetProperty("Picture"), _object, "Picture", category, attribs, typeof(PictureConverter), _resources.Images[annStickyNoteObject.DefaultPicture]));
        }