11using System . Collections . Generic ;
2+ using System . Diagnostics ;
3+ using System . IO ;
24using System . Linq ;
35using System . Text ;
46using System . Timers ;
@@ -14,9 +16,9 @@ namespace Spcode.UI.Windows
1416 /// <summary>
1517 /// Interaction logic for AboutWindow.xaml
1618 /// </summary>
17- public partial class SPDefinitionWindow : MetroWindow
19+ public partial class SPDefinitionWindow
1820 {
19- private readonly SPDefEntry [ ] defArray ;
21+ private readonly SMBaseDefinition [ ] defArray ;
2022 private readonly Brush errorSearchBoxBrush = new SolidColorBrush ( Color . FromArgb ( 0x50 , 0xA0 , 0x30 , 0 ) ) ;
2123 private readonly ListViewItem [ ] items ;
2224 private readonly Timer searchTimer = new Timer ( 1000.0 ) ;
@@ -38,25 +40,26 @@ public SPDefinitionWindow()
3840 return ;
3941 }
4042
41- var defList = new List < SPDefEntry > ( ) ;
42- defList . AddRange ( def . Functions . Select ( t => ( SPDefEntry ) t ) ) ;
43- defList . AddRange ( def . Constants . Select ( t => ( SPDefEntry ) t ) ) ;
44- defList . AddRange ( def . Enums . Select ( t => ( SPDefEntry ) t ) ) ;
45- defList . AddRange ( def . Defines . Select ( t => ( SPDefEntry ) t ) ) ;
46- defList . AddRange ( def . Structs . Select ( t => ( SPDefEntry ) t ) ) ;
47- defList . AddRange ( def . Methodmaps . Select ( t => ( SPDefEntry ) t ) ) ;
48- defList . AddRange ( def . Typedefs . Select ( t => ( SPDefEntry ) t ) ) ;
49- defList . AddRange ( def . EnumStructs . Select ( t => ( SPDefEntry ) t ) ) ;
43+ var defList = new List < SMBaseDefinition > ( ) ;
44+ defList . AddRange ( def . Functions ) ;
45+ defList . AddRange ( def . Constants ) ;
46+ defList . AddRange ( def . Enums ) ;
47+ defList . AddRange ( def . Defines ) ;
48+ defList . AddRange ( def . Structs ) ;
49+ defList . AddRange ( def . Methodmaps ) ;
50+ defList . AddRange ( def . Typedefs ) ;
51+ defList . AddRange ( def . EnumStructs ) ;
52+ defList . AddRange ( def . Variables ) ;
5053 foreach ( var mm in def . Methodmaps )
5154 {
52- defList . AddRange ( mm . Methods . Select ( t => ( SPDefEntry ) t ) ) ;
53- defList . AddRange ( mm . Fields . Select ( t => ( SPDefEntry ) t ) ) ;
55+ defList . AddRange ( mm . Methods ) ;
56+ defList . AddRange ( mm . Fields ) ;
5457 }
5558
5659 foreach ( var es in def . EnumStructs )
5760 {
58- defList . AddRange ( es . Methods . Select ( t => ( SPDefEntry ) t ) ) ;
59- defList . AddRange ( es . Fields . Select ( t => ( SPDefEntry ) t ) ) ;
61+ defList . AddRange ( es . Methods ) ;
62+ defList . AddRange ( es . Fields ) ;
6063 }
6164
6265 foreach ( var e in defList . Where ( e => string . IsNullOrWhiteSpace ( e . Name ) ) )
@@ -67,7 +70,7 @@ public SPDefinitionWindow()
6770 items = new ListViewItem [ defArrayLength ] ;
6871 for ( var i = 0 ; i < defArrayLength ; ++ i )
6972 {
70- items [ i ] = new ListViewItem { Content = defArray [ i ] . Name , Tag = defArray [ i ] . Entry } ;
73+ items [ i ] = new ListViewItem { Content = defArray [ i ] . Name , Tag = defArray [ i ] } ;
7174 SPBox . Items . Add ( items [ i ] ) ;
7275 }
7376
@@ -95,7 +98,7 @@ private void SPFunctionsListBox_SelectionChanged(object sender, SelectionChanged
9598 SPFileBlock . Text = sm1 . File + ".inc" +
9699 $ " ({ string . Format ( Program . Translations . GetLanguage ( "PosLen" ) , sm1 . Index , sm1 . Length ) } )";
97100 SPTypeBlock . Text = "Function" ;
98- SPCommentBox . Text = sm1 . CommentString ;
101+ SPCommentBox . Text = "comment:::" + sm1 . CommentString + " \n KIND:::: " + sm1 . FunctionKind ;
99102 return ;
100103 }
101104
@@ -218,6 +221,21 @@ private void SPFunctionsListBox_SelectionChanged(object sender, SelectionChanged
218221 SPCommentBox . Text = string . Empty ;
219222 }
220223
224+ private void SPFunctionsListBox_DoubleClick ( object sender , RoutedEventArgs e )
225+ {
226+ var item = ( ListViewItem ) SPBox . SelectedItem ;
227+ if ( item == null ) return ;
228+
229+ Close ( ) ;
230+ var sm = ( SMBaseDefinition ) item . Tag ;
231+ var config = Program . Configs [ Program . SelectedConfig ] . SMDirectories . First ( ) ;
232+ Program . MainWindow . TryLoadSourceFile ( Path . GetFullPath ( Path . Combine ( config , "include" , sm . File ) ) + ".inc" , true , false , true ) ;
233+ var ee = Program . MainWindow . GetCurrentEditorElement ( ) ;
234+ Debug . Assert ( ee != null ) ;
235+ ee . editor . TextArea . Caret . Offset = sm . Index ;
236+ ee . editor . TextArea . Caret . BringCaretToView ( ) ;
237+ }
238+
221239 private void TextBox_TextChanged ( object sender , TextChangedEventArgs e )
222240 {
223241 SPProgress . IsIndeterminate = true ;
@@ -253,71 +271,5 @@ private void Language_Translate()
253271 return;
254272 }*/
255273 }
256-
257- private class SPDefEntry
258- {
259- public object Entry ;
260- public string Name ;
261-
262- public static implicit operator SPDefEntry ( SMFunction func )
263- {
264- return new SPDefEntry { Name = func . Name , Entry = func } ;
265- }
266-
267- public static implicit operator SPDefEntry ( SMConstant sm )
268- {
269- return new SPDefEntry { Name = sm . Name , Entry = sm } ;
270- }
271-
272- public static implicit operator SPDefEntry ( SMDefine sm )
273- {
274- return new SPDefEntry { Name = sm . Name , Entry = sm } ;
275- }
276-
277- public static implicit operator SPDefEntry ( SMEnum sm )
278- {
279- return new SPDefEntry { Name = sm . Name , Entry = sm } ;
280- }
281-
282- public static implicit operator SPDefEntry ( SMStruct sm )
283- {
284- return new SPDefEntry { Name = sm . Name , Entry = sm } ;
285- }
286-
287- public static implicit operator SPDefEntry ( SMMethodmap sm )
288- {
289- return new SPDefEntry { Name = sm . Name , Entry = sm } ;
290- }
291-
292- public static implicit operator SPDefEntry ( SMMethodmapMethod sm )
293- {
294- return new SPDefEntry { Name = sm . Name , Entry = sm } ;
295- }
296-
297- public static implicit operator SPDefEntry ( SMMethodmapField sm )
298- {
299- return new SPDefEntry { Name = sm . Name , Entry = sm } ;
300- }
301-
302- public static implicit operator SPDefEntry ( SMTypedef sm )
303- {
304- return new SPDefEntry { Name = sm . Name , Entry = sm } ;
305- }
306-
307- public static implicit operator SPDefEntry ( SMEnumStruct sm )
308- {
309- return new SPDefEntry { Name = sm . Name , Entry = sm } ;
310- }
311-
312- public static implicit operator SPDefEntry ( SMEnumStructMethod sm )
313- {
314- return new SPDefEntry { Name = sm . Name , Entry = sm } ;
315- }
316-
317- public static implicit operator SPDefEntry ( SMEnumStructField sm )
318- {
319- return new SPDefEntry { Name = sm . Name , Entry = sm } ;
320- }
321- }
322274 }
323275}
0 commit comments