@@ -186,7 +186,6 @@ void StateUpdate(object sender, UIStateUpdate update)
186186 break ;
187187 case UIStateUpdate . UpdateType . FunctionListShow :
188188 var fls = ( UIState . FunctionList ) update . NewState ;
189- // TODO: TEMP
190189 _functionListWindow = fls . FunctionListWindow ;
191190 FunctionListShow ( ) ;
192191 FunctionListSelectedItemChange ( fls . SelectedItemText , fls . SelectedItemBounds , fls . FunctionListBounds ) ;
@@ -209,7 +208,7 @@ void StateUpdate(object sender, UIStateUpdate update)
209208 case UIStateUpdate . UpdateType . SelectDataSourceShow :
210209 case UIStateUpdate . UpdateType . SelectDataSourceWindowChange :
211210 case UIStateUpdate . UpdateType . SelectDataSourceHide :
212- // We ignore these
211+ // We ignore these for now
213212 break ;
214213 default :
215214 throw new InvalidOperationException ( "Unexpected UIStateUpdate" ) ;
@@ -240,24 +239,24 @@ void UpdateFormulaEditWindow(IntPtr formulaEditWindow)
240239 }
241240 }
242241
243- void UpdateFunctionListWindow ( IntPtr functionListWindow )
244- {
245- if ( _functionListWindow != functionListWindow )
246- {
247- _functionListWindow = functionListWindow ;
248- if ( _descriptionToolTip != null )
249- {
250- _descriptionToolTip . Dispose ( ) ;
251- _descriptionToolTip = null ;
252- }
253- if ( _functionListWindow != IntPtr . Zero )
254- {
255- _descriptionToolTip = new ToolTipForm ( _functionListWindow ) ;
256- //_descriptionToolTip.OwnerHandle = _functionListWindow;
257- }
242+ // void UpdateFunctionListWindow(IntPtr functionListWindow)
243+ // {
244+ // if (_functionListWindow != functionListWindow)
245+ // {
246+ // _functionListWindow = functionListWindow;
247+ // if (_descriptionToolTip != null)
248+ // {
249+ // _descriptionToolTip.Dispose();
250+ // _descriptionToolTip = null;
251+ // }
252+ // if (_functionListWindow != IntPtr.Zero)
253+ // {
254+ // _descriptionToolTip = new ToolTipForm(_functionListWindow);
255+ // //_descriptionToolTip.OwnerHandle = _functionListWindow;
256+ // }
258257
259- }
260- }
258+ // }
259+ // }
261260
262261 // Runs on the main thread
263262 void FormulaEditStart ( string formulaPrefix , Rect editWindowBounds , IntPtr excelToolTipWindow )
@@ -295,7 +294,17 @@ void FormulaEditMove(Rect editWindowBounds, IntPtr excelToolTipWindow)
295294 return ;
296295 }
297296 int topOffset = GetTopOffset ( excelToolTipWindow ) ;
298- _argumentsToolTip . MoveToolTip ( ( int ) editWindowBounds . Left , ( int ) editWindowBounds . Bottom + 5 , topOffset ) ;
297+ try
298+ {
299+ _argumentsToolTip . MoveToolTip ( ( int ) editWindowBounds . Left , ( int ) editWindowBounds . Bottom + 5 , topOffset ) ;
300+ }
301+ catch ( Exception ex )
302+ {
303+ Logger . Display . Warn ( $ "IntelliSenseDisplay - FormulaEditMove Error - { ex } ") ;
304+ // Recycle the Arguments ToolTip - won't show now, but should for the next function
305+ _argumentsToolTip . Dispose ( ) ;
306+ _argumentsToolTip = null ;
307+ }
299308 }
300309
301310 // Runs on the main thread
@@ -326,7 +335,16 @@ void FormulaEditTextChange(string formulaPrefix, Rect editWindowBounds, IntPtr e
326335 //}
327336 int topOffset = GetTopOffset ( excelToolTipWindow ) ;
328337 FormattedText infoText = GetFunctionIntelliSense ( functionInfo , currentArgIndex ) ;
329- _argumentsToolTip . ShowToolTip ( infoText , lineBeforeFunctionName , ( int ) editWindowBounds . Left , ( int ) editWindowBounds . Bottom + 5 , topOffset ) ;
338+ try
339+ {
340+ _argumentsToolTip . ShowToolTip ( infoText , lineBeforeFunctionName , ( int ) editWindowBounds . Left , ( int ) editWindowBounds . Bottom + 5 , topOffset ) ;
341+ }
342+ catch ( Exception ex )
343+ {
344+ Logger . Display . Warn ( $ "IntelliSenseDisplay - FormulaEditTextChange Error - { ex } ") ;
345+ _argumentsToolTip . Dispose ( ) ;
346+ _argumentsToolTip = null ;
347+ }
330348 }
331349 else
332350 {
@@ -338,12 +356,7 @@ void FormulaEditTextChange(string formulaPrefix, Rect editWindowBounds, IntPtr e
338356 }
339357
340358 // All other paths, we hide the box
341- if ( _argumentsToolTip != null )
342- {
343- _argumentsToolTip . Hide ( ) ;
344- //_argumentsToolTip.Dispose();
345- //_argumentsToolTip = null;
346- }
359+ _argumentsToolTip ? . Hide ( ) ;
347360 }
348361
349362
@@ -366,7 +379,16 @@ void FormulaEditExcelToolTipShow(Rect editWindowBounds, IntPtr excelToolTipWindo
366379 if ( _argumentsToolTip != null && _argumentsToolTip . Visible )
367380 {
368381 int topOffset = GetTopOffset ( excelToolTipWindow ) ;
369- _argumentsToolTip . MoveToolTip ( ( int ) editWindowBounds . Left , ( int ) editWindowBounds . Bottom + 5 , topOffset ) ;
382+ try
383+ {
384+ _argumentsToolTip . MoveToolTip ( ( int ) editWindowBounds . Left , ( int ) editWindowBounds . Bottom + 5 , topOffset ) ;
385+ }
386+ catch ( Exception ex )
387+ {
388+ Logger . Display . Warn ( $ "IntelliSenseDisplay - FormulaEditExcelToolTipShow Error - { ex } ") ;
389+ _argumentsToolTip . Dispose ( ) ;
390+ _argumentsToolTip = null ;
391+ }
370392 }
371393 }
372394
@@ -382,9 +404,7 @@ void FunctionListShow()
382404 void FunctionListHide ( )
383405 {
384406 Debug . Print ( $ "IntelliSenseDisplay - FunctionListHide") ;
385- _descriptionToolTip . Hide ( ) ;
386- //_descriptionToolTip.Dispose();
387- //_descriptionToolTip = null;
407+ _descriptionToolTip ? . Hide ( ) ;
388408 }
389409
390410 // Runs on the main thread
@@ -400,28 +420,49 @@ void FunctionListSelectedItemChange(string selectedItemText, Rect selectedItemBo
400420 var descriptionLines = GetFunctionDescriptionOrNull ( functionInfo ) ;
401421 if ( descriptionLines != null )
402422 {
403- _descriptionToolTip . ShowToolTip (
404- text : new FormattedText { GetFunctionDescriptionOrNull ( functionInfo ) } ,
405- linePrefix : null ,
406- left : ( int ) listBounds . Right + DescriptionLeftMargin ,
407- top : ( int ) selectedItemBounds . Bottom - 18 ,
408- topOffset : 0 ,
409- listLeft : ( int ) selectedItemBounds . Left ) ;
410- return ;
423+ try
424+ {
425+ _descriptionToolTip ? . ShowToolTip (
426+ text : new FormattedText { GetFunctionDescriptionOrNull ( functionInfo ) } ,
427+ linePrefix : null ,
428+ left : ( int ) listBounds . Right + DescriptionLeftMargin ,
429+ top : ( int ) selectedItemBounds . Bottom - 18 ,
430+ topOffset : 0 ,
431+ listLeft : ( int ) selectedItemBounds . Left ) ;
432+ return ;
433+ }
434+ catch ( Exception ex )
435+ {
436+ Logger . Display . Warn ( $ "IntelliSenseDisplay - PopupListSelectedItemChanged Error - { ex } ") ;
437+ // Recycle the _DescriptionToolTip - won't show now, but should for the next function
438+ _descriptionToolTip . Dispose ( ) ;
439+ _descriptionToolTip = null ;
440+ return ;
441+ }
411442 }
412443 }
413444
414445 // Not ours or no description
415- _descriptionToolTip . Hide ( ) ;
446+ _descriptionToolTip ? . Hide ( ) ;
416447 }
417448
418449 void FunctionListMove ( Rect selectedItemBounds , Rect listBounds )
419450 {
420- _descriptionToolTip . MoveToolTip (
421- left : ( int ) listBounds . Right + DescriptionLeftMargin ,
422- top : ( int ) selectedItemBounds . Bottom - 18 ,
423- topOffset : 0 ,
424- listLeft : ( int ) selectedItemBounds . Left ) ;
451+ try
452+ {
453+ _descriptionToolTip ? . MoveToolTip (
454+ left : ( int ) listBounds . Right + DescriptionLeftMargin ,
455+ top : ( int ) selectedItemBounds . Bottom - 18 ,
456+ topOffset : 0 ,
457+ listLeft : ( int ) selectedItemBounds . Left ) ;
458+ }
459+ catch ( Exception ex )
460+ {
461+ Logger . Display . Warn ( $ "IntelliSenseDisplay - FunctionListMove Error - { ex } ") ;
462+ // Recycle the _DescriptionToolTip - won't show now, but should for the next function
463+ _descriptionToolTip ? . Dispose ( ) ;
464+ _descriptionToolTip = null ;
465+ }
425466 }
426467
427468 // TODO: Performance / efficiency - cache these somehow
0 commit comments