ToolboxItemFilterAttribute 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
도구 상자 항목에 사용할 필터 문자열과 필터 형식을 지정합니다.
public ref class ToolboxItemFilterAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=true, Inherited=true)]
public sealed class ToolboxItemFilterAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=true, Inherited=true)]
[System.Serializable]
public sealed class ToolboxItemFilterAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=true, Inherited=true)>]
type ToolboxItemFilterAttribute = class
inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=true, Inherited=true)>]
[<System.Serializable>]
type ToolboxItemFilterAttribute = class
inherit Attribute
Public NotInheritable Class ToolboxItemFilterAttribute
Inherits Attribute
- 상속
- 특성
예제
다음 코드 예제에 적용 하는 방법을 보여 줍니다.는 ToolboxItemFilterAttribute합니다.
#using <System.Drawing.dll>
#using <System.dll>
#using <System.Design.dll>
#using <System.Windows.Forms.dll>
using namespace System;
using namespace System::Collections;
using namespace System::ComponentModel;
using namespace System::ComponentModel::Design;
using namespace System::Diagnostics;
using namespace System::Drawing;
using namespace System::Drawing::Design;
using namespace System::Windows::Forms;
using namespace System::Windows::Forms::Design;
// This example contains an IRootDesigner that implements the IToolboxUser interface.
// This example demonstrates how to enable the GetToolSupported method of an IToolboxUser
// designer in order to disable specific toolbox items, and how to respond to the
// invocation of a ToolboxItem in the ToolPicked method of an IToolboxUser implementation.
public ref class SampleRootDesigner;
// The following attribute associates the SampleRootDesigner with this example component.
[DesignerAttribute(__typeof(SampleRootDesigner),__typeof(IRootDesigner))]
public ref class RootDesignedComponent: public Control{};
// This example component class demonstrates the associated IRootDesigner which
// implements the IToolboxUser interface. When designer view is invoked, Visual
// Studio .NET attempts to display a design mode view for the class at the top
// of a code file. This can sometimes fail when the class is one of multiple types
// in a code file, and has a DesignerAttribute associating it with an IRootDesigner.
// Placing a derived class at the top of the code file solves this problem. A
// derived class is not typically needed for this reason, except that placing the
// RootDesignedComponent class in another file is not a simple solution for a code
// example that is packaged in one segment of code.
public ref class RootViewSampleComponent: public RootDesignedComponent{};
// This example IRootDesigner implements the IToolboxUser interface and provides a
// Windows Forms view technology view for its associated component using an internal
// Control type.
// The following ToolboxItemFilterAttribute enables the GetToolSupported method of this
// IToolboxUser designer to be queried to check for whether to enable or disable all
// ToolboxItems which create any components whose type name begins with "System.Windows.Forms".
[ToolboxItemFilterAttribute(S"System.Windows.Forms",ToolboxItemFilterType::Custom)]
public ref class SampleRootDesigner: public ParentControlDesigner, public IRootDesigner, public IToolboxUser
{
public private:
ref class RootDesignerView;
private:
// This field is a custom Control type named RootDesignerView. This field references
// a control that is shown in the design mode document window.
RootDesignerView^ view;
// This string array contains type names of components that should not be added to
// the component managed by this designer from the Toolbox. Any ToolboxItems whose
// type name matches a type name in this array will be marked disabled according to
// the signal returned by the IToolboxUser.GetToolSupported method of this designer.
array<String^>^blockedTypeNames;
public:
SampleRootDesigner()
{
array<String^>^tempTypeNames = {"System.Windows.Forms.ListBox","System.Windows.Forms.GroupBox"};
blockedTypeNames = tempTypeNames;
}
private:
property array<ViewTechnology>^ SupportedTechnologies
{
// IRootDesigner.SupportedTechnologies is a required override for an IRootDesigner.
// This designer provides a display using the Windows Forms view technology.
array<ViewTechnology>^ IRootDesigner::get()
{
ViewTechnology temp0[] = {ViewTechnology::WindowsForms};
return temp0;
}
}
// This method returns an object that provides the view for this root designer.
Object^ IRootDesigner::GetView( ViewTechnology technology )
{
// If the design environment requests a view technology other than Windows
// Forms, this method throws an Argument Exception.
if ( technology != ViewTechnology::WindowsForms )
throw gcnew ArgumentException( "An unsupported view technology was requested","Unsupported view technology." );
// Creates the view object if it has not yet been initialized.
if ( view == nullptr )
view = gcnew RootDesignerView( this );
return view;
}
// This method can signal whether to enable or disable the specified
// ToolboxItem when the component associated with this designer is selected.
bool IToolboxUser::GetToolSupported( ToolboxItem^ tool )
{
// Search the blocked type names array for the type name of the tool
// for which support for is being tested. Return false to indicate the
// tool should be disabled when the associated component is selected.
for ( int i = 0; i < blockedTypeNames->Length; i++ )
if ( tool->TypeName == blockedTypeNames[ i ] )
return false;
// Return true to indicate support for the tool, if the type name of the
// tool is not located in the blockedTypeNames string array.
return true;
}
// This method can perform behavior when the specified tool has been invoked.
// Invocation of a ToolboxItem typically creates a component or components,
// and adds any created components to the associated component.
void IToolboxUser::ToolPicked( ToolboxItem^ /*tool*/ ){}
public private:
// This control provides a Windows Forms view technology view object that
// provides a display for the SampleRootDesigner.
[DesignerAttribute(__typeof(ParentControlDesigner),__typeof(IDesigner))]
ref class RootDesignerView: public Control
{
private:
// This field stores a reference to a designer.
IDesigner^ m_designer;
public:
RootDesignerView( IDesigner^ designer )
{
// Perform basic control initialization.
m_designer = designer;
BackColor = Color::Blue;
Font = gcnew System::Drawing::Font( Font->FontFamily->Name,24.0f );
}
protected:
// This method is called to draw the view for the SampleRootDesigner.
void OnPaint( PaintEventArgs^ pe )
{
Control::OnPaint( pe );
// Draw the name of the component in large letters.
pe->Graphics->DrawString( m_designer->Component->Site->Name, Font, Brushes::Yellow, ClientRectangle );
}
};
};
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Design;
using System.Windows.Forms;
using System.Windows.Forms.Design;
// This example contains an IRootDesigner that implements the IToolboxUser interface.
// This example demonstrates how to enable the GetToolSupported method of an IToolboxUser
// designer in order to disable specific toolbox items, and how to respond to the
// invocation of a ToolboxItem in the ToolPicked method of an IToolboxUser implementation.
namespace IToolboxUserExample
{
// This example component class demonstrates the associated IRootDesigner which
// implements the IToolboxUser interface. When designer view is invoked, Visual
// Studio .NET attempts to display a design mode view for the class at the top
// of a code file. This can sometimes fail when the class is one of multiple types
// in a code file, and has a DesignerAttribute associating it with an IRootDesigner.
// Placing a derived class at the top of the code file solves this problem. A
// derived class is not typically needed for this reason, except that placing the
// RootDesignedComponent class in another file is not a simple solution for a code
// example that is packaged in one segment of code.
public class RootViewSampleComponent : RootDesignedComponent
{
}
// The following attribute associates the SampleRootDesigner with this example component.
[DesignerAttribute(typeof(SampleRootDesigner), typeof(IRootDesigner))]
public class RootDesignedComponent : System.Windows.Forms.Control
{
}
// This example IRootDesigner implements the IToolboxUser interface and provides a
// Windows Forms view technology view for its associated component using an internal
// Control type.
// The following ToolboxItemFilterAttribute enables the GetToolSupported method of this
// IToolboxUser designer to be queried to check for whether to enable or disable all
// ToolboxItems which create any components whose type name begins with "System.Windows.Forms".
[ToolboxItemFilterAttribute("System.Windows.Forms", ToolboxItemFilterType.Custom)]
public class SampleRootDesigner : ParentControlDesigner, IRootDesigner, IToolboxUser
{
// This field is a custom Control type named RootDesignerView. This field references
// a control that is shown in the design mode document window.
private RootDesignerView view;
// This string array contains type names of components that should not be added to
// the component managed by this designer from the Toolbox. Any ToolboxItems whose
// type name matches a type name in this array will be marked disabled according to
// the signal returned by the IToolboxUser.GetToolSupported method of this designer.
private string[] blockedTypeNames =
{
"System.Windows.Forms.ListBox",
"System.Windows.Forms.GroupBox"
};
// IRootDesigner.SupportedTechnologies is a required override for an IRootDesigner.
// This designer provides a display using the Windows Forms view technology.
ViewTechnology[] IRootDesigner.SupportedTechnologies
{
get { return new ViewTechnology[] {ViewTechnology.Default}; }
}
// This method returns an object that provides the view for this root designer.
object IRootDesigner.GetView(ViewTechnology technology)
{
// If the design environment requests a view technology other than Windows
// Forms, this method throws an Argument Exception.
if (technology != ViewTechnology.Default)
throw new ArgumentException("An unsupported view technology was requested",
"Unsupported view technology.");
// Creates the view object if it has not yet been initialized.
if (view == null)
view = new RootDesignerView(this);
return view;
}
// This method can signal whether to enable or disable the specified
// ToolboxItem when the component associated with this designer is selected.
bool IToolboxUser.GetToolSupported(ToolboxItem tool)
{
// Search the blocked type names array for the type name of the tool
// for which support for is being tested. Return false to indicate the
// tool should be disabled when the associated component is selected.
for( int i=0; i<blockedTypeNames.Length; i++ )
if( tool.TypeName == blockedTypeNames[i] )
return false;
// Return true to indicate support for the tool, if the type name of the
// tool is not located in the blockedTypeNames string array.
return true;
}
// This method can perform behavior when the specified tool has been invoked.
// Invocation of a ToolboxItem typically creates a component or components,
// and adds any created components to the associated component.
void IToolboxUser.ToolPicked(ToolboxItem tool)
{
}
// This control provides a Windows Forms view technology view object that
// provides a display for the SampleRootDesigner.
[DesignerAttribute(typeof(ParentControlDesigner), typeof(IDesigner))]
internal class RootDesignerView : Control
{
// This field stores a reference to a designer.
private IDesigner m_designer;
public RootDesignerView(IDesigner designer)
{
// Perform basic control initialization.
m_designer = designer;
BackColor = Color.Blue;
Font = new Font(Font.FontFamily.Name, 24.0f);
}
// This method is called to draw the view for the SampleRootDesigner.
protected override void OnPaint(PaintEventArgs pe)
{
base.OnPaint(pe);
// Draw the name of the component in large letters.
pe.Graphics.DrawString(m_designer.Component.Site.Name, Font, Brushes.Yellow, ClientRectangle);
}
}
}
}
Imports System.Collections
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Diagnostics
Imports System.Drawing
Imports System.Drawing.Design
Imports System.Windows.Forms
Imports System.Windows.Forms.Design
' This example contains an IRootDesigner that implements the IToolboxUser interface.
' This example demonstrates how to enable the GetToolSupported method of an IToolboxUser
' designer in order to disable specific toolbox items, and how to respond to the
' invocation of a ToolboxItem in the ToolPicked method of an IToolboxUser implementation.
' This example component class demonstrates the associated IRootDesigner which
' implements the IToolboxUser interface. When designer view is invoked, Visual
' Studio .NET attempts to display a design mode view for the class at the top
' of a code file. This can sometimes fail when the class is one of multiple types
' in a code file, and has a DesignerAttribute associating it with an IRootDesigner.
' Placing a derived class at the top of the code file solves this problem. A
' derived class is not typically needed for this reason, except that placing the
' RootDesignedComponent class in another file is not a simple solution for a code
' example that is packaged in one segment of code.
Public Class RootViewSampleComponent
Inherits RootDesignedComponent
End Class
' The following attribute associates the SampleRootDesigner with this example component.
<DesignerAttribute(GetType(SampleRootDesigner), GetType(IRootDesigner))> _
Public Class RootDesignedComponent
Inherits System.Windows.Forms.Control
End Class
' This example IRootDesigner implements the IToolboxUser interface and provides a
' Windows Forms view technology view for its associated component using an internal
' Control type.
' The following ToolboxItemFilterAttribute enables the GetToolSupported method of this
' IToolboxUser designer to be queried to check for whether to enable or disable all
' ToolboxItems which create any components whose type name begins with "System.Windows.Forms".
<ToolboxItemFilterAttribute("System.Windows.Forms", ToolboxItemFilterType.Custom)> _
<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _
Public Class SampleRootDesigner
Inherits ParentControlDesigner
Implements IRootDesigner, IToolboxUser
' Member field of custom type RootDesignerView, a control that is shown in the
' design mode document window. This member is cached to reduce processing needed
' to recreate the view control on each call to GetView().
Private m_view As RootDesignerView
' This string array contains type names of components that should not be added to
' the component managed by this designer from the Toolbox. Any ToolboxItems whose
' type name matches a type name in this array will be marked disabled according to
' the signal returned by the IToolboxUser.GetToolSupported method of this designer.
Private blockedTypeNames As String() = {"System.Windows.Forms.ListBox", "System.Windows.Forms.GroupBox"}
' IRootDesigner.SupportedTechnologies is a required override for an IRootDesigner.
' This designer provides a display using the Windows Forms view technology.
ReadOnly Property SupportedTechnologies() As ViewTechnology() Implements IRootDesigner.SupportedTechnologies
Get
Return New ViewTechnology() {ViewTechnology.Default}
End Get
End Property
' This method returns an object that provides the view for this root designer.
Function GetView(ByVal technology As ViewTechnology) As Object Implements IRootDesigner.GetView
' If the design environment requests a view technology other than Windows
' Forms, this method throws an Argument Exception.
If technology <> ViewTechnology.Default Then
Throw New ArgumentException("An unsupported view technology was requested", "Unsupported view technology.")
End If
' Creates the view object if it has not yet been initialized.
If m_view Is Nothing Then
m_view = New RootDesignerView(Me)
End If
Return m_view
End Function
' This method can signal whether to enable or disable the specified
' ToolboxItem when the component associated with this designer is selected.
Function GetToolSupported(ByVal tool As ToolboxItem) As Boolean Implements IToolboxUser.GetToolSupported
' Search the blocked type names array for the type name of the tool
' for which support for is being tested. Return false to indicate the
' tool should be disabled when the associated component is selected.
Dim i As Integer
For i = 0 To blockedTypeNames.Length - 1
If tool.TypeName = blockedTypeNames(i) Then
Return False
End If
Next i ' Return true to indicate support for the tool, if the type name of the
' tool is not located in the blockedTypeNames string array.
Return True
End Function
' This method can perform behavior when the specified tool has been invoked.
' Invocation of a ToolboxItem typically creates a component or components,
' and adds any created components to the associated component.
Sub ToolPicked(ByVal tool As ToolboxItem) Implements IToolboxUser.ToolPicked
End Sub
' This control provides a Windows Forms view technology view object that
' provides a display for the SampleRootDesigner.
<DesignerAttribute(GetType(ParentControlDesigner), GetType(IDesigner))> _
Friend Class RootDesignerView
Inherits Control
' This field stores a reference to a designer.
Private m_designer As IDesigner
Public Sub New(ByVal designer As IDesigner)
' Performs basic control initialization.
m_designer = designer
BackColor = Color.Blue
Font = New Font(Font.FontFamily.Name, 24.0F)
End Sub
' This method is called to draw the view for the SampleRootDesigner.
Protected Overrides Sub OnPaint(ByVal pe As PaintEventArgs)
MyBase.OnPaint(pe)
' Draws the name of the component in large letters.
pe.Graphics.DrawString(m_designer.Component.Site.Name, Font, Brushes.Yellow, New RectangleF(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, ClientRectangle.Height))
End Sub
End Class
End Class
설명
ToolboxItemFilterAttribute 는 도구 상자에서 항목을 사용하도록 설정하거나 사용하지 않도록 설정할지 여부를 결정하는 일치하는 특성 또는 코드가 있는 디자이너에서만 사용할 수 있도록 도구 상자 항목을 표시할 수 있는 메커니즘을 제공합니다.
을 ToolboxItemFilterAttributeToolboxItem 에 적용하여 항목을 사용하거나 사용하지 않도록 설정할 시기를 지정하는 필터 문자열 및 필터 형식을 나타낼 수 있습니다. ToolboxItemFilterAttribute 는 도구 상자에서 항목을 사용하도록 설정하기 위한 요구 사항을 나타내기 위해 디자이너에 적용할 수도 있습니다. 이 유형의 특성을 사용하여 필터 문자열이 일치하는 디자이너를 사용할 때만 도구 상자 항목을 사용하도록 설정할 수 있음을 나타낼 수 있습니다. 필터의 형식은 필터 문자열 일치의 사용 여부와 방법 또는 사용자 지정 코드를 사용하여 항목을 사용하도록 설정할지 여부를 나타내는 로 속성 ToolboxItemFilterType 에 표시됩니다FilterType.
생성자
ToolboxItemFilterAttribute(String) |
지정된 필터 문자열을 사용하여 ToolboxItemFilterAttribute 클래스의 새 인스턴스를 초기화합니다. |
ToolboxItemFilterAttribute(String, ToolboxItemFilterType) |
지정된 필터 문자열과 형식을 사용하여 ToolboxItemFilterAttribute 클래스의 새 인스턴스를 초기화합니다. |
속성
FilterString |
도구 상자 항목에 대한 필터 문자열을 가져옵니다. |
FilterType |
필터 형식을 가져옵니다. |
TypeId |
해당 특성의 형식 ID를 가져옵니다. |
메서드
Equals(Object) |
이 인스턴스가 지정된 개체와 같은지를 나타내는 값을 반환합니다. |
GetHashCode() |
이 인스턴스의 해시 코드를 반환합니다. |
GetType() |
현재 인스턴스의 Type을 가져옵니다. (다음에서 상속됨 Object) |
IsDefaultAttribute() |
파생 클래스에서 재정의된 경우 이 인스턴스 값이 파생 클래스에 대한 기본값인지 여부를 표시합니다. (다음에서 상속됨 Attribute) |
Match(Object) |
지정된 개체에 일치하는 필터 문자열이 있는지 여부를 나타냅니다. |
MemberwiseClone() |
현재 Object의 단순 복사본을 만듭니다. (다음에서 상속됨 Object) |
ToString() |
현재 개체를 나타내는 문자열을 반환합니다. |
ToString() |
현재 개체를 나타내는 문자열을 반환합니다. (다음에서 상속됨 Object) |
명시적 인터페이스 구현
_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
이름 집합을 해당하는 디스패치 식별자 집합에 매핑합니다. (다음에서 상속됨 Attribute) |
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) |
인터페이스의 형식 정보를 가져오는 데 사용할 수 있는 개체의 형식 정보를 검색합니다. (다음에서 상속됨 Attribute) |
_Attribute.GetTypeInfoCount(UInt32) |
개체에서 제공하는 형식 정보 인터페이스의 수를 검색합니다(0 또는 1). (다음에서 상속됨 Attribute) |
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
개체에서 노출하는 메서드와 속성에 대한 액세스를 제공합니다. (다음에서 상속됨 Attribute) |
적용 대상
추가 정보
.NET