예제 #1
0
        HelpInfo IHelpProvider.ProvideHoverHelp(Point localPos, ref bool captured)
        {
            // A dropdown is opened. Provide dropdown help.
            IPopupControlHost dropdownEdit = this.FocusEditor as IPopupControlHost;

            if (dropdownEdit != null && dropdownEdit.IsDropDownOpened)
            {
                EnumPropertyEditor           enumEdit           = dropdownEdit as EnumPropertyEditor;
                FlaggedEnumPropertyEditor    enumFlagEdit       = dropdownEdit as FlaggedEnumPropertyEditor;
                ObjectSelectorPropertyEditor objectSelectorEdit = dropdownEdit as ObjectSelectorPropertyEditor;

                // Its able to provide help. Redirect.
                if (dropdownEdit is IHelpProvider)
                {
                    captured = true;
                    Point dropdownEditorPos = this.GetEditorLocation(dropdownEdit as PropertyEditor, true);
                    return((dropdownEdit as IHelpProvider).ProvideHoverHelp(new Point(localPos.X - dropdownEditorPos.X, localPos.Y - dropdownEditorPos.Y), ref captured));
                }
                // Special case: Its a known basic dropdown.
                else if (enumEdit != null)
                {
                    captured = true;
                    if (enumEdit.DropDownHoveredName != null)
                    {
                        return(HelpInfo.FromMember(enumEdit.EditedType.GetField(enumEdit.DropDownHoveredName, ReflectionHelper.BindAll)));
                    }
                    else
                    {
                        FieldInfo field = enumEdit.EditedType.GetField(enumEdit.DisplayedValue.ToString(), ReflectionHelper.BindAll);
                        if (field != null)
                        {
                            return(HelpInfo.FromMember(field));
                        }
                    }
                }
                else if (enumFlagEdit != null)
                {
                    captured = true;
                    if (enumFlagEdit.DropDownHoveredItem != null)
                    {
                        return(HelpInfo.FromMember(enumFlagEdit.EditedType.GetField(enumFlagEdit.DropDownHoveredItem.Caption, ReflectionHelper.BindAll)));
                    }
                    else
                    {
                        FieldInfo field = enumFlagEdit.EditedType.GetField(enumFlagEdit.DisplayedValue.ToString(), ReflectionHelper.BindAll);
                        if (field != null)
                        {
                            return(HelpInfo.FromMember(field));
                        }
                    }
                }
                else if (objectSelectorEdit != null)
                {
                    captured = true;
                    if (objectSelectorEdit.DropDownHoveredObject != null)
                    {
                        return(HelpInfo.FromObject(objectSelectorEdit.DropDownHoveredObject.Value));
                    }
                    else
                    {
                        return(HelpInfo.FromObject(objectSelectorEdit.DisplayedValue));
                    }
                }

                // No help available.
                return(null);
            }
            captured = false;

            // Pick an editor and see if it has access to an actual IHelpProvider
            PropertyEditor pickedEditor = this.PickEditorAt(localPos.X, localPos.Y, true);
            PropertyEditor helpEditor   = pickedEditor;

            while (helpEditor != null)
            {
                Point helpEditorPos = this.GetEditorLocation(helpEditor, true);
                if (helpEditor is IHelpProvider)
                {
                    IHelpProvider localProvider = helpEditor as IHelpProvider;
                    HelpInfo      localHelp     = localProvider.ProvideHoverHelp(new Point(localPos.X - helpEditorPos.X, localPos.Y - helpEditorPos.Y), ref captured);
                    if (localHelp != null)
                    {
                        return(localHelp);
                    }
                }
                helpEditor = helpEditor.ParentEditor;
            }

            // If not, default to member or type information
            if (pickedEditor != null)
            {
                if (!string.IsNullOrEmpty(pickedEditor.PropertyDesc))
                {
                    return(HelpInfo.FromText(pickedEditor.PropertyName, pickedEditor.PropertyDesc));
                }
                else if (pickedEditor.EditedMember != null)
                {
                    return(HelpInfo.FromMember(pickedEditor.EditedMember));
                }
                else if (pickedEditor.EditedType != null)
                {
                    return(HelpInfo.FromMember(pickedEditor.EditedType));
                }
            }

            return(null);
        }