/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Focus got set to the draft view
		/// </summary>
		/// <param name="e">The event data</param>
		/// -----------------------------------------------------------------------------------
		protected override void OnGotFocus(EventArgs e)
		{
			base.OnGotFocus(e);

			// Supposedly, m_ftMonitor should always be null, since it only gets set in OnGetFocus
			// and it gets cleared in OnLostFocus. However there have been odd cases. If we're already
			// tracking a change we don't want to lose it.
			// Enhance JohnT: we don't really need this unless we're doing segment BTs.
			if (m_ftMonitor == null)
			{
				m_ftMonitor = new FreeTransEditMonitor(Cache, BackTranslationWS);
				// Unfortunately, when the main window closes, both our Dispose() method and our OnLostFocus() method
				// get called during the Dispose() of the main window, which is AFTER the FdoCache gets disposed.
				// We need to dispose our FreeTransEditMonitor before the cache is disposed, so we can update the
				// CmTranslation if necessary.
				if (TopLevelControl is Form)
					(TopLevelControl as Form).FormClosing += new FormClosingEventHandler(FormClosing);
			}
			if (m_cmtMonitor == null)
			{
				m_cmtMonitor = new CmTranslationEditMonitor(Cache, BackTranslationWS);
				// Unfortunately, when the main window closes, both our Dispose() method and our OnLostFocus() method
				// get called during the Dispose() of the main window, which is AFTER the FdoCache gets disposed.
				// We need to dispose our FreeTransEditMonitor before the cache is disposed, so we can update the
				// CmTranslation if necessary.
				if (TopLevelControl is Form)
					(TopLevelControl as Form).FormClosing += new FormClosingEventHandler(FormClosing);
			}
		}
		private void DisposeFtMonitor()
		{
			if (m_ftMonitor != null)
			{
				if (TopLevelControl is Form)
					(TopLevelControl as Form).FormClosing -= new FormClosingEventHandler(FormClosing);
				m_ftMonitor.Dispose();
				m_ftMonitor = null;
			}
			if (m_cmtMonitor != null)
			{
				if (TopLevelControl is Form)
					(TopLevelControl as Form).FormClosing -= new FormClosingEventHandler(FormClosing);
				m_cmtMonitor.Dispose();
				m_cmtMonitor = null;
			}
		}
Пример #3
0
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Focus got set to the draft view
		/// </summary>
		/// <param name="e">The event data</param>
		/// -----------------------------------------------------------------------------------
		protected override void OnGotFocus(EventArgs e)
		{
			base.OnGotFocus(e);

			if (DesignMode || !m_fRootboxMade)
				return;

			// Reset the previous selected paragraph value to reset the optimization
			// for scrolling the footnote pane.
			m_prevSelectedParagraph = 0;

			if (m_SelectionHelper != null)
			{
				if (m_SelectionHelper.SetSelection(this) == null)
				{
					// Set selection to beginning of first book if project has any books
					if (BookFilter.BookCount > 0)
						SetInsertionPoint((int)ScrBook.ScrBookTags.kflidTitle, 0, 0);
				}

				m_SelectionHelper = null;
			}
			// Supposedly, m_ftMonitor should always be null, since it only gets set in OnGetFocus
			// and it gets cleared in OnLostFocus. However there have been odd cases. If we're already
			// tracking a change we don't want to lose it.
			if (m_contentType == StVc.ContentTypes.kctSegmentBT && m_ftMonitor == null)
			{
				m_ftMonitor = new FreeTransEditMonitor(Cache, BackTranslationWS);
				// Unfortunately, when the main window closes, both our Dispose() method and our OnLostFocus() method
				// get called during the Dispose() of the main window, which is AFTER the FdoCache gets disposed.
				// We need to dispose our FreeTransEditMonitor before the cache is disposed, so we can update the
				// CmTranslation if necessary.
				if (TopLevelControl is Form)
					(TopLevelControl as Form).FormClosing += new FormClosingEventHandler(DraftView_FormClosing);
			}
			if (m_contentType == StVc.ContentTypes.kctSimpleBT && m_cmtMonitor == null)
			{
				m_cmtMonitor = new CmTranslationEditMonitor(Cache, BackTranslationWS);
				if (TopLevelControl is Form)
					(TopLevelControl as Form).FormClosing += new FormClosingEventHandler(DraftView_FormClosing);
			}

			// A draft view which has focus cannot display selected-segment highlighting.
			if (m_draftViewVc != null)
				m_draftViewVc.SetupOverrides(null, 0, 0, null, null);
		}