-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Core] Closing documents work properly
- Loading branch information
Showing
11 changed files
with
185 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,5 +23,4 @@ public interface IDocument | |
|
||
ContentControl Content { get; } | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Controls; | ||
using System.Windows.Input; | ||
|
||
namespace WDE.Common.Managers | ||
{ | ||
public interface ITool | ||
{ | ||
string Title { get; } | ||
ContentControl Content { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
WoWDatabaseEditor/Managers/ViewModels/DocumentDecorator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using Prism.Commands; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Controls; | ||
using System.Windows.Input; | ||
using WDE.Common.History; | ||
using WDE.Common.Managers; | ||
|
||
namespace WoWDatabaseEditor.Managers.ViewModels | ||
{ | ||
internal class DocumentDecorator : IDocument | ||
{ | ||
private readonly IDocument document; | ||
private readonly Action<DocumentDecorator> closeAction; | ||
|
||
public string Title => document.Title; | ||
|
||
public ICommand Undo => document.Undo; | ||
|
||
public ICommand Redo => document.Redo; | ||
|
||
public ICommand Save => document.Save; | ||
|
||
public ICommand CloseCommand { get; private set; } | ||
|
||
public bool CanClose => document.CanClose; | ||
|
||
public IHistoryManager History => document.History; | ||
|
||
public ContentControl Content => document.Content; | ||
|
||
public System.Windows.Visibility Visibility { get; set; } | ||
|
||
public DocumentDecorator(IDocument document, Action<DocumentDecorator> closeAction) | ||
{ | ||
this.document = document; | ||
this.closeAction = closeAction; | ||
CloseCommand = new DelegateCommand(Close); | ||
|
||
Visibility = System.Windows.Visibility.Visible; | ||
} | ||
|
||
private void Close() | ||
{ | ||
closeAction(this); | ||
document.CloseCommand?.Execute(null); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Prism.Commands; | ||
using Prism.Mvvm; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Input; | ||
using WDE.Common.Managers; | ||
|
||
namespace WoWDatabaseEditor.Managers.ViewModels | ||
{ | ||
internal class ToolWindow : BindableBase, ITool | ||
{ | ||
public string Title { get; private set; } | ||
|
||
public ContentControl Content { get; private set; } | ||
|
||
public bool CanClose => false; | ||
|
||
public ICommand CloseCommand { get; private set; } | ||
|
||
private Visibility _visibility; | ||
public Visibility Visibility | ||
{ | ||
get => _visibility; | ||
set => SetProperty(ref _visibility, value); | ||
} | ||
|
||
public ToolWindow(string title, ContentControl content) | ||
{ | ||
Title = title; | ||
Content = content; | ||
Visibility = System.Windows.Visibility.Visible; | ||
CloseCommand = new DelegateCommand(() => { }); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
WoWDatabaseEditor/Views/Helpers/ActiveDocumentConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Data; | ||
using WDE.Common.Managers; | ||
|
||
namespace WoWDatabaseEditor.Views.Helpers | ||
{ | ||
public class ActiveDocumentConverter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, | ||
object parameter, CultureInfo culture) | ||
{ | ||
if (value is IDocument) | ||
return value; | ||
|
||
return null; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, | ||
object parameter, CultureInfo culture) | ||
{ | ||
if (value is IDocument) | ||
return value; | ||
|
||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters