示例#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();
            }
        }
示例#2
0
        /// <summary>
        /// When the call tip is shown, check whether there
        /// are some performance statistics we can show.
        /// </summary>
        /// <param name="s"></param>
        /// <param name="e"></param>
        private void editor_ShowCallTip(object s, ShowTipEventHandlerArgs e)
        {
            var editor = s as CodeEditor;

            var type = editor.GetWordFromPosition(e.TextPosition);
            if (type != "pass")
                return;

            var pos = editor.WordEndPosition(e.TextPosition, false);
            pos = editor.WordEndPosition(pos + 1, true);
            var name = editor.GetWordFromPosition(pos);

            var pass = glControl.Scene.GetValueOrDefault<GLPass>(name);
            if (pass == null)
                return;

            editor.PerfTipShow(e.TextPosition,
                pass.Frames.Reverse().ToArray(),
                pass.Timings.Reverse().ToArray());
        }
示例#3
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);
                Theme.Apply(tip);
            }

            // get screen position
            var p = PointToScreen(new Point(
                PointXFromPosition(position),
                PointYFromPosition(position)));

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

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

                // show calltip
                var rect = GetWordBounds(position);
                rect.Location = PointToScreen(rect.Location);
                if (hint is string)
                    tip.Show(rect, (string)hint);
                else if (hint is Array)
                    tip.Show(rect, (Array)((Array)hint).GetValue(0), (Array)((Array)hint).GetValue(1));
            }
        }