예제 #1
0
 public void ShowToolTip(FormattedText text, string linePrefix, int left, int top, int topOffset, int?listLeft = null)
 {
     Debug.Print($"@@@ ShowToolTip - Old TopOffset: {_topOffset}, New TopOffset: {topOffset}");
     _text            = text;
     _linePrefixWidth = MeasureFormulaStringWidth(linePrefix);
     left            += _linePrefixWidth;
     if (left != _showLeft || top != _showTop || topOffset != _topOffset || listLeft != _listLeft)
     {
         // Update the start position and the current position
         _currentLeft = left;
         _currentTop  = top;
         _showLeft    = left;
         _showTop     = top;
         _topOffset   = topOffset;
         _listLeft    = listLeft;
     }
     if (!Visible)
     {
         Debug.Print($"ShowToolTip - Showing ToolTipForm: {linePrefix} => {_text.ToString()}");
         // Make sure we're in the right position before we're first shown
         SetBounds(_currentLeft, _currentTop + _topOffset, 0, 0);
         _showTimeTicks = DateTime.UtcNow.Ticks;
         ShowToolTip();
     }
     else
     {
         Debug.Print($"ShowToolTip - Invalidating ToolTipForm: {linePrefix} => {_text.ToString()}");
         Invalidate();
     }
 }
예제 #2
0
        public void ShowToolTip(FormattedText text, string linePrefix, int left, int top, int topOffset, int?listLeft = null)
        {
            Debug.Print($"@@@ ShowToolTip - Old TopOffset: {_topOffset}, New TopOffset: {topOffset}");
            _text            = text;
            _linePrefixWidth = MeasureFormulaStringWidth(linePrefix);

            left += _linePrefixWidth;

            // Mimic Excel native tooltip behaviour: it never goes beyond the screen's leftmost boundary.
            // -
            left = Math.Max(0, left);

            if (left != _showLeft || top != _showTop || topOffset != _topOffset || listLeft != _listLeft)
            {
                // Update the start position and the current position
                _currentLeft = Math.Max(left, 0);   // Don't move off the screen
                _currentTop  = Math.Max(top, -topOffset);
                _showLeft    = _currentLeft;
                _showTop     = _currentTop;
                _topOffset   = topOffset;
                _listLeft    = listLeft;
            }

            if (!Visible)
            {
                Debug.Print($"ShowToolTip - Showing ToolTipForm: {linePrefix} => {_text.ToString()}");
                // Make sure we're in the right position before we're first shown
                SetBounds(_currentLeft, _currentTop + _topOffset, 0, 0);
                _showTimeTicks = DateTime.UtcNow.Ticks;
                ShowToolTip();
            }
            else
            {
                Debug.Print($"ShowToolTip - Invalidating ToolTipForm: {linePrefix} => {_text.ToString()}");
                Invalidate();
            }
        }