Beispiel #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);
        }
        public CollectionSettingsDialog(CollectionSettings collectionSettings, XMatterPackFinder xmatterPackFinder, QueueRenameOfCollection queueRenameOfCollection, PageRefreshEvent pageRefreshEvent)
        {
            _collectionSettings      = collectionSettings;
            _xmatterPackFinder       = xmatterPackFinder;
            _queueRenameOfCollection = queueRenameOfCollection;
            _pageRefreshEvent        = pageRefreshEvent;
            InitializeComponent();
            // moved from the Designer where it was deleted if the Designer was touched
            _xmatterList.Columns.AddRange(new[] { new ColumnHeader()
                                                  {
                                                      Width = 250
                                                  } });

            if (_collectionSettings.IsSourceCollection)
            {
                _language1Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language1InSourceCollection", "Language 1", "In a local language collection, we say 'Local Language', but in a source collection, Local Language has no relevance, so we use this different label");
                _language2Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language2InSourceCollection", "Language 2", "In a local language collection, we say 'Language 2 (e.g. National Language)', but in a source collection, National Language has no relevance, so we use this different label");
                _language3Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language3InSourceCollection", "Language 3", "In a local language collection, we say 'Language 3 (e.g. Regional Language)', but in a source collection, National Language has no relevance, so we use this different label");
            }

            _showExperimentalFeatures.Checked = Settings.Default.ShowExperimentalFeatures;
            // AutoUpdate applies only to Windows: see https://silbloom.myjetbrains.com/youtrack/issue/BL-2317.
            if (SIL.PlatformUtilities.Platform.IsWindows)
            {
                _automaticallyUpdate.Checked = Settings.Default.AutoUpdate;
            }
            else
            {
                _automaticallyUpdate.Hide();
            }

//		    _showSendReceive.CheckStateChanged += (sender, args) =>
//		                                              {
//		                                                  Settings.Default.ShowSendReceive = _showSendReceive.CheckState ==
//		                                                                                     CheckState.Checked;
//
//                                                          _restartRequired = true;
//		                                                  UpdateDisplay();
//		                                              };

            CollectionSettingsApi.BrandingChangeHandler = ChangeBranding;

            SetupEnterpriseBrowser();

            UpdateDisplay();

            if (CollectionSettingsApi.FixEnterpriseSubscriptionCodeMode)
            {
                _tab.SelectedTab = _enterpriseTab;
            }
        }
        public CollectionSettingsDialog(CollectionSettings collectionSettings, XMatterPackFinder xmatterPackFinder, QueueRenameOfCollection queueRenameOfCollection)
        {
            _collectionSettings      = collectionSettings;
            _xmatterPackFinder       = xmatterPackFinder;
            _queueRenameOfCollection = queueRenameOfCollection;
            InitializeComponent();
            if (_collectionSettings.IsSourceCollection)
            {
                _language1Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language1InSourceCollection", "Language 1", "In a vernacular collection, we say 'Vernacular Language', but in a souce collection, Vernacular has no relevance, so we use this different label");
                _language2Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language2InSourceCollection", "Language 2", "In a vernacular collection, we say 'Language 2 (e.g. National Language)', but in a souce collection, National Language has no relevance, so we use this different label");
                _language3Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language3InSourceCollection", "Language 3", "In a vernacular collection, we say 'Language 3 (e.g. Regional Language)', but in a souce collection, National Language has no relevance, so we use this different label");
            }

#if !DEBUG
            _showSendReceive.Enabled = false;
#endif

            _showSendReceive.Checked           = Settings.Default.ShowSendReceive;
            _showExperimentalTemplates.Checked = Settings.Default.ShowExperimentalBooks;
            _showExperimentCommands.Checked    = Settings.Default.ShowExperimentalCommands;

//		    _showSendReceive.CheckStateChanged += (sender, args) =>
//		                                              {
//		                                                  Settings.Default.ShowSendReceive = _showSendReceive.CheckState ==
//		                                                                                     CheckState.Checked;
//
//                                                          _restartRequired = true;
//		                                                  UpdateDisplay();
//		                                              };

            switch (Settings.Default.ImageHandler)
            {
            case "":
                _useImageServer.CheckState = CheckState.Checked;
                break;

            case "off":
                _useImageServer.CheckState = CheckState.Unchecked;
                break;

            case "http":
                _useImageServer.CheckState = CheckState.Checked;
                break;
            }
//			this._useImageServer.CheckedChanged += new System.EventHandler(this._useImageServer_CheckedChanged);
            _useImageServer.CheckStateChanged += new EventHandler(_useImageServer_CheckedChanged);

            UpdateDisplay();
        }
Beispiel #4
0
        public Shell(Func<WorkspaceView> projectViewFactory, CollectionSettings collectionSettings, LibraryClosing libraryClosingEvent, QueueRenameOfCollection queueRenameOfCollection, Sparkle _sparkle)
        {
            queueRenameOfCollection.Subscribe(newName => _nameToChangeCollectionUponClosing = newName.Trim().SanitizeFilename('-'));
            _collectionSettings = collectionSettings;
            _libraryClosingEvent = libraryClosingEvent;
            InitializeComponent();

            #if DEBUG
            WindowState = FormWindowState.Normal;
            //this.FormBorderStyle = FormBorderStyle.None;  //fullscreen

            Size = new Size(1024,720);
            #endif
            _workspaceView = projectViewFactory();
            _workspaceView.CloseCurrentProject += ((x, y) =>
                                                    {
                                                        UserWantsToOpenADifferentProject = true;
                                                        Close();
                                                    });

            _sparkle.AboutToExitForInstallerRun += ((x, cancellable) =>
            {
                cancellable.Cancel = false;
                QuitForVersionUpdate = true;
                Close();
            });

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

            SystemEvents.SessionEnding += ((x,y)=>
            {
                QuitForSystemShutdown=true;
                Close();
            });

            _workspaceView.BackColor =
                System.Drawing.Color.FromArgb(64,64,64);
                                        _workspaceView.Dock = System.Windows.Forms.DockStyle.Fill;

            this.Controls.Add(this._workspaceView);

            SetWindowText();
        }
        public CollectionSettingsDialog(CollectionSettings collectionSettings, XMatterPackFinder xmatterPackFinder, QueueRenameOfCollection queueRenameOfCollection)
        {
            _collectionSettings = collectionSettings;
            _xmatterPackFinder = xmatterPackFinder;
            _queueRenameOfCollection = queueRenameOfCollection;
            InitializeComponent();
            if(_collectionSettings.IsSourceCollection)
            {
                _language1Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language1InSourceCollection", "Language 1", "In a vernacular collection, we say 'Vernacular Language', but in a souce collection, Vernacular has no relevance, so we use this different label");
                _language2Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language2InSourceCollection", "Language 2", "In a vernacular collection, we say 'Language 2 (e.g. National Language)', but in a souce collection, National Language has no relevance, so we use this different label");
                _language3Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language3InSourceCollection", "Language 3", "In a vernacular collection, we say 'Language 3 (e.g. Regional Language)', but in a souce collection, National Language has no relevance, so we use this different label");
            }

            #if !DEBUG
            _showSendReceive.Enabled = false;
            #endif

            _showSendReceive.Checked = Settings.Default.ShowSendReceive;
            _showExperimentalTemplates.Checked = Settings.Default.ShowExperimentalBooks;
            _showExperimentCommands.Checked = Settings.Default.ShowExperimentalCommands;

            //		    _showSendReceive.CheckStateChanged += (sender, args) =>
            //		                                              {
            //		                                                  Settings.Default.ShowSendReceive = _showSendReceive.CheckState ==
            //		                                                                                     CheckState.Checked;
            //
            //                                                          _restartRequired = true;
            //		                                                  UpdateDisplay();
            //		                                              };

            switch(Settings.Default.ImageHandler)
            {
                case "":
                    _useImageServer.CheckState = CheckState.Checked;
                    break;
                case "off":
                    _useImageServer.CheckState = CheckState.Unchecked;
                    break;
                case "http":
                    _useImageServer.CheckState = CheckState.Checked;
                    break;
            }
            //			this._useImageServer.CheckedChanged += new System.EventHandler(this._useImageServer_CheckedChanged);
            _useImageServer.CheckStateChanged += new EventHandler(_useImageServer_CheckedChanged);

            UpdateDisplay();
        }
        public CollectionSettingsDialog(CollectionSettings collectionSettings, XMatterPackFinder xmatterPackFinder, QueueRenameOfCollection queueRenameOfCollection, PageRefreshEvent pageRefreshEvent)
        {
            _collectionSettings = collectionSettings;
            _xmatterPackFinder = xmatterPackFinder;
            _queueRenameOfCollection = queueRenameOfCollection;
            _pageRefreshEvent = pageRefreshEvent;
            InitializeComponent();
            // moved from the Designer where it was deleted if the Designer was touched
            _xmatterList.Columns.AddRange(new[] { new ColumnHeader() { Width = 250 } });

            if (_collectionSettings.IsSourceCollection)
            {
                _language1Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language1InSourceCollection", "Language 1", "In a vernacular collection, we say 'Vernacular Language', but in a source collection, Vernacular has no relevance, so we use this different label");
                _language2Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language2InSourceCollection", "Language 2", "In a vernacular collection, we say 'Language 2 (e.g. National Language)', but in a source collection, National Language has no relevance, so we use this different label");
                _language3Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language3InSourceCollection", "Language 3", "In a vernacular collection, we say 'Language 3 (e.g. Regional Language)', but in a source collection, National Language has no relevance, so we use this different label");
            }

            _showExperimentalTemplates.Checked = Settings.Default.ShowExperimentalBooks;
            _showExperimentCommands.Checked = Settings.Default.ShowExperimentalCommands;
            // AutoUpdate applies only to Windows: see https://silbloom.myjetbrains.com/youtrack/issue/BL-2317.
            if (SIL.PlatformUtilities.Platform.IsWindows)
                _automaticallyUpdate.Checked = Settings.Default.AutoUpdate;
            else
                _automaticallyUpdate.Hide();

            //		    _showSendReceive.CheckStateChanged += (sender, args) =>
            //		                                              {
            //		                                                  Settings.Default.ShowSendReceive = _showSendReceive.CheckState ==
            //		                                                                                     CheckState.Checked;
            //
            //                                                          _restartRequired = true;
            //		                                                  UpdateDisplay();
            //		                                              };

            UpdateDisplay();
        }
Beispiel #7
0
        public CollectionSettingsDialog(CollectionSettings collectionSettings,
                                        QueueRenameOfCollection queueRenameOfCollection, PageRefreshEvent pageRefreshEvent,
                                        TeamCollectionManager tcManager, XMatterPackFinder xmatterPackFinder)
        {
            _collectionSettings      = collectionSettings;
            _queueRenameOfCollection = queueRenameOfCollection;
            _pageRefreshEvent        = pageRefreshEvent;
            _xmatterPackFinder       = xmatterPackFinder;
            InitializeComponent();

            _language1Name.UseMnemonic = false;             // Allow & to be part of the language display names.
            _language2Name.UseMnemonic = false;             // This may be unlikely, but can't be ruled out.
            _language3Name.UseMnemonic = false;             // See https://issues.bloomlibrary.org/youtrack/issue/BL-9919.

            PendingFontSelections[0] = _collectionSettings.LanguagesZeroBased[0].FontName;
            PendingFontSelections[1] = _collectionSettings.LanguagesZeroBased[1].FontName;
            var have3rdLanguage = _collectionSettings.LanguagesZeroBased[2] != null;

            PendingFontSelections[2] = have3rdLanguage ?
                                       _collectionSettings.LanguagesZeroBased[2].FontName :
                                       "";
            PendingNumberingStyle = _collectionSettings.PageNumberStyle;
            PendingXmatter        = _collectionSettings.XMatterPackName;
            CollectionSettingsApi.DialogBeingEdited = this;

            if (_collectionSettings.IsSourceCollection)
            {
                _language1Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language1InSourceCollection", "Language 1", "In a local language collection, we say 'Local Language', but in a source collection, Local Language has no relevance, so we use this different label");
                _language2Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language2InSourceCollection", "Language 2", "In a local language collection, we say 'Language 2 (e.g. National Language)', but in a source collection, National Language has no relevance, so we use this different label");
                _language3Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language3InSourceCollection", "Language 3", "In a local language collection, we say 'Language 3 (e.g. Regional Language)', but in a source collection, National Language has no relevance, so we use this different label");
            }

            _showExperimentalBookSources.Checked  = ExperimentalFeatures.IsFeatureEnabled(ExperimentalFeatures.kExperimentalSourceBooks);
            _allowTeamCollection.Checked          = ExperimentalFeatures.IsFeatureEnabled(ExperimentalFeatures.kTeamCollections);
            _allowSpreadsheetImportExport.Checked = ExperimentalFeatures.IsFeatureEnabled(ExperimentalFeatures.kSpreadsheetImportExport);

            if (!ExperimentalFeatures.IsFeatureEnabled(ExperimentalFeatures.kTeamCollections) && tcManager.CurrentCollectionEvenIfDisconnected == null)
            {
                this._tab.Controls.Remove(this._teamCollectionTab);
            }
            // Don't allow the user to disable the Team Collection feature if we're currently in a Team Collection.
            _allowTeamCollection.Enabled = !(_allowTeamCollection.Checked && tcManager.CurrentCollectionEvenIfDisconnected != null);

            // AutoUpdate applies only to Windows: see https://silbloom.myjetbrains.com/youtrack/issue/BL-2317.
            if (SIL.PlatformUtilities.Platform.IsWindows)
            {
                _automaticallyUpdate.Checked = Settings.Default.AutoUpdate;
            }
            else
            {
                _automaticallyUpdate.Hide();
            }

            // Without this, PendingDefaultBookshelf stays null unless the user changes it.
            // The result is the bookshelf selection gets cleared when other collection settings are saved. See BL-10093.
            PendingDefaultBookshelf = _collectionSettings.DefaultBookshelf;

            CollectionSettingsApi.BrandingChangeHandler = ChangeBranding;

            TeamCollectionApi.TheOneInstance.SetCallbackToReopenCollection(() =>
            {
                _restartRequired = true;
                ReactDialog.CloseCurrentModal();             // close the top Create dialog
                _okButton_Click(null, null);                 // close this dialog
            });

            UpdateDisplay();

            if (CollectionSettingsApi.FixEnterpriseSubscriptionCodeMode)
            {
                _tab.SelectedTab = _enterpriseTab;
            }

            if (tcManager.CurrentCollectionEvenIfDisconnected == null)
            {
                _noRenameTeamCollectionLabel.Visible = false;
            }
            else
            {
                _bloomCollectionName.Enabled = false;
            }
        }
Beispiel #8
0
        public CollectionSettingsDialog(CollectionSettings collectionSettings, XMatterPackFinder xmatterPackFinder, QueueRenameOfCollection queueRenameOfCollection, PageRefreshEvent pageRefreshEvent, TeamCollectionManager tcManager)
        {
            _collectionSettings      = collectionSettings;
            _xmatterPackFinder       = xmatterPackFinder;
            _queueRenameOfCollection = queueRenameOfCollection;
            _pageRefreshEvent        = pageRefreshEvent;
            InitializeComponent();
            // moved from the Designer where it was deleted if the Designer was touched
            _xmatterList.Columns.AddRange(new[] { new ColumnHeader()
                                                  {
                                                      Width = 250
                                                  } });

            _language1Name.UseMnemonic              = false;    // Allow & to be part of the language display names.
            _language2Name.UseMnemonic              = false;    // This may be unlikely, but can't be ruled out.
            _language3Name.UseMnemonic              = false;    // See https://issues.bloomlibrary.org/youtrack/issue/BL-9919.
            _language1FontLabel.UseMnemonic         = false;
            _language2FontLabel.UseMnemonic         = false;
            _language3FontLabel.UseMnemonic         = false;
            CollectionSettingsApi.DialogBeingEdited = this;

            if (_collectionSettings.IsSourceCollection)
            {
                _language1Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language1InSourceCollection", "Language 1", "In a local language collection, we say 'Local Language', but in a source collection, Local Language has no relevance, so we use this different label");
                _language2Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language2InSourceCollection", "Language 2", "In a local language collection, we say 'Language 2 (e.g. National Language)', but in a source collection, National Language has no relevance, so we use this different label");
                _language3Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language3InSourceCollection", "Language 3", "In a local language collection, we say 'Language 3 (e.g. Regional Language)', but in a source collection, National Language has no relevance, so we use this different label");
            }

            _showExperimentalBookSources.Checked = ExperimentalFeatures.IsFeatureEnabled(ExperimentalFeatures.kExperimentalSourceBooks);
            _allowTeamCollection.Checked         = ExperimentalFeatures.IsFeatureEnabled(ExperimentalFeatures.kTeamCollections);
            if (!ExperimentalFeatures.IsFeatureEnabled(ExperimentalFeatures.kTeamCollections) && tcManager.CurrentCollectionEvenIfDisconnected == null)
            {
                this._tab.Controls.Remove(this._teamCollectionTab);
            }
            // Don't allow the user to disable the Team Collection feature if we're currently in a Team Collection.
            _allowTeamCollection.Enabled = !(_allowTeamCollection.Checked && tcManager.CurrentCollectionEvenIfDisconnected != null);

            // AutoUpdate applies only to Windows: see https://silbloom.myjetbrains.com/youtrack/issue/BL-2317.
            if (SIL.PlatformUtilities.Platform.IsWindows)
            {
                _automaticallyUpdate.Checked = Settings.Default.AutoUpdate;
            }
            else
            {
                _automaticallyUpdate.Hide();
            }

            // Without this, PendingDefaultBookshelf stays null unless the user changes it.
            // The result is the bookshelf selection gets cleared when other collection settings are saved. See BL-10093.
            PendingDefaultBookshelf = _collectionSettings.DefaultBookshelf;

//		    _showSendReceive.CheckStateChanged += (sender, args) =>
//		                                              {
//		                                                  Settings.Default.ShowSendReceive = _showSendReceive.CheckState ==
//		                                                                                     CheckState.Checked;
//
//                                                          _restartRequired = true;
//		                                                  UpdateDisplay();
//		                                              };

            CollectionSettingsApi.BrandingChangeHandler = ChangeBranding;

            SetupEnterpriseBrowser();

            TeamCollectionApi.TheOneInstance.SetCallbackToReopenCollection(() =>
            {
                _restartRequired = true;
                ReactDialog.CloseCurrentModal();             // close the top Create dialog
                _okButton_Click(null, null);                 // close this dialog
            });

            UpdateDisplay();

            if (CollectionSettingsApi.FixEnterpriseSubscriptionCodeMode)
            {
                _tab.SelectedTab = _enterpriseTab;
            }

            if (tcManager.CurrentCollectionEvenIfDisconnected == null)
            {
                _noRenameTeamCollectionLabel.Visible = false;
            }
            else
            {
                _bloomCollectionName.Enabled = false;
            }

            // This code would mostly more naturally go in Designer. Unfortunately we can't run designer
            // until we get back in a state where all our dependencies are sufficiently consistent.

            _defaultBookshelfControl = ReactControl.Create("defaultBookshelfControlBundle");

            tabPage2.Controls.Add(_defaultBookshelfControl);
            _defaultBookshelfControl.Location = new Point(_xmatterDescription.Left, _xmatterDescription.Bottom + 30);
            // We'd like it to be as big as possible, not just big enough for the immediate content.
            // Until React takes over at least the whole tab, the pull-down part of the combo can't
            // stretch outside the Gecko control.
            _defaultBookshelfControl.Size = new Size(_xmatterList.Width, 200);
        }