private void m_btnStyles_Click(object sender, EventArgs e)
		{
			bool fRTL = m_cache.WritingSystemFactory.get_EngineOrNull(m_cache.DefaultUserWs).RightToLeftScript;
			using (var dlg = new FwStylesDlg(null, m_cache, m_stylesheet as FwStyleSheet,
				fRTL,
				m_cache.ServiceLocator.WritingSystems.AllWritingSystems.Any(ws => ws.RightToLeftScript),
				m_stylesheet.GetDefaultBasedOnStyleName(),
				0,		// customUserLevel
				m_app.MeasurementSystem,
				m_stylesheet.GetDefaultBasedOnStyleName(),
				String.Empty,
				0,		// hvoRootObject
				m_app, m_helpTopicProvider))
			{
				dlg.ShowTEStyleTypes = false;
				dlg.CanSelectParagraphBackgroundColor = false;
				if (dlg.ShowDialog(this) == DialogResult.OK &&
					((dlg.ChangeType & StyleChangeType.DefChanged) > 0 ||
					(dlg.ChangeType & StyleChangeType.Added) > 0 ||
					(dlg.ChangeType & StyleChangeType.RenOrDel) > 0))
				{
					m_app.Synchronize(SyncMsg.ksyncStyle);
					FwStyleSheet stylesheet = new FwStyleSheet();
					stylesheet.Init(m_cache, m_cache.LangProject.Hvo, LangProjectTags.kflidStyles);
					m_stylesheet = stylesheet;
				}
				string stySel = null;
				if (m_cbStyle.SelectedItem != null)
					stySel = m_cbStyle.SelectedItem.ToString();
				FillStylesCombo(stySel);
			}
		}
示例#2
0
		/// <summary>
		/// Run the styles dialog in order to configure styles for a combo box that selects a style.
		/// </summary>
		/// <param name="combo">The combo we are configuring. Items may be StyleComboItem or simple strings (style names)</param>
		/// <param name="fixCombo">An action to run after the dialog closes</param>
		/// <param name="defaultStyle">style to select in the combo if none chosen in the dialog</param>
		/// <param name="stylesheet">that the dialog will configure</param>
		/// <param name="nMaxStyleLevel">optional constraint on which styles show</param>
		/// <param name="hvoAppRoot">root HVO for the application, e.g., Scripture for TE</param>
		/// <param name="cache"></param>
		/// <param name="owner">parent window</param>
		/// <param name="app"></param>
		/// <param name="helpTopicProvider"></param>
		public static void RunStylesDialogForCombo(ComboBox combo, Action fixCombo, string defaultStyle,
			FwStyleSheet stylesheet, int nMaxStyleLevel, int hvoAppRoot, FdoCache cache,
			IWin32Window owner, IApp app, IHelpTopicProvider helpTopicProvider)
		{
			var sci = combo.SelectedItem as StyleComboItem;
			string charStyleName = combo.SelectedItem as string;
			if (sci != null)
				charStyleName = (sci != null && sci.Style != null) ? sci.Style.Name : "";
			var paraStyleName = stylesheet.GetDefaultBasedOnStyleName();
			// Although we call this 'paraStyleName', it's actual function is to determine the style that
			// will be selected in the dialog when it launches. We want that to be the one from the style
			// combo we are editing, whether it's a paragraph or character one.
			if (!string.IsNullOrEmpty(charStyleName))
				paraStyleName = charStyleName;
			// ReSharper disable ConvertToConstant.Local
			bool fRightToLeft = false;
			// ReSharper restore ConvertToConstant.Local
			IVwRootSite site = null;		// Do we need something better?  We don't have anything!
			// ReSharper disable RedundantAssignment
			var selectedStyle = "";
			// ReSharper restore RedundantAssignment
			using (var stylesDlg = new FwStylesDlg(
				site,
				cache,
				stylesheet,
				// ReSharper disable ConditionIsAlwaysTrueOrFalse
				fRightToLeft,
				// ReSharper restore ConditionIsAlwaysTrueOrFalse
				cache.ServiceLocator.WritingSystems.AllWritingSystems.Any(ws => ws.RightToLeftScript),
				stylesheet.GetDefaultBasedOnStyleName(),
				nMaxStyleLevel,
				app.MeasurementSystem,
				paraStyleName,
				charStyleName,
				hvoAppRoot,
				app,
				helpTopicProvider))
			{
				stylesDlg.ShowTEStyleTypes = false;
				stylesDlg.CanSelectParagraphBackgroundColor = false;
				if (stylesDlg.ShowDialog(owner) == DialogResult.OK &&
					((stylesDlg.ChangeType & StyleChangeType.DefChanged) > 0 ||
					 (stylesDlg.ChangeType & StyleChangeType.Added) > 0))
				{
					app.Synchronize(SyncMsg.ksyncStyle);
					selectedStyle = stylesDlg.SelectedStyle;
					var oldStyle = GetStyleName(combo.SelectedItem);
					if (fixCombo != null)
						fixCombo();
					if (string.IsNullOrEmpty(selectedStyle))
						selectedStyle = defaultStyle;
					// Make the requested change if possible...otherwise restore the previous selction.
					if (!SelectStyle(combo, selectedStyle))
						SelectStyle(combo, oldStyle);
				}
			}
		}
示例#3
0
		/// <summary>
		/// This crashes when the dialog is invoked for some reason.  ????
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void m_btnStyles_Click(object sender, EventArgs e)
		{
			StyleComboItem sci = (StyleComboItem)m_cbCharStyle.SelectedItem;
			string charStyleName = (sci != null && sci.Style != null) ? sci.Style.Name : "";
			string paraStyleName = m_styleSheet.GetDefaultBasedOnStyleName();
			bool fRightToLeft = false;
			IVwRootSite site = null;		// Do we need something better?  We don't have anything!
			int nMaxStyleLevel = m_callbacks != null ? m_callbacks.MaxStyleLevelToShow : 0;
			int hvoAppRoot = m_callbacks != null ? m_callbacks.HvoAppRootObject : 0;
			using (FwStylesDlg stylesDlg = new FwStylesDlg(site, m_cache,
				m_styleSheet, fRightToLeft, m_cache.ProjectIncludesRightToLeftWs,
				m_styleSheet.GetDefaultBasedOnStyleName(), nMaxStyleLevel,
				FwApp.MeasurementSystem, paraStyleName, charStyleName, hvoAppRoot, FwApp.App,
				FwApp.App))
			{
				//stylesDlg.StylesRenamedOrDeleted +=
				//    new FwStylesDlg.StylesRenOrDelDelegate(OnStylesRenamedOrDeleted);
				stylesDlg.AllowSelectStyleTypes = false;
				stylesDlg.CanSelectParagraphBackgroundColor = false;
				if (stylesDlg.ShowDialog(this) == DialogResult.OK &&
					((stylesDlg.ChangeType & StyleChangeType.DefChanged) > 0 ||
					(stylesDlg.ChangeType & StyleChangeType.Added) > 0))
				{
					FwApp.App.Synchronize(new SyncInfo(SyncMsg.ksyncStyle, 0, 0), m_cache);
				}
				// Reload the list for the styles combo box, and redisplay the controls.
				SetStylesList();
				DisplayStyleControls(m_current.AllParentsChecked);
			}
		}
		private void RunStyleDialog(string styleName)
		{
			using (var dlg = new FwStylesDlg(null, m_cache, m_stylesheet,
				m_cache.WritingSystemFactory.get_EngineOrNull(m_cache.DefaultUserWs).RightToLeftScript,
				m_cache.ServiceLocator.WritingSystems.AllWritingSystems.Any(ws => ws.RightToLeftScript),
				m_stylesheet.GetDefaultBasedOnStyleName(),
				0,		// customUserLevel
				m_app.MeasurementSystem,
				styleName, //m_stylesheet.GetDefaultBasedOnStyleName(),
				styleName,
				0,		// hvoRootObject
				m_app, m_helpTopicProvider))
			{
				dlg.ShowTEStyleTypes = false;
				dlg.CanSelectParagraphBackgroundColor = false;
				if (dlg.ShowDialog(this) == DialogResult.OK &&
					((dlg.ChangeType & StyleChangeType.DefChanged) > 0 ||
						(dlg.ChangeType & StyleChangeType.Added) > 0 ||
							(dlg.ChangeType & StyleChangeType.RenOrDel) > 0))
				{
					m_app.Synchronize(SyncMsg.ksyncStyle);
					FwStyleSheet stylesheet = new FwStyleSheet();
					stylesheet.Init(m_cache, m_cache.LangProject.Hvo, LangProjectTags.kflidStyles);
					m_stylesheet = stylesheet;
				}
			}
		}
示例#5
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Shows the Format Styles dialog.
		/// </summary>
		/// <param name="paraStyleName">Name of the initially selected paragraph style.</param>
		/// <param name="charStyleName">Name of the initially selected character style.</param>
		/// <param name="setPropsToFactorySettings">Delegate to set style info properties back
		/// to the default facotry settings</param>
		/// <returns>
		/// true if a refresh is needed to reload the cache
		/// </returns>
		/// ------------------------------------------------------------------------------------
		public bool ShowStylesDialog(string paraStyleName, string charStyleName,
			Action<StyleInfo> setPropsToFactorySettings)
		{
			StVc vc = null;
			IVwRootSite activeViewSite = null;
			if (EditingHelper == null)
				return true;
			if (ActiveView != null)
			{
				vc = ActiveView.EditingHelper.ViewConstructor as StVc;
				activeViewSite = ActiveView.CastAsIVwRootSite();
			}
			if (paraStyleName == null && charStyleName == null && EditingHelper.CurrentSelection != null
				&& EditingHelper.CurrentSelection.Selection != null)
			{
				// If the caller didn't know the default style, try to figure it out from
				// the selection.
				GetStyleNames(ActiveView as SimpleRootSite, EditingHelper.CurrentSelection.Selection,
					ref paraStyleName, ref charStyleName);
			}
			using (FwStylesDlg stylesDlg = new FwStylesDlg(activeViewSite,
				Cache, ActiveStyleSheet, (vc == null) ? false : vc.RightToLeft,
				Cache.ServiceLocator.WritingSystems.AllWritingSystems.Any(ws => ws.RightToLeftScript),
				ActiveStyleSheet.GetDefaultBasedOnStyleName(),
				MaxStyleLevelToShow, m_app.MeasurementSystem, paraStyleName, charStyleName,
				HvoAppRootObject, m_app, m_app))
			{
				stylesDlg.SetPropsToFactorySettings = setPropsToFactorySettings;
				stylesDlg.StylesRenamedOrDeleted += m_callbacks.OnStylesRenamedOrDeleted;
				stylesDlg.AllowSelectStyleTypes = true;
				stylesDlg.ShowTEStyleTypes = m_callbacks.ShowTEStylesComboInStylesDialog;
				stylesDlg.CanSelectParagraphBackgroundColor = m_callbacks.CanSelectParagraphBackgroundColor;
				return (stylesDlg.ShowDialog(m_callbacks) == DialogResult.OK &&
					((stylesDlg.ChangeType & StyleChangeType.DefChanged) > 0 ||
					(stylesDlg.ChangeType & StyleChangeType.Added) > 0));
			}

		}
示例#6
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Shows the Format Styles dialog.
		/// </summary>
		/// <param name="paraStyleName">Name of the initially selected paragraph style.</param>
		/// <param name="charStyleName">Name of the initially selected character style.</param>
		/// <returns>
		/// true if a refresh is needed to reload the cache
		/// </returns>
		/// ------------------------------------------------------------------------------------
		public bool ShowStylesDialog(string paraStyleName, string charStyleName)
		{
			StVc vc = null;
			IVwRootSite activeViewSite = null;
			if (ActiveView != null)
			{
				vc = ActiveView.EditingHelper.ViewConstructor as StVc;
				activeViewSite = ActiveView.CastAsIVwRootSite();
			}
			using (FwStylesDlg stylesDlg = new FwStylesDlg(activeViewSite,
				Cache, StyleSheet, (vc == null) ? false : vc.RightToLeft,
				Cache.ProjectIncludesRightToLeftWs, StyleSheet.GetDefaultBasedOnStyleName(),
				MaxStyleLevelToShow, FwApp.MeasurementSystem, paraStyleName, charStyleName,
				HvoAppRootObject, FwApp.App, FwApp.App))
			{
				stylesDlg.StylesRenamedOrDeleted +=
					new FwStylesDlg.StylesRenOrDelDelegate(m_callbacks.OnStylesRenamedOrDeleted);
				stylesDlg.AllowSelectStyleTypes = m_callbacks.ShowSelectStylesComboInStylesDialog;
				stylesDlg.CanSelectParagraphBackgroundColor = m_callbacks.CanSelectParagraphBackgroundColor;
				return (stylesDlg.ShowDialog(m_callbacks) == DialogResult.OK &&
					((stylesDlg.ChangeType & StyleChangeType.DefChanged) > 0 ||
					(stylesDlg.ChangeType & StyleChangeType.Added) > 0));
			}

		}