From c47aef4cba60be298953c78048be5800cc267a23 Mon Sep 17 00:00:00 2001 From: ole kristian homelien Date: Sun, 24 Nov 2024 19:30:42 +0100 Subject: [PATCH] Cleanup --- AssetEditor/Services/EditorManager.cs | 9 ++++----- AssetEditor/ViewModels/MainViewModel.cs | 4 +--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/AssetEditor/Services/EditorManager.cs b/AssetEditor/Services/EditorManager.cs index a559b868..160ba6be 100644 --- a/AssetEditor/Services/EditorManager.cs +++ b/AssetEditor/Services/EditorManager.cs @@ -34,7 +34,6 @@ public partial class EditorManager : ObservableObject, IEditorManager { private readonly ILogger _logger = Logging.Create(); - private readonly PackFileService _packfileService; private readonly PackFileService _packFileService; private readonly IEditorDatabase _editorDatabase; @@ -46,7 +45,7 @@ public EditorManager(IGlobalEventHub eventHub, PackFileService packFileService, _packFileService = packFileService; _editorDatabase = editorDatabase; - eventHub.Register(this, Database_BeforePackFileContainerRemoved); + eventHub.Register(this, OnBeforeRemoved); } public IList GetAllEditors() => CurrentEditorsList; @@ -133,8 +132,7 @@ void InsertEditorIntoTab(IEditorInterface editorView) SelectedEditorIndex = CurrentEditorsList.Count - 1; } - - private void Database_BeforePackFileContainerRemoved(BeforePackFileContainerRemovedEvent e) + private void OnBeforeRemoved(BeforePackFileContainerRemovedEvent e) { var container = e.Removed; var openFiles = new List(); @@ -143,7 +141,7 @@ private void Database_BeforePackFileContainerRemoved(BeforePackFileContainerRemo if (CurrentEditorsList[i] is not IFileEditor fileEditor) continue; - var containterForPack = _packfileService.GetPackFileContainer(fileEditor.CurrentFile); + var containterForPack = _packFileService.GetPackFileContainer(fileEditor.CurrentFile); if (containterForPack == container) openFiles.Add(CurrentEditorsList[i]); } @@ -216,6 +214,7 @@ public bool ShouldBlockCloseCommand(IEditorInterface editor, bool hasUnsavedFile return false; } + // Move to a drop handler public bool Drop(IEditorInterface node, IEditorInterface targetNode = default, bool insertAfterTargetNode = default) { var nodeIndex = CurrentEditorsList.IndexOf(node); diff --git a/AssetEditor/ViewModels/MainViewModel.cs b/AssetEditor/ViewModels/MainViewModel.cs index c45833b3..aa57e845 100644 --- a/AssetEditor/ViewModels/MainViewModel.cs +++ b/AssetEditor/ViewModels/MainViewModel.cs @@ -17,15 +17,14 @@ namespace AssetEditor.ViewModels { public partial class MainViewModel : ObservableObject, IDropTarget { - private readonly IEditorManager _editorManager; private readonly PackFileService _packfileService; private readonly IUiCommandFactory _uiCommandFactory; public PackFileBrowserViewModel FileTree { get; private set; } public MenuBarViewModel MenuBar { get; set; } public IEditorDatabase ToolsFactory { get; set; } - public IEditorManager EditorManager { get => _editorManager; } + [ObservableProperty] IEditorManager _editorManager; [ObservableProperty] private bool _isClosingWithoutPrompt; [ObservableProperty] private string _applicationTitle; [ObservableProperty] private string _currentGame; @@ -79,7 +78,6 @@ [RelayCommand] private void Closing(IEditorInterface editor) } [RelayCommand] void CloseTool(IEditorInterface tool) => _editorManager.CloseTool(tool); - [RelayCommand] void CloseOtherTools(IEditorInterface tool) => _editorManager.CloseOtherTools(tool); [RelayCommand] void CloseAllTools(IEditorInterface tool) => _editorManager.CloseAllTools(tool); [RelayCommand] void CloseToolsToLeft(IEditorInterface tool) => _editorManager.CloseToolsToLeft(tool);