コード例 #1
0
ファイル: TeEditingHelper.cs プロジェクト: sillsdev/WorldPad
		/// <summary>
		/// Executes in two distinct scenarios.
		///
		/// 1. If disposing is true, the method has been called directly
		/// or indirectly by a user's code via the Dispose method.
		/// Both managed and unmanaged resources can be disposed.
		///
		/// 2. If disposing is false, the method has been called by the
		/// runtime from inside the finalizer and you should not reference (access)
		/// other managed objects, as they already have been garbage collected.
		/// Only unmanaged resources can be disposed.
		/// </summary>
		/// <param name="disposing"></param>
		/// <remarks>
		/// If any exceptions are thrown, that is fine.
		/// If the method is being done in a finalizer, it will be ignored.
		/// If it is thrown by client code calling Dispose,
		/// it needs to be handled by fixing the bug.
		///
		/// If subclasses override this method, they should call the base implementation.
		/// </remarks>
		protected override void Dispose(bool disposing)
		{
			//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
			// Must not be run more than once.
			if (IsDisposed)
			{
				Debug.Assert(m_cpe == null);
				return;
			}

			if (disposing)
			{
				// Log disposing event - removed logging as part of fix for TE-6551
				//string message = "Disposing TeEditingHelper...\n" +
				//    "Stack Trace:\n" + Environment.StackTrace;
				//SIL.Utils.Logger.WriteEvent(message);

				// Dispose managed resources here.
				if (m_InsertVerseMessageFilter != null)
					Application.RemoveMessageFilter(m_InsertVerseMessageFilter);

				if (m_syncHandler != null)
				{
					m_syncHandler.ReferenceChanged -= ScrollToReference;
					m_syncHandler.AnnotationChanged -= ScrollToCitedText;
					m_syncHandler.Dispose();
				}

				if (m_annotationAdjuster != null)
					m_annotationAdjuster.Dispose();
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			PasteFixTssEvent -= RemoveHardFormatting;
			m_syncHandler = null;
			m_scr = null;
			m_bookFilter = null;
			m_InsertVerseMessageFilter = null;
			m_restoreCursor = null;
			m_lastFootnoteTextRepSelection = null;
			m_oldReference = null;
			if (m_cpe != null)
			{
				if (Marshal.IsComObject(m_cpe))
					Marshal.ReleaseComObject(m_cpe);
				m_cpe = null;
			}
			m_annotationAdjuster = null;
			base.Dispose(disposing);
		}
コード例 #2
0
ファイル: TeEditingHelper.cs プロジェクト: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="TeEditingHelper"/> class.
		/// </summary>
		/// <param name="callbacks">The callbacks.</param>
		/// <param name="cache">The cache.</param>
		/// <param name="filterInstance">The filter instance.</param>
		/// <param name="viewType">Type of the view.</param>
		/// ------------------------------------------------------------------------------------
		public TeEditingHelper(IEditingCallbacks callbacks, FdoCache cache, int filterInstance,
			TeViewType viewType) : base(cache, callbacks)
		{
			CanDoRtL = true;
			if (m_cache != null)
				m_scr = m_cache.LangProject.TranslatedScriptureOA;

			m_viewType = viewType;
			m_filterInstance = filterInstance;
			m_projectSettings = TeProjectSettings.LoadSettings(cache);
			m_annotationAdjuster = new AnnotationAdjuster(cache, this);
			PasteFixTssEvent += RemoveHardFormatting;
			m_syncHandler = new FocusMessageHandling(this);
		}
コード例 #3
0
ファイル: TeMainWnd.cs プロジェクト: sillsdev/FieldWorks
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Do required initializations
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected virtual void Init()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			if (m_cache != null)
			{
				m_lp = m_cache.LangProject;
				m_scr = m_lp.TranslatedScriptureOA;
				m_scr.BooksChanged += BooksChanged;

				m_bookFilter = Cache.ServiceLocator.GetInstance<IFilteredScrBookRepository>().GetFilterInstance(Handle.ToInt32());
				m_bookFilter.FilterChanged += BookFilterChanged;
				m_bookFilter.SetSavedFilterFromString(TeProjectSettings.BookFilterBooks);

				ILgWritingSystemFactory lgwsf = Cache.LanguageWritingSystemFactoryAccessor;
				m_defaultBackTranslationWs = -1;
				using (RegistryStringSetting regDefBtWs = GetBtWsRegistrySetting(String.Empty))
				{
					if (!String.IsNullOrEmpty(regDefBtWs.Value))
						m_defaultBackTranslationWs = lgwsf.GetWsFromStr(regDefBtWs.Value);
					if (m_defaultBackTranslationWs <= 0)
						m_defaultBackTranslationWs = Cache.DefaultAnalWs;
				}
			}
			Application.AddMessageFilter(this);

			if (TMAdapter != null)
				InitializeInsertBookMenus(); // must do after menus are created in InitializeComponent()

			if (DesignMode)
				return;
			SetupSideBarInfoBar();

			Debug.Assert(m_scr != null);
			// Initialize the scripture passage control object.
			GotoReferenceControl.Initialize(ScrReference.StartOfBible(m_scr.Versification));

			UpdateCaptionBar();

			MaxStyleLevel = ToolsOptionsDialog.MaxStyleLevel;

			m_syncHandler = new FocusMessageHandling(this);
			m_draftViewZoomSettingAlternate = new RegistryFloatSetting(MainWndSettingsKey,
				"ZoomFactor" + kDraftViewName, 1.5f);
			m_footnoteViewZoomSettingAlternate = new RegistryFloatSetting(MainWndSettingsKey,
				"ZoomFactor" + kDraftFootnoteViewName, 1.5f);
		}
コード例 #4
0
ファイル: NotesMainWnd.cs プロジェクト: sillsdev/FieldWorks
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		/// <param name="disposing"></param>
		/// ------------------------------------------------------------------------------------
		protected override void Dispose(bool disposing)
		{
			if (m_beingDisposed || IsDisposed)
				return;

			if (disposing)
			{
				// Need to make sure we set this flag back to false! (TE-4856)
				Debug.Assert(m_cache != null && m_cache.ActionHandlerAccessor != null);
				m_cache.ActionHandlerAccessor.CreateMarkIfNeeded(false);
				if (m_syncHandler != null)
				{
					m_syncHandler.ReferenceChanged -= ScrollToReference;
					m_syncHandler.ScrEditingLocationChanged -= ScrollToScrEditingLocation;
				}

				m_syncHandler = null;
			}

			base.Dispose(disposing);
		}
コード例 #5
0
ファイル: TeMainWnd.cs プロジェクト: sillsdev/FieldWorks
		/// <summary>
		/// Executes in two distinct scenarios.
		///
		/// 1. If disposing is true, the method has been called directly
		/// or indirectly by a user's code via the Dispose method.
		/// Both managed and unmanaged resources can be disposed.
		///
		/// 2. If disposing is false, the method has been called by the
		/// runtime from inside the finalizer and you should not reference (access)
		/// other managed objects, as they already have been garbage collected.
		/// Only unmanaged resources can be disposed.
		/// </summary>
		/// <param name="disposing"></param>
		/// <remarks>
		/// If any exceptions are thrown, that is fine.
		/// If the method is being done in a finalizer, it will be ignored.
		/// If it is thrown by client code calling Dispose,
		/// it needs to be handled by fixing the bug.
		///
		/// If subclasses override this method, they should call the base implementation.
		/// </remarks>
		protected override void Dispose(bool disposing)
		{
			//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
			// Must not be run more than once.
			if (IsDisposed || Disposing)
				return;

			if (disposing)
			{
				if (m_scr != null)
					m_scr.BooksChanged -= BooksChanged;

				// Dispose managed resources here.
				Application.RemoveMessageFilter(this);
				// KeyTermsViewWrapper gets disposed when base class disposes m_rgClientViews
				if (m_gotoRefCtrl != null && m_gotoRefCtrl.Parent == null)
					m_gotoRefCtrl.Dispose();

				if (m_syncHandler != null)
				{
					m_syncHandler.ReferenceChanged -= ScrollToReference;
					m_syncHandler.AnnotationChanged -= ScrollToCitedText;
					m_syncHandler.Dispose();
				}

				if (m_bookFilter != null)
					m_bookFilter.FilterChanged -= BookFilterChanged;

				if (m_draftViewZoomSettingAlternate != null)
					m_draftViewZoomSettingAlternate.Dispose();

				if (m_footnoteViewZoomSettingAlternate != null)
					m_footnoteViewZoomSettingAlternate.Dispose();
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			m_gotoRefCtrl = null;
			m_syncHandler = null;
			m_viewThatLostFocus = null;
			m_bookFilter = null;
			m_lp = null;
			m_scr = null;
			m_draftViewZoomSettingAlternate = null;
			m_footnoteViewZoomSettingAlternate = null;

			base.Dispose(disposing);
		}