/// ------------------------------------------------------------------------------------
        /// <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">true to release both managed and unmanaged resources; false to release only unmanaged resources.</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)
        {
            System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType() + ". ****** ");

            if (disposing)
            {
                Application.RemoveMessageFilter(this);

                if (m_list != null)
                {
                    m_list.Clear();
                }

                if (m_dataGridView != null && !m_dataGridView.Disposing)
                {
                    m_dataGridView.Dispose();
                }

                if (m_zoomFactor != null)
                {
                    m_zoomFactor.Dispose();
                }
            }

            m_tsStrComparer = null;
            m_dataGridView  = null;
            m_list          = null;
            m_zoomFactor    = null;

            base.Dispose(disposing);
        }
Ejemplo n.º 2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected override void Dispose(bool disposing)
        {
            // Must not be run more than once.
            if (IsDisposed)
            {
                return;
            }

            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
                var disposable = m_vc as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
                if (m_zoomFactor != null)
                {
                    m_zoomFactor.Dispose();
                }
            }
            m_vc         = null;
            m_zoomFactor = null;
            base.Dispose(disposing);
        }
Ejemplo n.º 3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="T:DraftViewWrapper"/> class.
        /// </summary>
        /// <param name="name">The name of the split grid</param>
        /// <param name="parent">The parent of the split wrapper (can be null). Will be replaced
        /// with real parent later.</param>
        /// <param name="cache">The cache.</param>
        /// <param name="styleSheet">The style sheet.</param>
        /// <param name="settingsRegKey">The settings reg key.</param>
        /// <param name="draftView">The vernacular Scripture draft view proxy.</param>
        /// <param name="stylebar">The Scripture stylebar proxy.</param>
        /// <param name="btDraftView">The BT Scripture draft view proxy.</param>
        /// <param name="footnoteDraftView">The vernacular footnote draft view proxy.</param>
        /// <param name="footnoteStylebar">The footnote stylebar proxy.</param>
        /// <param name="footnoteBtDraftView">The BT footnote draft view proxy.</param>
        /// ------------------------------------------------------------------------------------
        internal BtDraftSplitWrapper(string name, Control parent, FdoCache cache,
                                     IVwStylesheet styleSheet, RegistryKey settingsRegKey, TeScrDraftViewProxy draftView,
                                     DraftStylebarProxy stylebar, TeScrDraftViewProxy btDraftView,
                                     TeFootnoteDraftViewProxy footnoteDraftView, DraftStylebarProxy footnoteStylebar,
                                     TeFootnoteDraftViewProxy footnoteBtDraftView)
            : base(name, parent, cache, styleSheet, settingsRegKey, draftView, stylebar,
                   footnoteDraftView, footnoteStylebar, 2, 3)
        {
            m_settingsRegKey = settingsRegKey;

            IRootSiteGroup group = GetGroup(kDraftRow, kDraftViewColumn);

            AddControl(group, kDraftRow, kBackTransColumn, btDraftView, true,
                       !ChangeSides);

            group = GetGroup(kFootnoteRow, kDraftViewColumn);
            AddControl(group, kFootnoteRow, kBackTransColumn, footnoteBtDraftView, false,
                       !ChangeSides);

            DataGridViewControlColumn frontTransColumn = GetColumn(kDraftViewColumn);

            frontTransColumn.FillWeight    = 100;
            frontTransColumn.MaxPercentage = 0.9f;
            frontTransColumn.MinimumWidth  = 60;
            frontTransColumn.IsCollapsible = false;
            frontTransColumn.Visible       = true;

            DataGridViewControlColumn backTransColumn = GetColumn(kBackTransColumn);

            backTransColumn.FillWeight    = 100;
            backTransColumn.MaxPercentage = 0.9f;
            backTransColumn.MinimumWidth  = 60;
            backTransColumn.IsCollapsible = false;
            backTransColumn.Visible       = true;

            // Now set up a persistence object for loading. This will be disposed automatically
            // when we dispose m_Container.
            m_Container = new FwContainer();
            Persistence persistence = new Persistence(m_Container, this);

            persistence.LoadSettings += new Persistence.Settings(OnLoadSettings);

            // Retrieve the parent's Persistence service. We use that for saving rather then
            // our own because otherwise some things like the FDO cache might already be disposed
            // when we try to save the settings.
            if (parent.Site != null)
            {
                persistence = (Persistence)parent.Site.GetService(typeof(Persistence));
                if (persistence != null)
                {
                    persistence.SaveSettings += new Persistence.Settings(OnSaveSettings);
                }
            }

            m_leftPaneWeight  = new RegistryFloatSetting(settingsRegKey, Name + "LeftPaneWeight", -1.0f);
            m_rightPaneWeight = new RegistryFloatSetting(settingsRegKey, Name + "RightPaneWeight", -1.0f);
        }
Ejemplo n.º 4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Called to load settings.
        /// </summary>
        /// <param name="key">The key.</param>
        /// ------------------------------------------------------------------------------------
        public virtual void OnLoadSettings(RegistryKey key)
        {
            CheckDisposed();
            m_firstPanePct = new RegistryFloatSetting(SettingsKey,
                                                      Name + "FirstPanePercentage", m_desiredFirstPanePercentage);

            if (m_firstPanePct.Value > 0 && m_firstPanePct.Value <= 1)
            {
                DesiredFirstPanePercentage = m_firstPanePct.Value;
                SplitterDistance           = (int)(m_firstPanePct.Value *
                                                   ((Orientation == Orientation.Horizontal) ? Height : Width));
            }
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected virtual void OnLoadSettings(RegistryKey key)
        {
            if (m_dataGridView != null && key != null)
            {
                m_dataGridView.TMAdapter = (m_mainWnd == null ? null : m_mainWnd.TMAdapter);

                if (m_zoomFactor != null)
                {
                    m_zoomFactor.Dispose();
                }
                m_zoomFactor = new RegistryFloatSetting(key, "ZoomFactor" + Name, 1.5f);
                ChangeZoomPercent(1.0f, ZoomFactor);
            }

            // Set the display order of columns.
            SetColOrderFromReg(key);

            // Keep track of each time the grid changes sizes until its width is at its
            // maximum. When that happens, then set the widths of each column from values
            // read from the registry.
            m_dataGridView.SizeChanged -= HandleRenderingGridSizeChanged;
            m_dataGridView.SizeChanged += HandleRenderingGridSizeChanged;
        }
Ejemplo n.º 6
0
		internal BtDraftSplitWrapper(string name, Control parent, FdoCache cache,
			IVwStylesheet styleSheet, RegistryKey settingsRegKey, TeScrDraftViewProxy draftView,
			DraftStylebarProxy stylebar, TeScrDraftViewProxy btDraftView,
			TeFootnoteDraftViewProxy footnoteDraftView, DraftStylebarProxy footnoteStylebar,
			TeFootnoteDraftViewProxy footnoteBtDraftView)
			: base(name, parent, cache, styleSheet, settingsRegKey, draftView, stylebar,
			footnoteDraftView, footnoteStylebar, 2, 3)
		{
			m_settingsRegKey = settingsRegKey;

			IRootSiteGroup group = GetGroup(kDraftRow, kDraftViewColumn);
			AddControl(group, kDraftRow, kBackTransColumn, btDraftView, true,
				!ChangeSides);

			group = GetGroup(kFootnoteRow, kDraftViewColumn);
			AddControl(group, kFootnoteRow, kBackTransColumn, footnoteBtDraftView, false,
				!ChangeSides);

			DataGridViewControlColumn frontTransColumn = GetColumn(kDraftViewColumn);
			frontTransColumn.FillWeight = 100;
			frontTransColumn.MaxPercentage = 0.9f;
			frontTransColumn.MinimumWidth = 60;
			frontTransColumn.IsCollapsible = false;
			frontTransColumn.Visible = true;

			DataGridViewControlColumn backTransColumn = GetColumn(kBackTransColumn);
			backTransColumn.FillWeight = 100;
			backTransColumn.MaxPercentage = 0.9f;
			backTransColumn.MinimumWidth = 60;
			backTransColumn.IsCollapsible = false;
			backTransColumn.Visible = true;

			// Now set up a persistence object for loading. This will be disposed automatically
			// when we dispose m_Container.
			m_Container = new FwContainer();
			Persistence persistence = new Persistence(m_Container, this);
			persistence.LoadSettings += new Persistence.Settings(OnLoadSettings);

			// Retrieve the parent's Persistence service. We use that for saving rather then
			// our own because otherwise some things like the FDO cache might already be disposed
			// when we try to save the settings.
			if (parent.Site != null)
			{
				persistence = (Persistence)parent.Site.GetService(typeof(Persistence));
				if (persistence != null)
					persistence.SaveSettings += new Persistence.Settings(OnSaveSettings);
			}

			m_leftPaneWeight = new RegistryFloatSetting(settingsRegKey, Name + "LeftPaneWeight", -1.0f);
			m_rightPaneWeight = new RegistryFloatSetting(settingsRegKey, Name + "RightPaneWeight", -1.0f);
		}
Ejemplo n.º 7
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected virtual void OnLoadSettings(RegistryKey key)
		{
			if (m_dataGridView != null && key != null)
			{
				m_dataGridView.TMAdapter = (m_mainWnd == null ? null : m_mainWnd.TMAdapter);

				if (m_zoomFactor != null)
					m_zoomFactor.Dispose();
				m_zoomFactor = new RegistryFloatSetting(key, "ZoomFactor" + Name, 1.5f);
				ChangeZoomPercent(1.0f, ZoomFactor);
			}

			// Set the display order of columns.
			SetColOrderFromReg(key);

			// Keep track of each time the grid changes sizes until its width is at its
			// maximum. When that happens, then set the widths of each column from values
			// read from the registry.
			m_dataGridView.SizeChanged -= HandleRenderingGridSizeChanged;
			m_dataGridView.SizeChanged += HandleRenderingGridSizeChanged;
		}
Ejemplo n.º 8
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">true to release both managed and unmanaged resources; false to release only unmanaged resources.</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)
		{
			System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType() + ". ****** ");

			if (disposing)
			{
				Application.RemoveMessageFilter(this);

				if (m_list != null)
					m_list.Clear();

				if (m_dataGridView != null && !m_dataGridView.Disposing)
					m_dataGridView.Dispose();

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

			m_tsStrComparer = null;
			m_dataGridView = null;
			m_list = null;
			m_zoomFactor = null;

			base.Dispose(disposing);
		}
Ejemplo n.º 9
0
		///-------------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// <param name="key">Location in the registry</param>
		///-------------------------------------------------------------------------------------
		protected virtual void OnLoadSettings(RegistryKey key)
		{
			CheckDisposed();
			m_zoomFactor = new RegistryFloatSetting(key, "ZoomFactor" + Name, 1.5f);
			Zoom = m_zoomFactor.Value;
		}
Ejemplo n.º 10
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected override void Dispose(bool disposing)
		{
			// Must not be run more than once.
			if (IsDisposed)
				return;

			if (disposing)
			{
				if (components != null)
					components.Dispose();
				var disposable = m_vc as IDisposable;
				if (disposable != null)
					disposable.Dispose();
				if (m_zoomFactor != null)
					m_zoomFactor.Dispose();
			}
			m_vc = null;
			m_zoomFactor = null;
			base.Dispose(disposing);
		}
Ejemplo n.º 11
0
 ///-------------------------------------------------------------------------------------
 /// <summary>
 ///
 /// </summary>
 /// <param name="key">Location in the registry</param>
 ///-------------------------------------------------------------------------------------
 protected virtual void OnLoadSettings(RegistryKey key)
 {
     CheckDisposed();
     m_zoomFactor = new RegistryFloatSetting(key, "ZoomFactor" + Name, 1.5f);
     Zoom         = m_zoomFactor.Value;
 }
Ejemplo n.º 12
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Called to load settings.
		/// </summary>
		/// <param name="key">The key.</param>
		/// ------------------------------------------------------------------------------------
		public virtual void OnLoadSettings(RegistryKey key)
		{
			CheckDisposed();
			m_firstPanePct = new RegistryFloatSetting(SettingsKey,
					Name + "FirstPanePercentage", m_desiredFirstPanePercentage);

			if (m_firstPanePct.Value > 0 && m_firstPanePct.Value <= 1)
			{
				DesiredFirstPanePercentage = m_firstPanePct.Value;
				SplitterDistance = (int)(m_firstPanePct.Value *
					((Orientation == Orientation.Horizontal) ? Height : Width));
			}
		}
Ejemplo n.º 13
0
		/// ------------------------------------------------------------------------------------
		/// <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);
		}
Ejemplo n.º 14
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)
			{
				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);
		}
Ejemplo n.º 15
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="DiffDialog"/> class.
		/// </summary>
		/// <param name="bookMerger">The book merger.</param>
		/// <param name="cache">The cache.</param>
		/// <param name="stylesheet">The stylesheet.</param>
		/// <param name="zoomFactorDraft">The zoom percentage to be used for the "draft" (i.e.,
		/// main Scripture) view</param>
		/// <param name="zoomFactorFootnote">The zoom percentage to be used for the "footnote"
		/// view</param>
		/// <param name="fDoCollapseUndo">true if we want to collapse to a single Undo item on close.</param>
		/// <param name="app">The app.</param>
		/// <param name="helpTopicProvider">The help topic provider.</param>
		/// ------------------------------------------------------------------------------------
		public DiffDialog(BookMerger bookMerger, FdoCache cache, IVwStylesheet stylesheet,
			float zoomFactorDraft, float zoomFactorFootnote, bool fDoCollapseUndo, IApp app,
			IHelpTopicProvider helpTopicProvider)
		{
			Debug.Assert(cache != null);
			m_viewHelper = new ActiveViewHelper(this);
			m_fDoCollapseUndo = fDoCollapseUndo;
			m_app = app;
			m_helpTopicProvider = helpTopicProvider;

			// Required for Windows Form Designer support
			InitializeComponent();

			// just as fallback in case the Designer replaced FwContainer with Container
			// in InitializeComponent()...
			if (!(components is FwContainer))
				components = new FwContainer(components);

			// the last column of the table layout manager in the last row should have the
			// width of the scroll bar
			TableLayoutPanel tablePanel = tableLayoutPanel.GetControlFromPosition(0, 3)
				as TableLayoutPanel;
			tablePanel.ColumnStyles[3].Width = SystemInformation.VerticalScrollBarWidth -
				SystemInformation.FixedFrameBorderSize.Width;
			tablePanel = tableLayoutPanel.GetControlFromPosition(1, 3)
							as TableLayoutPanel;
			tablePanel.ColumnStyles[3].Width = SystemInformation.VerticalScrollBarWidth -
				SystemInformation.FixedFrameBorderSize.Width;

			m_msgMediator = new Mediator();
			m_msgMediator.AddColleague(this);
			components.Add(m_msgMediator);

			m_bookMerger = bookMerger;
			m_differences = bookMerger.Differences;
			m_cache = cache;
			m_scr = m_cache.LangProject.TranslatedScriptureOA;
			m_stylesheet = stylesheet;
			ZoomFactorDraft = new RegistryFloatSetting(SettingsKey, "ZoomFactorDiffDialogDraft", zoomFactorDraft);
			ZoomFactorFootnote = new RegistryFloatSetting(SettingsKey, "ZoomFactorDiffDialogFootnote", zoomFactorFootnote);

			// Don't start out in edit mode
			m_editMode = false;

			// If the diff is a comparison of the current against a normal saved version, then
			// change the label text.
			IScrDraft draft = (IScrDraft)m_bookMerger.BookRev.Owner;
			if (draft.Type == ScrDraftType.SavedVersion)
			{
				lblSavedVersion.Text = string.Format(TeDiffViewResources.kstidSavedVersion,
					draft.Description);
			}
			else
				lblSavedVersion.Text = string.Format(lblSavedVersion.Text, draft.Description);

			CreateUndoMark();
		}