AmbientValueAttribute 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
속성이 다른 소스에서 해당 값을 가져올 수 있도록 속성에 전달할 값을 지정합니다. 이를 앰비언스. 이 클래스는 상속할 수 없습니다.
public ref class AmbientValueAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.All)]
public sealed class AmbientValueAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.All)>]
type AmbientValueAttribute = class
inherit Attribute
Public NotInheritable Class AmbientValueAttribute
Inherits Attribute
- 상속
- 특성
예제
다음 코드 예제에서는 호출 AlertForeColor된 속성에 대 한 앰비언트 동작을 적용 하는 데 사용 AmbientValueAttribute 하는 방법을 보여 줍니다. 전체 코드 목록은 방법: Windows Forms 컨트롤에서 특성 적용을 참조하세요.
[AmbientValue(typeof(Color), "Empty")]
[Category("Appearance")]
[DefaultValue(typeof(Color), "White")]
[Description("The color used for painting alert text.")]
public Color AlertForeColor
{
get =>
_alertForeColorValue == Color.Empty &&
Parent != null
? Parent.ForeColor
: _alertForeColorValue;
set => _alertForeColorValue = value;
}
// This method is used by designers to enable resetting the
// property to its default value.
public void ResetAlertForeColor() =>
AlertForeColor = s_defaultAlertForeColorValue;
// This method indicates to designers whether the property
// value is different from the ambient value, in which case
// the designer should persist the value.
bool ShouldSerializeAlertForeColor() =>
_alertForeColorValue != s_ambientColorValue;
<AmbientValue(GetType(Color), "Empty"), _
Category("Appearance"), _
DefaultValue(GetType(Color), "White"), _
Description("The color used for painting alert text.")> _
Public Property AlertForeColor() As Color
Get
If Me.alertForeColorValue = Color.Empty AndAlso (Me.Parent IsNot Nothing) Then
Return Parent.ForeColor
End If
Return Me.alertForeColorValue
End Get
Set(ByVal value As Color)
Me.alertForeColorValue = value
End Set
End Property
' This method is used by designers to enable resetting the
' property to its default value.
Public Sub ResetAlertForeColor()
Me.AlertForeColor = AttributesDemoControl.defaultAlertForeColorValue
End Sub
' This method indicates to designers whether the property
' value is different from the ambient value, in which case
' the designer should persist the value.
Private Function ShouldSerializeAlertForeColor() As Boolean
Return Me.alertForeColorValue <> AttributesDemoControl.ambientColorValue
End Function
설명
컨트롤의 속성에 앰비언트 동작이 있는 경우 이 특성이 있어야 합니다. 앰비언트 속성은 부모 값(예: 속성 또는 Control.BackColor 속성)을 Control.Font 쿼리합니다.
일반적으로 비주얼 디자이너는 특성을 사용하여 속성에 AmbientValueAttribute 유지할 값을 결정합니다. 이 값은 일반적으로 속성이 다른 소스에서 해당 값을 가져오는 값입니다. 앰비언트 값의 예는 Color.Empty 속성의 앰비언트 값입니다 BackColor . 폼에 컨트롤이 있고 컨트롤의 속성이 폼의 속성과 BackColor 다른 색 BackColor 으로 설정된 경우 컨트롤을 설정하여 컨트롤의 속성을 폼의 속성으로 다시 BackColor 설정할 BackColorColor.Empty수 있습니다.
생성자
| Name | Description |
|---|---|
| AmbientValueAttribute(Boolean) |
해당 값에 대한 부울 값이 AmbientValueAttribute 지정된 경우 클래스의 새 인스턴스를 초기화합니다. |
| AmbientValueAttribute(Byte) |
해당 값에 대해 부호 없는 8비트 정수가 지정된 경우 클래스의 AmbientValueAttribute 새 인스턴스를 초기화합니다. |
| AmbientValueAttribute(Char) |
해당 값에 대한 유니코드 문자가 AmbientValueAttribute 지정된 경우 클래스의 새 인스턴스를 초기화합니다. |
| AmbientValueAttribute(Double) |
해당 값에 대한 배정밀도 부동 소수점 번호가 지정된 경우 클래스의 AmbientValueAttribute 새 인스턴스를 초기화합니다. |
| AmbientValueAttribute(Int16) |
해당 값에 대해 부가된 16비트 정수가 지정된 경우 클래스의 AmbientValueAttribute 새 인스턴스를 초기화합니다. |
| AmbientValueAttribute(Int32) |
해당 값에 대해 부가된 32비트 정수가 지정된 경우 클래스의 AmbientValueAttribute 새 인스턴스를 초기화합니다. |
| AmbientValueAttribute(Int64) |
해당 값에 대해 부가된 64비트 정수가 지정된 경우 클래스의 AmbientValueAttribute 새 인스턴스를 초기화합니다. |
| AmbientValueAttribute(Object) |
해당 값에 대한 개체가 AmbientValueAttribute 지정된 경우 클래스의 새 인스턴스를 초기화합니다. |
| AmbientValueAttribute(Single) |
해당 값에 대한 단정밀도 부동 소수점 번호가 지정된 경우 클래스의 AmbientValueAttribute 새 인스턴스를 초기화합니다. |
| AmbientValueAttribute(String) |
해당 값에 대한 문자열이 AmbientValueAttribute 지정된 경우 클래스의 새 인스턴스를 초기화합니다. |
| AmbientValueAttribute(Type, String) |
값과 해당 형식이 AmbientValueAttribute 지정된 경우 클래스의 새 인스턴스를 초기화합니다. |
속성
| Name | Description |
|---|---|
| TypeId |
파생 클래스에서 구현되는 경우 이 Attribute대한 고유 식별자를 가져옵니다. (다음에서 상속됨 Attribute) |
| Value |
이 AmbientValueAttribute값인 개체를 가져옵니다. |
메서드
| Name | Description |
|---|---|
| Equals(Object) |
지정된 AmbientValueAttribute 값이 현재 AmbientValueAttribute와 같은지 여부를 확인합니다. |
| GetHashCode() |
이 인스턴스의 해시 코드를 반환합니다. |
| GetType() |
현재 인스턴스의 Type 가져옵니다. (다음에서 상속됨 Object) |
| IsDefaultAttribute() |
파생 클래스에서 재정의되는 경우 이 인스턴스의 값이 파생 클래스의 기본값인지 여부를 나타냅니다. (다음에서 상속됨 Attribute) |
| Match(Object) |
파생 클래스에서 재정의되는 경우 이 인스턴스가 지정된 개체와 같은지 여부를 나타내는 값을 반환합니다. (다음에서 상속됨 Attribute) |
| MemberwiseClone() |
현재 Object단순 복사본을 만듭니다. (다음에서 상속됨 Object) |
| ToString() |
현재 개체를 나타내는 문자열을 반환합니다. (다음에서 상속됨 Object) |
명시적 인터페이스 구현
| Name | Description |
|---|---|
| _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) |