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

プロパティ値

Boolean

要求元のデバイスが斜体のテキストをサポートしている場合は true。それ以外の場合は false。 既定値は、true です。

次のコード例は、メソッドとRenderAfterContentメソッドをオーバーライドする方法をRenderBeforeContent示しています。 各オーバーライドは、要素がレンダリングされているかどうかを span 確認し、そのプロパティを SupportsItalic 使用して、要求するデバイスが斜体の書式設定を表示できるかどうかを確認します。 デバイスが斜体の書式設定をサポートしている場合、メソッドは RenderBeforeContent 要素の開始タグを i 書き込み、メソッドはその RenderAfterContent 終了タグを書き込みます。 デバイスが斜体の書式設定をサポートしていない場合、RenderBeforeContentメソッドは、属性がネイビー ブルーの 16 進値に設定された要素colorFont開始タグを書き込み、メソッドは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

適用対象

こちらもご覧ください