Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit 5571623

Browse files
committed
fixed file button in OB not working properly with DASMElements
1 parent 45be5df commit 5571623

File tree

2 files changed

+16
-44
lines changed

2 files changed

+16
-44
lines changed

UI/MainWindow/MainWindow.xaml.cs

Lines changed: 15 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

UI/MainWindow/MainWindowObjectBrowser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ private static TreeViewItem VisualUpwardSearch(DependencyObject source)
724724
/// </summary>
725725
public void UpdateOBFileButton()
726726
{
727-
if (GetAllEditorElements() == null)
727+
if (GetAllEditorElements() == null && GetAllDASMElements() == null)
728728
{
729729
OBTabFile.IsEnabled = false;
730730
OBTabFile.IsSelected = false;

0 commit comments

Comments
 (0)