FontNamesConverter クラス
アセンブリ: System.Web (system.web.dll 内)
構文
解説このクラスの ConvertFrom メソッドを使用して、フォント名のリストを含んでいる 1 つの文字列を、個別のフォント名を含んでいる文字列の配列に変換します。文字列の各フォント名をコンマで区切る必要があります。たとえば、"arial, times new roman, verdana" という文字列は、"arial"、"times new roman"、"verdana" の各文字列を含む配列に変換されます。コンマおよびフォント名の前後の空白は削除されます。フォント名の中間にある空白は削除されません。
ConvertTo メソッドは逆の操作を実行します。このメソッドは、個別のフォント名を含んでいる文字列の配列を、フォント名のリストを含んでいる 1 つの文字列に変換します。たとえば、"arial"、"times new roman"、"verdana" という文字列を含んでいる配列は、"arial,times new roman,verdana" という文字列に変換されます。フォント名の間に空白なしでコンマが自動的に挿入されます。
CanConvertFrom メソッドを使用して、ConvertFrom メソッドを使用する前に、変換できるかどうかを確認します。
使用例FontNamesConverter クラスを使用して、フォント名のリストを含んでいる文字列を、個別のフォント名を含んでいる文字列の配列に変換する方法の例を次に示します。文字列の配列は、1 つの文字列に変換し直され、表示されます。
<%@ Page Language="VB" AutoEventWireup="True" %> <html> <head> <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> <p> <form 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="C#" AutoEventWireup="True" %> <html> <head> <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> <p> <form 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>
.NET Framework のセキュリティ
継承階層System.ComponentModel.TypeConverter
System.Web.UI.WebControls.FontNamesConverter
スレッド セーフ
プラットフォームWindows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照FontNamesConverter コンストラクタ
アセンブリ: System.Web (system.web.dll 内)
構文
解説 メモ |
|---|
| 型コンバータには直接アクセスしないでください。代わりに、TypeDescriptor オブジェクトを使用して、該当するコンバータを呼び出します。詳細については、TypeConverter のトピックの例を参照してください。 |
プラットフォームWindows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照FontNamesConverter メソッド
パブリック メソッド
プロテクト メソッド| 名前 | 説明 | |
|---|---|---|
| Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
| GetConvertFromException | 変換を実行できなかった場合にスローされる例外を返します。 ( TypeConverter から継承されます。) |
| GetConvertToException | 変換を実行できなかった場合にスローされる例外を返します。 ( TypeConverter から継承されます。) |
| MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |
| SortProperties | プロパティのコレクションを並べ替えます。 ( TypeConverter から継承されます。) |
参照FontNamesConverter メンバ
フォント名のリストを含んでいる 1 つの文字列を、個別のフォント名を含んでいる文字列の配列に変換します。また、その逆の変換も行います。
FontNamesConverter データ型で公開されるメンバを以下の表に示します。
パブリック コンストラクタ
パブリック メソッド
プロテクト メソッド| 名前 | 説明 | |
|---|---|---|
| Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
| GetConvertFromException | 変換を実行できなかった場合にスローされる例外を返します。 (TypeConverter から継承されます。) |
| GetConvertToException | 変換を実行できなかった場合にスローされる例外を返します。 (TypeConverter から継承されます。) |
| MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |
| SortProperties | プロパティのコレクションを並べ替えます。 (TypeConverter から継承されます。) |
参照- FontNamesConverterのページへのリンク
.gif)