当前位置: 首页>>代码示例>>C#>>正文


C# FwStyleSheet.GetDefaultBasedOnStyleName方法代码示例

本文整理汇总了C#中FwStyleSheet.GetDefaultBasedOnStyleName方法的典型用法代码示例。如果您正苦于以下问题:C# FwStyleSheet.GetDefaultBasedOnStyleName方法的具体用法?C# FwStyleSheet.GetDefaultBasedOnStyleName怎么用?C# FwStyleSheet.GetDefaultBasedOnStyleName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FwStyleSheet的用法示例。


在下文中一共展示了FwStyleSheet.GetDefaultBasedOnStyleName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RunStylesDialogForCombo

		/// <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);
				}
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:70,代码来源:FwStylesDlg.cs


注:本文中的FwStyleSheet.GetDefaultBasedOnStyleName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。