@@ -14,11 +14,11 @@ public partial class FormMain : Form
1414 {
1515 private const string Loading = "Loading" ;
1616
17- private readonly string _assemblyPath ;
17+ private string _assemblyPath ;
1818
1919 private static readonly Dictionary < string , Form > AssemblyFormMap = new Dictionary < string , Form > ( ) ;
2020
21- private readonly AssemblyInformationLoader assemblyInformation ;
21+ private AssemblyInformationLoader assemblyInformation ;
2222
2323 private List < Binary > recursiveDependencies ;
2424
@@ -27,15 +27,43 @@ public partial class FormMain : Form
2727 public FormMain ( string assemblyPath )
2828 {
2929 InitializeComponent ( ) ;
30+ FormClosing += FormMainFormClosing ;
31+ if ( assemblyPath != null )
32+ LoadAssembly ( assemblyPath ) ;
33+ }
34+
35+ private void LoadAssembly ( string assemblyPath )
36+ {
37+ // Clean up previous state
38+ if ( _assemblyPath != null )
39+ AssemblyFormMap . Remove ( _assemblyPath ) ;
40+ directDependencies = null ;
41+ recursiveDependencies = null ;
42+ dependencyTreeView . Nodes . Clear ( ) ;
43+ referenceListListBox . Items . Clear ( ) ;
44+ referringAssembliesListtBox . Items . Clear ( ) ;
45+
3046 _assemblyPath = assemblyPath ;
3147 assemblyInformation = new AssemblyInformationLoader ( assemblyPath ) ;
3248 referringAssemblyFolderTextBox . Text = Path . GetDirectoryName ( assemblyPath ) ;
3349 AssemblyFormMap [ assemblyPath ] = this ;
34- FormClosing += FormMainFormClosing ;
50+ Text = $ "Assembly Information - { Path . GetFileName ( assemblyPath ) } ";
51+ panel1 . Visible = true ;
52+
53+ // Re-run the load logic
54+ FormMainLoad ( this , EventArgs . Empty ) ;
3555 }
3656
3757 private void FormMainLoad ( object sender , EventArgs e )
3858 {
59+ // If no assembly loaded, show empty state
60+ if ( assemblyInformation == null )
61+ {
62+ panel1 . Visible = false ;
63+ Text = "Assembly Information" ;
64+ return ;
65+ }
66+
3967 string debuggableFlagsToolTipText ;
4068
4169 // Prevent read-only display fields from receiving focus
@@ -144,7 +172,8 @@ private void FormMainLoad(object sender, EventArgs e)
144172
145173 private void FormMainFormClosing ( object sender , FormClosingEventArgs e )
146174 {
147- AssemblyFormMap . Remove ( _assemblyPath ) ;
175+ if ( _assemblyPath != null )
176+ AssemblyFormMap . Remove ( _assemblyPath ) ;
148177 }
149178
150179 private void FillAssemblyReferences ( IEnumerable < Binary > dependencies , TreeNode treeNode = null )
@@ -279,7 +308,7 @@ private void DependencyTreeViewBeforeExpand(object sender, TreeViewCancelEventAr
279308
280309 private void tabControl1_SelectedIndexChanged ( object sender , EventArgs e )
281310 {
282- if ( ! assemblyInformation . IsManaged ) return ;
311+ if ( assemblyInformation == null || ! assemblyInformation . IsManaged ) return ;
283312
284313 if ( tabControl1 . SelectedIndex == 1 && referenceListListBox . Items . Count == 0 )
285314 {
@@ -411,6 +440,48 @@ private void RefreshDependencyDisplay()
411440 if ( recursiveDependencies != null )
412441 FillRecursiveDependency ( ) ;
413442 }
443+
444+ private void OpenAssemblyToolStripMenuItem_Click ( object sender , EventArgs e )
445+ {
446+ using var dlg = new OpenFileDialog
447+ {
448+ Title = "Open Assembly" ,
449+ Filter = "Assemblies (*.dll;*.exe)|*.dll;*.exe|All files (*.*)|*.*" ,
450+ FilterIndex = 1
451+ } ;
452+ if ( _assemblyPath != null )
453+ dlg . InitialDirectory = Path . GetDirectoryName ( _assemblyPath ) ;
454+ if ( dlg . ShowDialog ( ) == DialogResult . OK )
455+ LoadAssembly ( dlg . FileName ) ;
456+ }
457+
458+ private void FormMain_DragEnter ( object sender , DragEventArgs e )
459+ {
460+ if ( e . Data . GetDataPresent ( DataFormats . FileDrop ) )
461+ {
462+ var files = ( string [ ] ) e . Data . GetData ( DataFormats . FileDrop ) ;
463+ if ( files . Length == 1 )
464+ {
465+ var ext = Path . GetExtension ( files [ 0 ] ) . ToLowerInvariant ( ) ;
466+ if ( ext == ".dll" || ext == ".exe" )
467+ {
468+ e . Effect = DragDropEffects . Copy ;
469+ return ;
470+ }
471+ }
472+ }
473+ e . Effect = DragDropEffects . None ;
474+ }
475+
476+ private void FormMain_DragDrop ( object sender , DragEventArgs e )
477+ {
478+ if ( e . Data . GetDataPresent ( DataFormats . FileDrop ) )
479+ {
480+ var files = ( string [ ] ) e . Data . GetData ( DataFormats . FileDrop ) ;
481+ if ( files . Length == 1 )
482+ LoadAssembly ( files [ 0 ] ) ;
483+ }
484+ }
414485 }
415486
416487 internal class AssemblyNameComparer : IComparer < AssemblyName >
0 commit comments