LoginStatusDesigner クラス
アセンブリ: System.Design (system.design.dll 内)
構文
LoginStatus コントロールは、ユーザーの認証ステータスを自動的に確認するボタンを表示し、必要なログインまたはログアウトのオプションを表示します。
ビジュアル デザイナでソース ビューからデザイン ビューに切り替えると、LoginStatus コントロールを記述するマークアップのソース コードが解析され、コントロールのデザイン時バージョンがデザイン サーフェイスに作成されます。元のソース ビューに切り替えると、デザイン時コントロールがマークアップのソース コードに永続化され、Web ページのマークアップに反映されます。LoginStatusDesigner クラスは、LoginStatus コントロールをデザイン時に使用できるようにします。
ActionLists プロパティは、DesignerActionListCollection オブジェクトを返します。一般にこのオブジェクトには、デザイナの継承ツリーの各レベルについて、DesignerActionList クラスから派生したオブジェクトが格納されます。UsePreviewControl プロパティは、常に true を返します。デザイン時にはユーザーの認証ステータスが利用できないため、デザイナは、関連付けられた LoginStatus の一時的なコピーを作成して、デザイン時のマークアップを生成します。
GetDesignTimeHtml メソッドは、デザイン時に、関連付けられた LoginStatus のレンダリングに使用するマークアップを返します。Initialize メソッドは、関連付けられた LoginStatus をデザイナで表示、編集、デザインできるように準備します。
LoginStatusDesigner クラスを拡張し、LoginStatus コントロールから派生したコントロールの外観をデザイン時に変更するコード例を次に示します。
この例では、MyLoginStatus コントロールを LoginStatus から派生させています。MyLoginStatus は、LoginStatus コントロールのコピーです。また、この例では、MyLoginStatusDesigner クラスを LoginStatusDesigner から派生させ、この MyLoginStatusDesigner を指定した DesignerAttribute 属性を MyLoginStatus コントロールに適用します。
MyLoginStatus の BorderStyle プロパティ値が NotSet または None の場合、 MyLoginStatusDesigner は、GetDesignTimeHtml メソッドをオーバーライドして、コントロールの範囲をわかりやすくする青い破線の境界線を周囲に描画します。
Imports System Imports System.Web Imports System.Drawing Imports System.Web.UI.WebControls Imports System.Web.UI.Design.WebControls Imports System.Collections Imports System.ComponentModel Imports System.Security.Permissions Namespace Examples.VB.WebControls.Design ' The MyLoginStatus is a copy of the LoginStatus. <AspNetHostingPermission(SecurityAction.Demand, _ Level:=AspNetHostingPermissionLevel.Minimal)> _ <AspNetHostingPermission(SecurityAction.InheritanceDemand, _ Level:=AspNetHostingPermissionLevel.Minimal)> _ <Designer(GetType(Examples.VB.WebControls.Design.MyLoginStatusDesigner))> _ Public Class MyLoginStatus Inherits LoginStatus End Class ' MyLoginStatus ' Override members of the LoginStatusDesigner. Public Class MyLoginStatusDesigner Inherits LoginStatusDesigner ' Generate the design-time markup. Public Overrides Function GetDesignTimeHtml() As String ' Make the control more visible in the designer. If the border ' style is None or NotSet, change the border to a blue dashed line. Dim myLoginStatusCtl As MyLoginStatus = _ CType(ViewControl, MyLoginStatus) Dim markup As String = Nothing ' Check if the border style should be changed. If (myLoginStatusCtl.BorderStyle = BorderStyle.NotSet Or _ myLoginStatusCtl.BorderStyle = BorderStyle.None) Then Dim oldBorderStyle As BorderStyle = myLoginStatusCtl.BorderStyle Dim oldBorderColor As Color = myLoginStatusCtl.BorderColor ' Set the design time properties and catch any exceptions. Try myLoginStatusCtl.BorderStyle = BorderStyle.Dashed myLoginStatusCtl.BorderColor = Color.Blue ' Call the base method to generate the markup. markup = MyBase.GetDesignTimeHtml() Catch ex As Exception markup = GetErrorDesignTimeHtml(ex) Finally ' It is not necessary to restore the border properties ' to their original values because the ViewControl ' was used to reference the associated control and the ' UsePreviewControl was not overridden. ' myLoginCtl.BorderStyle = oldBorderStyle ' myLoginCtl.BorderColor = oldBorderColor End Try Else ' Call the base method to generate the markup. markup = MyBase.GetDesignTimeHtml() End If Return markup End Function ' GetDesignTimeHtml End Class ' MyLoginStatusDesigner End Namespace ' Examples.VB.WebControls.Design
using System; using System.Web; using System.Drawing; using System.Web.UI.WebControls; using System.Web.UI.Design.WebControls; using System.Collections; using System.ComponentModel; using System.Security.Permissions; using System.IO; namespace Examples.CS.WebControls.Design { // The MyLoginStatus is a copy of the LoginStatus. [AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)] [Designer(typeof(Examples.CS.WebControls.Design.MyLoginStatusDesigner))] public class MyLoginStatus : LoginStatus { } // MyLoginStatus // Override members of the LoginStatusDesigner. public class MyLoginStatusDesigner : LoginStatusDesigner { // Generate the design-time markup. public override string GetDesignTimeHtml() { // Make the control more visible in the designer. If the border // style is None or NotSet, change the border to a blue dashed line. MyLoginStatus myLoginStatusCtl = (MyLoginStatus)ViewControl; string markup = null; // Check if the border style should be changed. if (myLoginStatusCtl.BorderStyle == BorderStyle.NotSet || myLoginStatusCtl.BorderStyle == BorderStyle.None) { BorderStyle oldBorderStyle = myLoginStatusCtl.BorderStyle; Color oldBorderColor = myLoginStatusCtl.BorderColor; // Set the design time properties and catch any exceptions. try { myLoginStatusCtl.BorderStyle = BorderStyle.Dashed; myLoginStatusCtl.BorderColor = Color.Blue; // Call the base method to generate the markup. markup = base.GetDesignTimeHtml(); } catch (Exception ex) { markup = GetErrorDesignTimeHtml(ex); } finally { // It is not necessary to restore the border properties // to their original values because the ViewControl // was used to reference the associated control and the // UsePreviewControl was not overridden. // myLoginCtl.BorderStyle = oldBorderStyle; // myLoginCtl.BorderColor = oldBorderColor; } } else // Call the base method to generate the markup. markup = base.GetDesignTimeHtml(); return markup; } // GetDesignTimeHtml } // MyLoginStatusDesigner } // Examples.CS.WebControls.Design
System.ComponentModel.Design.ComponentDesigner
System.Web.UI.Design.HtmlControlDesigner
System.Web.UI.Design.ControlDesigner
System.Web.UI.Design.WebControls.CompositeControlDesigner
System.Web.UI.Design.WebControls.LoginStatusDesigner
プラットフォーム
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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
- LoginStatusDesigner クラスのページへのリンク