FontNamesConverter.ConvertFrom メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
フォント名の一リストを表す文字列を、個別のフォント名を含んでいる文字列の配列に変換します。
public:
override System::Object ^ ConvertFrom(System::ComponentModel::ITypeDescriptorContext ^ context, System::Globalization::CultureInfo ^ culture, System::Object ^ value);
public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value);
override this.ConvertFrom : System.ComponentModel.ITypeDescriptorContext * System.Globalization.CultureInfo * obj -> obj
Public Overrides Function ConvertFrom (context As ITypeDescriptorContext, culture As CultureInfo, value As Object) As Object
パラメーター
- context
- ITypeDescriptorContext
型コンバーターのコンテキストに関する情報を提供する ITypeDescriptorContext オブジェクト。 このパラメーターは、このメソッドでは使用されません。 このメソッドの将来のバージョンで使用するために予約されています。 このパラメーターには、null を渡すこともできます。
- culture
- CultureInfo
言語、暦システムなどのカルチャに関する情報を表す CultureInfo オブジェクト。 このパラメーターは、このメソッドでは使用されません。 このメソッドの将来のバージョンで使用するために予約されています。 このパラメーターには、null を渡すこともできます。
戻り値
個別のフォント名を含んでいる文字列の配列を表す Object インスタンス。
例外
value が String 型ではありません。
例
次のコード例では、 メソッドを ConvertFrom 使用して、フォント名の一覧を含む文字列を、個々の名前を含む文字列の配列に変換する方法を示します。
<%@ Page Language="C#" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>FontNamesConverter Example</title>
<script language="C#" runat="server">
void Page_Load(Object sender, EventArgs e)
{
// Declare local variables.
System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo("en");
System.ComponentModel.ITypeDescriptorContext context = null;
Object names;
Object name_string;
// Create FontNamesConverter object.
FontNamesConverter fontconverter = new FontNamesConverter();
// Create original list of fonts.
string font_list = "arial, times new roman, verdana";
// Check for type compatibility.
if (fontconverter.CanConvertFrom(context, typeof(string)))
{
// Display original string.
Label1.Text = "Original String :" + "<br /><br />" + font_list;
// Convert string to array to strings and display results.
names = fontconverter.ConvertFrom(context, culture, font_list);
Label2.Text = "Converted to Array of Strings : " + "<br /><br />";
foreach (string name_element in (string[])names)
{
Label2.Text += name_element + "<br />";
}
// Convert array of strings back to a string and display results.
name_string = fontconverter.ConvertTo(context, culture, names, typeof(string));
Label3.Text = "Converted back to String :" + "<br /><br />" + (string)name_string;
}
}
</script>
</head>
<body>
<h3>FontNamesConverter Example</h3>
<br />
<form id="form1" runat="server">
<asp:Label id="Label1" runat="server"/>
<br /><hr />
<asp:Label id="Label2" runat="server"/>
<br /><hr />
<asp:Label id="Label3" runat="server"/>
</form>
</body>
</html>
<%@ Page Language="VB" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>FontNamesConverter Example</title>
<script language="VB" runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
' Declare local variables.
Dim culture As New System.Globalization.CultureInfo("en")
Dim context As System.ComponentModel.ITypeDescriptorContext = Nothing
Dim names As Object
Dim name_string As Object
' Create FontNamesConverter object.
Dim fontconverter As New FontNamesConverter()
' Create original list of fonts.
Dim font_list As String = "arial, times new roman, verdana"
' Check for type compatibility.
If fontconverter.CanConvertFrom(context, GetType(String)) Then
' Display original string.
Label1.Text = "Original String :" & "<br /><br />" & font_list
' Convert string to array to strings and display results.
names = fontconverter.ConvertFrom(context, culture, font_list)
Label2.Text = "Converted to Array of Strings : " & "<br /><br />"
Dim name_element As String
For Each name_element In CType(names, String())
Label2.Text &= name_element & "<br />"
Next name_element
' Convert array of strings back to a string and display results.
name_string = fontconverter.ConvertTo(context, culture, names, _
GetType(String))
Label3.Text = "Converted back to String :" & "<br /><br />" & _
CType(name_string, String)
End If
End Sub 'Page_Load
</script>
</head>
<body>
<h3>FontNamesConverter Example</h3>
<br />
<form id="form1" runat="server">
<asp:Label id="Label1" runat="server"/>
<br /><hr />
<asp:Label id="Label2" runat="server"/>
<br /><hr />
<asp:Label id="Label3" runat="server"/>
</form>
</body>
</html>
注釈
フォント名の ConvertFrom リストを含む文字列を、個々の名前を含む文字列の配列に変換するには、 メソッドを使用します。 文字列内の各フォント名は、コンマで区切る必要があります。 たとえば、文字列 "arial, times new roman, verdana" は、文字列 "arial"、"times new roman"、および "verdana" を含む配列に変換します。 コンマは、フォント名の先頭または末尾に空白と共に削除されます。 フォント名の中央にある空白は削除されません。
注意
contextパラメーターと culture パラメーターは、このバージョンの メソッドでは使用されません。これらは、 メソッドの将来のバージョン用に予約されています。 必要に応じて、これらのパラメーターを null 渡すことができます。