Exemplo n.º 1
0
		/// ------------------------------------------------------------------------------------
		/// <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.ActionHandlerAccessor,
					  ActiveView.CastAsIVwRootSite(), undo, redo))
			{
				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.
				using (HeaderFooterSetupDlg dlg = new HeaderFooterSetupDlg(m_cache, CurrentPublication,
					m_app, TePublicationsInit.FactoryHeaderFooterSets, 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 m_rgClientViews.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 =
										m_cache.ServiceLocator.GetInstance<IPubHFSetRepository>().GetObject(hfHvo);
									div.HFSetOA.CloneDetails(scrHFset);
								}
							}
						}
					}
				}
				undoTaskHelper.RollBack = false;
			}
			return true;
		}
Exemplo n.º 2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Handles the Click event of the btnHeaderFooter control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
		/// ------------------------------------------------------------------------------------
		private void btnHeaderFooter_Click(object sender, EventArgs e)
		{
			using (HeaderFooterSetupDlg dlg = new HeaderFooterSetupDlg(m_publication.Cache,
				m_publication, m_helpTopicProvider, m_callbacks.FactoryHeaderFooterSetNames,
				m_pubOwner))
			{
				dlg.ShowDialog();
			}
		}