Example #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...");
         }
     }
 }
Example #2
0
        void MainWindowChanged()
        {
            // TODO: This is to guard against shutdown, but we should not have a race here
            //       - shutdown should be on the main thread, as is this event handler.
            if (_windowWatcher == null)
            {
                return;
            }


            // TODO: !!! Reset / re-parent ToolTipWindows
            Debug.Print("MainWindow Change - " + _windowWatcher.MainWindow.ToString("X"));
            Debug.Print("### Thread calling MainWindowChanged method: " + Thread.CurrentThread.ManagedThreadId);

            // _descriptionToolTip.SetOwner(e.Handle); // Not Parent, of course!
            if (_descriptionToolTip != null)
            {
                if (_descriptionToolTip.OwnerHandle != _windowWatcher.MainWindow)
                {
                    _descriptionToolTip.Dispose();
                    _descriptionToolTip = null;
                }
            }
            if (_argumentsToolTip != null)
            {
                if (_argumentsToolTip.OwnerHandle != _windowWatcher.MainWindow)
                {
                    _argumentsToolTip.Dispose();
                    _argumentsToolTip = null;
                }
            }
            // _descriptionToolTip = new ToolTipWindow("", _windowWatcher.MainWindow);
        }
        // Runs on the main thread
        void FunctionListSelectedItemChange(string selectedItemText, Rect selectedItemBounds, Rect listBounds)
        {
            Logger.Display.Verbose(string.Format("IntelliSenseDisplay - PopupListSelectedItemChanged - {0} List/Item Bounds: {1} / {2}", selectedItemText, 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 {
                            GetFunctionDescriptionOrNull(functionInfo)
                        },
                            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(string.Format("IntelliSenseDisplay - PopupListSelectedItemChanged Error - {0}", 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();
        }
Example #4
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;
         }
     }
 }
Example #5
0
 void FunctionListMove(Rect selectedItemBounds, Rect listBounds)
 {
     try
     {
         _descriptionToolTip?.MoveToolTip(
             left: (int)listBounds.Right + DescriptionLeftMargin,
             top: (int)selectedItemBounds.Bottom - 18,
             topOffset: 0,
             listLeft: (int)selectedItemBounds.Left);
     }
     catch (Exception ex)
     {
         Logger.Display.Warn($"IntelliSenseDisplay - FunctionListMove Error - {ex}");
         // Recycle the _DescriptionToolTip - won't show now, but should for the next function
         _descriptionToolTip?.Dispose();
         _descriptionToolTip = null;
     }
 }