コード例 #1
0
 // Runs on the main thread
 void UpdateFormulaEditWindow(IntPtr formulaEditWindow)
 {
     if (_formulaEditWindow != formulaEditWindow)
     {
         _formulaEditWindow = formulaEditWindow;
         if (_argumentsToolTip != null)
         {
             // Rather ChangeParent...?
             _argumentsToolTip.Dispose();
             _argumentsToolTip = null;
             _selectBox.Dispose();
             _selectBox = null;
         }
         if (_formulaEditWindow != IntPtr.Zero)
         {
             _argumentsToolTip = new ToolTipForm(_formulaEditWindow);
             _selectBox        = new SelectBoxForm(_formulaEditWindow);
             //_argumentsToolTip.OwnerHandle = _formulaEditWindow;
         }
         else
         {
             // Debug.Fail("Unexpected null FormulaEditWindow...");
         }
     }
 }
コード例 #2
0
        //void UpdateFunctionListWindow(IntPtr functionListWindow)
        //{
        //    if (_functionListWindow != functionListWindow)
        //    {
        //        _functionListWindow = functionListWindow;
        //        if (_descriptionToolTip != null)
        //        {
        //            _descriptionToolTip.Dispose();
        //            _descriptionToolTip = null;
        //        }
        //        if (_functionListWindow != IntPtr.Zero)
        //        {
        //            _descriptionToolTip = new ToolTipForm(_functionListWindow);
        //            //_descriptionToolTip.OwnerHandle = _functionListWindow;
        //        }

        //    }
        //}

        // Runs on the main thread
        void FormulaEditStart(string formulaPrefix, Rect editWindowBounds, IntPtr excelToolTipWindow)
        {
            Debug.Print($"IntelliSenseDisplay - FormulaEditStart - FormulaEditWindow: {_formulaEditWindow}, ArgumentsToolTip: {_argumentsToolTip}");
            if (_formulaEditWindow != IntPtr.Zero && _argumentsToolTip == null)
            {
                _argumentsToolTip = new ToolTipForm(_formulaEditWindow);
                _selectBox        = new SelectBoxForm(_formulaEditWindow);
            }

            // Normally we would have no formula at this point.
            // One exception is after mouse-click on the formula list, we then need to process it.
            if (!string.IsNullOrEmpty(formulaPrefix))
            {
                FormulaEditTextChange(formulaPrefix, editWindowBounds, excelToolTipWindow);
            }
        }
コード例 #3
0
 // Runs on the main thread
 void FormulaEditEnd()
 {
     Debug.Print($"IntelliSenseDisplay - FormulaEditEnd");
     // TODO: When can it be null
     if (!_selectBox?.ContainsFocus ?? true)
     {
         if (_argumentsToolTip != null)
         {
             //_argumentsToolTip.Hide();
             _argumentsToolTip.Dispose();
             _argumentsToolTip = null;
         }
         if (_selectBox != null)
         {
             _selectBox.Dispose();
             _selectBox = null;
         }
     }
 }
コード例 #4
0
        // Runs on the main thread
        void FormulaEditTextChange(string formulaPrefix, Rect editWindowBounds, IntPtr excelToolTipWindow)
        {
            Debug.Print($"^^^ FormulaEditStateChanged. CurrentPrefix: {formulaPrefix}, Thread {Thread.CurrentThread.ManagedThreadId}");
            string functionName;
            int    currentArgIndex;
            int    toolTipBottom = (int)editWindowBounds.Location.Y + 5;

            if (FormulaParser.TryGetFormulaInfo(formulaPrefix, out functionName, out currentArgIndex))
            {
                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.Location.X, (int)editWindowBounds.Location.Y + (int)editWindowBounds.Height + 5, topOffset);
                            toolTipBottom = (int)editWindowBounds.Location.Y + (int)editWindowBounds.Height + 5 + _argumentsToolTip.Height;
                        }
                        catch (Exception ex)
                        {
                            Logger.Display.Warn($"IntelliSenseDisplay - FormulaEditTextChange Error - {ex}");
                            _argumentsToolTip.Dispose();
                            _argumentsToolTip = null;
                        }
                    }
                    else
                    {
                        Logger.Display.Warn("FormulaEditTextChange with no arguments tooltip !?");
                    }

                    if (_selectBox != null)
                    {
                        try
                        {
                            var argDescription = functionInfo.ArgumentList[currentArgIndex].Description;
                            int topOffset      = GetTopOffset(excelToolTipWindow);
                            if (hasArgList(argDescription))
                            {
                                _selectBox.ShowToolTip(argDescription, lineBeforeFunctionName, (int)editWindowBounds.Location.X, toolTipBottom + 10, topOffset);
                            }
                            //else
                            //{
                            //    _selectBox.Dispose();
                            //    _selectBox = null;
                            //}
                        }
                        catch (Exception ex)
                        {
                            Logger.Display.Warn($"IntelliSenseDisplay - FormulaEditTextChange Error - {ex}");
                            _selectBox.Dispose();
                            _selectBox = null;
                        }
                    }

                    return;
                }
            }

            // All other paths, we hide the box
            _argumentsToolTip?.Hide();
        }