Esempio n. 1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Do required initializations
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected virtual void Init()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			if (Cache != null)
			{
				m_bookFilterEnabled = new RegistryBoolSetting(FwSubKey.TE, Cache.ServerName,
					Cache.DatabaseName, "BookFilterEnabled", false);
				m_filtersKey = new RegistryStringSetting(FwSubKey.TE, Cache.ServerName,
					Cache.DatabaseName, "BookFilterBooks", string.Empty);

				m_bookFilter = new FilteredScrBooks(Cache, Handle.ToInt32());
				m_bookFilter.FilterChanged += BookFilterChanged;
				m_bookFilter.SetSavedFilterFromString(m_filtersKey.Value);

				ILgWritingSystemFactory lgwsf = Cache.LanguageWritingSystemFactoryAccessor;
				m_defaultBackTranslationWs = -1;
				RegistryStringSetting regDefBtWs = GetBtWsRegistrySetting(String.Empty);
				if (!String.IsNullOrEmpty(regDefBtWs.Value))
					m_defaultBackTranslationWs = lgwsf.GetWsFromStr(regDefBtWs.Value);
				if (m_defaultBackTranslationWs <= 0)
					m_defaultBackTranslationWs = Cache.DefaultAnalWs;
			}
			else
			{
				// Not sure if this is necessary, but just to avoid possible problems in tests...
				m_bookFilterEnabled = new RegistryBoolSetting(FwSubKey.TE, "TestBookFilterEnabled", false);
				m_filtersKey = new RegistryStringSetting(FwSubKey.TE, "TestBookFilterBooks", string.Empty);
			}

			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),
				(Scripture)m_scr, true);

			UpdateCaptionBar();

			MaxStyleLevel = ToolsOptionsDialog.MaxStyleLevel;

			// We need to store this in a variable so that it can be removed for notification
			m_changeWatcher = new BookChangeWatcher(this);
		}
Esempio n. 2
0
		/// <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)
			{
				// Dispose managed resources here.
				Application.RemoveMessageFilter(this);
				// KeyTermsViewWrapper gets disposed when base class disposes ClientWindows
				if (m_gotoRefCtrl != null && m_gotoRefCtrl.Parent == null)
					m_gotoRefCtrl.Dispose();
				if (m_changeWatcher != null)
					m_changeWatcher.Dispose();
				if (m_scrDraftView != null && (m_scrDraftView as Control).Parent == null && m_scrDraftView is IDisposable)
					(m_scrDraftView as IDisposable).Dispose();
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			m_gotoRefCtrl = null;
			m_changeWatcher = null;
			m_scrDraftView = null;

			base.Dispose(disposing);
		}