ShowToolTip() private méthode

private ShowToolTip ( ) : void
Résultat void
Exemple #1
0
        void PopupListSelectedItemChanged()
        {
            if (_popupListWatcher == null)
            {
                return;
            }
            string functionName = _popupListWatcher.SelectedItemText;

            IntelliSenseFunctionInfo functionInfo;

            if (_functionInfoMap.TryGetValue(functionName, out functionInfo))
            {
                if (_descriptionToolTip == null)
                {
                    _descriptionToolTip = new ToolTipForm(_windowWatcher.MainWindow);
                    _argumentsToolTip   = new ToolTipForm(_windowWatcher.MainWindow);
                }
                // It's ours!
                _descriptionToolTip.ShowToolTip(
                    new FormattedText {
                    GetFunctionDescription(functionInfo)
                },
                    (int)_popupListWatcher.SelectedItemBounds.Right + 25, (int)_popupListWatcher.SelectedItemBounds.Top);
            }
            else
            {
                if (_descriptionToolTip != null)
                {
                    _descriptionToolTip.Hide();
                }
            }
        }
Exemple #2
0
        // Runs on the main thread
        void FunctionListSelectedItemChange(string selectedItemText, Rect selectedItemBounds, Rect listBounds)
        {
            Logger.Display.Verbose($"IntelliSenseDisplay - PopupListSelectedItemChanged - {selectedItemText} List/Item Bounds: {listBounds} / {selectedItemBounds}");

            FunctionInfo functionInfo;

            if (!string.IsNullOrEmpty(selectedItemText) &&
                _functionInfoMap.TryGetValue(selectedItemText, out functionInfo))
            {
                // It's ours!
                var descriptionLines = GetFunctionDescriptionOrNull(functionInfo);
                if (descriptionLines != null)
                {
                    _descriptionToolTip.ShowToolTip(
                        text: new FormattedText {
                        GetFunctionDescriptionOrNull(functionInfo)
                    },
                        linePrefix: null,
                        left: (int)listBounds.Right + DescriptionLeftMargin,
                        top: (int)selectedItemBounds.Bottom - 18,
                        topOffset: 0,
                        listLeft: (int)selectedItemBounds.Left);
                    return;
                }
            }

            // Not ours or no description
            _descriptionToolTip.Hide();
        }
Exemple #3
0
        // Runs on the main thread
        void FormulaEditTextChange(string formulaPrefix, Rect editWindowBounds, IntPtr excelToolTipWindow)
        {
            Debug.Print($"^^^ FormulaEditStateChanged. CurrentPrefix: {formulaPrefix}, Thread {Thread.CurrentThread.ManagedThreadId}");

            var couldGet = FormulaParser.TryGetFormulaInfo(formulaPrefix, out string functionName, out int currentArgIndex);

            IntelliSenseEvents.Instance.OnEditingFunction(functionName);

            if (!couldGet)
            {
                IntelliSenseEvents.Instance.OnEditingArgument(null, null);
            }
            else
            {
                FunctionInfo functionInfo;

                if (_functionInfoMap.TryGetValue(functionName, out functionInfo))
                {
                    var lineBeforeFunctionName = FormulaParser.GetLineBeforeFunctionName(formulaPrefix, functionName);

                    // We have a function name and we want to show info
                    if (_argumentsToolTip != null)
                    {
                        // NOTE: Hiding or moving just once doesn't help - the tooltip pops up in its original place again
                        // TODO: Try to move it off-screen, behind or make invisible
                        //if (!_argumentsToolTip.Visible)
                        //{
                        //    // Fiddle a bit with the ExcelToolTip if it is already visible when we first show our FunctionEdit ToolTip
                        //    // At other times, the explicit UI update should catch and hide as appropriate
                        //    if (excelToolTipWindow != IntPtr.Zero)
                        //    {
                        //        Win32Helper.HideWindow(excelToolTipWindow);
                        //    }
                        //}
                        int           topOffset = GetTopOffset(excelToolTipWindow);
                        FormattedText infoText  = GetFunctionIntelliSense(functionInfo, currentArgIndex);
                        try
                        {
                            _argumentsToolTip.ShowToolTip(infoText, lineBeforeFunctionName, (int)editWindowBounds.Left, (int)editWindowBounds.Bottom + 5, topOffset);
                        }
                        catch (Exception ex)
                        {
                            Logger.Display.Warn($"IntelliSenseDisplay - FormulaEditTextChange Error - {ex}");
                            _argumentsToolTip.Dispose();
                            _argumentsToolTip = null;
                        }
                    }
                    else
                    {
                        Logger.Display.Info("FormulaEditTextChange with no arguments tooltip !?");
                    }
                    return;
                }
            }

            // All other paths, we hide the box
            _argumentsToolTip?.Hide();
        }
Exemple #4
0
        // TODO: Need better formula parsing story here
        // Here are some ideas: http://fastexcel.wordpress.com/2013/10/27/parsing-functions-from-excel-formulas-using-vba-is-mid-or-a-byte-array-the-best-method/
        void FormulaEditStateChanged(StateChangeTypeEnum stateChangeType)
        {
            // Check for watcher already disposed
            // CONSIDER: How to manage threading with disposal...?
            if (_formulaEditWatcher == null)
            {
                return;
            }

            if (stateChangeType == StateChangeTypeEnum.Move && _argumentsToolTip != null)
            {
                _argumentsToolTip.MoveToolTip(
                    (int)_formulaEditWatcher.EditWindowBounds.Left, (int)_formulaEditWatcher.EditWindowBounds.Bottom + 5);
                return;
            }

            Debug.Print("^^^ FormulaEditStateChanged. CurrentPrefix: " + _formulaEditWatcher.CurrentPrefix);
            if (_formulaEditWatcher.IsEditingFormula && _formulaEditWatcher.CurrentPrefix != null)
            {
                string prefix = _formulaEditWatcher.CurrentPrefix;
                var    match  = Regex.Match(prefix, @"^=(?<functionName>\w*)\(");
                if (match.Success)
                {
                    string functionName = match.Groups["functionName"].Value;

                    IntelliSenseFunctionInfo functionInfo;
                    if (_functionInfoMap.TryGetValue(functionName, out functionInfo))
                    {
                        // It's ours!
                        if (_argumentsToolTip == null)
                        {
                            _argumentsToolTip = new ToolTipForm(_windowWatcher.MainWindow);
                        }

                        // TODO: Fix this: Need to consider subformulae
                        int currentArgIndex = _formulaEditWatcher.CurrentPrefix.Count(c => c == ',');
                        _argumentsToolTip.ShowToolTip(
                            GetFunctionIntelliSense(functionInfo, currentArgIndex),
                            (int)_formulaEditWatcher.EditWindowBounds.Left, (int)_formulaEditWatcher.EditWindowBounds.Bottom + 5);
                        return;
                    }
                }
            }

            // All other paths, we just clear the box
            if (_argumentsToolTip != null)
            {
                _argumentsToolTip.Hide();
            }
        }
Exemple #5
0
        // Runs on the main thread
        void FunctionListSelectedItemChange(string selectedItemText, Rect selectedItemBounds, Rect listBounds)
        {
            Logger.Display.Verbose($"IntelliSenseDisplay - PopupListSelectedItemChanged - {selectedItemText} List/Item Bounds: {listBounds} / {selectedItemBounds}");

            FunctionInfo functionInfo;

            if (!string.IsNullOrEmpty(selectedItemText) &&
                _functionInfoMap.TryGetValue(selectedItemText, out functionInfo))
            {
                // It's ours!
                var descriptionLines = GetFunctionDescriptionOrNull(functionInfo);
                if (descriptionLines != null)
                {
                    try
                    {
                        _descriptionToolTip?.ShowToolTip(
                            text: new FormattedText {
                            descriptionLines
                        },
                            linePrefix: null,
                            left: (int)listBounds.Right + DescriptionLeftMargin,
                            top: (int)selectedItemBounds.Bottom - 18,
                            topOffset: 0,
                            listLeft: (int)selectedItemBounds.Left);
                        return;
                    }
                    catch (Exception ex)
                    {
                        Logger.Display.Warn($"IntelliSenseDisplay - PopupListSelectedItemChanged Error - {ex}");
                        // Recycle the _DescriptionToolTip - won't show now, but should for the next function
                        _descriptionToolTip.Dispose();
                        _descriptionToolTip = null;
                        return;
                    }
                }
            }

            // Not ours or no description
            _descriptionToolTip?.Hide();
        }