Summary description for TeResourceHelper.
Inheritance: SIL.FieldWorks.Resources.ResourceHelper
Example #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="T:KeyTermsControl"/> class.
        /// </summary>
        /// <param name="sCaption">The caption to use when this control is displayed as a
        /// floating window</param>
        /// <param name="sProject">The name of the current project</param>
        /// ------------------------------------------------------------------------------------
        internal KeyTermsControl(string sCaption, string sProject) : base(sCaption, sProject)
        {
            InitializeComponent();

            m_sepShowOnlyAtTop = new ToolStripSeparator();
            m_ToolStrip.Items.Insert(0, m_sepShowOnlyAtTop);

            AddToolStripButton(0, TeResourceHelper.KeyTermFilterImage,
                               TeResourceHelper.GetTmResourceString("kstidApplyFilterToKeyTermsToolTip"));

            m_tbbApplyFilter = m_ToolStrip.Items[0] as ToolStripButton;
            m_ToolStrip.Items.Insert(0, new ToolStripSeparator());

            AddToolStripButton(0, TeResourceHelper.KeyTermNotRenderedImage,
                               TeResourceHelper.GetTmResourceString("kstidVernEqNotAssignedToolTip"));

            m_tbbNotRendered = m_ToolStrip.Items[0] as ToolStripButton;

            AddToolStripButton(0, TeResourceHelper.KeyTermIgnoreRenderingImage,
                               TeResourceHelper.GetTmResourceString("kstidNotRenderedToolTip"));

            m_tbbVernNotAssigned = m_ToolStrip.Items[0] as ToolStripButton;

            AddToolStripButton(0, TeResourceHelper.KeyTermRenderedImage,
                               TeResourceHelper.GetTmResourceString("kstidUseAsVernEqToolTip"));

            m_tbbUseAsVern = m_ToolStrip.Items[0] as ToolStripButton;

            m_ToolStrip.Items.Insert(0, new ToolStripSeparator());
            AddToolStripButton(0, TeResourceHelper.UpdateKeyTermEquivalentsImage,
                               TeResourceHelper.GetTmResourceString("kstidUpdateKeyTermEquivalentsToolTip"));
            m_tbbUpdateKeyTermEquivalents = m_ToolStrip.Items[0] as ToolStripButton;
            m_ToolStrip.ItemClicked      += new ToolStripItemClickedEventHandler(OnItemClicked);
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Shows the category chooser dialog to let the user set the category for the
        /// specified annotation.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void SetAnnotationCategory(IScrScriptureNote ann)
        {
            if (ann == null)
            {
                return;                 // Not much we can do
            }
            m_rootb.DestroySelection();
            string sUndo, sRedo;

            TeResourceHelper.MakeUndoRedoLabels("kstidSetAnnotationCategory", out sUndo, out sRedo);

            using (new WaitCursor(this))
                using (CategoryChooserDlg dlg = new CategoryChooserDlg(m_scr.NoteCategoriesOA,
                                                                       ann.CategoriesRS.ToHvoArray(), m_helpTopicProvider, TheMainWnd.App))
                {
                    if (dlg.ShowDialog(ParentForm) == DialogResult.OK)
                    {
                        using (UndoTaskHelper undoHelper = new UndoTaskHelper(this, sUndo, sRedo))
                        {
                            dlg.GetPossibilities(ann.CategoriesRS);
                            ann.DateModified    = DateTime.Now;
                            undoHelper.RollBack = false;
                        }
                    }
                }
        }
Example #3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Load the Paratext project and enumerator, preparing us to read the data files.
        /// </summary>
        /// <param name="paratextProjectId">3-letter Paratext project ID</param>
        /// <returns>true if the project was loaded, else false</returns>
        /// ------------------------------------------------------------------------------------
        protected virtual void LoadParatextProject(string paratextProjectId)
        {
            try
            {
                m_ptProjectText = ScriptureProvider.MakeScrText(paratextProjectId);
            }
            catch (Exception e)
            {
                // Can't load Paratext project if Paratext is not installed.
                throw new ParatextLoadException(
                          TeResourceHelper.GetResourceString("kstidCheckParatextInstallation"), e);
            }

            try
            {
                // create ref objs of the Paratext lib
                Logger.WriteEvent("Loading Paratext project " + paratextProjectId + " to import from " +
                                  m_settings.StartRef.AsString + " to " + m_settings.EndRef.AsString);

                // Now initialize the TextEnum with the range of Scripture text we want
                m_ptParser   = m_ptProjectText.Parser;
                m_ptCurrBook = ScriptureProvider.MakeVerseRef(m_settings.StartRef.Book, 0, 0);
                ResetParatextState();
            }
            catch (Exception e)
            {
                string msg = string.Format(
                    TeResourceHelper.GetResourceString("kstidParatextProjectLoadFailure"),
                    paratextProjectId);
                throw new ParatextLoadException(msg, e);
            }
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="BookPropertiesDialog"/> class.
        /// </summary>
        /// <param name="book">the current book</param>
        /// <param name="stylesheet">The stylesheet.</param>
        /// <param name="helpTopicProvider">The help topic provider.</param>
        /// ------------------------------------------------------------------------------------
        public BookPropertiesDialog(IScrBook book, IVwStylesheet stylesheet, IHelpTopicProvider helpTopicProvider)
        {
            m_currentBook       = book;
            m_helpTopicProvider = helpTopicProvider;
            // TE-5663: make sure the book's name and abbreviation are updated if some were added
            IScrRefSystem scrRefSystem = book.Cache.ServiceLocator.GetInstance <IScrRefSystemRepository>().AllInstances().FirstOrDefault();

            book.Name.MergeAlternatives(scrRefSystem.BooksOS[book.CanonicalNum - 1].BookName);
            book.Abbrev.MergeAlternatives(scrRefSystem.BooksOS[book.CanonicalNum - 1].BookAbbrev);

            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            // Put the book name in the dialog caption
            Text = string.Format(Text, book.Name.UserDefaultWritingSystem.Text);

            m_listBookInfo.Cache = book.Cache;
            m_listBookInfo.FieldsToDisplay.Add(new FwMultilingualPropView.ColumnInfo(
                                                   ScrBookTags.kflidName, TeResourceHelper.GetResourceString("kstidBookNameColHeader"), 60));
            m_listBookInfo.FieldsToDisplay.Add(new FwMultilingualPropView.ColumnInfo(
                                                   ScrBookTags.kflidAbbrev, TeResourceHelper.GetResourceString("kstidBookAbbrevColHeader"), 40));
            m_listBookInfo.RootObject = book.Hvo;

            foreach (IWritingSystem ws in book.Cache.ServiceLocator.WritingSystems.AllWritingSystems)
            {
                m_listBookInfo.WritingSystemsToDisplay.Add(ws.Handle);
            }

            // Initialize the ID textbox.
            m_txtScrBookIdText.Text = m_currentBook.IdText;
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Throws an exception. Release mode overrides the message.
        /// </summary>
        /// <param name="message">The message to display (in debug mode)</param>
        /// <param name="e">Optional inner exception</param>
        /// ------------------------------------------------------------------------------------
        static protected void ReportInvalidInstallation(string message, Exception e)
        {
#if !DEBUG
            message = TeResourceHelper.GetResourceString("kstidInvalidInstallation");
#endif
            throw new Exception(message, e);
        }
Example #6
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="ExportUsfmDialog"/> class.
        /// </summary>
        /// <param name="cache">database cache</param>
        /// <param name="filter">book filter to display which books we will export</param>
        /// <param name="appKey">location of registry</param>
        /// <param name="markup">type of markup format for export:
        /// Paratext (one domain, non-interleaved) OR Toolbox (optionally interleaved)</param>
        /// ------------------------------------------------------------------------------------
        public ExportUsfmDialog(FdoCache cache, FilteredScrBooks filter, RegistryKey appKey,
                                MarkupType markup) : this()
        {
            m_cache      = cache;
            m_markupType = markup;          // let dialog know if this is for Paratext or Toolbox
            if (appKey != null)             // might be null in tests - in this case derived class has to provide a m_regGroup
            {
                m_regGroup = new RegistryGroup(appKey, "ExportUsfmSettings");
            }

            // Display books and markup labels
            string filtered = (filter.AllBooks ? TeResourceHelper.GetResourceString("kstidExportDlgUnfiltered") :
                               TeResourceHelper.GetResourceString("kstidExportDlgFiltered"));
            string booksToExport = GetExportedBooksStr(filter);

            if (filter.BookCount == 1)
            {
                lblBooks.Text = string.Format(TeResourceHelper.GetResourceString("kstidBooksToExportSingularForm"),
                                              filtered, booksToExport);
            }
            else
            {
                lblBooks.Text = string.Format(lblBooks.Text, filter.BookCount, filtered, booksToExport);
            }
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="T:FilesOverwriteDialog"/> class.
        /// </summary>
        /// <param name="filename">name of the file that may be overwritten</param>
        /// ------------------------------------------------------------------------------------
        public FilesOverwriteDialog(string filename)
        {
            InitializeComponent();

            this.Text        = TeResourceHelper.GetResourceString("kstidApplicationName");
            lblFilename.Text = filename;
        }
Example #8
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Get a string that describes the Scripture passage based on the selection.
        /// </summary>
        /// <param name="tag">The flid of the selected element</param>
        /// <param name="hvoSel">The hvo of the selected element, either a ScrSection (usually)
        /// or ScrBook (if in a title)</param>
        /// <param name="fSimpleFormat">Gets a simple, standardized reference (uses SIL 3-letter
        /// codes and no verse bridges)</param>
        /// <returns>
        /// String that describes the Scripture passage or null if the selection
        /// can't be interpreted as a book and/or section reference.
        /// </returns>
        /// ------------------------------------------------------------------------------------
        public override string GetPassageAsString(int tag, int hvoSel, bool fSimpleFormat)
        {
            CheckDisposed();

            if (m_cache == null)
            {
                return(null);
            }

            string sEditRef = null;             // Title/reference/etc of text being edited in the draft pane

            switch (tag)
            {
            case (int)ScrBook.ScrBookTags.kflidFootnotes:
            {
                ScrBook book = new ScrBook(m_cache, hvoSel, false, false);
                sEditRef = (fSimpleFormat ? (book.BookId + " 0:0") : book.BestUIName);
                break;
            }

            default:
                return(base.GetPassageAsString(tag, hvoSel, fSimpleFormat));
            }

            // Add the back translation writing system info to the output string, if needed
            if (IsBackTranslation)
            {
                LgWritingSystem ws = new LgWritingSystem(m_cache, ViewConstructorWS);
                sEditRef = string.Format(
                    TeResourceHelper.GetResourceString("kstidCaptionInBackTrans"),
                    sEditRef, ws.Name.UserDefaultWritingSystem);
            }

            return(string.IsNullOrEmpty(sEditRef) ? null : sEditRef);
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Deletes a footnote
        /// </summary>
        /// <param name="args"></param>
        /// <returns><c>true</c> if we handle this</returns>
        /// ------------------------------------------------------------------------------------
        protected bool OnDeleteFootnote(object args)
        {
            if (DataUpdateMonitor.IsUpdateInProgress() || !ValidFootnoteSelection)
            {
                return(true);                //discard this event
            }
            string undo;
            string redo;

            TeResourceHelper.MakeUndoRedoLabels("kstidUndoDelFootnote", out undo, out redo);
            using (UndoTaskHelper undoTaskHelper = new UndoTaskHelper(this, undo, redo))
                using (new DataUpdateMonitor(this, "DeleteFootnote"))
                {
                    // Put code to do work in separate method for testing
                    DeleteFootnoteAux();
                    undoTaskHelper.RollBack = false;
                }

            // If there are no more footnotes, then give focus back to the main draft view
            if (RootBox.Height <= 0 && DraftView != null)
            {
                DraftView.Focus();
            }

            return(true);
        }
Example #10
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Called when the user pressed the cancel button on the progress dialog.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void OnCancelPressed(object sender, CancelEventArgs e)
        {
            CheckDisposed();
            Debug.Assert(!m_ctrl.InvokeRequired);

            try
            {
                // pause the import thread, while we ask if they really want to cancel
                m_importer.Pause();
                if (m_importer.PrevBook != null)
                {
                    string sMsg = string.Format(TeResourceHelper.GetResourceString("kstidConfirmStopImport"),
                                                m_importer.PrevBook);

                    if (MessageBox.Show(sMsg, FwUtils.ksTeAppName,
                                        MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                    {
                        // the user does not wish to cancel the import, so cancel the event
                        e.Cancel = true;
                        return;
                    }
                }
                //Display "stopping" message in progress bar
                m_progressDialog.Message  = TeResourceHelper.GetResourceString("kstidStoppingImport");
                m_progressDialog.Position = m_progressDialog.Maximum;
            }
            finally
            {
                // resume the import thread
                m_importer.Resume();
            }
        }
Example #11
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Handles the Click event of the m_btnImport control.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void m_btnImport_Click(object sender, EventArgs e)
        {
            if (!File.Exists(m_tbFilename.Text))
            {
                // "{0} does not exist!"
                string sFmt = TeResourceHelper.GetResourceString("kstidImportXmlNotAFile");
                string sMsg = String.Format(sFmt, m_tbFilename.Text);
                // "Warning"
                string sCaption = TeResourceHelper.GetResourceString("kstidImportXmlWarning");
                MessageBox.Show(sMsg, sCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (VerifyLanguageInOxesFile() && EnsureProperOxesFile())
            {
                string validationErrors = Validator.GetAnyValidationErrors(m_tbFilename.Text);
                if (validationErrors == null)
                {
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    DisplayImportError(SUE_ErrorCode.OxesValidationFailed, null, null, validationErrors);
                }
            }
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Get a string that describes the Scripture passage based on the selection.
        /// </summary>
        /// <param name="tag">The flid of the selected element</param>
        /// <param name="hvoSel">The hvo of the selected element, either a ScrSection (usually)
        /// or ScrBook (if in a title)</param>
        /// <param name="fSimpleFormat">Gets a simple, standardized reference (uses SIL 3-letter
        /// codes and no verse bridges)</param>
        /// <returns>
        /// String that describes the Scripture passage or null if the selection
        /// can't be interpreted as a book and/or section reference.
        /// </returns>
        /// ------------------------------------------------------------------------------------
        public override string GetPassageAsString(int tag, int hvoSel, bool fSimpleFormat)
        {
            CheckDisposed();

            if (m_cache == null)
            {
                return(null);
            }

            string sEditRef = null;             // Title/reference/etc of text being edited in the draft pane

            switch (tag)
            {
            case ScrBookTags.kflidFootnotes:
                IScrBook book =
                    m_cache.ServiceLocator.GetInstance <IScrBookRepository>().GetObject(hvoSel);
                sEditRef = (fSimpleFormat ? (book.BookId + " 0:0") : book.BestUIName);
                break;

            default:
                return(base.GetPassageAsString(tag, hvoSel, fSimpleFormat));
            }

            // Add the back translation writing system info to the output string, if needed
            if (IsBackTranslation)
            {
                IWritingSystem ws = m_cache.ServiceLocator.WritingSystemManager.Get(ViewConstructorWS);

                sEditRef = string.Format(
                    TeResourceHelper.GetResourceString("kstidCaptionInBackTrans"),
                    sEditRef, ws.DisplayLabel);
            }

            return(string.IsNullOrEmpty(sEditRef) ? null : sEditRef);
        }
Example #13
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// When really, truly done with all merging etc, collapse all the things we can Undo
        /// for the import into a single Undo Item.
        /// </summary>
        /// <returns>True if some actions were collapsed, false otherwise</returns>
        /// ------------------------------------------------------------------------------------
        public bool CollapseAllUndoActions()
        {
            string undo;
            string redo;

            TeResourceHelper.MakeUndoRedoLabels("kstidImport", out undo, out redo);
            return(m_cache.DomainDataByFlid.GetActionHandler().CollapseToMark(m_hMark, undo, redo));
        }
Example #14
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// When really, truly done with all merging etc, collapse all the things we can Undo
        /// for the import into a single Undo Item.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public void CollapseAllUndoActions()
        {
            string undo;
            string redo;

            TeResourceHelper.MakeUndoRedoLabels("kstidImport", out undo, out redo);
            m_cache.ActionHandlerAccessor.CollapseToMark(m_hMark, undo, redo);
        }
Example #15
0
 /// <summary>
 /// Shut down the TEResourceHelper Form.
 /// </summary>
 public static void ShutDownTEResourceHelper()
 {
     if (s_form != null)
     {
         s_form.Dispose();
         s_form = null;
     }
 }
Example #16
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Complain if the context is not valid for the tool that is loading the styles.
 /// TE currently allows all but Flex's private context
 /// </summary>
 /// <returns></returns>
 /// ------------------------------------------------------------------------------------
 protected override void ValidateContext(ContextValues context, string styleName)
 {
     if (context == ContextValues.InternalConfigureView)
     {
         ReportInvalidInstallation(String.Format(TeResourceHelper.GetResourceString("ksInvalidStyleContext"),
                                                 styleName, context.ToString(), ResourceFileName));
     }
 }
Example #17
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Throw an exception if the specified context is not valid for the specified paragraph
 /// style. TE overrides to forbid 'general' paragraph styles.
 /// </summary>
 /// <param name="context"></param>
 /// <param name="styleName"></param>
 /// ------------------------------------------------------------------------------------
 protected override void ValidateParagraphContext(ContextValues context, string styleName)
 {
     if (context == ContextValues.General)
     {
         ReportInvalidInstallation(String.Format(TeResourceHelper.GetResourceString("ksInvalidParagraphStyleContext"),
                                                 styleName, context.ToString()));
     }
 }
Example #18
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="SaveVersionDialog"/> class.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public SaveVersionDialog(FdoCache cache, IHelpTopicProvider helpTopicProvider)
        {
            m_cache             = cache;
            m_scr               = m_cache.LangProject.TranslatedScriptureOA;
            m_helpTopicProvider = helpTopicProvider;

            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            if (m_cache == null)
            {
                return;
            }

            m_BooksToSave = new List <IScrBook>();
            m_treeView.BeginUpdate();

            List <TreeNode> otBooks = new List <TreeNode>();
            List <TreeNode> ntBooks = new List <TreeNode>();

            foreach (IScrBook book in m_scr.ScriptureBooksOS)
            {
                TreeNode node = new TreeNode(book.BestUIName);
                node.Tag = book;

                if (book.CanonicalNum < ScriptureTags.kiNtMin)
                {
                    otBooks.Add(node);                     // OT book
                }
                else
                {
                    ntBooks.Add(node);                     // NT book
                }
            }
            TreeNode bibleNode = new TreeNode(TeResourceHelper.GetResourceString("kstidBibleNode"));

            if (otBooks.Count > 0)
            {
                bibleNode.Nodes.Add(new TreeNode(TeResourceHelper.GetResourceString("kstidOtNode"),
                                                 otBooks.ToArray()));
            }
            if (ntBooks.Count > 0)
            {
                bibleNode.Nodes.Add(new TreeNode(TeResourceHelper.GetResourceString("kstidNtNode"),
                                                 ntBooks.ToArray()));
            }

            m_treeView.Nodes.Add(bibleNode);

            // REVIEW: once we have sections we probably don't want to expand below book level
            m_treeView.ExpandAll();
            m_treeView.EndUpdate();
            // update the ok button enabled state
            m_treeView_NodeCheckChanged(null, EventArgs.Empty);
        }
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Update the interleaved labels to reflect the current state of the check boxes.
 /// </summary>
 /// ------------------------------------------------------------------------------------
 private void UpdateInterleavedLabels()
 {
     // If Scripture is checked, then mark back translation as interleaved
     chkBackTranslation.Text = m_defaultBtLabel;
     if (ExportScriptureDomain)
     {
         chkBackTranslation.Text += " " + TeResourceHelper.GetResourceString("kstidExportUSFMInterleavedLabel");
     }
 }
        /// -------------------------------------------------------------------------------------
        /// <summary>
        /// Create publications and header/footer sets (in the DB) from the given XML document.
        /// </summary>
        /// <remarks>tests are able to call this method</remarks>
        /// <param name="progressDlg">Progress dialog</param>
        /// <param name="rootNode">The XmlNode from which to read the publication info</param>
        /// -------------------------------------------------------------------------------------
        protected void SetNamesAndAbbreviations(IProgress progressDlg, XmlNode rootNode)
        {
            IScrRefSystem srs = m_cache.ServiceLocator.GetInstance <IScrRefSystemRepository>().Singleton;

            Debug.Assert(srs != null && srs.BooksOS.Count == BCVRef.LastBook);

            XmlNodeList tagList = rootNode.SelectNodes("/ScrBookRef/writingsystem");

            progressDlg.Minimum  = 0;
            progressDlg.Maximum  = tagList.Count * BCVRef.LastBook;
            progressDlg.Position = 0;
            progressDlg.Title    = TeResourceHelper.GetResourceString("kstidCreatingBookNames");
            ITsStrFactory  tsf = m_cache.TsStrFactory;
            IWritingSystem ws;

            foreach (XmlNode writingSystem in tagList)
            {
                XmlAttributeCollection attributes = writingSystem.Attributes;
                string sWsTag = attributes.GetNamedItem("xml:lang").Value;
                m_cache.ServiceLocator.WritingSystemManager.GetOrSet(sWsTag, out ws);

                XmlNodeList WSBooks = writingSystem.SelectNodes("book");
                foreach (XmlNode book in WSBooks)
                {
                    XmlAttributeCollection bookAttributes = book.Attributes;
                    string sSilBookId = bookAttributes.GetNamedItem("SILBookId").Value;
                    Debug.Assert(sSilBookId != null);
                    int    nCanonicalBookNum = BCVRef.BookToNumber(sSilBookId);
                    string sName             = bookAttributes.GetNamedItem("Name").Value;
                    string sAbbrev           = bookAttributes.GetNamedItem("Abbreviation").Value;
                    string sAltName          = bookAttributes.GetNamedItem("AlternateName").Value;
                    progressDlg.Message = string.Format(
                        TeResourceHelper.GetResourceString("kstidCreatingBookNamesStatusMsg"), sName);
                    progressDlg.Step(0);

                    // check for the book id
                    IScrBookRef bookRef = srs.BooksOS[nCanonicalBookNum - 1];

                    int wsHandle = ws.Handle;
                    if (sName != null)
                    {
                        bookRef.BookName.set_String(wsHandle, tsf.MakeString(sName, wsHandle));
                    }
                    if (sAbbrev != null)
                    {
                        bookRef.BookAbbrev.set_String(wsHandle, tsf.MakeString(sAbbrev, wsHandle));
                    }
                    if (sAltName != null)
                    {
                        bookRef.BookNameAlt.set_String(wsHandle, tsf.MakeString(sAltName, wsHandle));
                    }
                }
            }
            // Finally, update resource version in database.
            SetNewResourceVersion(GetVersion(rootNode));
        }
Example #21
0
        /// <summary>
        /// This must be called before starting import.
        /// </summary>
        public void StartImportingFiles()
        {
            Debug.Assert(m_cache.DomainDataByFlid.GetActionHandler() != null);
            Debug.Assert(m_cache.DomainDataByFlid.GetActionHandler().CurrentDepth == 0);
            m_hMark = m_cache.DomainDataByFlid.GetActionHandler().Mark();
            IActionHandler actionHandler = m_cache.ActionHandlerAccessor;

            actionHandler.BeginUndoTask("Create saved version", "Create saved version");
            m_backupVersion = GetOrCreateVersion(TeResourceHelper.GetResourceString("kstidSavedVersionDescriptionOriginal"));
        }
Example #22
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Deletes a footnote
        /// </summary>
        /// <param name="args"></param>
        /// <returns><c>true</c> if we handle this</returns>
        /// ------------------------------------------------------------------------------------
        protected bool OnDeleteFootnote(object args)
        {
            if (DataUpdateMonitor.IsUpdateInProgress(DataAccess))
            {
                return(true);                //discard this event
            }
            if (!ValidFootnoteSelection)
            {
                return(true);
            }

            string undo;
            string redo;

            TeResourceHelper.MakeUndoRedoLabels("kstidUndoDelFootnote", out undo, out redo);
            using (new UndoTaskHelper(this, undo, redo, false))
                using (new DataUpdateMonitor(this, RootBox.DataAccess, this, "DeleteFootnote"))
                {
                    SelectionHelper helper  = SelectionHelper.Create(this);
                    int             fnLevel = helper.GetLevelForTag((int)ScrBook.ScrBookTags.kflidFootnotes);

                    if (helper.Selection.IsRange)
                    {
                        DeleteFootnoteRange(helper);
                    }
                    else
                    {
                        // There's no range selection, so delete only one footnote
                        ScrFootnote footnote = new ScrFootnote(m_fdoCache, helper.LevelInfo[fnLevel].hvo);
                        ScrFootnote.DeleteFootnoteAndMarker(footnote);
                    }

                    if (RootBox.Height <= 0)
                    {
                        DraftView.Focus();
                    }
                    else
                    {
                        int     iBook     = helper.LevelInfo[fnLevel + 1].ihvo;
                        ScrBook book      = m_bookFilter.GetBook(iBook);
                        int     iFootnote = helper.LevelInfo[fnLevel].ihvo;

                        // If the last footnote in the book was deleted find a footnote to move to
                        if (iFootnote >= book.FootnotesOS.Count)
                        {
                            FindNearestFootnote(ref iBook, ref iFootnote);
                        }

                        FootnoteEditingHelper.ScrollToFootnote(iBook, iFootnote, 0);
                    }
                }

            return(true);
        }
Example #23
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Returns the help urls for each tab on the styles dialog (currently 5 tabs)
        /// </summary>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        public override string[] GetStyleDlgHelpUrls()
        {
            CheckDisposed();

            return(new string[] {
                TeResourceHelper.GetHelpString("khtpTeStylesGeneral"),
                TeResourceHelper.GetHelpString("khtpTeStylesFont"),
                TeResourceHelper.GetHelpString("khtpTeStylesParagraph"),
                TeResourceHelper.GetHelpString("khtpTeStylesBullets"),
                TeResourceHelper.GetHelpString("khtpTeStylesBorder")
            });
        }
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Fills in the versification system combo box
 /// </summary>
 /// ------------------------------------------------------------------------------------
 private void FillVersificationSchemes()
 {
     for (int iVers = 1; iVers <= 6; iVers++)
     {
         ScrVers vers = (ScrVers)iVers;
         m_cboVersification.Items.Add(TeResourceHelper.GetResourceString(
                                          "kstid" + vers.ToString() + "Versification"));
         if (m_scr.Versification == vers)
         {
             m_cboVersification.SelectedIndex = iVers - 1;
         }
     }
 }
Example #25
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Update the existing categories and terms with new localized strings.
        /// </summary>
        /// <param name="dlg">The progress dialog.</param>
        /// <param name="parameters">The parameters: 1) the BiblicalTermsLocalization object
        /// representing the contents of the XML file with the localized strings; 2) The ICU
        /// locale (string).</param>
        /// <returns>always null</returns>
        /// ------------------------------------------------------------------------------------
        protected object UpdateLocalization(IThreadedProgress dlg, params object[] parameters)
        {
            BiblicalTermsLocalization loc = (BiblicalTermsLocalization)parameters[0];
            string locale = (string)parameters[1];

            const int kcStepsToBuildLookupTable = 4;

            dlg.Position = 0;
            dlg.Minimum  = 0;
            dlg.Maximum  = loc.Categories.Count + loc.Terms.Count + kcStepsToBuildLookupTable;
            dlg.Title    = TeResourceHelper.GetResourceString("kstidLoadKeyTermsInDBCaption");
            dlg.Message  = TeResourceHelper.FormatResourceString("kstidLoadKeyTermsLocalizations",
                                                                 m_wsf.get_Engine(locale).LanguageName);

            m_wsDefault = m_servLoc.WritingSystemManager.GetWsFromStr("en");

            int hvoLocWs = loc.WritingSystemHvo = m_wsf.GetWsFromStr(locale);

            IEnumerable <ICmPossibility> categories = ((ILangProject)m_scr.Owner).KeyTermsList.PossibilitiesOS;

            foreach (CategoryLocalization localizedCategory in loc.Categories)
            {
                ICmPossibility category = categories.FirstOrDefault(
                    p => p.Abbreviation.get_String(m_wsDefault).Text == localizedCategory.Id);
                if (category != null)
                {
                    category.Name.set_String(hvoLocWs, localizedCategory.Gloss);
                }
                dlg.Step(1);
            }

            Dictionary <int, IChkTerm> termLookupTable =
                m_servLoc.GetInstance <IChkTermRepository>().AllInstances().ToDictionary(t => t.TermId);

            dlg.Step(kcStepsToBuildLookupTable);

            IChkTerm term;
            string   message = TeResourceHelper.GetResourceString("kstidLoadKeyTermsInDBStatus");

            foreach (TermLocalization localizedTerm in loc.Terms)
            {
                dlg.Message = string.Format(message, localizedTerm.Gloss);

                if (termLookupTable.TryGetValue(localizedTerm.Id, out term))
                {
                    SetLocalizedGlossAndDescription(term, localizedTerm, loc.WritingSystemHvo);
                }
                dlg.Step(1);
            }
            return(null);
        }
Example #26
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Save results when closed.
 /// </summary>
 /// <param name="e">The <see cref="T:System.EventArgs"/> that contains the event data.</param>
 /// ------------------------------------------------------------------------------------
 protected override void OnClosed(EventArgs e)
 {
     if (DialogResult == DialogResult.OK)
     {
         using (new UndoRedoTaskHelper(m_draft.Cache,
                                       TeResourceHelper.GetResourceString("ksUndoDraftProperties"),
                                       TeResourceHelper.GetResourceString("ksRedoDraftProperties")))
         {
             m_draft.Protected   = m_cbProtected.Checked;
             m_draft.Description = m_tbDescription.Text;
         }
     }
     base.OnClosed(e);
 }
Example #27
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Handle the Folder browse button to locate a folder to write to.
 /// </summary>
 /// ------------------------------------------------------------------------------------
 protected virtual void btnFolderBrowse_Click(object sender, System.EventArgs e)
 {
     using (FolderBrowserDialog dlg = new FolderBrowserDialog())
     {
         dlg.SelectedPath        = BaseOutputFolder;
         dlg.Description         = TeResourceHelper.GetResourceString(StidExportDlgFolderBrowserPrompt);
         dlg.ShowNewFolderButton = true;
         if (dlg.ShowDialog() == DialogResult.OK)
         {
             BaseOutputFolder      = dlg.SelectedPath;
             m_fUserModifiedFolder = true;
         }
     }
 }
Example #28
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Handles the NodeMouseClick event of the m_treeArchives control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.Windows.Forms.TreeNodeMouseClickEventArgs"/>
 /// instance containing the event data.</param>
 /// ------------------------------------------------------------------------------------
 private void m_treeArchives_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
 {
     if (e.Button == System.Windows.Forms.MouseButtons.Right)
     {
         TreeNode node = e.Node;
         if (node == null || !(node.Tag is IScrDraft))
         {
             return;
         }
         m_treeArchives.SelectedNode = node;
         ContextMenuStrip menu = new ContextMenuStrip();
         menu.Items.Add(new ToolStripMenuItem(TeResourceHelper.GetResourceString("kstidProperties"), null,
                                              new EventHandler(propertiesClick)));
         menu.Show(m_treeArchives, e.Location);
     }
 }
Example #29
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Save results when closed.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs"/> that contains the event data.</param>
        /// ------------------------------------------------------------------------------------
        protected override void OnClosed(EventArgs e)
        {
            if (DialogResult == DialogResult.OK)
            {
                using (UndoableUnitOfWorkHelper undoHelper = new UndoableUnitOfWorkHelper(
                           m_draft.Cache.ServiceLocator.GetInstance <IActionHandler>(),
                           TeResourceHelper.GetResourceString("ksUndoDraftProperties"),
                           TeResourceHelper.GetResourceString("ksRedoDraftProperties")))
                {
                    m_draft.Protected   = m_cbProtected.Checked;
                    m_draft.Description = m_tbDescription.Text;

                    undoHelper.RollBack = false;
                }
            }
            base.OnClosed(e);
        }
Example #30
0
        /// -------------------------------------------------------------------------------------
        /// <summary>
        /// Perform one-time initialization of a new Scripture project
        /// </summary>
        /// <returns>true if data loaded successfully; false, otherwise</returns>
        /// -------------------------------------------------------------------------------------
        protected bool Initialize(IFwSplashScreen splashScreen)
        {
            ILangProject lp = m_cache.LangProject;

            if (m_scr != null)
            {
                // Preload all book, section and paragraphs if we already have Scripture
                PreloadData(m_cache, splashScreen);

                if (m_scr.BookAnnotationsOS.Count != 0 &&
                    m_cache.ScriptureReferenceSystem.BooksOS.Count != 0 && m_scr.PublicationsOC.Count != 0 &&
                    lp.KeyTermsList.PossibilitiesOS.Count >= 1 &&
                    m_scr.NoteCategoriesOA != null && m_scr.NoteCategoriesOA.PossibilitiesOS.Count > 0)
                {
                    return(true);
                }
            }

            IAdvInd4 existingProgressDlg = null;

            if (splashScreen != null)
            {
                existingProgressDlg = splashScreen.ProgressBar as IAdvInd4;
            }

            using (ProgressDialogWithTask dlg = new ProgressDialogWithTask(Form.ActiveForm))
            {
                try
                {
                    dlg.RunTask(existingProgressDlg, true, new BackgroundTaskInvoker(InitializeScriptureProject));
                }
                catch (WorkerThreadException e)
                {
                    UndoResult ures;
                    while (m_cache.Undo(out ures))
                    {
                        ;                                                // Enhance JohnT: make use of ures?
                    }
                    MessageBox.Show(Form.ActiveForm, e.InnerException.Message,
                                    TeResourceHelper.GetResourceString("kstidApplicationName"),
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
            }
            return(true);
        }
Example #31
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Adds the Scripture/Print layout View
		/// </summary>
		/// <param name="viewName">Name of the resource string for the view.</param>
		/// <param name="viewType">Type of the view.</param>
		/// <param name="pubName">Name of the publication.</param>
		/// <param name="sideBarIndex">Index of the side bar.</param>
		/// <param name="sideBarItemName">Name of the side bar item.</param>
		/// ------------------------------------------------------------------------------------
		protected override void  AddPrintLayoutView(string viewName, TeViewType viewType,
			string pubName, TeResourceHelper.SideBarIndices sideBarIndex,
			string sideBarItemName)
		{
			// We don't want to add anything but Scripture/Draft View.
		}
Example #32
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Adds the Scripture/Print layout View
		/// </summary>
		/// <param name="viewName">Name of the resource string for the view.</param>
		/// <param name="viewType">Type of the view.</param>
		/// <param name="pubName">Name of the publication.</param>
		/// <param name="sideBarIndex">Index of the icon for the view in the side bar.</param>
		/// <param name="sideBarItemName">Name of the side bar item.</param>
		/// ------------------------------------------------------------------------------------
		protected virtual void AddPrintLayoutView(string viewName, TeViewType viewType,
			string pubName, TeResourceHelper.SideBarIndices sideBarIndex, string sideBarItemName)
		{
			// Add this user view to the Scripture sidebar tab.
			SBTabItemProperties itemProps = new SBTabItemProperties(this);
			itemProps.Name = sideBarItemName;
			itemProps.Text = viewName;
			itemProps.ImageIndex = (int)sideBarIndex;
			itemProps.Tag = viewType;
			itemProps.Message = "SwitchActiveView";
			AddSideBarTabItem(kScrSBTabName, itemProps);
			m_uncreatedViews.Add(viewType,
				new TePrintLayoutViewFactory(viewName, viewType, pubName, CreatePrintLayoutView));
		}
Example #33
0
		/// <summary>
		/// Shut down the TEResourceHelper Form.
		/// </summary>
		public static void ShutDownTEResourceHelper()
		{
			if (s_form != null)
			{
				s_form.Dispose();
				s_form = null;
			}
		}