39 lines
955 B
C#
39 lines
955 B
C#
using Minesweeper.Commands;
|
|
using Minesweeper.Presentation.Views;
|
|
|
|
namespace Minesweeper.Presentation.Presenters
|
|
{
|
|
public sealed class MainMenuPresenter : IPresenter
|
|
{
|
|
private readonly IGameCommandDispatcher commandDispatcher;
|
|
private readonly IMainMenuView view;
|
|
|
|
public MainMenuPresenter(IGameCommandDispatcher commandDispatcher, IMainMenuView view = null)
|
|
{
|
|
this.commandDispatcher = commandDispatcher;
|
|
this.view = view;
|
|
}
|
|
|
|
public void Initialize()
|
|
{
|
|
if (view != null)
|
|
{
|
|
view.StartClicked += OnStartClicked;
|
|
}
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
if (view != null)
|
|
{
|
|
view.StartClicked -= OnStartClicked;
|
|
}
|
|
}
|
|
|
|
private void OnStartClicked()
|
|
{
|
|
commandDispatcher.Dispatch(new StartGameCommand());
|
|
}
|
|
}
|
|
}
|