static private TryGetFormulaInfo ( string formulaPrefix, string &functionName, int ¤tArgIndex ) : bool | ||
formulaPrefix | string | |
functionName | string | |
currentArgIndex | int | |
리턴 | bool |
// 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(); }
// Runs on the UIMonitor's automation thread - return true if we might want to process bool ShouldProcessFormulaEditTextChange(string formulaPrefix) { // CAREFUL: Because of threading, this might run before FormulaEditStart! if (_argumentsToolTip?.Visible == true) { return(true); } // TODO: Why do this twice....? string functionName; int currentArgIndex; if (FormulaParser.TryGetFormulaInfo(formulaPrefix, out functionName, out currentArgIndex)) { if (_functionInfoMap.ContainsKey(functionName)) { return(true); } } // Not interested... Debug.Print($"Not processing formula {formulaPrefix}"); return(false); }