/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="HeaderFooterConfigurer"/> class. /// </summary> /// <param name="cache">The cache representing our DB connection.</param> /// <param name="hvoHeaderFooterSet">Id of the header/footer set to be used</param> /// <param name="wsDefault">Default writing system</param> /// <param name="printDateTime">printing date/time</param> /// ------------------------------------------------------------------------------------ public HeaderFooterConfigurer(FdoCache cache, int hvoHeaderFooterSet, int wsDefault, DateTime printDateTime) { m_fdoCache = cache; if (hvoHeaderFooterSet > 0) m_hfSet = new PubHFSet(m_fdoCache, hvoHeaderFooterSet); m_wsDefault = wsDefault; m_printDateTime = printDateTime; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates 2 fake HF sets for use in testing /// </summary> /// <returns>the created publication</returns> /// ------------------------------------------------------------------------------------ private IPublication CreateFakeHFSets() { // create a publication IPublication pub = new Publication(); Cache.LangProject.LexDbOA.PublicationsOC.Add(pub); IPubDivision pubDiv = new PubDivision(); pub.DivisionsOS.Append(pubDiv); // create the current HF set for the publication pubDiv.HFSetOA = new PubHFSet(); pubDiv.HFSetOA.DefaultHeaderOA = new PubHeader(); pubDiv.HFSetOA.DefaultFooterOA = new PubHeader(); pubDiv.HFSetOA.FirstHeaderOA = new PubHeader(); pubDiv.HFSetOA.FirstFooterOA = new PubHeader(); pubDiv.HFSetOA.EvenHeaderOA = new PubHeader(); pubDiv.HFSetOA.EvenFooterOA = new PubHeader(); pubDiv.HFSetOA.Name = "Test HF Set of Matthew printed in Tabaluga"; // create a dummy HF set IPubHFSet hfset = new PubHFSet(); m_hfSets.Add(hfset); hfset.Name = "Test HF Set created today"; hfset.Description.Text = "This is a test HF set"; hfset.DefaultHeaderOA = new PubHeader(); hfset.DefaultFooterOA = new PubHeader(); hfset.EvenHeaderOA = new PubHeader(); hfset.EvenFooterOA = new PubHeader(); hfset.FirstFooterOA = new PubHeader(); hfset.FirstHeaderOA = new PubHeader(); hfset.DefaultFooterOA.OutsideAlignedText.Text = "outside text"; hfset.DefaultFooterOA.CenteredText.Text = "Song of songs"; hfset.EvenHeaderOA.CenteredText.Text = "Song even pages"; hfset.EvenHeaderOA.InsideAlignedText.Text = "Inside text"; hfset.FirstFooterOA.InsideAlignedText.Text = "Inside text"; // create another dummy HF set IPubHFSet hfset2 = new PubHFSet(); m_hfSets.Add(hfset2); hfset2.Name = "Test HF Set of Matthew printed in Tabaluga"; hfset2.Description.Text = "This is another test HF set"; hfset2.DefaultHeaderOA = new PubHeader(); hfset2.DefaultFooterOA = new PubHeader(); hfset2.EvenHeaderOA = new PubHeader(); hfset2.EvenFooterOA = new PubHeader(); hfset2.FirstFooterOA = new PubHeader(); hfset2.FirstHeaderOA = new PubHeader(); hfset2.DefaultHeaderOA.OutsideAlignedText.UnderlyingTsString = StringUtils.CreateOrcFromGuid(HeaderFooterVc.PageNumberGuid, FwObjDataTypes.kodtContextString, Cache.DefaultUserWs); hfset2.DefaultFooterOA.CenteredText.Text = "Matthew"; hfset2.EvenFooterOA.CenteredText.Text = "From Reference"; hfset2.EvenHeaderOA.InsideAlignedText.Text = "nothing"; hfset2.FirstFooterOA.InsideAlignedText.Text = "Inside text"; return pub; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Called when the add button is pressed /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// ------------------------------------------------------------------------------------ protected void m_btnAdd_Click(object sender, System.EventArgs e) { PubHFSet HFSet = new PubHFSet(); m_HfSetOwner.HeaderFooterSetsOC.Add(HFSet); HFSet.DefaultFooterOA = new PubHeader(); HFSet.DefaultHeaderOA = new PubHeader(); HFSet.FirstFooterOA = new PubHeader(); HFSet.FirstHeaderOA = new PubHeader(); HFSet.EvenFooterOA = new PubHeader(); HFSet.EvenHeaderOA = new PubHeader(); using (HeaderFooterModifyDlg dlg = new HeaderFooterModifyDlg(m_cache, HFSet as IPubHFSet, m_pub, m_helpProvider)) { if (dlg.ShowDialog() == DialogResult.OK) { UpdateNameBox(null); UpdatePreView(); } else { // We don't want a new PubHFSet after all... m_cache.DeleteObject(HFSet.Hvo); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Brings up the header footer setup dialog from the View menu /// </summary> /// <param name="arg"></param> /// <returns><c>true</c> if handled, otherwise <c>false</c></returns> /// ------------------------------------------------------------------------------------ protected bool OnHeaderFooterSetup(object arg) { if (CurrentPublication == null) return false; string undo; string redo; TeResourceHelper.MakeUndoRedoLabels("kstidUndoRedoHeaderFooterSetup", out undo, out redo); using (UndoTaskHelper undoTaskHelper = new UndoTaskHelper(m_cache.MainCacheAccessor, ActiveView.CastAsIVwRootSite(), undo, redo, true)) { Dictionary<IPubDivision, DivInfo> divHfSets = new Dictionary<IPubDivision, DivInfo>(); foreach (IPubDivision div in CurrentPublication.DivisionsOS) divHfSets[div] = new DivInfo(div); // Save the names and hvos of the HF sets before going into the dialog. // In case the user changes the name of one or more sets, we need to // be able to get back to the original names. Dictionary<string, int> origHfSets = new Dictionary<string, int>(); foreach (IPubHFSet hfs in m_scr.HeaderFooterSetsOC) origHfSets[hfs.Name] = hfs.Hvo; // get default writing system. Use the default vernacular writing system // if the ScripturePublication is null. ScripturePublication scrPubControl = ActiveView as ScripturePublication; using (HeaderFooterSetupDlg dlg = new HeaderFooterSetupDlg(m_cache, CurrentPublication, FwApp.App, TePublicationsInit.FactoryHeaderFooterSets, (CmMajorObject)m_scr)) { dlg.ShowDialog(); // If the H/F set for any of the divisions of the current publication has changed // refresh its view foreach (IPubDivision div in CurrentPublication.DivisionsOS) { if (divHfSets[div] != new DivInfo(div)) { ActiveView.RefreshDisplay(); break; } } // Need to refresh the views for any other publications that are // using an H/F set that was modified foreach (ISelectableView view in ClientWindows.Values) { PublicationControl pubCtrl = view as PublicationControl; if (pubCtrl != null && pubCtrl != ActiveView) { foreach (IPubDivision div in pubCtrl.Publication.DivisionsOS) { // Lookup the hvo for the changed HF set based on the // original name, which is still stored in the division. int hfHvo; if (origHfSets.TryGetValue(div.HFSetOA.Name, out hfHvo) && dlg.HFSetWasModified(hfHvo)) { IPubHFSet scrHFset = new PubHFSet(m_cache, hfHvo); div.HFSetOA.CloneDetails(scrHFset); } } } } } } return true; }