Example #1
0
        /// <summary>
        /// Show the call tip.
        /// </summary>
        /// <param name="tip"></param>
        /// <param name="handlers"></param>
        /// <param name="position"></param>
        /// <param name="hint"></param>
        private void TipShow(ref CallTip tip, ShowTipEventHandler handlers, int position, object hint)
        {
            // create calltip class
            if (tip == null)
            {
                tip        = new CallTip();
                tip.Enter += new EventHandler(tip_MouseEnter);
                tip.SetChartIntervals(10, 0);
                Theme.Apply(tip);
            }

            // get screen position
            var rect = GetWordBounds(position);

            rect.Location = PointToScreen(rect.Location);
            rect.Inflate(3, 3);

            // Fore some reason PointToScreen can return
            // different positions. In this case the call
            // tip needs to be repositioned.
            if (!tip.Visible || tip.Location != rect.Location)
            {
                // invoke event hadlers
                var e = new ShowTipEventHandlerArgs();
                e.TextPosition   = position;
                e.Definition     = hint;
                e.ScreenPosition = rect.Location;
                handlers?.Invoke(this, e);
                if (e.Cancle)
                {
                    return;
                }

                // show calltip
                if (hint is string)
                {
                    tip.Show(rect, (string)hint);
                }
                else if (hint is Array)
                {
                    const int w = 500;
                    var       X = (Array)((Array)hint).GetValue(0);
                    var       Y = (Array)((Array)hint).GetValue(1);
                    tip.Show(rect, X, Y, w, w * 0.6, ContentAlignment.TopLeft, 0.3, 0.3);
                }

                // make sure the calltip window
                // is in front of all others
                tip.BringToFront();
            }
        }