Exemple #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Show or hide the footnote view.
        /// </summary>
        /// <param name="footnote">Footnote to scroll to or <c>null</c> to just display or hide
        /// the footnote view. If a footnote is given the footnote view will always be shown.</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>
        /// ------------------------------------------------------------------------------------
        internal virtual void ShowOrHideFootnoteView(StFootnote footnote, bool fPutInsertionPtAtEnd)
        {
            CheckDisposed();

            //toggle
            bool fShow = !m_grid.Rows[kFootnoteRow].Visible || footnote != null;

            // Prevent painting while we possibly expand lazy boxes
            ((IRootSite)this).AllowPainting = false;
            try
            {
                // show or hide the footnote view
                m_grid.Rows[kFootnoteRow].Visible = fShow;
            }
            finally
            {
                ((IRootSite)this).AllowPainting = true;
            }

            if (fShow && FootnoteView != null)
            {
                if (footnote != null)
                {
                    FootnoteView.ScrollToFootnote(footnote, fPutInsertionPtAtEnd);
                }

                FootnoteView.Focus();
            }
        }
Exemple #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Method to create the view when needed
        /// </summary>
        /// <param name="host">The control that will host (or "wrap") the view (can be
        /// <c>null</c>)</param>
        /// <returns>The created view</returns>
        /// ------------------------------------------------------------------------------------
        public override Control CreateView(Control host)
        {
            ViewWrapper  wrapper      = (ViewWrapper)host;
            FootnoteView footnoteView = new FootnoteView(m_mainWnd.Cache,
                                                         m_mainWnd.Handle.ToInt32(), m_mainWnd.App, m_name, m_editable, m_viewType,
                                                         GetBtWs(wrapper), wrapper.DraftView);

            m_mainWnd.RegisterFocusableView(footnoteView);
            return(footnoteView);
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Show the footnote view.
        /// </summary>
        /// <param name="footnote">Footnote to scroll to or null to just display the footnote view</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>
        /// ------------------------------------------------------------------------------------
        internal override void ShowOrHideFootnoteView(StFootnote footnote, bool fPutInsertionPtAtEnd)
        {
            CheckDisposed();

            bool fBtActivated = IsBtActivated;

            if (!FootnoteViewShowing)
            {
                base.ShowOrHideFootnoteView(footnote, fPutInsertionPtAtEnd);
            }
            else if (footnote != null)
            {
                FootnoteView footnoteView = (FootnoteView)GetControl(kFootnoteRow,
                                                                     fBtActivated ? kBackTransColumn : kDraftViewColumn);
                footnoteView.ScrollToFootnote(footnote, fPutInsertionPtAtEnd);
            }

            SetFocus(fBtActivated);
        }
Exemple #4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Show or hide the footnote view.
        /// </summary>
        /// <param name="footnote">Footnote to scroll to or <c>null</c> to just display or hide
        /// the footnote view. If a footnote is given the footnote view will always be shown.</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>
        /// ------------------------------------------------------------------------------------
        internal virtual void ShowOrHideFootnoteView(IStFootnote footnote, bool fPutInsertionPtAtEnd)
        {
            CheckDisposed();

            // toggle the footnote view on or off
            bool fShow = !m_grid.Rows[kFootnoteRow].Visible || footnote != null;

            // Prevent painting while we possibly expand lazy boxes
            ((IRootSite)this).AllowPainting = false;
            try
            {
                // show or hide the footnote view
                m_grid.Rows[kFootnoteRow].Visible = fShow;
#if __MonoCS__
                // FWNX-360: work around mono datagridview differences
                //
                // TODO-Linux: write a datagridview test case a submit a bug report to mono
                // on mono after setting m_grid.Rows[kFootnoteRow].Visible to false
                // GetControl(kFootnoteRow, kDraftViewColumn) still returns true.
                // Also on mono Setting the last Row visiblity to false doesn't causes
                // the grid to expand to cover the space.
                // explicity changing it height works around this.

                FootnoteView.Visible             = fShow;     // set the Actual Control Visibilty.
                m_grid.Rows[kFootnoteRow].Height = m_grid.Rows[kFootnoteRow].Height - 1;
                m_grid.Rows[kFootnoteRow].Height = m_grid.Rows[kFootnoteRow].Height + 1;
#endif
            }
            finally
            {
                ((IRootSite)this).AllowPainting = true;
            }

            if (fShow && FootnoteView != null)
            {
                if (footnote != null)
                {
                    FootnoteView.ScrollToFootnote(footnote, fPutInsertionPtAtEnd);
                }

                FootnoteView.Focus();
            }
        }
Exemple #5
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Connect each BT view to its corresponding main view.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.ControlEventArgs"/> that
        /// contains the event data.</param>
        /// ------------------------------------------------------------------------------------
        protected override void OnControlAdded(ControlEventArgs e)
        {
            base.OnControlAdded(e);
            if (e.Control is DataGridView)
            {
                e.Control.ControlAdded += DataGridView_ControlAdded;
            }

            if (e.Control is DraftView)
            {
                DraftView view = (DraftView)e.Control;
                if (view.IsBackTranslation)
                {
                    m_mainBtView = view;
                }
                else
                {
                    m_mainDraftView = view;
                }
                if (m_mainBtView != null && m_mainDraftView != null)
                {
                    m_mainBtView.VernacularDraftView = m_mainDraftView;
                }
            }
            else if (e.Control is FootnoteView)
            {
                FootnoteView ftView = (FootnoteView)e.Control;
                if (ftView.IsBackTranslation)
                {
                    m_ftBtView = ftView;
                }
                else
                {
                    m_ftDraftView = ftView;
                }
                if (m_ftBtView != null && m_ftDraftView != null)
                {
                    m_ftBtView.VernacularDraftView = m_ftDraftView;
                }
            }
        }
Exemple #6
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Method to create the view when needed
		/// </summary>
		/// <param name="host">The control that will host (or "wrap") the view (can be
		/// <c>null</c>)</param>
		/// <returns>The created view</returns>
		/// ------------------------------------------------------------------------------------
		public override Control CreateView(Control host)
		{
			ViewWrapper wrapper = (ViewWrapper)host;
			FootnoteView footnoteView = new FootnoteView(m_mainWnd.Cache,
				m_mainWnd.Handle.ToInt32(), m_mainWnd.App, m_name, m_editable, m_viewType,
				GetBtWs(wrapper), wrapper.DraftView);
			m_mainWnd.RegisterFocusableView(footnoteView);
			return footnoteView;
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Connect each BT view to its corresponding main view.
		/// </summary>
		/// <param name="e">A <see cref="T:System.Windows.Forms.ControlEventArgs"/> that
		/// contains the event data.</param>
		/// ------------------------------------------------------------------------------------
		protected override void OnControlAdded(ControlEventArgs e)
		{
			base.OnControlAdded(e);
			if (e.Control is DataGridView)
				e.Control.ControlAdded += DataGridView_ControlAdded;

			if (e.Control is DraftView)
			{
				DraftView view = (DraftView)e.Control;
				if (view.IsBackTranslation)
					m_mainBtView = view;
				else
					m_mainDraftView = view;
				if (m_mainBtView != null && m_mainDraftView != null)
					m_mainBtView.VernacularDraftView = m_mainDraftView;
			}
			else if (e.Control is FootnoteView)
			{
				FootnoteView ftView = (FootnoteView)e.Control;
				if (ftView.IsBackTranslation)
					m_ftBtView = ftView;
				else
					m_ftDraftView = ftView;
				if (m_ftBtView != null && m_ftDraftView != null)
					m_ftBtView.VernacularDraftView = m_ftDraftView;
			}
		}
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Sets up the specifed SelectionHelper for the specified paragraph and StText.
        /// </summary>
        /// <param name="helper">The SelectionHelper.</param>
        /// <param name="text">The StText.</param>
        /// <param name="para">The para.</param>
        /// <param name="limit">The limit.</param>
        /// <param name="view">The view</param>
        /// ------------------------------------------------------------------------------------
        private void SetupSelectionFor(SelectionHelper helper, IStText text, IStTxtPara para,
                                       SelectionHelper.SelLimitType limit, FwRootSite view)
        {
            Debug.Assert((view is DraftView && ((DraftView)view).TeEditingHelper != null) ||
                         (view is FootnoteView && ((FootnoteView)view).EditingHelper != null));

            helper.SetTextPropId(limit, StTxtParaTags.kflidContents);

            if (view is DraftView)
            {
                DraftView draftView = (DraftView)view;

                if ((text.OwningFlid == ScrSectionTags.kflidContent ||
                     text.OwningFlid == ScrSectionTags.kflidHeading))
                {
                    // text belongs to section heading or contents
                    IScrSection section = (IScrSection)text.Owner;
                    Debug.Assert(section.OwningFlid == ScrBookTags.kflidSections);

                    helper.SetNumberOfLevels(limit, 4);
                    SelLevInfo[] info = helper.GetLevelInfo(limit);
                    info[0].ihvo = para.IndexInOwner;
                    info[0].tag  = StTextTags.kflidParagraphs;
                    info[1].ihvo = 0;
                    info[1].tag  = text.OwningFlid;
                    info[2].ihvo = section.IndexInOwner;
                    info[2].tag  = ScrBookTags.kflidSections;
                    info[3].ihvo = draftView.TeEditingHelper.BookFilter.GetBookIndex((IScrBook)section.Owner);
                    info[3].tag  = draftView.TeEditingHelper.BookFilter.Tag;
                }
                else
                {
                    // text belongs to a book title
                    Debug.Assert(text.OwningFlid == ScrBookTags.kflidTitle);
                    IScrBook book = (IScrBook)text.Owner;

                    helper.SetNumberOfLevels(limit, 3);
                    SelLevInfo[] info = helper.GetLevelInfo(limit);
                    info[0].ihvo = para.IndexInOwner;
                    info[0].tag  = StTextTags.kflidParagraphs;
                    info[1].ihvo = 0;
                    info[1].tag  = text.OwningFlid;
                    info[2].ihvo = draftView.TeEditingHelper.BookFilter.GetBookIndex(book);
                    info[2].tag  = draftView.TeEditingHelper.BookFilter.Tag;
                }
            }
            else if (view is FootnoteView && text.OwningFlid == ScrBookTags.kflidFootnotes)
            {
                // text belongs to a footnote
                FootnoteView footnoteView = (FootnoteView)view;
                IStFootnote  footnote     = (IStFootnote)para.Owner;
                IScrBook     book         = (IScrBook)text.Owner;

                helper.SetNumberOfLevels(limit, 3);
                SelLevInfo[] info = helper.GetLevelInfo(limit);
                info[0].hvo  = text.Hvo;
                info[0].tag  = StTextTags.kflidParagraphs;
                info[1].hvo  = footnote.Hvo;
                info[1].ihvo = footnote.IndexInOwner;
                info[1].tag  = ScrBookTags.kflidFootnotes;
                info[2].hvo  = book.Hvo;
                info[2].ihvo = footnoteView.BookFilter.GetBookIndex(book);
                info[2].tag  = footnoteView.BookFilter.Tag;
                info[0].ich  = info[1].ich = info[2].ich = -1;
            }
        }
Exemple #9
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Setups the specifed SelectionHelper for the specified paragraph and StText.
        /// </summary>
        /// <param name="helper">The SelectionHelper.</param>
        /// <param name="text">The StText.</param>
        /// <param name="para">The para.</param>
        /// <param name="limit">The limit.</param>
        /// <param name="view">The view</param>
        /// ------------------------------------------------------------------------------------
        private void SetupSelectionFor(SelectionHelper helper, StText text, StTxtPara para,
                                       SelectionHelper.SelLimitType limit, FwRootSite view)
        {
            Debug.Assert((view is DraftView && ((DraftView)view).TeEditingHelper != null) ||
                         (view is FootnoteView && ((FootnoteView)view).EditingHelper != null));
            if (view is DraftView)
            {
                DraftView draftView = (DraftView)view;

                if ((text.OwningFlid == (int)ScrSection.ScrSectionTags.kflidContent ||
                     text.OwningFlid == (int)ScrSection.ScrSectionTags.kflidHeading))
                {
                    // text belongs to section heading or contents
                    ScrSection section = new ScrSection(m_fdoCache, text.OwnerHVO);
                    Debug.Assert(section.OwningFlid == (int)ScrBook.ScrBookTags.kflidSections);

                    helper.SetNumberOfLevels(limit, 4);
                    SelLevInfo[] info = helper.GetLevelInfo(limit);
                    info[0].ihvo = para.IndexInOwner;
                    info[0].tag  = (int)StText.StTextTags.kflidParagraphs;
                    info[1].ihvo = text.IndexInOwner;
                    info[1].tag  = text.OwningFlid;
                    info[2].ihvo = section.IndexInBook;
                    info[2].tag  = (int)ScrBook.ScrBookTags.kflidSections;
                    info[3].ihvo = draftView.TeEditingHelper.BookFilter.GetBookIndex(section.OwnerHVO);
                    info[3].tag  = draftView.TeEditingHelper.BookFilter.Tag;
                    helper.SetLevelInfo(SelectionHelper.SelLimitType.End, info);
                }
                else
                {
                    // text belongs to a book title
                    Debug.Assert(text.OwningFlid == (int)ScrBook.ScrBookTags.kflidTitle);
                    ScrBook book = new ScrBook(m_fdoCache, text.OwnerHVO);

                    helper.SetNumberOfLevels(limit, 3);
                    SelLevInfo[] info = helper.GetLevelInfo(limit);
                    info[0].ihvo = para.IndexInOwner;
                    info[0].tag  = (int)StText.StTextTags.kflidParagraphs;
                    info[1].ihvo = text.IndexInOwner;
                    info[1].tag  = text.OwningFlid;
                    info[2].ihvo = draftView.TeEditingHelper.BookFilter.GetBookIndex(book.Hvo);
                    info[2].tag  = draftView.TeEditingHelper.BookFilter.Tag;
                    helper.SetLevelInfo(SelectionHelper.SelLimitType.End, info);
                }
            }
            else if (view is FootnoteView && text.OwningFlid == (int)ScrBook.ScrBookTags.kflidFootnotes)
            {
                // text belongs to a footnote
                FootnoteView footnoteView = (FootnoteView)view;
                StFootnote   footnote     = new StFootnote(m_fdoCache, para.OwnerHVO);
                ScrBook      book         = new ScrBook(m_fdoCache, text.OwnerHVO);

                helper.SetNumberOfLevels(limit, 3);
                SelLevInfo[] info = helper.GetLevelInfo(limit);
                info[0].hvo  = text.Hvo;
                info[0].tag  = (int)StText.StTextTags.kflidParagraphs;
                info[1].hvo  = footnote.Hvo;
                info[1].ihvo = footnote.IndexInOwner;
                info[1].tag  = (int)ScrBook.ScrBookTags.kflidFootnotes;
                info[2].hvo  = book.Hvo;
                info[2].ihvo = footnoteView.BookFilter.GetBookIndex(book.Hvo);
                info[2].tag  = footnoteView.BookFilter.Tag;
                info[0].ich  = info[1].ich = info[2].ich = -1;
                helper.SetLevelInfo(SelectionHelper.SelLimitType.End, info);
            }
        }
Exemple #10
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Creates the footnote view.
		/// </summary>
		/// <param name="createInfo">The create info.</param>
		/// <param name="wrapper">The wrapper.</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		private Control CreateFootnoteView(object createInfo, ViewWrapper wrapper)
		{
			FootnoteCreateInfo fnInfo = (FootnoteCreateInfo)createInfo;
			FootnoteView footnoteView = new FootnoteView(m_cache, Handle.ToInt32(), wrapper.DraftView,
				fnInfo.IsBackTrans ? GetBackTranslationWsForView(wrapper.Name) : -1);
			footnoteView.Name = fnInfo.Name;
			footnoteView.LostFocus += ViewLostFocus;
			footnoteView.GotFocus += ViewGotFocus;
			footnoteView.Editable = fnInfo.IsEditable;
			return footnoteView;
		}