コード例 #1
0
ファイル: FootnoteView.cs プロジェクト: sillsdev/WorldPad
        /// ------------------------------------------------------------------------------------
        /// <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);
        }
コード例 #2
0
ファイル: FootnoteView.cs プロジェクト: sillsdev/WorldPad
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Scrolls the requested footnote to the top of the view
        /// </summary>
        /// <param name="footnote">The target footnote</param>
        /// <param name="fPutInsertionPtAtEnd">if set to <c>true</c> and showing the view,
        /// the insertion point will be put at the end of the footnote text instead of at the
        /// beginning, as would be appropriate in the case of a newly inserted footnote that has
        /// Reference Text. This parameter is ignored if footnote is null.</param>
        /// ------------------------------------------------------------------------------------
        public void ScrollToFootnote(StFootnote footnote, bool fPutInsertionPtAtEnd)
        {
            CheckDisposed();

            // find book owning this footnote
            int     iBook = m_bookFilter.GetBookIndex(footnote.OwnerHVO);
            ScrBook book  = new ScrBook(Cache, footnote.OwnerHVO);

            // find index of this footnote
            int iFootnote = footnote.IndexInOwner;

            // create selection pointing to this footnote
            FootnoteEditingHelper.ScrollToFootnote(iBook, iFootnote, (fPutInsertionPtAtEnd ?
                                                                      ((StTxtPara)footnote.ParagraphsOS[0]).Contents.Length: 0));
        }
コード例 #3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Scrolls the requested footnote to the top of the view
        /// </summary>
        /// <param name="footnote">The target footnote</param>
        /// <param name="fPutInsertionPtAtEnd">if set to <c>true</c> and showing the view,
        /// the insertion point will be put at the end of the footnote text instead of at the
        /// beginning, as would be appropriate in the case of a newly inserted footnote that has
        /// Reference Text. This parameter is ignored if footnote is null.</param>
        /// ------------------------------------------------------------------------------------
        public void ScrollToFootnote(IStFootnote footnote, bool fPutInsertionPtAtEnd)
        {
            CheckDisposed();

            // find book owning this footnote
            int iBook = m_bookFilter.GetBookIndex((IScrBook)footnote.Owner);

            // find index of this footnote
            int iFootnote = footnote.IndexInOwner;

            // create selection pointing to this footnote
            // TODO (FWR-2270): This won't work correctly in BT or segmented BT footnote views whe
            // attempting to put the IP at the end of the footnote.
            FootnoteEditingHelper.ScrollToFootnote(iBook, iFootnote, (fPutInsertionPtAtEnd ?
                                                                      ((IStTxtPara)footnote.ParagraphsOS[0]).Contents.Length: 0));
        }
コード例 #4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Deletes a footnote or footnotes within a text selection.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected void DeleteFootnoteAux()
        {
            SelectionHelper helper = SelectionHelper.Create(this);

            if (helper == null)
            {
                return;                 // Better then crashing :)
            }
            int fnLevel = helper.GetLevelForTag(ScrBookTags.kflidFootnotes);

            if (helper.Selection.IsRange)
            {
                DeleteFootnoteRange(helper);
            }
            else
            {
                // There's no range selection, so delete only one footnote
                IScrFootnote footnote =
                    Cache.ServiceLocator.GetInstance <IScrFootnoteRepository>().GetObject(helper.LevelInfo[fnLevel].hvo);
                ((IScrBook)footnote.Owner).FootnotesOS.Remove(footnote);
            }

            if (RootBox.Height <= 0)
            {
                DraftView.Focus();
            }
            else
            {
                int      iBook     = helper.LevelInfo[fnLevel + 1].ihvo;
                IScrBook 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);
            }
        }