@@ -343,12 +343,7 @@ public bool TryLoadSourceFile(string filePath, out EditorElement outEditor, bool
343343 }
344344 }
345345 }
346- var layoutDocument = new LayoutDocument { Title = "DASM: " + fileInfo . Name } ;
347- var dasmElement = new DASMElement ( fileInfo ) ;
348- layoutDocument . Content = dasmElement ;
349- DockingPane . Children . Add ( layoutDocument ) ;
350- DockingPane . SelectedContentIndex = DockingPane . ChildrenCount - 1 ;
351- DASMReferences . Add ( dasmElement ) ;
346+ AddDASMElement ( fileInfo ) ;
352347 }
353348
354349 if ( UseBlendoverEffect )
@@ -385,6 +380,20 @@ private void AddEditorElement(string filePath, string name, bool SelectMe, out E
385380 }
386381 }
387382
383+ /// <summary>
384+ /// Adds a new DASM element associated with the file to the Docking Manager.
385+ /// </summary>
386+ private void AddDASMElement ( FileInfo fileInfo )
387+ {
388+ var layoutDocument = new LayoutDocument { Title = "DASM: " + fileInfo . Name } ;
389+ var dasmElement = new DASMElement ( fileInfo ) ;
390+ DASMReferences . Add ( dasmElement ) ;
391+ layoutDocument . Content = dasmElement ;
392+ DockingPane . Children . Add ( layoutDocument ) ;
393+ DockingPane . SelectedContentIndex = DockingPane . ChildrenCount - 1 ;
394+ AddNewRecentFile ( fileInfo . FullName ) ;
395+ }
396+
388397 /// <summary>
389398 /// Performs a visual refresh on the editor.
390399 /// </summary>
@@ -442,42 +451,5 @@ public void UpdateWindowTitle()
442451 Title = outString ;
443452 }
444453 #endregion
445-
446- private void AddNewRecentFile ( string filePath )
447- {
448- if ( Program . OptionsObject . RecentFiles . Any ( x => x . Equals ( filePath ) ) )
449- {
450- return ;
451- }
452- MenuI_Recent . IsEnabled = true ;
453- Program . OptionsObject . RecentFiles . AddFirst ( filePath ) ;
454- var fInfo = new FileInfo ( filePath ) ;
455- var lbl = new TextBlock ( ) ;
456-
457- lbl . Inlines . Add ( $ "{ fInfo . Name } ") ;
458- lbl . Inlines . Add ( new Run ( fInfo . FullName )
459- {
460- FontSize = FontSize - 2 ,
461- Foreground = new SolidColorBrush ( Colors . DarkGray ) ,
462- FontStyle = FontStyles . Italic
463- } ) ;
464-
465- var mi = new MenuItem ( )
466- {
467- Header = lbl
468- } ;
469-
470- mi . Click += ( sender , e ) =>
471- {
472- TryLoadSourceFile ( fInfo . FullName , out _ , true , false , true ) ;
473- } ;
474-
475- MenuI_Recent . Items . Insert ( 0 , mi ) ;
476- if ( MenuI_Recent . Items . Count > 10 )
477- {
478- MenuI_Recent . Items . RemoveAt ( 10 ) ;
479- Program . OptionsObject . RecentFiles . RemoveLast ( ) ;
480- }
481- }
482454 }
483455}
0 commit comments