11using System ;
22using System . Diagnostics ;
33using System . Drawing ;
4- using System . Linq ;
54using System . Windows . Forms ;
65using ASCompletion . Model ;
76using JetBrains . Annotations ;
@@ -27,6 +26,8 @@ public ClassModelExplorerForm([NotNull] Settings settings)
2726 InitializeContextMenu ( ) ;
2827 }
2928
29+ [ CanBeNull ] public virtual TypeNode SelectedNode => null ;
30+
3031 protected override void Dispose ( bool disposing )
3132 {
3233 if ( disposing )
@@ -67,41 +68,33 @@ protected virtual void ShowContextMenu(Point position)
6768 protected void OnGotoLineOrPosition ( object sender , EventArgs e )
6869 {
6970 Debug . Assert ( GotoPositionOrLine != null , "GotoPositionOrLine != null" ) ;
70- GotoPositionOrLine ( this , GetModelFromSelectedNode ( ) ) ;
71+ GotoPositionOrLine ( this , SelectedNode ? . Model ) ;
7172 }
7273
7374 protected void OnShowInQuickOutline ( object sender , EventArgs e )
7475 {
7576 Debug . Assert ( ShowInQuickOutline != null , "ShowInQuickOutline != null" ) ;
76- ShowInQuickOutline ( this , GetModelFromSelectedNode ( ) ) ;
77+ ShowInQuickOutline ( this , SelectedNode ? . Model ) ;
7778 }
7879
7980 protected void OnShowInClassHierarchy ( object sender , EventArgs e )
8081 {
8182 Debug . Assert ( ShowInClassHierarchy != null , "ShowInClassHierarchy != null" ) ;
82- ShowInClassHierarchy ( this , GetModelFromSelectedNode ( ) ) ;
83+ ShowInClassHierarchy ( this , SelectedNode ? . Model ) ;
8384 }
8485
8586 protected void OnShowInProjectManager ( object sender , EventArgs e )
8687 {
8788 Debug . Assert ( ShowInProjectManager != null , "ShowInProjectManager != null" ) ;
88- ShowInProjectManager ( this , GetModelFromSelectedNode ( ) ) ;
89+ ShowInProjectManager ( this , SelectedNode ? . Model ) ;
8990 }
9091
9192 protected void OnShowInFileExplorer ( object sender , EventArgs e )
9293 {
9394 Debug . Assert ( ShowInFileExplorer != null , "ShowInFileExplorer != null" ) ;
94- ShowInFileExplorer ( this , GetModelFromSelectedNode ( ) ) ;
95+ ShowInFileExplorer ( this , SelectedNode ? . Model ) ;
9596 }
9697
97- TreeView GetTreeView ( )
98- {
99- var tree = ContextMenuStrip . SourceControl as TreeView ;
100- return tree ?? ContextMenuStrip . SourceControl . Controls . OfType < TreeView > ( ) . FirstOrDefault ( ) ;
101- }
102-
103- ClassModel GetModelFromSelectedNode ( ) => ( ( TypeNode ) GetTreeView ( ) . SelectedNode ) . Model ;
104-
10598 #region Event Handlers
10699
107100 protected virtual void OnTreeNodeMouseClick ( object sender , TreeNodeMouseClickEventArgs e )
0 commit comments