Html32TextWriter.SupportsItalic Свойство
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Возвращает или задает логическое значение, указывающее, поддерживает ли запрашивающее устройство курсивный HTML-текст. SupportsItalic Используйте свойство для условной отрисовки курсивного текста в выходной Html32TextWriter поток.
public:
property bool SupportsItalic { bool get(); void set(bool value); };
public bool SupportsItalic { get; set; }
member this.SupportsItalic : bool with get, set
Public Property SupportsItalic As Boolean
Значение свойства
true Значение , если запрашивающее устройство поддерживает курсивный текст; falseв противном случае . Значение по умолчанию — true.
Примеры
В следующем примере кода показано, как переопределить RenderBeforeContent методы и RenderAfterContent методы. Каждое переопределение проверяет, отображается ли span элемент, а затем используется SupportsItalic свойство для проверки того, может ли запрашивающее устройство отображать курсивное форматирование. Если устройство поддерживает курсивное форматирование, RenderBeforeContent метод записывает открывающий тег i элемента, а RenderAfterContent метод записывает его закрывающий тег. Если устройство не поддерживает курсивное форматирование, RenderBeforeContent метод записывает открывающий тег элемента с color атрибутом, заданным шестнадцатеричным значением для темно-синего Font цвета, а RenderAfterContent метод записывает закрывающий тег.
Этот пример кода является частью более крупного примера, предоставленного для Html32TextWriter класса.
// Override the RenderBeforeContent method to render
// styles before rendering the content of a <th> element.
protected override string RenderBeforeContent()
{
// Check the TagKey property. If its value is
// HtmlTextWriterTag.TH, check the value of the
// SupportsBold property. If true, return the
// opening tag of a <b> element; otherwise, render
// the opening tag of a <font> element with a color
// attribute set to the hexadecimal value for red.
if (TagKey == HtmlTextWriterTag.Th)
{
if (SupportsBold)
return "<b>";
else
return "<font color=\"FF0000\">";
}
// Check whether the element being rendered
// is an <H4> element. If it is, check the
// value of the SupportsItalic property.
// If true, render the opening tag of the <i> element
// prior to the <H4> element's content; otherwise,
// render the opening tag of a <font> element
// with a color attribute set to the hexadecimal
// value for navy blue.
if (TagKey == HtmlTextWriterTag.H4)
{
if (SupportsItalic)
return "<i>";
else
return "<font color=\"000080\">";
}
// Call the base method.
return base.RenderBeforeContent();
}
' Override the RenderBeforeContent method to render
' styles before rendering the content of a <th> element.
Protected Overrides Function RenderBeforeContent() As String
' Check the TagKey property. If its value is
' HtmlTextWriterTag.TH, check the value of the
' SupportsBold property. If true, return the
' opening tag of a <b> element; otherwise, render
' the opening tag of a <font> element with a color
' attribute set to the hexadecimal value for red.
If TagKey = HtmlTextWriterTag.Th Then
If (SupportsBold) Then
Return "<b>"
Else
Return "<font color=""FF0000"">"
End If
End If
' Check whether the element being rendered
' is an <H4> element. If it is, check the
' value of the SupportsItalic property.
' If true, render the opening tag of the <i> element
' prior to the <H4> element's content; otherwise,
' render the opening tag of a <font> element
' with a color attribute set to the hexadecimal
' value for navy blue.
If TagKey = HtmlTextWriterTag.H4 Then
If (SupportsItalic) Then
Return "<i>"
Else
Return "<font color=""000080"">"
End If
End If
' Call the base method.
Return MyBase.RenderBeforeContent()
End Function