/// ------------------------------------------------------------------------------------
        /// <summary>
        /// Converts the chapter verse numbers.
        /// </summary>
        /// <param name="progressDlg">The progress DLG.</param>
        /// <param name="parameters">The parameters.</param>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        private object ConvertChapterVerseNumbers(IThreadedProgress progressDlg, params object[] parameters)
        {
            char zeroDigit = (m_scr.UseScriptDigits ? (char)m_scr.ScriptDigitZero : '0');

            ILgCharacterPropertyEngine charEngine = m_cache.ServiceLocator.UnicodeCharProps;

            foreach (IScrBook book in m_scr.ScriptureBooksOS)
            {
                // update the status with the book name.
                progressDlg.Message =
                    string.Format(DlgResources.ResourceString("kstidConvertChapterVerseNumbersMessage"),
                                  book.BestUIName);

                foreach (IScrSection section in book.SectionsOS)
                {
                    foreach (IScrTxtPara para in section.ContentOA.ParagraphsOS)
                    {
                        ConvertChapterVerseNumbers(para, zeroDigit, charEngine);
                    }
                }

                progressDlg.Step(0);
            }

            return(null);
        }
Example #2
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Run the export
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public void Run()
 {
     // Check whether we're about to overwrite an existing file.
     if (File.Exists(m_fileName))
     {
         string sFmt     = DlgResources.ResourceString("kstidAlreadyExists");
         string sMsg     = String.Format(sFmt, m_fileName);
         string sCaption = DlgResources.ResourceString("kstidExportXHTML");
         if (MessageBox.Show(sMsg, sCaption, MessageBoxButtons.YesNo,
                             MessageBoxIcon.Warning) == DialogResult.No)
         {
             return;
         }
     }
     try
     {
         try
         {
             m_writer = new StreamWriter(m_fileName, false, Encoding.UTF8);
             m_strm   = new TextWriterStream(m_writer);
             m_xhtml  = new XhtmlHelper(m_writer, m_cache);
         }
         catch (Exception e)
         {
             MessageBox.Show(e.Message, Application.ProductName,
                             MessageBoxButtons.OK, MessageBoxIcon.Information);
             return;
         }
         ExportTE();
     }
     catch (Exception e)
     {
         Exception inner = e.InnerException != null ? e.InnerException : e;
         if (inner is IOException)
         {
             MessageBox.Show(inner.Message, Application.ProductName,
                             MessageBoxButtons.OK, MessageBoxIcon.Information);
             return;
         }
         else
         {
             throw inner;
         }
     }
     finally
     {
         if (m_writer != null)
         {
             try
             {
                 m_writer.Close();
             }
             catch
             {
                 // ignore errors on close
             }
         }
         m_writer = null;
     }
 }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Updates the verse bridges.
        /// </summary>
        /// <param name="progressDlg">The progress dialog.</param>
        /// <param name="parameters">The parameters.</param>
        /// <returns>Always null.</returns>
        /// ------------------------------------------------------------------------------------
        private object UpdateVerseBridges(IThreadedProgress progressDlg, object[] parameters)
        {
            Debug.Assert(parameters.Length == 1);
            string oldBridge = (string)parameters[0];
            string newBridge = m_scr.Bridge;

            foreach (IScrBook book in m_scr.ScriptureBooksOS)
            {
                progressDlg.Message =
                    string.Format(DlgResources.ResourceString("kstidUpdateVerseBridgesInBook"),
                                  book.Name.UserDefaultWritingSystem.Text);

                foreach (IScrSection section in book.SectionsOS)
                {
                    foreach (IScrTxtPara para in section.ContentOA.ParagraphsOS)
                    {
                        UpdateVerseBridgesInParagraph(para, oldBridge, newBridge);
                    }
                }

                progressDlg.Step(0);
            }

            return(null);
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <param name="baseChar"></param>
        /// ------------------------------------------------------------------------------------
        private void LoadOneLanguage(string id, char baseChar)
        {
            string language = DlgResources.ResourceString(id);

            Debug.Assert(language != null);
            m_languageMap.Add(language, baseChar);
            m_baseDigitMap.Add(baseChar, language);
            m_cboScriptLanguages.Items.Add(language);
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Handle the View Differences button. Display the Review Differences window to
        /// view/merge differences between the current scripture and selected book in the tree.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void m_btnDiff_Click(object sender, System.EventArgs e)
        {
            // If the selected item is not a book, then don't do a diff.
            TreeNode node = m_treeArchives.SelectedNode;

            if (node == null)
            {
                return;
            }

            ScrBook bookRev = node.Tag as ScrBook;

            if (bookRev == null)
            {
                return;
            }

            //ScrDraft archive = node.Parent.Tag as ScrDraft;

            using (BookMerger merger = new BookMerger(m_cache, m_styleSheet, bookRev))
            {
                using (ProgressDialogWithTask progress = new ProgressDialogWithTask(this))
                {
                    progress.Title   = DlgResources.ResourceString("kstidCompareCaption");
                    progress.Message = string.Format(
                        DlgResources.ResourceString("kstidMergeProgress"), bookRev.BestUIName);
                    progress.RunTask(true, new BackgroundTaskInvoker(merger.DetectDifferences));
                }

                // always hide diffs that could cause deletion of current sections, if reverted
                merger.UseFilteredDiffList();

                // If there were differences detected then show the diff dialog
                if (merger.NumberOfDifferences != 0)
                {
                    using (DiffDialog dlg = new DiffDialog(merger, m_cache, m_styleSheet, m_zoomDraft,
                                                           m_zoomFootnote))
                    {
                        // We have to pass the owner (this), so that the dialog shows when the
                        // user clicks on the TE icon in the taskbar. Otherwise only the Archive
                        // dialog would pop up and beeps; diff dialog could only be regained by Alt-Tab.
                        dlg.ShowDialog(this);
                    }
                }
                else
                {
                    // Tell users that no differences were found in the merge
                    MessageBox.Show(this,
                                    string.Format(DlgResources.ResourceString("kstidNoDifferencesDetected"),
                                                  bookRev.BestUIName), Application.ProductName, MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
            }
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// When Script number options have changed, all of the chapter and verse numbers in the
        /// database will be updated.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected void ConvertChapterVerseNumbers()
        {
            // Show a progress dialog for this operation
            using (ProgressDialogWithTask progressDlg = new ProgressDialogWithTask(this))
            {
                progressDlg.Minimum     = 0;
                progressDlg.Maximum     = m_scr.ScriptureBooksOS.Count;
                progressDlg.Title       = DlgResources.ResourceString("kstidConvertChapterVerseNumbersCaption");
                progressDlg.AllowCancel = false;

                progressDlg.RunTask(ConvertChapterVerseNumbers);
            }
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// When the verse bridge character changes, this will update all of the verse bridges
        /// in scripture.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void UpdateVerseBridges(string oldBridge)
        {
            // Show a progress dialog for this operation
            using (ProgressDialogWithTask progressDlg = new ProgressDialogWithTask(this))
            {
                progressDlg.Minimum     = 0;
                progressDlg.Maximum     = m_scr.ScriptureBooksOS.Count;
                progressDlg.Title       = DlgResources.ResourceString("kstidUpdateVerseBridges");
                progressDlg.AllowCancel = false;

                progressDlg.RunTask(UpdateVerseBridges, oldBridge);
            }
        }
        ///-------------------------------------------------------------------------------
        /// <summary>
        /// When the Source button is clicked, display the import wizard.
        /// </summary>
        ///-------------------------------------------------------------------------------
        private void btnSource_Click(object sender, System.EventArgs e)
        {
            using (ImportWizard importWizard = new ImportWizard(m_scr.Cache.ProjectId.Name,
                                                                m_scr, m_StyleSheet, m_helpTopicProvider, m_app))
            {
                using (NonUndoableUnitOfWorkHelper undoHelper = new NonUndoableUnitOfWorkHelper(ActionHandler))
                {
                    if (importWizard.ShowDialog() == DialogResult.Cancel)
                    {
                        // Ditch any in-memory changes made to the settings. Reload from the DB.
                        m_importSettings.RevertToSaved();
                    }
                    else
                    {
                        undoHelper.RollBack = false;
                    }
                }

                // If there are no files after showing the wizard, close the import dialog
                if (InitBookNameList() == 0)
                {
                    MessageBox.Show(this, DlgResources.ResourceString("kstidImportFilesUnavailable"),
                                    m_app.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Close();
                    return;
                }

                // The default set of settings may have changed.
                m_importSettings = m_scr.DefaultImportSettings;

                // Update the file ranges for import because they may have changed.
                InitializeStartAndEndRefControls();

                // Update the passage controls to reflect the new range of files available
                // Only make changes that do not expand the available range of books since a
                // range may have been specified before the wizard was run that we do not
                // want to overwrite
                if (!scrPsgFrom.IsReferenceValid(scrPsgFrom.ScReference))
                {
                    SetStartRefToFirstImportableBook();
                }

                if (!scrPsgTo.IsReferenceValid(scrPsgTo.ScReference))
                {
                    SetEndRefToLastImportableBook();
                }
            }
            btnOK.Focus();
        }
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Return a string from a resource ID.
        /// </summary>
        /// <param name="stid">String resource id</param>
        /// <returns>String</returns>
        /// -----------------------------------------------------------------------------------
        public static new string GetResourceString(string stid)
        {
            if (s_stringResources == null)
            {
                s_stringResources = new System.Resources.ResourceManager(
                    "SIL.FieldWorks.TE.TeStrings", Assembly.GetExecutingAssembly());
            }
            string toReturn = (stid == null ? "NullStringID" : s_stringResources.GetString(stid));

            if (toReturn == null)
            {
                toReturn = DlgResources.ResourceString(stid);
            }

            return(toReturn);
        }
Example #10
0
        ///-------------------------------------------------------------------------------
        /// <summary>
        /// When the Source button is clicked, display the import wizard.
        /// </summary>
        ///-------------------------------------------------------------------------------
        private void btnSource_Click(object sender, System.EventArgs e)
        {
            ILangProject lp  = m_cache.LangProject;
            Scripture    scr = (Scripture)lp.TranslatedScriptureOA;

            using (ImportWizard importWizard = new ImportWizard(lp.Name.AnalysisDefaultWritingSystem,
                                                                scr, m_StyleSheet, m_cache, m_helpFile))
            {
                if (importWizard.ShowDialog() == DialogResult.Cancel)
                {
                    // Ditch any in-memory changes made to the settings. Reload from the DB.
                    m_importSettings.RevertToSaved();
                }

                // If there are no files after showing the wizard, close the import dialog
                if (InitBookNameList() == 0)
                {
                    MessageBox.Show(this, DlgResources.ResourceString("kstidImportFilesUnavailable"),
                                    Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Close();
                    return;
                }

                // Update the file ranges for import because they may have changed. The default
                // set of settings may also have changed, so we re-retrieve them from the DB.
                m_importSettings = (ScrImportSet)scr.DefaultImportSettings;
                scrPsgFrom.Initialize(new ScrReference(StartRef, scr.Versification), scr,
                                      m_importSettings.BooksForProject.ToArray());
                scrPsgTo.Initialize(new ScrReference(EndRef, scr.Versification), scr,
                                    m_importSettings.BooksForProject.ToArray());

                // Update the passage controls to reflect the new range of files available
                // Only make changes that do not expand the available range of books since a
                // range may have been specified before the wizard was run that we do not
                // want to overwrite
                if (!scrPsgFrom.IsReferenceValid(scrPsgFrom.ScReference))
                {
                    SetStartRefToFirstImportableBook();
                }

                if (!scrPsgTo.IsReferenceValid(scrPsgTo.ScReference))
                {
                    SetEndRefToLastImportableBook();
                }
            }
            btnOK.Focus();
        }
Example #11
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Export all of scripture
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void ExportScripture()
        {
            int sectionCount = 0;

            for (int i = 0; i < m_bookFilter.BookCount; i++)
            {
                sectionCount += m_bookFilter.GetBook(i).SectionsOS.Count;
            }
            using (ProgressDialogWithTask progressDlg = new ProgressDialogWithTask(Form.ActiveForm))
            {
                progressDlg.SetRange(0, sectionCount);
                progressDlg.Title = DlgResources.ResourceString("kstidExportXmlProgress");
                progressDlg.CancelButtonVisible = true;
                progressDlg.Cancel += new CancelHandler(OnExportCancel);

                progressDlg.RunTask(true, new BackgroundTaskInvoker(ExportScripture));
            }
        }
Example #12
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Handle a click on the Browse button used to change the default backup directory.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void m_btnBrowse_Click(object sender, System.EventArgs e)
        {
            using (FolderBrowserDialog fldrBrowse = new FolderBrowserDialog())
            {
                fldrBrowse.ShowNewFolderButton = true;
                fldrBrowse.Description         = DlgResources.ResourceString("kstidBrowseForBackupDir");;

                bool backupDirExists = ConfirmBackupDirectoryExists(m_textBoxBackupPath.Text, false);

                // if the directory exists which is typed in the text box...
                if (backupDirExists)
                {
                    fldrBrowse.SelectedPath = m_textBoxBackupPath.Text;
                }
                else
                {
                    // check the last directory used in the registry. If it exists, begin looking
                    // here.
                    if (ConfirmBackupDirectoryExists(FwRegistrySettings.BackupDirectorySetting, false))
                    {
                        fldrBrowse.SelectedPath = FwRegistrySettings.BackupDirectorySetting;
                    }

                    // Otherwise, begin looking on the root directory of the C:\ drive
                    else
                    {
                        fldrBrowse.SelectedPath = "C:\\";
                    }
                }

                // if directory selected, set path to it.
                if (fldrBrowse.ShowDialog() == DialogResult.OK)
                {
                    m_textBoxBackupPath.Text = fldrBrowse.SelectedPath;
                }
            }
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Handles the Click event of the m_btnCopyToCurr control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event
        /// data.</param>
        /// ------------------------------------------------------------------------------------
        private void m_btnCopyToCurr_Click(object sender, EventArgs e)
        {
            // If nothing or a complete archive is selected, do nothing.
            TreeNode node = m_treeArchives.SelectedNode;

            if (node == null || !(node.Tag is ScrBook))
            {
                return;
            }

            ScrBook            savedBook        = node.Tag as ScrBook;
            ScrBook            originalBook     = (ScrBook)m_scr.FindBook(savedBook.CanonicalNum);
            TreeNode           parentNode       = node.Parent;
            ScrDraft           archive          = parentNode.Tag as ScrDraft;
            OverwriteType      typeOfOverwrite  = OverwriteType.FullNoDataLoss;
            List <IScrSection> sectionsToRemove = null;

            if (originalBook != null)
            {
                string     sDetails;
                List <int> missingBtWs;
                typeOfOverwrite = originalBook.DetermineOverwritability(savedBook, out sDetails,
                                                                        out sectionsToRemove, out missingBtWs);
                if (typeOfOverwrite == OverwriteType.DataLoss)
                {
                    // There will be data loss if the user overwrites so we don't allow them
                    // to continue.
                    ImportedBooks.ReportDataLoss(originalBook, ScrDraftType.SavedVersion, this, sDetails);
                    return;
                }

                if (missingBtWs != null && !ImportedBooks.ConfirmBtOverwrite(originalBook,
                                                                             ScrDraftType.SavedVersion, sectionsToRemove, missingBtWs, this))
                {
                    // The user might lose back translation(s) if they proceed and they decided
                    // against it.
                    return;
                }
            }

            string stUndo;
            string stRedo;

            TeResourceHelper.MakeUndoRedoLabels("kstidOverwriteCurrentWithSaved", out stUndo, out stRedo);
            using (new WaitCursor(this))
                using (UndoTaskHelper helper = new UndoTaskHelper(m_cache.MainCacheAccessor, null, stUndo, stRedo, true))
                {
                    try
                    {
                        if (typeOfOverwrite == OverwriteType.Partial)
                        {
                            // Perform an automerge of the original book and the saved version.
                            using (BookMerger merger = new BookMerger(m_cache, m_styleSheet, savedBook))
                            {
                                using (ProgressDialogWithTask progress = new ProgressDialogWithTask(this))
                                {
                                    progress.Title = DlgResources.ResourceString("kstidOverwriteCaption");
                                    progress.RunTask(true, new BackgroundTaskInvoker(merger.DoPartialOverwrite), sectionsToRemove);
                                }
                                if (!merger.AutoMerged)
                                {
                                    throw new Exception("Partial Overwrite was not successful.");
                                }
                            }
                        }
                        else
                        {
                            if (originalBook != null)
                            {
                                if (m_cache.ActionHandlerAccessor != null)
                                {
                                    // When Undoing, we need to first resurrect the deleted book, then
                                    // put it back in the book filter...so we need a RIFF in the sequence
                                    // BEFORE the delete.
                                    ReplaceInFilterFixer fixer1 = new ReplaceInFilterFixer(originalBook.Hvo, 0, m_cache);
                                    m_cache.ActionHandlerAccessor.AddAction(fixer1);
                                }
                                originalBook.DeleteUnderlyingObject();
                            }
                            int hvoNew = (m_scr as Scripture).CopyBookToCurrent(savedBook);
                            ReplaceInFilterFixer fixer = new ReplaceInFilterFixer(0, hvoNew, m_cache);
                            fixer.Redo(false);
                            if (m_cache.ActionHandlerAccessor != null)
                            {
                                m_cache.ActionHandlerAccessor.AddAction(fixer);
                            }
                        }
                    }
                    catch
                    {
                        helper.EndUndoTask = false;
                        throw;
                    }
                }
        }
Example #14
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Handle the OK button click event.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// ------------------------------------------------------------------------------------
        protected void btnOK_Click(object sender, System.EventArgs e)
        {
            // Save values to the registry for the "Draft View" tab.
            Options.ShowEmptyParagraphPromptsSetting    = m_chkPromptEmptyParas.Checked;
            Options.ShowMarkerlessIconsSetting          = m_chkMarkerlessFootnoteIcons.Checked;
            Options.ShowFormatMarksSetting              = m_chkShowFormatMarks.Checked;
            Options.FootnoteSynchronousScrollingSetting = m_chkSynchFootnoteScroll.Checked;
            Options.ShowPasteWsChoice = m_rdoPromptForNewWs.Checked;

            // Save values to the registry for the "Styles" tab.
            if (rdoAllStyles.Checked)
            {
                Options.ShowTheseStylesSetting = Options.ShowTheseStyles.All;
            }
            else if (rdoBasicStyles.Checked)
            {
                Options.ShowTheseStylesSetting = Options.ShowTheseStyles.Basic;
            }
            else if (rdoCustomList.Checked)
            {
                Options.ShowTheseStylesSetting = Options.ShowTheseStyles.Custom;
            }

            string s = (string)cboStyleLevel.SelectedItem;

            if (s == DlgResources.ResourceString("kstidStyleLevelBasic"))
            {
                Options.ShowStyleLevelSetting = Options.StyleLevel.Basic;
            }
            else if (s == DlgResources.ResourceString("kstidStyleLevelIntermediate"))
            {
                Options.ShowStyleLevelSetting = Options.StyleLevel.Intermediate;
            }
            else if (s == DlgResources.ResourceString("kstidStyleLevelAdvanced"))
            {
                Options.ShowStyleLevelSetting = Options.StyleLevel.Advanced;
            }
            else if (s == DlgResources.ResourceString("kstidStyleLevelExpert"))
            {
                Options.ShowStyleLevelSetting = Options.StyleLevel.Expert;
            }

            Options.ShowUserDefinedStylesSetting = chkShowUserDefined.Checked;

            // Save values to the registry for the "General" tab.
            FwApp app = FwApp.App;

            app.AutoStartLibronix                     = m_chkStartLibronixWithTE.Checked;
            Options.ShowImportBackupSetting           = m_chkDisplayBackupReminder.Checked;
            FwRegistrySettings.MeasurementUnitSetting = m_cboMeasurement.SelectedIndex;

            string sNewUserWs = m_userInterfaceChooser.NewUserWs;

            if (Options.UserInterfaceWritingSystem != sNewUserWs)
            {
                CultureInfo ci = MiscUtils.GetCultureForWs(sNewUserWs);
                if (ci != null)
                {
                    FormLanguageSwitchSingleton.Instance.ChangeCurrentThreadUICulture(ci);
                    FormLanguageSwitchSingleton.Instance.ChangeLanguage(this);
                    Options.UserInterfaceWritingSystem = sNewUserWs;
                }
            }

            // Save values to the registry for the "Advanced" tab.
            bool backupDirExists = ConfirmBackupDirectoryExists(m_textBoxBackupPath.Text, true);

            // Only set the directory if it already exists or could be created.
            if (backupDirExists && FwApp.App != null)
            {
                FwRegistrySettings.BackupDirectorySetting = m_textBoxBackupPath.Text;
            }

            // Use the following code block to set registry values for experimental features.
            // Currently, there are no experimental features that can be turned on/off through the
            // Tools/Options dialog.
#if DEBUG
            Options.UseVerticalDraftView = m_cboExperimentalFeatures.GetItemChecked(kVerticalDraftView);
#endif
            Options.UseInterlinearBackTranslation = m_cboExperimentalFeatures.GetItemChecked(kInterlinearBackTranslation);
            Options.UseXhtmlExport = m_cboExperimentalFeatures.GetItemChecked(kXhtmlExport);
            Options.AddErrorReportingInfo();

            if (Options.UseInterlinearBackTranslation != m_origInterLinearBTValue)
            {
                string msg =
                    "You have changed the setting for enabling or disabling the" + Environment.NewLine +
                    "Experimental feature for Segmented Back Translation. For this" + Environment.NewLine +
                    "change to take effect, you must restart Translation Editor.";

                MessageBox.Show(this, msg, Application.ProductName,
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #15
0
            /// <summary>
            /// Initializes the variables.
            /// </summary>
            public void Init()
            {
                if (TeRegistryKey != null)
                {
                    return;
                }

                TeRegistryKey = FwRegistryHelper.FieldWorksRegistryKey.CreateSubKey(FwSubKey.TE);
                ShowMarkerlessIconsSetting       = new RegistryBoolSetting(TeRegistryKey, "FootnoteShowMarkerlessIcons", true);
                ShowEmptyParagraphPromptsSetting = new RegistryBoolSetting(TeRegistryKey, "ShowEmptyParagraphPrompts", true);
                ShowFormatMarksSetting           = new RegistryBoolSetting(TeRegistryKey, "ShowFormatMarks", false);
                UserInterfaceLanguage            = new RegistryStringSetting(FwRegistryHelper.FieldWorksRegistryKey,
                                                                             FwRegistryHelper.UserLocaleValueName, MiscUtils.CurrentUICulture);
                UseVerticalDraftView          = new RegistryBoolSetting(TeRegistryKey, "UseVerticalDraftView", false);
                UseInterlinearBackTranslation = new RegistryBoolSetting(TeRegistryKey, "UseInterlinearBackTranslation", false);
                UseXhtmlExport                      = new RegistryBoolSetting(TeRegistryKey, "UseXhtmlExport", false);
                ShowTranslateUnsQuestions           = new RegistryBoolSetting(TeRegistryKey, "ShowTranslateUnsQuestions", false);
                FootnoteSynchronousScrollingSetting = new RegistryBoolSetting(TeRegistryKey, "FootnoteSynchronousScrolling", true);
                ShowTheseStylesSetting              = new RegistryStringSetting(TeRegistryKey, "ShowTheseStyles", "all");
                ShowStyleLevelSetting               = new RegistryStringSetting(TeRegistryKey, "ShowStyleLevel", DlgResources.ResourceString("kstidStyleLevelBasic"));
                ShowUserDefinedStylesSetting        = new RegistryBoolSetting(TeRegistryKey, "ShowUserDefinedStyles", true);
                AutoStartLibronix                   = new RegistryBoolSetting(TeRegistryKey, "AutoStartLibronix", false);
                //UseEnableSendReceiveSyncMsgs = new RegistryBoolSetting(FwSubKey.TE, "UseSendReceiveSyncMsgs", false);
            }
Example #16
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="ToolsOptionsDialog"/> class.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public ToolsOptionsDialog()
        {
            InitializeComponent();

            // Get registry settings for the "Draft View" tab of the dialog.
            m_chkPromptEmptyParas.Checked        = Options.ShowEmptyParagraphPromptsSetting;
            m_chkMarkerlessFootnoteIcons.Checked = Options.ShowMarkerlessIconsSetting;
            m_chkShowFormatMarks.Checked         = Options.ShowFormatMarksSetting;
            m_chkSynchFootnoteScroll.Checked     = Options.FootnoteSynchronousScrollingSetting;
            m_rdoPromptForNewWs.Checked          = Options.ShowPasteWsChoice;
            m_rdoUseOnlyWSsInThisProj.Checked    = !m_rdoPromptForNewWs.Checked;

            // Load strings and get registry settings for the "Styles" tab of the dialog.
            // check the radio button for the "show these styles" buttons
            switch (Options.ShowTheseStylesSetting)
            {
            case Options.ShowTheseStyles.All:
                rdoAllStyles.Checked = true;
                break;

            case Options.ShowTheseStyles.Basic:
                rdoBasicStyles.Checked = true;
                break;

            case Options.ShowTheseStyles.Custom:
                rdoCustomList.Checked = true;
                break;
            }
            // enable/disable the custom style controls
            rdoCustomList_CheckedChanged(rdoCustomList, null);
            // add style levels for Styles tab
            cboStyleLevel.Items.Add(DlgResources.ResourceString("kstidStyleLevelBasic"));
            cboStyleLevel.Items.Add(DlgResources.ResourceString("kstidStyleLevelIntermediate"));
            cboStyleLevel.Items.Add(DlgResources.ResourceString("kstidStyleLevelAdvanced"));
            cboStyleLevel.Items.Add(DlgResources.ResourceString("kstidStyleLevelExpert"));
            // set the style level combo box selection
            switch (Options.ShowStyleLevelSetting)
            {
            case Options.StyleLevel.Basic:
                cboStyleLevel.SelectedIndex = 0;
                break;

            case Options.StyleLevel.Intermediate:
                cboStyleLevel.SelectedIndex = 1;
                break;

            case Options.StyleLevel.Advanced:
                cboStyleLevel.SelectedIndex = 2;
                break;

            case Options.StyleLevel.Expert:
                cboStyleLevel.SelectedIndex = 3;
                break;
            }
            chkShowUserDefined.Checked = Options.ShowUserDefinedStylesSetting;

            // Get registry settings for the "General" tab of the dialog.
            FwApp app = FwApp.App;

            m_chkStartLibronixWithTE.Checked   = app.AutoStartLibronix;
            m_chkDisplayBackupReminder.Checked = Options.ShowImportBackupSetting;
            m_cboMeasurement.SelectedIndex     = FwRegistrySettings.MeasurementUnitSetting;

            // Get registry settings for the "Advanced" tab of the dialog.
            // set the default backup directory
            if (FwApp.App != null)
            {
                m_textBoxBackupPath.Text = FwRegistrySettings.BackupDirectorySetting;
            }
            m_userInterfaceChooser.Init(Options.UserInterfaceWritingSystem);

            // Use the following code block to set the checked values for experimental features.
            // Currently, there are no experimental features that can be turned on/off through the
            // Tools/Options dialog.
#if DEBUG
            m_cboExperimentalFeatures.SetItemChecked(kVerticalDraftView, Options.UseVerticalDraftView);
#endif
            m_origInterLinearBTValue = Options.UseInterlinearBackTranslation;
            m_cboExperimentalFeatures.SetItemChecked(kInterlinearBackTranslation, m_origInterLinearBTValue);
            m_cboExperimentalFeatures.SetItemChecked(kXhtmlExport, Options.UseXhtmlExport);
#if !DEBUG
            m_cboExperimentalFeatures.Items.RemoveAt(kVerticalDraftView);
#endif
            // Execute this block if there are no experimental features (or none we want the user to see in a release build).
            //{
            //    m_cboExperimentalFeatures.Visible = false;
            //    m_lblNoTestFeatures.Visible = true;
            //}
        }
Example #17
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="FilterBookDialog"/> class.
 /// </summary>
 /// <param name="cache">The cache.</param>
 /// <param name="bookList">A list of books to check as an array</param>
 /// <param name="helpTopicProvider">The help topic provider.</param>
 /// ------------------------------------------------------------------------------------
 public FilterBookDialog(FdoCache cache, IScrBook[] bookList, IHelpTopicProvider helpTopicProvider)
     : base(cache, bookList, helpTopicProvider)
 {
     m_helpTopicId = "khtpBookFilter";
     Text          = DlgResources.ResourceString("kstidBookFilterCaption");
 }
Example #18
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Handle the View Differences button. Display the Review Differences window to
        /// view/merge differences between the current scripture and selected book in the tree.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void m_btnDiff_Click(object sender, System.EventArgs e)
        {
            // If the selected item is not a book, then don't do a diff.
            TreeNode node = m_treeArchives.SelectedNode;

            if (node == null)
            {
                return;
            }

            IScrBook bookRev = (IScrBook)node.Tag;

            if (bookRev == null)
            {
                return;
            }

            using (BookMerger merger = new BookMerger(m_cache, m_styleSheet, bookRev))
            {
                using (ProgressDialogWithTask progress = new ProgressDialogWithTask(this, m_cache.ThreadHelper))
                {
                    progress.Title   = DlgResources.ResourceString("kstidCompareCaption");
                    progress.Message = string.Format(
                        DlgResources.ResourceString("kstidMergeProgress"), bookRev.BestUIName);
                    progress.RunTask(merger.DetectDifferences);
                }

                int cUnfilteredDifferences = merger.NumberOfDifferences;

                // always hide diffs that could cause deletion of current sections, if reverted
                merger.UseFilteredDiffList = true;

                bool fShowCompareAndMergeDlg = (merger.NumberOfDifferences != 0);
                if (!fShowCompareAndMergeDlg && cUnfilteredDifferences > 0)
                {
                    // Tell users that no differences were found in the merge
                    if (MessageBox.Show(this,
                                        string.Format(DlgResources.ResourceString("kstidOnlyAdditionsDetected"), bookRev.BestUIName),
                                        m_app.ApplicationName, MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        fShowCompareAndMergeDlg    = true;
                        merger.UseFilteredDiffList = false;
                    }
                }

                // If there were differences detected then show the diff dialog
                if (fShowCompareAndMergeDlg)
                {
                    using (DiffDialog dlg = new DiffDialog(merger, m_cache, m_styleSheet, m_zoomDraft,
                                                           m_zoomFootnote, m_app, m_helpTopicProvider))
                    {
                        // We have to pass the owner (this), so that the dialog shows when the
                        // user clicks on the TE icon in the taskbar. Otherwise only the Archive
                        // dialog would pop up and beeps; diff dialog could only be regained by Alt-Tab.
                        dlg.ShowDialog(this);
                    }
                }
                else if (cUnfilteredDifferences == 0)
                {
                    // Tell users that no differences were found in the merge
                    MessageBoxUtils.Show(this,
                                         string.Format(DlgResources.ResourceString("kstidNoDifferencesDetected"), bookRev.BestUIName),
                                         m_app.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Example #19
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="ExportXmlDialog"/> class.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public ExportXmlDialog(FdoCache cache, FilteredScrBooks filter, ScrReference refBook,
                               IVwStylesheet stylesheet, FileType exportType)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();
            m_scr         = cache.LangProject.TranslatedScriptureOA;
            m_eExportType = exportType;
            string key;

            switch (m_eExportType)
            {
            case FileType.OXES:
                key = "ExportFolderForXML";
                break;

            case FileType.XHTML:
                Text = TeResourceHelper.GetResourceString("kstidExportXHTML");                         // "Export XHTML"
                key  = "ExportFolderForXhtml";
                break;

            case FileType.ODT:
                Text = TeResourceHelper.GetResourceString("kstidExportODT");                         // "Export Open Office file"
                key  = "ExportFolderForXhtml";
                break;

            case FileType.PDF:
                Text = TeResourceHelper.GetResourceString("kstidExportPDF");                         // "Export Adobe Portable Document"
                key  = "ExportFolderForXhtml";
                break;

            default:
                key = "ExportFolderForXML";
                break;
            }
            m_xmlFolder = new RegistryStringSetting(FwSubKey.TE, cache.ServerName,
                                                    cache.DatabaseName, key, Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
            string fileName = m_xmlFolder.Value;

            m_fileDialog = new TeImportExportFileDialog(cache, m_eExportType);

            // Append a filename if it was set to just a directory
            if (Directory.Exists(fileName))
            {
                fileName = Path.Combine(fileName, m_fileDialog.DefaultFileName);
            }
            m_txtOutputFile.Text = fileName;
            // Ensure that the end of the filename is visible.
            m_txtOutputFile.Select(fileName.Length, 0);

            FillFilterListLabel(filter);

            // Set the single book from the current one in use if possible, otherwise set
            // it from the first available book, if any are available.
            if (refBook == null)
            {
                refBook          = new ScrReference();
                refBook.BBCCCVVV = 1001001;
                if (m_scr.ScriptureBooksOS.Count > 0)
                {
                    refBook.Book = m_scr.ScriptureBooksOS[0].CanonicalNum;
                }
            }

            m_scrBook.Initialize(refBook, m_scr as Scripture, true);
            m_scrBook.PassageChanged += m_scrBook_PassageChanged;

            // Initialize the combo boxes, and then adjust their heights (and the locations
            // of following controls) as needed.
            m_oldComboHeight = cboFrom.Height;
            m_gap            = cboTo.Top - cboFrom.Bottom;
            FwStyleSheet ss = stylesheet as FwStyleSheet;

            m_fntVern    = new Font(ss.GetNormalFontFaceName(cache, cache.DefaultVernWs), 10);
            cboFrom.Font = cboTo.Font = m_fntVern;

            // Now that the sizes are fixed, load the combo box lists.
            LoadSectionsForBook(refBook.Book);

            m_nBookForSections = refBook.Book;
            m_sRangeBookFmt    = m_grpSectionRange.Text;
            UpdateBookSectionGroupLabel();

            //m_scrBook.Enabled = false;
            //m_grpSectionRange.Enabled = false;
            m_grpSectionRange.Visible = true;

            // Initialize the description.
            DateTime now = DateTime.Now;

            // "{0} exported by {1} on {2} {3}, {4} at {5}"
            m_txtDescription.Text = String.Format(DlgResources.ResourceString("kstidOxesExportDescription"),
                                                  cache.LangProject.Name.BestAnalysisVernacularAlternative.Text,
                                                  System.Security.Principal.WindowsIdentity.GetCurrent().Name.Normalize(),
                                                  now.ToString("MMMM"), now.Day, now.Year, now.ToShortTimeString());

            // TODO: Set export type from the stored registry setting.
        }