Skip to content

Commit

Permalink
Windows: Added SyncCloud and SyncWebBrowser forms and views in Naviga…
Browse files Browse the repository at this point in the history
…tionManager.
  • Loading branch information
ycastonguay committed Oct 17, 2013
1 parent 91c1366 commit 8c48dee
Show file tree
Hide file tree
Showing 18 changed files with 5,671 additions and 3,532 deletions.
Expand Up @@ -305,7 +305,7 @@ public void OnDatastoreStatusChange(DbxDatastore store)
{
Console.WriteLine("SyncCloudActivity - OnDatastoreStatusChange exception: {0}", ex);
if (OnDropboxDataChanged != null) OnDropboxDataChanged(string.Format("Error: {0}", ex));
throw;
//throw;
}
}
}
Expand Down
18 changes: 17 additions & 1 deletion MPfm/MPfm.Library/Services/DropboxCoreService.cs
Expand Up @@ -56,6 +56,8 @@ private void Initialize()
{
}

public bool HasLinkedAccount { get; private set; }

public void LinkApp(object view)
{
try
Expand Down Expand Up @@ -192,8 +194,22 @@ public void UnlinkApp()
{
}

public void PushNowPlaying(AudioFile audioFile, long positionBytes, string position)
public void PushStuff()
{
}

public string PullStuff()
{
return string.Empty;
}

public void DeleteStuff()
{
}

public string PushNowPlaying(AudioFile audioFile, long positionBytes, string position)
{
return string.Empty;
}

public string PullNowPlaying()
Expand Down
58 changes: 58 additions & 0 deletions MPfm/MPfm.MVP/Navigation/NavigationManager.cs
Expand Up @@ -80,6 +80,10 @@ public abstract class NavigationManager
ISyncMenuPresenter _syncMenuPresenter;
ISyncDownloadView _syncDownloadView;
ISyncDownloadPresenter _syncDownloadPresenter;
ISyncCloudView _syncCloudView;
ISyncCloudPresenter _syncCloudPresenter;
ISyncWebBrowserView _syncWebBrowserView;
ISyncWebBrowserPresenter _syncWebBrowserPresenter;

public virtual ISplashView CreateSplashView()
{
Expand Down Expand Up @@ -231,6 +235,60 @@ public virtual ISyncView CreateSyncView()
return _syncView;
}

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

// 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) =>
{
_syncCloudPresenter = Bootstrapper.GetContainer().Resolve<ISyncCloudPresenter>();
_syncCloudPresenter.BindView((ISyncCloudView)view);
};

// Create view and manage view destruction
_syncCloudView = Bootstrapper.GetContainer().Resolve<ISyncCloudView>(new NamedParameterOverloads() { { "onViewReady", onViewReady } });
_syncCloudView.OnViewDestroy = (view) =>
{
_syncCloudPresenter.ViewDestroyed();
_syncCloudPresenter = null;
_syncCloudView = null;
};
return _syncCloudView;
}

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

// 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) =>
{
_syncWebBrowserPresenter = Bootstrapper.GetContainer().Resolve<ISyncWebBrowserPresenter>();
_syncWebBrowserPresenter.BindView((ISyncWebBrowserView)view);
};

// Create view and manage view destruction
_syncWebBrowserView = Bootstrapper.GetContainer().Resolve<ISyncWebBrowserView>(new NamedParameterOverloads() { { "onViewReady", onViewReady } });
_syncWebBrowserView.OnViewDestroy = (view) =>
{
_syncWebBrowserPresenter.ViewDestroyed();
_syncWebBrowserPresenter = null;
_syncWebBrowserView = null;
};
return _syncWebBrowserView;
}

public virtual ISyncMenuView CreateSyncMenuView(SyncDevice device)
{
if(_syncMenuView != null)
Expand Down
52 changes: 9 additions & 43 deletions MPfm/MPfm.MVP/Presenters/MainPresenter.cs
Expand Up @@ -37,51 +37,17 @@ public MainPresenter(NavigationManager navigationManager)

public override void BindView(IMainView view)
{
view.OnOpenPlaylistWindow = OpenPlaylistWindow;
view.OnOpenEffectsWindow = OpenEffectsWindow;
view.OnOpenPreferencesWindow = OpenPreferencesWindow;
view.OnOpenSyncWindow = OpenSyncWindow;
view.OnAddFilesToLibrary = AddFilesToLibrary;
view.OnAddFolderToLibrary = AddFolderToLibrary;
view.OnUpdateLibrary = UpdateLibrary;
view.OnOpenPlaylistWindow = () => _navigationManager.CreatePlaylistView();
view.OnOpenEffectsWindow = () => _navigationManager.CreateEffectsView();
view.OnOpenPreferencesWindow = () => _navigationManager.CreatePreferencesView();
view.OnOpenSyncWindow = () => _navigationManager.CreateSyncView();
view.OnOpenSyncWindow = () => _navigationManager.CreateSyncCloudView();
view.OnOpenSyncWindow = () => _navigationManager.CreateSyncWebBrowserView();
view.OnAddFilesToLibrary = (filePaths) => _navigationManager.CreateUpdateLibraryView(UpdateLibraryMode.SpecificFiles, filePaths, null);
view.OnAddFolderToLibrary = (folderPath) => _navigationManager.CreateUpdateLibraryView(UpdateLibraryMode.SpecificFolder, null, folderPath);
view.OnUpdateLibrary = () => _navigationManager.CreateUpdateLibraryView(UpdateLibraryMode.WholeLibrary, null, null);

base.BindView(view);
}

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

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

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

void OpenSyncWindow()
{
_navigationManager.CreateSyncView();
}

void AddFolderToLibrary(string folderPath)
{
_navigationManager.CreateUpdateLibraryView(UpdateLibraryMode.SpecificFolder, null, folderPath);
}

void AddFilesToLibrary(List<string> filePaths)
{
_navigationManager.CreateUpdateLibraryView(UpdateLibraryMode.SpecificFiles, filePaths, null);
}

void UpdateLibrary()
{
_navigationManager.CreateUpdateLibraryView(UpdateLibraryMode.WholeLibrary, null, null);
}
}
}

2 changes: 2 additions & 0 deletions MPfm/MPfm.MVP/Views/IMainView.cs
Expand Up @@ -29,6 +29,8 @@ public interface IMainView : ILibraryBrowserView, ISongBrowserView, IPlayerView,
Action OnOpenEffectsWindow { get; set; }
Action OnOpenPlaylistWindow { get; set; }
Action OnOpenSyncWindow { get; set; }
Action OnOpenSyncCloudWindow { get; set; }
Action OnOpenSyncWebBrowserWindow { get; set; }

Action<List<string>> OnAddFilesToLibrary { get; set; }
Action<string> OnAddFolderToLibrary { get; set; }
Expand Down

0 comments on commit 8c48dee

Please sign in to comment.