SIL.FieldWorks.Common.Widgets.FwTextBox.ApplyStyle C# (CSharp) Method

ApplyStyle() public method

Applies the specified style to the current selection of the Tss string
public ApplyStyle ( string sStyle ) : void
sStyle string The name of the style to apply
return void
		public void ApplyStyle(string sStyle)
		{
			CheckDisposed();

			m_innerFwTextBox.EditingHelper.ApplyStyle(sStyle);
			if (m_innerFwTextBox.Tss.Length == 0)
			{
				// Need to also set the properties on the string. This allows searching for
				// styles only.
				ITsStrBldr bldr = m_innerFwTextBox.Tss.GetBldr();
				bldr.SetStrPropValue(0, 0, (int)FwTextPropType.ktptNamedStyle, sStyle);
				m_innerFwTextBox.Tss = bldr.GetString();
			}
			m_innerFwTextBox.RefreshDisplay();
		}

Usage Example

Ejemplo n.º 1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Applies the specified style to the current selection of the Tss string in the
		/// specified Tss edit control
		/// </summary>
		/// <param name="fwTextBox">The Tss edit control whose selection should have the
		/// specified style applied to it.</param>
		/// <param name="sStyle">The name of the style to apply</param>
		/// ------------------------------------------------------------------------------------
		public void ApplyStyle(FwTextBox fwTextBox, string sStyle)
		{
			CheckDisposed();

			// Apply the specified style to the current selection
			if (sStyle.ToLowerInvariant() == FwCoreDlgs.kstidNoStyle.ToLowerInvariant())
				sStyle = null;
			else if (sStyle.ToLowerInvariant() == FdoResources.DefaultParaCharsStyleName.ToLowerInvariant())
				sStyle = FwStyleSheet.kstrDefaultCharStyle;
			fwTextBox.ApplyStyle(sStyle);
			SetFormatLabels();

			fwTextBox.Focus();
		}