using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using Infragistics.Win;
using Infragistics.Win.UltraWinToolbars;

namespace _139922
{
    class MyCreation:IUIElementCreationFilter
    {
        #region IUIElementCreationFilter Members

        public void AfterCreateChildElements(UIElement parent)
        {
            //throw new NotImplementedException();
            if ((parent is TextUIElement || parent is Infragistics.Win.ImageAndTextUIElement.ImageAndTextDependentTextUIElement) && parent.GetContext(typeof(ToolBase), true) != null)
            {
                Debug.WriteLine(((ToolBase)parent.GetContext(typeof(ToolBase), true)).Key);
                parent.ToolTipItem = new mYToolTip();
            }
        }

        public bool BeforeCreateChildElements(UIElement parent)
        {
            return false;
        }

        #endregion
    }

    public class mYToolTip : IToolTipItem
    {
        Font f = new Font("MingLiU", 14);
        #region IToolTipItem Members

        public ToolTipInfo GetToolTipInfo(System.Drawing.Point mousePosition, UIElement element, UIElement previousToolTipElement, ToolTipInfo toolTipInfoDefault)
        {
            ToolBase tool = (ToolBase)element.GetContext(typeof(ToolBase), true);
            if (tool.ShouldDisplayToolTip)
            {
                toolTipInfoDefault.ToolTipText = tool.SharedProps.ToolTipText;
                toolTipInfoDefault.Title = tool.SharedProps.ToolTipTitle;
            }
         
            toolTipInfoDefault.Font = f;
            return toolTipInfoDefault;
        }

        #endregion
    }

}
