Skip to content

Commit

Permalink
Mac: Added IDesktopEffectsView, which combines IEqualizerPresetsView …
Browse files Browse the repository at this point in the history
…and IEqualizerPresetDetailsView. Added PlaylistWindow and EffectsWindow to NavigationManager; they can now be opened through the MainPresenter. EffectsWindow now implements IDesktopEffectsView (but the implementation is empty for now). Updated the look of Effects window with newer theme.

Related to issue #381.
  • Loading branch information
ycastonguay committed Aug 17, 2013
1 parent 17880a0 commit 50c1e20
Show file tree
Hide file tree
Showing 13 changed files with 1,307 additions and 536 deletions.
1 change: 1 addition & 0 deletions MPfm/MPfm.MVP/MPfm.MVP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -231,5 +231,6 @@
<Compile Include="Presenters\SyncDownloadPresenter.cs" />
<Compile Include="Messages\PlayerPlaylistUpdatedMessage.cs" />
<Compile Include="Views\IDesktopPreferencesView.cs" />
<Compile Include="Views\IDesktopEffectsView.cs" />
</ItemGroup>
</Project>
73 changes: 62 additions & 11 deletions MPfm/MPfm.MVP/Navigation/NavigationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,21 @@ public abstract class NavigationManager
private ILibraryBrowserPresenter _libraryBrowserPresenter;
private ISongBrowserPresenter _songBrowserPresenter;

private IDesktopPreferencesView _desktopPreferencesView;
private IDesktopPreferencesView _preferencesView;
private IAudioPreferencesPresenter _audioPreferencesPresenter;
private IGeneralPreferencesPresenter _generalPreferencesPresenter;
private ILibraryPreferencesPresenter _libraryPreferencesPresenter;

private IPlaylistView _playlistView;
private IPlaylistPresenter _playlistPresenter;

private IUpdateLibraryView _updateLibraryView;
private IUpdateLibraryPresenter _updateLibraryPresenter;

private IDesktopEffectsView _effectsView;
private IEqualizerPresetsPresenter _equalizerPresetsPresenter;
private IEqualizerPresetDetailsPresenter _equalizerPresetDetailsPresenter;

private ISyncView _syncView;
private ISyncPresenter _syncPresenter;
private ISyncMenuView _syncMenuView;
Expand Down Expand Up @@ -105,14 +112,12 @@ public virtual IMainView CreateMainView()

public virtual IDesktopPreferencesView CreatePreferencesView()
{
// If the view is still visible, just make it the top level window
if(_desktopPreferencesView != null)
if(_preferencesView != null)
{
_desktopPreferencesView.ShowView(true);
return _desktopPreferencesView;
_preferencesView.ShowView(true);
return _preferencesView;
}

// The view invokes the OnViewReady action when the view is ready. This means the presenter can be created and bound to the view.
Action<IBaseView> onViewReady = (view) => {
_audioPreferencesPresenter = Bootstrapper.GetContainer().Resolve<IAudioPreferencesPresenter>();
_audioPreferencesPresenter.BindView((IAudioPreferencesView)view);
Expand All @@ -122,15 +127,38 @@ public virtual IDesktopPreferencesView CreatePreferencesView()
_libraryPreferencesPresenter.BindView((ILibraryPreferencesView)view);
};

// Create view and manage view destruction
_desktopPreferencesView = Bootstrapper.GetContainer().Resolve<IDesktopPreferencesView>(new NamedParameterOverloads() { { "onViewReady", onViewReady } });
_desktopPreferencesView.OnViewDestroy = (view) => {
_desktopPreferencesView = null;
_preferencesView = Bootstrapper.GetContainer().Resolve<IDesktopPreferencesView>(new NamedParameterOverloads() { { "onViewReady", onViewReady } });
_preferencesView.OnViewDestroy = (view) => {
_preferencesView = null;
_audioPreferencesPresenter = null;
_generalPreferencesPresenter = null;
_libraryPreferencesPresenter = null;
};
return _desktopPreferencesView;
return _preferencesView;
}

public virtual IDesktopEffectsView CreateEffectsView()
{
if(_effectsView != null)
{
_effectsView.ShowView(true);
return _effectsView;
}

Action<IBaseView> onViewReady = (view) => {
_equalizerPresetsPresenter = Bootstrapper.GetContainer().Resolve<IEqualizerPresetsPresenter>();
_equalizerPresetsPresenter.BindView((IEqualizerPresetsView)view);
_equalizerPresetDetailsPresenter = Bootstrapper.GetContainer().Resolve<IEqualizerPresetDetailsPresenter>();
_equalizerPresetDetailsPresenter.BindView((IEqualizerPresetDetailsView)view);
};

_effectsView = Bootstrapper.GetContainer().Resolve<IDesktopEffectsView>(new NamedParameterOverloads() { { "onViewReady", onViewReady } });
_effectsView.OnViewDestroy = (view) => {
_effectsView = null;
_equalizerPresetsPresenter = null;
_equalizerPresetDetailsPresenter = null;
};
return _effectsView;
}

public virtual ISyncView CreateSyncView()
Expand Down Expand Up @@ -203,5 +231,28 @@ public virtual ISyncDownloadView CreateSyncDownloadView(SyncDevice device, IEnum
};
return _syncDownloadView;
}

public virtual IPlaylistView CreatePlaylistView()
{
if(_playlistView != null)
{
_playlistView.ShowView(true);
return _playlistView;
}

Action<IBaseView> onViewReady = (view) =>
{
_playlistPresenter = Bootstrapper.GetContainer().Resolve<IPlaylistPresenter>();
_playlistPresenter.BindView((IPlaylistView)view);
};

// Create view and manage view destruction
_playlistView = Bootstrapper.GetContainer().Resolve<IPlaylistView>(new NamedParameterOverloads() { { "onViewReady", onViewReady } });
_playlistView.OnViewDestroy = (view) => {
_playlistView = null;
_playlistPresenter = null;
};
return _playlistView;
}
}
}
17 changes: 12 additions & 5 deletions MPfm/MPfm.MVP/Presenters/EqualizerPresetsPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,33 @@
using MPfm.MVP.Views;
using TinyMessenger;
using MPfm.Library.Services.Interfaces;
using MPfm.MVP.Bootstrap;

namespace MPfm.MVP.Presenters
{
public class EqualizerPresetsPresenter : BasePresenter<IEqualizerPresetsView>, IEqualizerPresetsPresenter
{
readonly MobileNavigationManager _navigationManager;
readonly NavigationManager _navigationManager;
readonly MobileNavigationManager _mobileNavigationManager;
readonly ITinyMessengerHub _messageHub;
readonly IPlayerService _playerService;
readonly ILibraryService _libraryService;
Timer _timerOutputMeter;

public EqualizerPresetsPresenter(MobileNavigationManager navigationManager, ITinyMessengerHub messageHub, IPlayerService playerService, ILibraryService libraryService)
public EqualizerPresetsPresenter(ITinyMessengerHub messageHub, IPlayerService playerService, ILibraryService libraryService)
{
_navigationManager = navigationManager;
_messageHub = messageHub;
_playerService = playerService;
_libraryService = libraryService;
_timerOutputMeter = new Timer();
_timerOutputMeter.Interval = 40;
_timerOutputMeter.Elapsed += HandleOutputMeterTimerElapsed;

#if IOS || ANDROID
_mobileNavigationManager = Bootstrapper.GetContainer().Resolve<MobileNavigationManager>();
#else
_navigationManager = Bootstrapper.GetContainer().Resolve<NavigationManager>();
#endif
}

public override void BindView(IEqualizerPresetsView view)
Expand Down Expand Up @@ -130,7 +137,7 @@ private void AddPreset()
{
try
{
_navigationManager.CreateEqualizerPresetDetailsView(View, new EQPreset());
_mobileNavigationManager.CreateEqualizerPresetDetailsView(View, new EQPreset());
}
catch(Exception ex)
{
Expand Down Expand Up @@ -162,7 +169,7 @@ private void EditPreset(Guid presetId)
if(preset == null)
return;

_navigationManager.CreateEqualizerPresetDetailsView(View, preset);
_mobileNavigationManager.CreateEqualizerPresetDetailsView(View, preset);
}
catch(Exception ex)
{
Expand Down
20 changes: 6 additions & 14 deletions MPfm/MPfm.MVP/Presenters/MainPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,12 @@ namespace MPfm.MVP.Presenters
/// </summary>
public class MainPresenter : BasePresenter<IMainView>, IMainPresenter
{
readonly NavigationManager navigationManager;
readonly NavigationManager _navigationManager;

#region Constructor and Dispose

/// <summary>
/// Initializes a new instance of the <see cref="MPfm.MVP.EffectsPresenter"/> class.
/// </summary>
/// <param name='playerService'>
/// Player service.
/// </param>
public MainPresenter(NavigationManager navigationManager)
{
this.navigationManager = navigationManager;
_navigationManager = navigationManager;
}

#endregion

public override void BindView(IMainView view)
{
Expand All @@ -56,20 +46,22 @@ public override void BindView(IMainView view)

void OpenPlaylistWindow()
{
_navigationManager.CreatePlaylistView();
}

void OpenEffectsWindow()
{
_navigationManager.CreateEffectsView();
}

void OpenPreferencesWindow()
{
navigationManager.CreatePreferencesView();
_navigationManager.CreatePreferencesView();
}

void OpenSyncWindow()
{
navigationManager.CreateSyncView();
_navigationManager.CreateSyncView();
}
}
}
Expand Down
29 changes: 29 additions & 0 deletions MPfm/MPfm.MVP/Views/IDesktopEffectsView.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright © 2011-2013 Yanick Castonguay
//
// This file is part of MPfm.
//
// MPfm is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// MPfm is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with MPfm. If not, see <http://www.gnu.org/licenses/>.

using System;
using System.Collections.Generic;

namespace MPfm.MVP.Views
{
/// <summary>
/// Effects view for desktop (combines EqualizerPresets/EqualizerPresetDetails)
/// </summary>
public interface IDesktopEffectsView : IEqualizerPresetsView, IEqualizerPresetDetailsView
{
}
}
2 changes: 1 addition & 1 deletion MPfm/MPfm.MVP/Views/IDesktopPreferencesView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
namespace MPfm.MVP.Views
{
/// <summary>
/// Preferences view interface (menu for mobile devices).
/// Preferences view for desktop (combines audio/general/library preferences)
/// </summary>
public interface IDesktopPreferencesView : IAudioPreferencesView, IGeneralPreferencesView, ILibraryPreferencesView
{
Expand Down
2 changes: 1 addition & 1 deletion MPfm/MPfm.Mac/Classes/Delegates/AppDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public override void FinishedLaunching(NSObject notification)
Bootstrapper.GetContainer().Register<IMainView, MainWindowController>().AsMultiInstance();
Bootstrapper.GetContainer().Register<IUpdateLibraryView, UpdateLibraryWindowController>().AsMultiInstance();
Bootstrapper.GetContainer().Register<IPlaylistView, PlaylistWindowController>().AsMultiInstance();
//Bootstrapper.GetContainer().Register<IEffectsView, EffectsWindowController>().AsMultiInstance();
Bootstrapper.GetContainer().Register<IDesktopEffectsView, EffectsWindowController>().AsMultiInstance();
Bootstrapper.GetContainer().Register<IDesktopPreferencesView, PreferencesWindowController>().AsMultiInstance();
Bootstrapper.GetContainer().Register<ISyncView, SyncWindowController>().AsMultiInstance();
Bootstrapper.GetContainer().Register<ISyncMenuView, SyncMenuWindowController>().AsMultiInstance();
Expand Down
Loading

0 comments on commit 50c1e20

Please sign in to comment.