77
88namespace ExcelDna . IntelliSense
99{
10- class IntelliSenseFunctionInfo
11- {
12- public class ArgumentInfo
13- {
14- public string ArgumentName ;
15- public string Description ;
16- }
17- public string FunctionName ;
18- public string Description ;
19- public List < ArgumentInfo > ArgumentList ;
20- public string SourcePath ; // XllPath for .xll, Workbook Name for Workbook
21- }
22-
2310 // CONSIDER: Revisit UI Automation Threading: http://msdn.microsoft.com/en-us/library/windows/desktop/ee671692(v=vs.85).aspx
2411 // And this threading sample using tlbimp version of Windows 7 native UIA: http://code.msdn.microsoft.com/Windows-7-UI-Automation-6390614a/sourcecode?fileId=21469&pathId=715901329
2512 // NOTE: TrackFocus example shows how to do a window 'natively'.
@@ -33,8 +20,8 @@ class IntelliSenseDisplay : IDisposable
3320 SynchronizationContext _syncContextMain ;
3421 readonly UIMonitor _uiMonitor ;
3522
36- readonly Dictionary < string , IntelliSenseFunctionInfo > _functionInfoMap =
37- new Dictionary < string , IntelliSenseFunctionInfo > ( StringComparer . CurrentCultureIgnoreCase ) ;
23+ readonly Dictionary < string , FunctionInfo > _functionInfoMap =
24+ new Dictionary < string , FunctionInfo > ( StringComparer . CurrentCultureIgnoreCase ) ;
3825
3926 // Need to make these late ...?
4027 ToolTipForm _descriptionToolTip ;
@@ -58,7 +45,7 @@ public IntelliSenseDisplay(SynchronizationContext syncContextMain, UIMonitor uiM
5845 }
5946
6047 // TODO: Still not sure how to delete / unregister...
61- internal void UpdateFunctionInfos ( IEnumerable < IntelliSenseFunctionInfo > functionInfos )
48+ internal void UpdateFunctionInfos ( IEnumerable < FunctionInfo > functionInfos )
6249 {
6350 foreach ( var fi in functionInfos )
6451 {
@@ -262,7 +249,7 @@ void FormulaEditTextChange(string formulaPrefix, Rect editWindowBounds, Rect exc
262249 int currentArgIndex ;
263250 if ( FormulaParser . TryGetFormulaInfo ( formulaPrefix , out functionName , out currentArgIndex ) )
264251 {
265- IntelliSenseFunctionInfo functionInfo ;
252+ FunctionInfo functionInfo ;
266253 if ( _functionInfoMap . TryGetValue ( functionName , out functionInfo ) )
267254 {
268255 if ( _argumentsToolTip != null )
@@ -312,7 +299,7 @@ void FunctionListSelectedItemChange(string selectedItemText, Rect selectedItemBo
312299 {
313300 Logger . Display . Verbose ( $ "IntelliSenseDisplay - PopupListSelectedItemChanged - { selectedItemText } List/Item Bounds: { listBounds } / { selectedItemBounds } ") ;
314301
315- IntelliSenseFunctionInfo functionInfo ;
302+ FunctionInfo functionInfo ;
316303 if ( _functionInfoMap . TryGetValue ( selectedItemText , out functionInfo ) )
317304 {
318305 // It's ours!
@@ -339,7 +326,7 @@ void FunctionListMove(Rect selectedItemBounds, Rect listBounds)
339326 // TODO: Performance / efficiency - cache these somehow
340327 // TODO: Probably not a good place for LINQ !?
341328 static readonly string [ ] s_newLineStringArray = new string [ ] { Environment . NewLine } ;
342- IEnumerable < TextLine > GetFunctionDescriptionOrNull ( IntelliSenseFunctionInfo functionInfo )
329+ IEnumerable < TextLine > GetFunctionDescriptionOrNull ( FunctionInfo functionInfo )
343330 {
344331 var description = functionInfo . Description ;
345332 if ( string . IsNullOrEmpty ( description ) )
@@ -355,12 +342,12 @@ IEnumerable<TextLine> GetFunctionDescriptionOrNull(IntelliSenseFunctionInfo func
355342 } } ) ;
356343 }
357344
358- FormattedText GetFunctionIntelliSense ( IntelliSenseFunctionInfo functionInfo , int currentArgIndex )
345+ FormattedText GetFunctionIntelliSense ( FunctionInfo functionInfo , int currentArgIndex )
359346 {
360- var nameLine = new TextLine { new TextRun { Text = functionInfo . FunctionName + "(" } } ;
347+ var nameLine = new TextLine { new TextRun { Text = functionInfo . Name + "(" } } ;
361348 if ( functionInfo . ArgumentList . Count > 0 )
362349 {
363- var argNames = functionInfo . ArgumentList . Take ( currentArgIndex ) . Select ( arg => arg . ArgumentName ) . ToArray ( ) ;
350+ var argNames = functionInfo . ArgumentList . Take ( currentArgIndex ) . Select ( arg => arg . Name ) . ToArray ( ) ;
364351 if ( argNames . Length >= 1 )
365352 {
366353 nameLine . Add ( new TextRun { Text = string . Join ( ", " , argNames ) } ) ;
@@ -378,11 +365,11 @@ FormattedText GetFunctionIntelliSense(IntelliSenseFunctionInfo functionInfo, int
378365
379366 nameLine . Add ( new TextRun
380367 {
381- Text = functionInfo . ArgumentList [ currentArgIndex ] . ArgumentName ,
368+ Text = functionInfo . ArgumentList [ currentArgIndex ] . Name ,
382369 Style = System . Drawing . FontStyle . Bold
383370 } ) ;
384371
385- argNames = functionInfo . ArgumentList . Skip ( currentArgIndex + 1 ) . Select ( arg => arg . ArgumentName ) . ToArray ( ) ;
372+ argNames = functionInfo . ArgumentList . Skip ( currentArgIndex + 1 ) . Select ( arg => arg . Name ) . ToArray ( ) ;
386373 if ( argNames . Length >= 1 )
387374 {
388375 nameLine . Add ( new TextRun { Text = ", " + string . Join ( ", " , argNames ) } ) ;
@@ -403,13 +390,13 @@ FormattedText GetFunctionIntelliSense(IntelliSenseFunctionInfo functionInfo, int
403390 return formattedText ;
404391 }
405392
406- TextLine GetArgumentDescription ( IntelliSenseFunctionInfo . ArgumentInfo argumentInfo )
393+ TextLine GetArgumentDescription ( FunctionInfo . ArgumentInfo argumentInfo )
407394 {
408395 return new TextLine {
409396 new TextRun
410397 {
411398 Style = System . Drawing . FontStyle . Bold | System . Drawing . FontStyle . Italic ,
412- Text = argumentInfo . ArgumentName + ": "
399+ Text = argumentInfo . Name + ": "
413400 } ,
414401 new TextRun
415402 {
@@ -442,24 +429,24 @@ public void Dispose()
442429
443430 // TODO: Think about case again
444431 // TODO: Consider locking...
445- public void RegisterFunctionInfo ( IntelliSenseFunctionInfo functionInfo )
432+ public void RegisterFunctionInfo ( FunctionInfo functionInfo )
446433 {
447434 // TODO : Dictionary from KeyLookup
448- IntelliSenseFunctionInfo oldFunctionInfo ;
449- if ( ! _functionInfoMap . TryGetValue ( functionInfo . FunctionName , out oldFunctionInfo ) )
435+ FunctionInfo oldFunctionInfo ;
436+ if ( ! _functionInfoMap . TryGetValue ( functionInfo . Name , out oldFunctionInfo ) )
450437 {
451- _functionInfoMap . Add ( functionInfo . FunctionName , functionInfo ) ;
438+ _functionInfoMap . Add ( functionInfo . Name , functionInfo ) ;
452439 }
453440 else
454441 {
455442 // Update against the function name
456- _functionInfoMap [ functionInfo . FunctionName ] = functionInfo ;
443+ _functionInfoMap [ functionInfo . Name ] = functionInfo ;
457444 }
458445 }
459446
460- public void UnregisterFunctionInfo ( IntelliSenseFunctionInfo functionInfo )
447+ public void UnregisterFunctionInfo ( FunctionInfo functionInfo )
461448 {
462- _functionInfoMap . Remove ( functionInfo . FunctionName ) ;
449+ _functionInfoMap . Remove ( functionInfo . Name ) ;
463450 }
464451 }
465452}
0 commit comments