@@ -320,21 +320,33 @@ public static bool VerifyDestinationPath(string path)
320320 }
321321
322322 // Checks if any dependencies were not marked for download by the user, and marks them accordingly
323- public static void CheckDependencies ( )
323+ public static bool CheckDependencies ( )
324324 {
325- List < string > requiredDepends = new List < string > ( ) ;
326- List < string > missingDepends = new List < string > ( ) ;
325+ List < string > requiredDepends = new List < string > ( ) ;
326+ List < TreeNode > missingDepends = new List < TreeNode > ( ) ;
327+
328+ void AddDependencies ( string [ ] depends )
329+ {
330+ requiredDepends . AddRange ( depends ) ;
331+
332+ foreach ( string depend in depends )
333+ {
334+ var query = Main . ComponentList . Nodes . Find ( depend , true ) ;
335+
336+ if ( query . Length > 0 ) AddDependencies ( ( query [ 0 ] . Tag as Component ) . Depends ) ;
337+ }
338+ }
327339
328340 // First, fill out a list of dependencies
329341 IterateList ( Main . ComponentList . Nodes , node =>
330342 {
331343 if ( node . Checked && node . Tag . GetType ( ) . ToString ( ) . EndsWith ( "Component" ) )
332344 {
333- requiredDepends . AddRange ( ( node . Tag as Component ) . Depends ) ;
345+ AddDependencies ( ( node . Tag as Component ) . Depends ) ;
334346 }
335347 } ) ;
336348
337- // Then make sure they're all marked for installation
349+ // Then make sure they're all marked accordingly
338350 IterateList ( Main . ComponentList . Nodes , node =>
339351 {
340352 if ( node . Tag . GetType ( ) . ToString ( ) . EndsWith ( "Component" ) )
@@ -343,20 +355,33 @@ public static void CheckDependencies()
343355
344356 if ( requiredDepends . Any ( depend => depend == component . ID ) && ! node . Checked )
345357 {
346- node . Checked = true ;
347- missingDepends . Add ( component . Title ) ;
358+ missingDepends . Add ( node ) ;
348359 }
349360 }
350361 } ) ;
351362
352363 if ( missingDepends . Count > 0 )
353364 {
354- MessageBox . Show (
365+ long missingSize = missingDepends . Select ( n => ( n . Tag as Component ) . Size ) . Sum ( ) ;
366+
367+ var result = MessageBox . Show (
355368 "The following dependencies will also be installed:\n \n " +
356- string . Join ( ", " , missingDepends ) + "\n \n Click the OK button to proceed." ,
357- "Notice" , MessageBoxButtons . OK , MessageBoxIcon . Information
369+ string . Join ( ", " , missingDepends . Select ( n => ( n . Tag as Component ) . Title ) ) + "\n \n " +
370+ $ "This adds an additional { GetFormattedBytes ( missingSize ) } to your download. Is this OK?",
371+ "Notice" , MessageBoxButtons . YesNo , MessageBoxIcon . Information
358372 ) ;
373+
374+ if ( result == DialogResult . Yes )
375+ {
376+ missingDepends . ForEach ( d => d . Checked = true ) ;
377+ }
378+ else
379+ {
380+ return false ;
381+ }
359382 }
383+
384+ return true ;
360385 }
361386
362387 // Gets total size in bytes of all checked components in the specified TreeView
0 commit comments