예제 #1
0
        private void AddPageButton_Click()
        {
            // Turn double-click into a single-click
            if (_lastButtonClickedTime > DateTime.Now.AddSeconds(-1))
            {
                return;
            }
            _lastButtonClickedTime = DateTime.Now;

            if (_editingModel.CanAddPages)
            {
                _editingModel.ShowAddPageDialog();
            }
            else
            {
                // TODO: localize buttons
                MessageBox.Show(EditingView.GetInstructionsForUnlockingBook(), "Bloom", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
예제 #2
0
        private void GridReordered(string s)
        {
            var newSeq = new List <IPage>();
            var keys   = s.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var key in keys)
            {
                IPage page;
                if (_pageMap.TryGetValue(key, out page))
                {
                    newSeq.Add(page);
                }
            }
            Debug.Assert(newSeq.Count == _pages.Count);
            // Now, which one moved?
            int firstDiff = 0;

            while (firstDiff < _pages.Count && _pages[firstDiff] == newSeq[firstDiff])
            {
                firstDiff++;
            }
            int limDiff = _pages.Count;

            while (limDiff > firstDiff && _pages[limDiff - 1] == newSeq[limDiff - 1])
            {
                limDiff--;
            }
            if (firstDiff == limDiff)
            {
                return;                 // spurious notification somehow? Nothing changed.
            }
            // We have the subsequence that altered.
            // Is the change legal?
            for (int i = firstDiff; i < limDiff; i++)
            {
                if (!_pages[i].CanRelocate)
                {
                    var msg = LocalizationManager.GetString("EditTab.PageList.CantMoveXMatter",
                                                            "That change is not allowed. Front matter and back matter pages must remain where they are.");
                    //previously had a caption that didn't add value, just more translation work
                    if (_pages[i].Book.LockedDown)
                    {
                        msg = LocalizationManager.GetString("PageList.CantMoveWhenTranslating",
                                                            "Pages can not be re-ordered when you are translating a book.");
                        msg = msg + System.Environment.NewLine + EditingView.GetInstructionsForUnlockingBook();
                    }
                    MessageBox.Show(msg);
                    UpdateItems(_pages);                     // reset to old state
                    return;
                }
            }
            // There are two possibilities: the user dragged the item that used to be at the start to the end,
            // or the item that used to be the end to the start.
            IPage movedPage;
            int   newPageIndex;

            if (_pages[firstDiff] == newSeq[limDiff - 1])
            {
                // Move forward
                movedPage    = _pages[firstDiff];
                newPageIndex = limDiff - 1;
            }
            else
            {
                Debug.Assert(_pages[limDiff - 1] == newSeq[firstDiff]);                 // moved last page forwards
                movedPage    = _pages[limDiff - 1];
                newPageIndex = firstDiff;
            }
            var relocatePageInfo = new RelocatePageInfo(movedPage, newPageIndex);

            RelocatePageEvent.Raise(relocatePageInfo);
            if (relocatePageInfo.Cancel)
            {
                UpdateItems(_pages);
            }
            else
            {
                _pages = newSeq;
                UpdatePageNumbers();
                // This is only needed if left and right pages are styled differently.
                // Unfortunately gecko does not re-apply the styles when things are re-ordered!
                UpdateItems(_pages);
            }
        }
예제 #3
0
        //autofac uses this
        public WorkspaceView(WorkspaceModel model,
							 Control libraryView,
							 EditingView.Factory editingViewFactory,
							 PublishView.Factory pdfViewFactory,
							 CollectionSettingsDialog.Factory settingsDialogFactory,
							 EditBookCommand editBookCommand,
							SendReceiveCommand sendReceiveCommand,
							 SelectedTabAboutToChangeEvent selectedTabAboutToChangeEvent,
							SelectedTabChangedEvent selectedTabChangedEvent,
							 FeedbackDialog.Factory feedbackDialogFactory,
							ChorusSystem chorusSystem,
							Sparkle sparkleApplicationUpdater,
							LocalizationManager localizationManager

			)
        {
            _model = model;
            _settingsDialogFactory = settingsDialogFactory;
            _selectedTabAboutToChangeEvent = selectedTabAboutToChangeEvent;
            _selectedTabChangedEvent = selectedTabChangedEvent;
            _feedbackDialogFactory = feedbackDialogFactory;
            _chorusSystem = chorusSystem;
            _sparkleApplicationUpdater = sparkleApplicationUpdater;
            _localizationManager = localizationManager;
            _model.UpdateDisplay += new System.EventHandler(OnUpdateDisplay);
            InitializeComponent();

            #if !DEBUG
            _sparkleApplicationUpdater.CheckOnFirstApplicationIdle();
            #endif
            _toolStrip.Renderer = new NoBorderToolStripRenderer();

            //we have a number of buttons which don't make sense for the remote (therefore vulnerable) low-end user
            //_settingsLauncherHelper.CustomSettingsControl = _toolStrip;

            _settingsLauncherHelper.ManageComponent(_settingsButton);

            //NB: the rest of these aren't really settings, but we're using that feature to simplify this menu down to what makes sense for the easily-confused user
            _settingsLauncherHelper.ManageComponent(_openCreateCollectionButton);
            _settingsLauncherHelper.ManageComponent(deepBloomPaperToolStripMenuItem);
            _settingsLauncherHelper.ManageComponent(_makeASuggestionMenuItem);
            _settingsLauncherHelper.ManageComponent(_webSiteMenuItem);
            _settingsLauncherHelper.ManageComponent(_showLogMenuItem);
            _settingsLauncherHelper.ManageComponent(_releaseNotesMenuItem);
            _settingsLauncherHelper.ManageComponent(_divider2);
            _settingsLauncherHelper.ManageComponent(_divider3);
            _settingsLauncherHelper.ManageComponent(_divider4);

            OnSettingsProtectionChanged(this, null);//initial setup
            SettingsProtectionSettings.Default.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(OnSettingsProtectionChanged);

            _uiLanguageMenu.Visible = true;
               _settingsLauncherHelper.ManageComponent(_uiLanguageMenu);

            editBookCommand.Subscribe(OnEditBook);
            sendReceiveCommand.Subscribe(OnSendReceive);

            //Cursor = Cursors.AppStarting;
            Application.Idle += new EventHandler(Application_Idle);
            Text = _model.ProjectName;

            //SetupTabIcons();

            //
            // _collectionView
            //
            this._collectionView = (LibraryView) libraryView;
            this._collectionView.Dock = System.Windows.Forms.DockStyle.Fill;

            //
            // _editingView
            //
            this._editingView = editingViewFactory();
            this._editingView.Dock = System.Windows.Forms.DockStyle.Fill;

            //
            // _pdfView
            //
            this._publishView = pdfViewFactory();
            this._publishView.Dock = System.Windows.Forms.DockStyle.Fill;

            _collectionTab.Tag = _collectionView;
            _publishTab.Tag = _publishView;
            _editTab.Tag = _editingView;

            this._collectionTab.Text = _collectionView.CollectionTabLabel;

            SetTabVisibility(_publishTab, false);
            SetTabVisibility(_editTab, false);

            //			if (Program.StartUpWithFirstOrNewVersionBehavior)
            //			{
            //				_tabStrip.SelectedTab = _infoTab;
            //				SelectPage(_infoView);
            //			}
            //			else
            //			{
                _tabStrip.SelectedTab = _collectionTab;
                SelectPage(_collectionView);
            //			}

            SetupUILanguageMenu();
        }
예제 #4
0
 //        private void InvokeUpdatePageList()
 //        {
 //            if (UpdatePageList != null)
 //            {
 //                UpdatePageList(this, null);
 //            }
 //        }
 public void SetView(EditingView view)
 {
     _view = view;
 }
예제 #5
0
//        private void InvokeUpdatePageList()
//        {
//            if (UpdatePageList != null)
//            {
//                UpdatePageList(this, null);
//            }
//        }

        public void SetView(EditingView view)
        {
            _view = view;
        }