/// ------------------------------------------------------------------------------------ /// <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); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="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 draft view.</param> /// <param name="stylebar">The stylebar.</param> /// <param name="btDraftView">The bt draft view.</param> /// <param name="footnoteDraftView">The footnote draft view.</param> /// <param name="footnoteStylebar">The footnote stylebar</param> /// <param name="footnoteBtDraftView">The footnote bt draft view.</param> /// ------------------------------------------------------------------------------------ public BtDraftSplitWrapper(string name, Control parent, FdoCache cache, IVwStylesheet styleSheet, RegistryKey settingsRegKey, object draftView, object stylebar, object btDraftView, object footnoteDraftView, object footnoteStylebar, object footnoteBtDraftView) : base(name, parent, cache, styleSheet, settingsRegKey, draftView, stylebar, footnoteDraftView, footnoteStylebar, 2, 3) { 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); // we don't want to implement ISettings, so we set the default key path instead, // but we have to strip the HKCU\ of the name. persistence.DefaultKeyPath = settingsRegKey.Name.Substring(Registry.CurrentUser.Name.Length + 1); // 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); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates the control in column. /// </summary> /// <param name="cell">The cell that will host the control we create.</param> /// ------------------------------------------------------------------------------------ private void CreateHostedControl(DataGridViewControlCell cell) { if (cell.ControlCreateInfo == null || cell.ControlCreateInfo.ViewProxy == null) { return; } IRootSiteGroup group = cell.ControlCreateInfo.Group; Control c = cell.ControlCreateInfo.ViewProxy.CreateView(this); if (c is RootSite) { RootSite rs = c as RootSite; rs.Cache = m_cache; rs.StyleSheet = m_StyleSheet; } if (group != null && c is IRootSiteSlave) { IRootSiteSlave slave = c as IRootSiteSlave; group.AddToSyncGroup(slave); if (cell.ControlCreateInfo.IsScrollingController) { #if __MonoCS__ // TODO-Linux: HACK Check to see if a ScrollingControl has (in error) already been set. // hack to prevent multiple scrollbars controling a group // This isn't needed in Windows as RootSite.cs check to see if it is the Group ScrollingController // Which should mean that if multiple scrolling Control are set only the last one actually contains a scrollbar // However because on mono Creating events aren't exactly the same (shame!) the group property of the RootSite get set before // the second RootSite with the ScrollingControl set, get created meaning when the group is set it IS the scrolling controler! (and hence AutoScroll isn't set to false) // A alternative way of fixing this (and probably better) would be to change the ViewWrapperContructor to only set a single ScrollingControl // (currently BtWrapper set one) and calls it base which also has set one. if (group.ScrollingController != null) { if (group.ScrollingController is ScrollableControl) { (group.ScrollingController as ScrollableControl).AutoScroll = false; } } #endif group.ScrollingController = slave; } } if (c is ISelectableView) { ((ISelectableView)c).BaseInfoBarCaption = m_baseInfoBarCaption; } cell.ControlCreateInfo.Control = c; OnHostedControlCreated(c); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates the control in column. /// </summary> /// <param name="cell">The cell that will host the control we create.</param> /// ------------------------------------------------------------------------------------ private void CreateHostedControl(DataGridViewControlCell cell) { if (cell.ControlCreateInfo == null || (ControlCreator == null && !(cell.ControlCreateInfo.ClientControlInfo is FixedControlCreateInfo))) { return; } IRootSiteGroup group = cell.ControlCreateInfo.Group; Control c; if (cell.ControlCreateInfo.ClientControlInfo is FixedControlCreateInfo) { // We know how to deal with this! c = ((FixedControlCreateInfo)cell.ControlCreateInfo.ClientControlInfo).Control; } else { c = ControlCreator.Create(this, cell.ControlCreateInfo.ClientControlInfo); } if (c is RootSite) { RootSite rs = c as RootSite; rs.Cache = m_cache; rs.StyleSheet = m_StyleSheet; } if (group != null && c is IRootSiteSlave) { IRootSiteSlave slave = c as IRootSiteSlave; group.AddToSyncGroup(slave); if (cell.ControlCreateInfo.IsScrollingController) { group.ScrollingController = slave; } } if (c is ISelectableView) { ((ISelectableView)c).BaseInfoBarCaption = m_baseInfoBarCaption; } cell.ControlCreateInfo.Control = c; OnHostedControlCreated(c); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="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 Scripture draft view proxy.</param> /// <param name="stylebar">The Scripture stylebar proxy.</param> /// <param name="footnoteDraftView">The footnote draft view proxy.</param> /// <param name="footnoteStylebar">The footnote stylebar proxy</param> /// <param name="rows">The number of rows.</param> /// <param name="columns">The number of columns.</param> /// <remarks>If the view wrapper does not have a stylebar, then override the /// kStyleColumn property to a negative value so that it will be ignored.</remarks> /// ------------------------------------------------------------------------------------ internal ViewWrapper(string name, Control parent, FdoCache cache, IVwStylesheet styleSheet, RegistryKey settingsRegKey, TeScrDraftViewProxy draftView, DraftStylebarProxy stylebar, TeFootnoteDraftViewProxy footnoteDraftView, DraftStylebarProxy footnoteStylebar, int rows, int columns) : base(cache, styleSheet, rows, columns) { Dock = DockStyle.Fill; Name = name; m_stylePaneWidth = new RegistryIntSetting(settingsRegKey, name + "StyleWidth", 0); if (parent != null) { Site = parent.Site; } IRootSiteGroup group = CreateGroup((int)TeViewGroup.Scripture); if (kStyleColumn >= 0) { AddControl(group, kDraftRow, kStyleColumn, stylebar); } AddControl(group, kDraftRow, kDraftViewColumn, draftView, true, true); group = CreateGroup((int)TeViewGroup.Footnote); if (kStyleColumn >= 0) { AddControl(group, kFootnoteRow, kStyleColumn, footnoteStylebar); } AddControl(group, kFootnoteRow, kDraftViewColumn, footnoteDraftView, false, true); GetRow(kFootnoteRow).FillWeight = 18; m_grid.Rows[kDraftRow].Visible = true; m_grid.Columns[kDraftViewColumn].Visible = true; m_grid.ColumnWidthChanged += new DataGridViewColumnEventHandler(OnColumnWidthChanged); m_grid.RowHeightChanged += new DataGridViewRowEventHandler(OnRowHeightChanged); if (kStyleColumn >= 0) { DataGridViewControlColumn styleColumn = GetColumn(kStyleColumn); styleColumn.ThresholdWidth = 20; styleColumn.StandardWidth = 100; styleColumn.MaxPercentage = 0.5f; styleColumn.IsCollapsible = true; styleColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.None; if (m_stylePaneWidth.Value > 0) { styleColumn.Width = Math.Max(m_stylePaneWidth.Value, styleColumn.ThresholdWidth); styleColumn.Visible = true; } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="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="topDraftView">The top draft view.</param> /// <param name="topStylebar">The top stylebar.</param> /// <param name="bottomDraftView">The bottom draft view.</param> /// <param name="bottomStylebar">The bottom stylebar.</param> /// <param name="footnoteDraftView">The footnote draft view.</param> /// <param name="footnoteStylebar">The footnote stylebar</param> /// ------------------------------------------------------------------------------------ public DraftViewWrapper(string name, Control parent, FdoCache cache, IVwStylesheet styleSheet, RegistryKey settingsRegKey, object topDraftView, object topStylebar, object bottomDraftView, object bottomStylebar, object footnoteDraftView, object footnoteStylebar) : base(name, parent, cache, styleSheet, settingsRegKey, bottomDraftView, bottomStylebar, footnoteDraftView, footnoteStylebar, 3, 2) { IRootSiteGroup group = CreateGroup((int)TeViewGroup.Scripture); AddControl(group, kUpperDraftRow, kStyleColumn, topStylebar); AddControl(group, kUpperDraftRow, kDraftViewColumn, topDraftView, false, true); GetRow(kUpperDraftRow).Visible = false; m_colSplit = new CollapsibleSplitter(this); m_colSplit.SplitterMoved += new CollapsibleSplitter.SplitterMovedDelegate(OnCollapsibleSplitterMoved); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds the control at the specified location. /// </summary> /// <param name="group">The group.</param> /// <param name="column">The column index.</param> /// <param name="row">The row index.</param> /// <param name="controlProxy">Client-provided information necessary to create the /// control.</param> /// <param name="fDefaultFocusControl"><c>true</c> if this control will get focus /// if this split grid receives focus.</param> /// <param name="fScrollingContainer"><c>true</c> if this control should control /// scrolling (and display a scroll bar)</param> /// ------------------------------------------------------------------------------------ public void AddControl(IRootSiteGroup group, int row, int column, ViewProxy controlProxy, bool fDefaultFocusControl, bool fScrollingContainer) { CheckBounds(row, column); if (fDefaultFocusControl) { m_CellToActivate = new Point(column, row); } if (row >= m_grid.RowCount) { m_grid.RowCount = row + 1; m_grid.Rows[m_grid.RowCount - 1].Visible = false; m_grid.Rows[m_grid.RowCount - 1].MinimumHeight = DataGridViewControlColumn.kMinimumValue; } DataGridViewControlCell cell = m_grid.Rows[row].Cells[column] as DataGridViewControlCell; Debug.Assert(cell != null); cell.ControlCreateInfo = new ControlCreateInfo(group ?? m_defaultGroup, controlProxy, fScrollingContainer); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="T:ControlCreateInfo"/> class. /// </summary> /// <param name="group">The group.</param> /// <param name="viewProxy">The view proxy.</param> /// <param name="fScrollingContainer"><c>true</c> if this control should control /// scrolling (and display a scroll bar)</param> /// ------------------------------------------------------------------------------------ public ControlCreateInfo(IRootSiteGroup group, ViewProxy viewProxy, bool fScrollingContainer) { Group = group; ViewProxy = viewProxy; IsScrollingController = fScrollingContainer; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds the control at the specified location. /// </summary> /// <param name="group">The group.</param> /// <param name="column">The column index.</param> /// <param name="row">The row index.</param> /// <param name="controlProxy">Client-provided information necessary to create the /// control.</param> /// ------------------------------------------------------------------------------------ public void AddControl(IRootSiteGroup group, int row, int column, ViewProxy controlProxy) { AddControl(group, row, column, controlProxy, false, false); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="T:ControlCreateInfo"/> class. /// </summary> /// <param name="group">The group.</param> /// <param name="controlInfo">The control info.</param> /// <param name="fScrollingContainer"><c>true</c> if this control should control /// scrolling (and display a scroll bar)</param> /// ------------------------------------------------------------------------------------ public ControlCreateInfo(IRootSiteGroup group, object controlInfo, bool fScrollingContainer) { Group = group; ClientControlInfo = controlInfo; IsScrollingController = fScrollingContainer; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds the control at the specified location. /// </summary> /// <param name="group">The group.</param> /// <param name="column">The column index.</param> /// <param name="row">The row index.</param> /// <param name="controlInfo">Client provided information necessary to create the /// control. This information is passed to IControlCreator when creating the control.</param> /// ------------------------------------------------------------------------------------ public void AddControl(IRootSiteGroup group, int row, int column, object controlInfo) { AddControl(group, row, column, controlInfo, false, false); }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// <param name="disposing"></param> /// ------------------------------------------------------------------------------------ protected override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) return; if (m_rootb != null) { CloseRootBox(); m_rootb = null; } base.Dispose(disposing); if (disposing) { // Not good here, since it causes infinite loop. //if (m_group != null) // m_group.Dispose(); } m_fdoCache = null; m_group = null; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds the control at the specified location. /// </summary> /// <param name="group">The group.</param> /// <param name="column">The column index.</param> /// <param name="row">The row index.</param> /// <param name="controlProxy">Client-provided information necessary to create the /// control.</param> /// <param name="fDefaultFocusControl"><c>true</c> if this control will get focus /// if this split grid receives focus.</param> /// <param name="fScrollingContainer"><c>true</c> if this control should control /// scrolling (and display a scroll bar)</param> /// ------------------------------------------------------------------------------------ public void AddControl(IRootSiteGroup group, int row, int column, ViewProxy controlProxy, bool fDefaultFocusControl, bool fScrollingContainer) { CheckBounds(row, column); if (fDefaultFocusControl) m_CellToActivate = new Point(column, row); if (row >= m_grid.RowCount) { m_grid.RowCount = row + 1; m_grid.Rows[m_grid.RowCount - 1].Visible = false; m_grid.Rows[m_grid.RowCount - 1].MinimumHeight = DataGridViewControlColumn.kMinimumValue; } DataGridViewControlCell cell = m_grid.Rows[row].Cells[column] as DataGridViewControlCell; Debug.Assert(cell != null); cell.ControlCreateInfo = new ControlCreateInfo(group ?? m_defaultGroup, controlProxy, fScrollingContainer); }