Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        public Shell(Func <WorkspaceView> projectViewFactory,
                     CollectionSettings collectionSettings,
                     BookDownloadStartingEvent bookDownloadStartingEvent,
                     LibraryClosing libraryClosingEvent,
                     QueueRenameOfCollection queueRenameOfCollection,
                     ControlKeyEvent controlKeyEvent,
                     SignLanguageApi signLanguageApi)
        {
            queueRenameOfCollection.Subscribe(newName =>
                                              _nameToChangeCollectionUponClosing = newName.Trim().SanitizeFilename('-'));
            _collectionSettings  = collectionSettings;
            _libraryClosingEvent = libraryClosingEvent;
            _controlKeyEvent     = controlKeyEvent;
            InitializeComponent();
            Activated += (sender, args) =>
            {
                // Some of the stuff we do to update things depends on a current editing view and model.
                // So just don't try if the user is for some reason editing the videos while not editing
                // the book. Hopefuly in that case he hasn't opened the book and none of its old state
                // is cached.
                if (_workspaceView.InEditMode)
                {
                    signLanguageApi.CheckForChangedVideoOnActivate(sender, args);
                }
            };
            Deactivate += (sender, args) => signLanguageApi.DeactivateTime = DateTime.Now;

            //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.
                }
            });



            WindowState = FormWindowState.Normal;
            Size        = new Size(1024, 720);

            _contextMenu.Opening += _contextMenu_Opening;

            _workspaceView = projectViewFactory();
            _workspaceView.CloseCurrentProject += ((x, y) =>
            {
                UserWantsToOpenADifferentProject = true;
                Close();
            });

            _workspaceView.ReopenCurrentProject += ((x, y) =>
            {
                UserWantsToOpeReopenProject = true;
                Close();
            });

            _workspaceView.BackColor = Bloom.Palette.GeneralBackground;
            _workspaceView.Dock      = System.Windows.Forms.DockStyle.Fill;

            this.Controls.Add(this._workspaceView);

            SetWindowText(null);
        }