/// <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 virtual void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (m_isDisposed) { return; } m_activeSite = null; if (disposing) { // Dispose managed resources here. if (m_rootControl != null) { DeepRemoveControl(m_rootControl); } if (m_availableSites != null) { m_availableSites.Clear(); } } // Dispose unmanaged resources here, whether disposing is true or false. m_rootControl = null; m_availableSites = null; m_isDisposed = true; }
/// ------------------------------------------------------------------------------------ /// <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().Name + ". ****** "); if (disposing) { // NOTE: don't dispose m_gridControl, m_draftView and m_treeContainer here. // They all got added to a Controls collection and will be disposed when the // base class disposes below. // This should only be null when running tests. if (m_mainWnd != null && m_mainWnd.Mediator != null) { m_mainWnd.Mediator.RemoveColleague(this); } if (m_dockExtender != null) { m_dockExtender.Dispose(); } } m_dockExtender = null; m_draftView = null; m_treeContainer = null; m_gridControl = null; base.Dispose(disposing); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Updates the paragraph style list of the combo box /// </summary> /// <param name="style">the current paragraph style where the IP is</param> /// <param name="view">The currently active view</param> /// ------------------------------------------------------------------------------------ public void RefreshParaStyleComboBoxList(IStStyle style, IRootSite view) { if (m_callbacks.PopulateParaStyleListOverride()) { return; } if (ParaStyleListHelper.ActiveView == view && style != null && m_prevParaStyleContext == style.Context) { return; } ParaStyleListHelper.IncludeStylesWithContext.Clear(); FwEditingHelper editingHelper = view.EditingHelper as FwEditingHelper; if (editingHelper != null && editingHelper.ApplicableStyleContexts != null) { ParaStyleListHelper.IncludeStylesWithContext.AddRange(editingHelper.ApplicableStyleContexts); } else { if (style != null) { ParaStyleListHelper.IncludeStylesWithContext.Add((ContextValues)style.Context); } ParaStyleListHelper.IncludeStylesWithContext.Add(ContextValues.General); } ParaStyleListHelper.Refresh(); ParaStyleListHelper.ActiveView = view as Control; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Updates the character style list of the combo box /// </summary> /// <param name="styleContext">the current Paragraph style context, usually based on /// the selection</param> /// <param name="view">The currently active view</param> /// ------------------------------------------------------------------------------------ private void RefreshCharStyleComboBoxList(ContextValues styleContext, IRootSite view) { CharStyleListHelper.IncludeStylesWithContext.Clear(); FwEditingHelper editingHelper = view.EditingHelper as FwEditingHelper; if (editingHelper != null && editingHelper.ApplicableStyleContexts != null) { CharStyleListHelper.IncludeStylesWithContext.AddRange(editingHelper.ApplicableStyleContexts); } else { CharStyleListHelper.IncludeStylesWithContext.Add(styleContext); if (!CharStyleListHelper.IncludeStylesWithContext.Contains(ContextValues.General)) { CharStyleListHelper.IncludeStylesWithContext.Add(ContextValues.General); } if (editingHelper != null && !CharStyleListHelper.IncludeStylesWithContext.Contains(editingHelper.InternalContext)) { CharStyleListHelper.IncludeStylesWithContext.Add(editingHelper.InternalContext); } } CharStyleListHelper.Refresh(); CharStyleListHelper.ActiveView = view as Control; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Recursively remove handlers for the ControlAdded and GotFocus events of the specified /// control and all its sub-controls. /// </summary> /// <param name="control"></param> /// ------------------------------------------------------------------------------------ private void DeepRemoveControl(Control control) { control.ControlAdded -= new ControlEventHandler(ControlWasAdded); control.ControlRemoved -= new ControlEventHandler(ControlWasRemoved); if (control is IRootSite) { control.GotFocus -= new EventHandler(ViewGotFocus); m_availableSites.Remove((IRootSite)control); if (m_activeSite == control) { m_activeSite = null; } } foreach (Control con in control.Controls) { DeepRemoveControl(con); } if (control is IControl) { foreach (Control con in ((IControl)control).FocusableControls) { DeepRemoveControl(con); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Recursively remove handlers for the ControlAdded and GotFocus events of the specified /// control and all its sub-controls. /// </summary> /// <param name="control"></param> /// ------------------------------------------------------------------------------------ private void DeepRemoveControl(Control control) { control.ControlAdded -= new ControlEventHandler(ControlWasAdded); control.ControlRemoved -= new ControlEventHandler(ControlWasRemoved); if (control is IRootSite) { control.GotFocus -= new EventHandler(ViewGotFocus); m_availableSites.Remove((IRootSite)control); if (m_activeSite == control) { m_activeSite = null; } } foreach (Control childControl in control.Controls) { DeepRemoveControl(childControl); } if (control is IControl) { #if __MonoCS__ // TODO-Linux FWNX-534: work around for mono bug: https://bugzilla.novell.com/show_bug.cgi?id=656701 if (!control.IsDisposed) #endif foreach (Control focusableControl in ((IControl)control).FocusableControls) { DeepRemoveControl(focusableControl); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// This function attempts to determine whether a root site can really be seen /// in the sense that it can reasonably receive commands (such as from the style /// dialog). It doesn't check everything possible; for example, a control could /// be visible in all the ways checked here and still covered by another control /// or scrolled out of sight. /// </summary> /// <param name="site">The rootsite</param> /// <returns></returns> /// ------------------------------------------------------------------------------------ bool IsReallyVisible(IRootSite site) { Control control = site as Control; if (!control.Visible) { return(false); } // Unfortunately the above can somehow still be true for a control that is // part of a disposed window. Check some more things to make sure. if (!control.IsHandleCreated) { return(false); } if (site is IVwRootSite && (site as IVwRootSite).RootBox == null) { return(false); } // Don't do this! It produces a stack overflow because CastAsIVwRootBox // uses ActiveView to try to get a RootSite. //if (site.CastAsIVwRootSite().RootBox == null) // return false; if (control.IsDisposed) { return(false); } // It may be visible along with all its parents, but if the chain doesn't // go up to a form we can't really see it. return(control.TopLevelControl is Form); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes this instance. /// </summary> /// ------------------------------------------------------------------------------------ protected virtual void Initialize() { if (m_fShownBefore) { return; } // Create a FwSplitContainer with two draft views. Control draftView = ControlCreator.Create(this, m_rightView.Tag); draftView.Dock = DockStyle.Fill; m_draftView = draftView as IRootSite; if (draftView is ISelectableView) { ((ISelectableView)draftView).BaseInfoBarCaption = m_baseInfoBarCaption; } // Create a draft view of Scripture in the project. m_rightView.Panel2.Controls.Add(draftView); // Create a view for the list of renderings for the selected key term m_gridControl = CreateGridControl(m_mainWnd); m_gridControl.Dock = DockStyle.Fill; if (m_gridControl is ISelectableView) { ((ISelectableView)m_gridControl).BaseInfoBarCaption = m_baseInfoBarCaption; } if (m_gridControl is IChecksViewWrapperView) { ((IChecksViewWrapperView)m_gridControl).Persistence = m_persistence; } m_rightView.Panel1.Controls.Add(m_gridControl); // Create a key terms control (containing the tool strip and tree). // Subscribe to events so that the enabled status of the tool strip buttons can be updated. m_treeContainer = CreateCheckControl(); m_treeContainer.Dock = DockStyle.Left; if (m_treeContainer is IChecksViewWrapperView) { ((IChecksViewWrapperView)m_treeContainer).Persistence = m_persistence; } Controls.Add(m_treeContainer); m_dockExtender = new DockExtender(this); m_floaty = m_dockExtender.Attach(m_treeContainer, m_treeContainer.ToolStrip, true, m_persistence); m_floaty.DockOnInside = false; // outside m_floaty.HideHandle = false; m_floaty.AllowedDocking = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; m_floaty.ShowCloseButton = false; m_treeContainer.Floaty = m_floaty; m_fShownBefore = true; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Handler for when a view gains focus. This sets the active view to the view that got /// focus. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// ------------------------------------------------------------------------------------ private void ViewGotFocus(object sender, EventArgs e) { var oldActiveView = ActiveView; m_activeSite = sender as IRootSite; if (ActiveView != oldActiveView && ActiveViewChanged != null) { ActiveViewChanged(this, new EventArgs()); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Updates the styles combo boxes on the formatting toolbar, with the correct style name. /// </summary> /// ------------------------------------------------------------------------------------ public void UpdateStyleComboBoxValue(IRootSite rootsite) { // If we don't have a paraStyleListHelper, we can't update the paragraph or // character style combo. if (ParaStyleListHelper == null || rootsite == null || rootsite.EditingHelper == null) { return; } FwEditingHelper fwEditingHelper = rootsite.EditingHelper as FwEditingHelper; if (fwEditingHelper != null && fwEditingHelper.IsPictureReallySelected) { return; } string paraStyleName = rootsite.EditingHelper.GetParaStyleNameFromSelection(); var style = (paraStyleName == string.Empty) ? null : ParaStyleListHelper.StyleFromName(paraStyleName); RefreshParaStyleComboBoxList(style, rootsite); if (ParaStyleListHelper.SelectedStyleName != paraStyleName) { ParaStyleListHelper.SelectedStyleName = paraStyleName; } ContextValues currentContext = (style != null) ? style.Context : (fwEditingHelper != null) ? fwEditingHelper.InternalContext : ContextValues.General; if (CharStyleListHelper != null) { string charStyleName = rootsite.EditingHelper.GetCharStyleNameFromSelection(); if (CharStyleListHelper.ActiveView != rootsite as Control || m_prevParaStyleContext != currentContext || (charStyleName != null && !CharStyleListHelper.Contains(charStyleName)) || (charStyleName == null && m_prevParaStyleContext == ContextValues.Note) || (fwEditingHelper != null && fwEditingHelper.ForceCharStyleComboRefresh)) { RefreshCharStyleComboBoxList(currentContext, rootsite); } if (charStyleName == string.Empty) { charStyleName = StyleUtils.DefaultParaCharsStyleName; } if (charStyleName == null) { charStyleName = string.Empty; } if (CharStyleListHelper.SelectedStyleName != charStyleName) { CharStyleListHelper.SelectedStyleName = charStyleName; } } m_prevParaStyleContext = currentContext; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Determines whether or not the specified view is visible. /// </summary> /// <param name="view"></param> /// <returns></returns> /// ------------------------------------------------------------------------------------ public bool IsViewVisible(IRootSite view) { CheckDisposed(); Control ctrl = view as Control; if (ctrl != null) { return(ctrl.Visible && ctrl.FindForm() != null); } return(false); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="ScriptureProperties"/> class. /// </summary> /// <param name="cache">The cache.</param> /// <param name="styleSheet">The style sheet.</param> /// <param name="rootSite">The active view (or the draft view if the footnote view is /// active).</param> /// <param name="showFootnoteTab">True to show the footnote tab. Otherwise the /// footnote tab will be hidden.</param> /// <param name="helpTopicProvider">The help topic provider.</param> /// ------------------------------------------------------------------------------------ public ScriptureProperties(FdoCache cache, IVwStylesheet styleSheet, IRootSite rootSite, bool showFootnoteTab, IHelpTopicProvider helpTopicProvider) { m_cache = cache; m_helpTopicProvider = helpTopicProvider; m_styleSheet = styleSheet; m_scr = cache.LangProject.TranslatedScriptureOA; m_rootSite = rootSite; // // Required for Windows Form Designer support // InitializeComponent(); if (!showFootnoteTab) { tabControl1.TabPages.Remove(tpgFootnotes); } fpsCrossRefOptions.SiblingPropertiesSelector = fpsFootnoteOptions; fpsFootnoteOptions.SiblingPropertiesSelector = fpsCrossRefOptions; m_fCombineFootnotes = m_scr.CrossRefsCombinedWithFootnotes; opnCombined.Checked = m_fCombineFootnotes; opnSeparate.Checked = !m_fCombineFootnotes; UpdateCombinedFootnotes(); FillScriptLanguages(); FillVersificationSchemes(); UpdateFootnoteTabs(); if (m_scr.UseScriptDigits) { m_btnScriptNumbers.Checked = true; string language = m_baseDigitMap[(char)m_scr.ScriptDigitZero]; m_cboScriptLanguages.SelectedIndex = m_cboScriptLanguages.FindString(language); } else { m_btnLatinNumbers.Checked = true; } // Fill in the reference separator fields to edit m_txtRefSep.Text = m_scr.RefSepr; m_txtChapterVerseSep.Text = m_scr.ChapterVerseSepr; m_txtVerseSep.Text = m_scr.VerseSepr; m_txtVerseBridge.Text = m_scr.Bridge; // Make the option button for footnotes and cross references invisible. fpsFootnoteOptions.ShowSequenceButton = false; fpsCrossRefOptions.ShowSequenceButton = false; }
/// <summary> /// Try to find a WfiWordform object corresponding the the focus selection. /// If successful return its guid, otherwise, return Guid.Empty. /// </summary> /// <returns></returns> internal static Guid ActiveWordform(FdoCache cache, Mediator mediator) { IApp app = mediator.PropertyTable.GetValue("App") as IApp; if (app == null) { return(Guid.Empty); } IFwMainWnd window = app.ActiveMainWindow as IFwMainWnd; if (window == null) { return(Guid.Empty); } IRootSite activeView = window.ActiveView; if (activeView == null) { return(Guid.Empty); } List <IVwRootBox> roots = activeView.AllRootBoxes(); if (roots.Count < 1) { return(Guid.Empty); } SelectionHelper helper = SelectionHelper.Create(roots[0].Site); if (helper == null) { return(Guid.Empty); } ITsString word = helper.SelectedWord; if (word == null || word.Length == 0) { return(Guid.Empty); } #if WANTPORT // FWR-2784 int hvoWordform = cache.LangProject.WordformInventoryOA.GetWordformId(word); if (hvoWordform == 0 || cache.IsDummyObject(hvoWordform)) { return(Guid.Empty); } return(cache.GetGuidFromId(hvoWordform)); #else return(Guid.Empty); #endif }
// /// ------------------------------------------------------------------------------------ // /// <summary> // /// Initializes the component. // /// </summary> // /// ------------------------------------------------------------------------------------ // private void InitializeComponent() // { // this.SuspendLayout(); // // // // SimpleDraftViewWrapper // // // this.AccessibleName = "SimpleDraftViewWrapper"; // this.ResumeLayout(false); // } /// ------------------------------------------------------------------------------------ /// <summary> /// Called when a hosted control has been newly created. We hook into this in order to /// listen for VwSelectionChanged events in the draft view and pass them on to anyone who /// has subscribed to our VwSelectionChanged event. /// </summary> /// ------------------------------------------------------------------------------------ protected override void OnHostedControlCreated(Control c) { IRootSite rootsite = c as IRootSite; if (rootsite != null) { rootsite.EditingHelper.VwSelectionChanged += delegate(object sender, VwSelectionArgs e) { if (VwSelectionChanged != null) { VwSelectionChanged(sender, e); } }; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Add another slave to the synchronization group. /// Note that it is usually also necessary to add it to the Controls collection. /// That isn't done here to give the client more control over when it is done. /// </summary> /// <param name="rootSiteSlave">The slave to add</param> /// ------------------------------------------------------------------------------------ public virtual void AddToSyncGroup(IRootSiteSlave rootSiteSlave) { CheckDisposed(); if (rootSiteSlave == null) { return; } m_slaves.Add(rootSiteSlave); IRootSite rootSite = rootSiteSlave as IRootSite; if (rootSite != null) { rootSite.AllowPainting = AllowPainting; } }
/// <summary> /// Try to find a WfiWordform object corresponding the the focus selection. /// If successful return its guid, otherwise, return Guid.Empty. /// </summary> /// <returns></returns> internal static Guid ActiveWordform(FdoCache cache) { if (!(FwApp.App is FwXApp)) { return(Guid.Empty); } FwXWindow window = (FwApp.App as FwXApp).ActiveMainWindow as FwXWindow; if (window == null) { return(Guid.Empty); } IRootSite activeView = window.ActiveView; if (activeView == null) { return(Guid.Empty); } List <IVwRootBox> roots = activeView.AllRootBoxes(); if (roots.Count < 1) { return(Guid.Empty); } SelectionHelper helper = SelectionHelper.Create(roots[0].Site); if (helper == null) { return(Guid.Empty); } ITsString word = helper.SelectedWord; if (word == null || word.Length == 0) { return(Guid.Empty); } int hvoWordform = cache.LangProject.WordformInventoryOA.GetWordformId(word); if (hvoWordform == 0 || cache.IsDummyObject(hvoWordform)) { return(Guid.Empty); } return(cache.GetGuidFromId(hvoWordform)); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Called when the row height changed. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="T:System.Windows.Forms.DataGridViewRowEventArgs"/> /// instance containing the event data.</param> /// ------------------------------------------------------------------------------------ protected virtual void OnRowHeightChanged(object sender, DataGridViewRowEventArgs e) { if (!e.Row.Visible && m_grid.DisplayedRowCount(false) == 1) { // If the user drags the footnote pane all the way up to the top, we want // to display the draftview instead of the footnote pane if (FootnoteViewShowing) { m_grid.Rows[kFootnoteRow].Visible = false; m_grid.Rows[kDraftRow].Visible = true; } IRootSite rootSite = FocusedRootSite; if (rootSite != null) { ((Control)rootSite).Focus(); if (rootSite.EditingHelper.CurrentSelection == null) { rootSite.CastAsIVwRootSite().RootBox.MakeSimpleSel(true, true, false, true); } } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Handler for when a view gains focus. This sets the active view to the view that got /// focus. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// ------------------------------------------------------------------------------------ private void ViewGotFocus(object sender, EventArgs e) { m_activeSite = sender as IRootSite; }
/// ------------------------------------------------------------------------------------ /// <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) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); if (disposing) { // NOTE: don't dispose m_gridControl, m_draftView and m_treeContainer here. // They all got added to a Controls collection and will be disposed when the // base class disposes below. // This should only be null when running tests. if (m_mainWnd != null && m_mainWnd.Mediator != null) m_mainWnd.Mediator.RemoveColleague(this); } m_draftView = null; m_treeContainer = null; m_gridControl = null; base.Dispose(disposing); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Saves the selection of the view that loses focus /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// ------------------------------------------------------------------------------------ private void ViewLostFocus(object sender, EventArgs e) { IRootSite site = sender as IRootSite; if (site != null) { if (sender is Control && !((Control)sender).Visible) return; IVwRootBox rootBox = site.CastAsIVwRootSite().RootBox; if (rootBox == null) return; CommonSelection = rootBox.Selection; m_viewThatLostFocus = site; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Updates the styles combo boxes on the formatting toolbar, with the correct style name. /// </summary> /// ------------------------------------------------------------------------------------ public void UpdateStyleComboBoxValue(IRootSite rootsite) { CheckDisposed(); m_delegate.UpdateStyleComboBoxValue(rootsite); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes this instance. /// </summary> /// ------------------------------------------------------------------------------------ protected virtual void Initialize() { if (m_fShownBefore) return; // Create a FwSplitContainer with two draft views. Control draftView = ControlCreator.Create(this, m_rightView.Tag); draftView.Dock = DockStyle.Fill; m_draftView = draftView as IRootSite; if (draftView is ISelectableView) ((ISelectableView)draftView).BaseInfoBarCaption = m_baseInfoBarCaption; // Create a draft view of Scripture in the project. m_rightView.Panel2.Controls.Add(draftView); // Create a view for the list of renderings for the selected key term m_gridControl = CreateGridControl(m_mainWnd); m_gridControl.Dock = DockStyle.Fill; if (m_gridControl is ISelectableView) ((ISelectableView)m_gridControl).BaseInfoBarCaption = m_baseInfoBarCaption; if (m_gridControl is IChecksViewWrapperView) ((IChecksViewWrapperView)m_gridControl).Persistence = m_persistence; m_rightView.Panel1.Controls.Add(m_gridControl); // Create a key terms control (containing the tool strip and tree). // Subscribe to events so that the enabled status of the tool strip buttons can be updated. m_treeContainer = CreateCheckControl(); m_treeContainer.Dock = DockStyle.Left; if (m_treeContainer is IChecksViewWrapperView) ((IChecksViewWrapperView)m_treeContainer).Persistence = m_persistence; Controls.Add(m_treeContainer); m_dockExtender = new DockExtender(this); m_floaty = m_dockExtender.Attach(m_treeContainer, m_treeContainer.ToolStrip, true, m_persistence); m_floaty.DockOnInside = false; // outside m_floaty.HideHandle = false; m_floaty.AllowedDocking = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; m_floaty.ShowCloseButton = false; m_treeContainer.Floaty = m_floaty; m_fShownBefore = true; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Updates the character style list of the combo box /// </summary> /// <param name="styleContext">the current Paragraph style context, usually based on /// the selection</param> /// <param name="view">The currently active view</param> /// ------------------------------------------------------------------------------------ private void RefreshCharStyleComboBoxList(ContextValues styleContext, IRootSite view) { CharStyleListHelper.IncludeStylesWithContext.Clear(); FwEditingHelper editingHelper = view.EditingHelper as FwEditingHelper; if (editingHelper != null && editingHelper.ApplicableStyleContexts != null) { CharStyleListHelper.IncludeStylesWithContext.AddRange(editingHelper.ApplicableStyleContexts); } else { CharStyleListHelper.IncludeStylesWithContext.Add(styleContext); if (!CharStyleListHelper.IncludeStylesWithContext.Contains(ContextValues.General)) CharStyleListHelper.IncludeStylesWithContext.Add(ContextValues.General); if (editingHelper != null && !CharStyleListHelper.IncludeStylesWithContext.Contains(editingHelper.InternalContext)) { CharStyleListHelper.IncludeStylesWithContext.Add(editingHelper.InternalContext); } } CharStyleListHelper.Refresh(); CharStyleListHelper.ActiveView = view as Control; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Updates the paragraph style list of the combo box /// </summary> /// <param name="style">the current paragraph style where the IP is</param> /// <param name="view">The currently active view</param> /// ------------------------------------------------------------------------------------ public void RefreshParaStyleComboBoxList(IStStyle style, IRootSite view) { if (m_callbacks.PopulateParaStyleListOverride()) return; if (ParaStyleListHelper.ActiveView == view && style != null && m_prevParaStyleContext == style.Context) { return; } ParaStyleListHelper.IncludeStylesWithContext.Clear(); FwEditingHelper editingHelper = view.EditingHelper as FwEditingHelper; if (editingHelper != null && editingHelper.ApplicableStyleContexts != null) { ParaStyleListHelper.IncludeStylesWithContext.AddRange(editingHelper.ApplicableStyleContexts); } else { if (style != null) ParaStyleListHelper.IncludeStylesWithContext.Add(style.Context); ParaStyleListHelper.IncludeStylesWithContext.Add(ContextValues.General); } ParaStyleListHelper.Refresh(); ParaStyleListHelper.ActiveView = view as Control; }
/// <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 virtual void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (m_isDisposed) return; m_activeSite = null; if (disposing) { // Dispose managed resources here. if (m_rootControl != null) DeepRemoveControl(m_rootControl); if (m_availableSites != null) m_availableSites.Clear(); } // Dispose unmanaged resources here, whether disposing is true or false. m_rootControl = null; m_availableSites = null; m_isDisposed = true; }
/// ------------------------------------------------------------------------------------ /// <summary> /// This function attempts to determine whether a root site can really be seen /// in the sense that it can reasonably receive commands (such as from the style /// dialog). It doesn't check everything possible; for example, a control could /// be visible in all the ways checked here and still covered by another control /// or scrolled out of sight. /// </summary> /// <param name="site">The rootsite</param> /// <returns></returns> /// ------------------------------------------------------------------------------------ bool IsReallyVisible(IRootSite site) { Control control = site as Control; if (!control.Visible) return false; // Unfortunately the above can somehow still be true for a control that is // part of a disposed window. Check some more things to make sure. if (!control.IsHandleCreated) return false; if (site is IVwRootSite && (site as IVwRootSite).RootBox == null) return false; // Don't do this! It produces a stack overflow because CastAsIVwRootBox // uses ActiveView to try to get a RootSite. //if (site.CastAsIVwRootSite().RootBox == null) // return false; if (control.IsDisposed) return false; // It may be visible along with all its parents, but if the chain doesn't // go up to a form we can't really see it. return control.TopLevelControl is Form; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Recursively remove handlers for the ControlAdded and GotFocus events of the specified /// control and all its sub-controls. /// </summary> /// <param name="control"></param> /// ------------------------------------------------------------------------------------ private void DeepRemoveControl(Control control) { control.ControlAdded -= new ControlEventHandler(ControlWasAdded); control.ControlRemoved -= new ControlEventHandler(ControlWasRemoved); if (control is IRootSite) { control.GotFocus -= new EventHandler(ViewGotFocus); m_availableSites.Remove((IRootSite)control); if (m_activeSite == control) m_activeSite = null; } foreach (Control childControl in control.Controls) DeepRemoveControl(childControl); if (control is IControl) { #if __MonoCS__ // TODO-Linux FWNX-534: work around for mono bug: https://bugzilla.novell.com/show_bug.cgi?id=656701 if (!control.IsDisposed) #endif foreach (Control focusableControl in ((IControl)control).FocusableControls) DeepRemoveControl(focusableControl); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Called when the user presses the mouse button on the grid. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance /// containing the event data.</param> /// ------------------------------------------------------------------------------------ protected void OnGridMouseDown(object sender, MouseEventArgs e) { m_lastFocusedRootSite = FocusedRootSite; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Handler for when a view gains focus. This sets the active view to the view that got /// focus. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// ------------------------------------------------------------------------------------ private void ViewGotFocus(object sender, EventArgs e) { var oldActiveView = ActiveView; m_activeSite = sender as IRootSite; if (ActiveView != oldActiveView && ActiveViewChanged != null) ActiveViewChanged(this, new EventArgs()); }
/// <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 virtual void Dispose(bool disposing) { Debug.WriteLineIf(!disposing, "****************** Missing Dispose() call for " + GetType().Name + "******************"); // Must not be run more than once. if (m_isDisposed) return; if (disposing) { // Dispose managed resources here. if (m_Parent != null) m_Parent.AllowPainting = true; } // Dispose unmanaged resources here, whether disposing is true or false. m_Parent = null; m_isDisposed = true; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Updates the styles combo boxes on the formatting toolbar, with the correct style name. /// </summary> /// ------------------------------------------------------------------------------------ public void UpdateStyleComboBoxValue(IRootSite rootsite) { // If we don't have a paraStyleListHelper, we can't update the paragraph or // character style combo. if (ParaStyleListHelper == null || rootsite == null || rootsite.EditingHelper == null) return; FwEditingHelper fwEditingHelper = rootsite.EditingHelper as FwEditingHelper; if (fwEditingHelper != null && fwEditingHelper.IsPictureReallySelected) return; string paraStyleName = rootsite.EditingHelper.GetParaStyleNameFromSelection(); var style = (paraStyleName == string.Empty) ? null : ParaStyleListHelper.StyleFromName(paraStyleName); RefreshParaStyleComboBoxList(style, rootsite); if (ParaStyleListHelper.SelectedStyleName != paraStyleName) ParaStyleListHelper.SelectedStyleName = paraStyleName; ContextValues currentContext = (style != null) ? style.Context : (fwEditingHelper != null) ? fwEditingHelper.InternalContext : ContextValues.General; if (CharStyleListHelper != null) { string charStyleName = rootsite.EditingHelper.GetCharStyleNameFromSelection(); if (CharStyleListHelper.ActiveView != rootsite as Control || m_prevParaStyleContext != currentContext || (charStyleName != null && !CharStyleListHelper.Contains(charStyleName)) || (charStyleName == null && m_prevParaStyleContext == ContextValues.Note) || (fwEditingHelper != null && fwEditingHelper.ForceCharStyleComboRefresh)) { RefreshCharStyleComboBoxList(currentContext, rootsite); } if (charStyleName == string.Empty) charStyleName = StyleUtils.DefaultParaCharsStyleName; if (charStyleName == null) charStyleName = string.Empty; if (CharStyleListHelper.SelectedStyleName != charStyleName) CharStyleListHelper.SelectedStyleName = charStyleName; } m_prevParaStyleContext = currentContext; }
/// <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); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="ScriptureProperties"/> class. /// </summary> /// <param name="cache">The cache.</param> /// <param name="styleSheet">The style sheet.</param> /// <param name="rootSite">The active view (or the draft view if the footnote view is /// active).</param> /// <param name="showFootnoteTab">True to show the footnote tab. Otherwise the /// footnote tab will be hidden.</param> /// <param name="helpTopicProvider">The help topic provider.</param> /// ------------------------------------------------------------------------------------ public ScriptureProperties(FdoCache cache, IVwStylesheet styleSheet, IRootSite rootSite, bool showFootnoteTab, IHelpTopicProvider helpTopicProvider) { m_cache = cache; m_helpTopicProvider = helpTopicProvider; m_styleSheet = styleSheet; m_scr = cache.LangProject.TranslatedScriptureOA; m_rootSite = rootSite; // // Required for Windows Form Designer support // InitializeComponent(); if (!showFootnoteTab) tabControl1.TabPages.Remove(tpgFootnotes); fpsCrossRefOptions.SiblingPropertiesSelector = fpsFootnoteOptions; fpsFootnoteOptions.SiblingPropertiesSelector = fpsCrossRefOptions; m_fCombineFootnotes = m_scr.CrossRefsCombinedWithFootnotes; opnCombined.Checked = m_fCombineFootnotes; opnSeparate.Checked = !m_fCombineFootnotes; UpdateCombinedFootnotes(); FillScriptLanguages(); FillVersificationSchemes(); UpdateFootnoteTabs(); if (m_scr.UseScriptDigits) { m_btnScriptNumbers.Checked = true; string language = m_baseDigitMap[(char)m_scr.ScriptDigitZero]; m_cboScriptLanguages.SelectedIndex = m_cboScriptLanguages.FindString(language); } else m_btnLatinNumbers.Checked = true; // Fill in the reference separator fields to edit m_txtRefSep.Text = m_scr.RefSepr; m_txtChapterVerseSep.Text = m_scr.ChapterVerseSepr; m_txtVerseSep.Text = m_scr.VerseSepr; m_txtVerseBridge.Text = m_scr.Bridge; // Make the option button for footnotes and cross references invisible. fpsFootnoteOptions.ShowSequenceButton = false; fpsCrossRefOptions.ShowSequenceButton = false; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Determines whether or not the specified view is visible. /// </summary> /// <param name="view"></param> /// <returns></returns> /// ------------------------------------------------------------------------------------ public bool IsViewVisible(IRootSite view) { CheckDisposed(); Control ctrl = view as Control; if (ctrl != null) return ctrl.Visible && ctrl.FindForm() != null; return false; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Recursively remove handlers for the ControlAdded and GotFocus events of the specified /// control and all its sub-controls. /// </summary> /// <param name="control"></param> /// ------------------------------------------------------------------------------------ private void DeepRemoveControl(Control control) { control.ControlAdded -= new ControlEventHandler(ControlWasAdded); control.ControlRemoved -= new ControlEventHandler(ControlWasRemoved); if (control is IRootSite) { control.GotFocus -= new EventHandler(ViewGotFocus); m_availableSites.Remove((IRootSite)control); if (m_activeSite == control) m_activeSite = null; } foreach (Control con in control.Controls) DeepRemoveControl(con); if (control is IControl) { foreach (Control con in ((IControl)control).FocusableControls) DeepRemoveControl(con); } }
/// <summary> /// Try to find a WfiWordform object corresponding the the focus selection. /// If successful return its guid, otherwise, return Guid.Empty. /// </summary> /// <returns></returns> private ITsString ActiveWord() { if (InFriendliestTool) { // we should be able to get our info from the current record clerk. // but return null if we can't get the info, otherwise we allow the user to // bring up the change spelling dialog and crash because no wordform can be found (LT-8766). RecordClerk clerk = m_mediator.PropertyTable.GetValue("ActiveClerk") as RecordClerk; if (clerk == null || clerk.CurrentObject == null) { return(null); } IWfiWordform wfiWordform = clerk.CurrentObject as IWfiWordform; if (wfiWordform == null) { return(null); } ITsString tssVern = wfiWordform.Form.BestVernacularAlternative; return(tssVern); } if (!(FwApp.App is FwXApp)) { return(null); } FwXWindow window = (FwApp.App as FwXApp).ActiveMainWindow as FwXWindow; if (window == null) { return(null); } IRootSite activeView = window.ActiveView; if (activeView == null) { return(null); } List <IVwRootBox> roots = activeView.AllRootBoxes(); if (roots.Count < 1) { return(null); } SelectionHelper helper = SelectionHelper.Create(roots[0].Site); if (helper == null) { return(null); } ITsString tssWord = helper.SelectedWord; if (tssWord != null) { // Check for a valid vernacular writing system. (See LT-8892.) int ws = StringUtils.GetWsAtOffset(tssWord, 0); FdoCache cache = m_mediator.PropertyTable.GetValue("cache") as FdoCache; if (cache.LangProject.VernWssRC.Contains(ws)) { return(tssWord); } } return(null); }
/// -------------------------------------------------------------------------------- /// <summary> /// Suspend drawing of the parent. /// </summary> /// <param name="parent">Containing rootsite</param> /// -------------------------------------------------------------------------------- public SuspendDrawing(IRootSite parent) { m_Parent = parent; m_Parent.AllowPainting = false; }