public Shell(Func<WorkspaceView> projectViewFactory,
CollectionSettings collectionSettings,
BookDownloadStartingEvent bookDownloadStartingEvent,
LibraryClosing libraryClosingEvent,
QueueRenameOfCollection queueRenameOfCollection,
ControlKeyEvent controlKeyEvent)
{
queueRenameOfCollection.Subscribe(newName => _nameToChangeCollectionUponClosing = newName.Trim().SanitizeFilename('-'));
_collectionSettings = collectionSettings;
_libraryClosingEvent = libraryClosingEvent;
_controlKeyEvent = controlKeyEvent;
InitializeComponent();
//bring the application to the front (will normally be behind the user's web browser)
bookDownloadStartingEvent.Subscribe((x) =>
{
try
{
this.Invoke((Action)this.Activate);
}
catch (Exception e)
{
Debug.Fail("(Debug Only) Can't bring to front in the current state: " + e.Message);
//swallow... so we were in some state that we couldn't come to the front... that's ok.
}
});
#if DEBUG
WindowState = FormWindowState.Normal;
//this.FormBorderStyle = FormBorderStyle.None; //fullscreen
Size = new Size(1024,720);
#else
// We only want this screen size context menu in Debug mode
ContextMenuStrip = null;
#endif
_workspaceView = projectViewFactory();
_workspaceView.CloseCurrentProject += ((x, y) =>
{
UserWantsToOpenADifferentProject = true;
Close();
});
_workspaceView.ReopenCurrentProject += ((x, y) =>
{
UserWantsToOpeReopenProject = true;
Close();
});
_workspaceView.BackColor =
System.Drawing.Color.FromArgb(64,64,64);
_workspaceView.Dock = System.Windows.Forms.DockStyle.Fill;
this.Controls.Add(this._workspaceView);
SetWindowText(null);
}