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

Commit 6399def

Browse files
committed
fix close shortcuts not closing DASMelements (fix #111)
1 parent d46a489 commit 6399def

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

UI/Components/DASMElement/DASMElement.xaml.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
using System.Windows.Controls;
77
using System.Windows.Input;
88
using smxdasm;
9+
using Xceed.Wpf.AvalonDock.Layout;
910

1011
namespace SPCode.UI.Components
1112
{
1213
public partial class DASMElement : UserControl
1314
{
1415
private double LineHeight = 0.0;
15-
16+
public new LayoutDocument Parent;
1617
private SmxFile file_;
1718
private readonly StringBuilder detail_buffer_ = new();
1819
public string FilePath;
@@ -922,6 +923,7 @@ private void Treeview__SelectedItemChanged(object sender, RoutedPropertyChangedE
922923

923924
public void Close()
924925
{
926+
Program.MainWindow.DockingPane.RemoveChild(Parent);
925927
Program.MainWindow.DASMReferences.Remove(this);
926928
Program.RecentFilesStack.Push(FilePath);
927929
Program.MainWindow.UpdateWindowTitle();

UI/MainWindow/MainWindow.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ private void AddEditorElement(FileInfo fInfo, string editorTitle, bool SelectMe,
449449
private void AddDASMElement(FileInfo fileInfo)
450450
{
451451
var layoutDocument = new LayoutDocument { Title = "DASM: " + fileInfo.Name };
452-
var dasmElement = new DASMElement(fileInfo);
452+
var dasmElement = new DASMElement(fileInfo) { Parent = layoutDocument };
453453
DASMReferences.Add(dasmElement);
454454
layoutDocument.Content = dasmElement;
455455
DockingPane.Children.Add(layoutDocument);

UI/MainWindow/MainWindowCommands.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,12 +338,13 @@ private void Command_Close()
338338
try
339339
{
340340
var ee = GetCurrentEditorElement();
341-
if (ee == null || ee.IsTemplateEditor || ee.ClosingPromptOpened)
341+
var de = GetCurrentDASMElement();
342+
if (ee != null && (ee.IsTemplateEditor || ee.ClosingPromptOpened))
342343
{
343344
return;
344345
}
345-
346-
ee.Close();
346+
ee?.Close();
347+
de?.Close();
347348
}
348349
catch (Exception ex)
349350
{
@@ -359,13 +360,15 @@ private async void Command_CloseAll()
359360
try
360361
{
361362
var editors = GetAllEditorElements();
363+
var dasm = GetAllDASMElements();
362364

363365
if (editors == null || editors.Any(x => x.IsTemplateEditor) || editors.Length == 0 || editors.Any(x => x.ClosingPromptOpened))
364366
{
365367
return;
366368
}
367369

368370
editors.ToList().ForEach(x => x.Close());
371+
dasm?.ToList().ForEach(y => y.Close());
369372
}
370373
catch (Exception ex)
371374
{

0 commit comments

Comments
 (0)