PropertyValueUIItemInvokeHandler 代理人

定義

代表將處理 InvokeHandlerPropertyValueUIItem 事件的方法。

public delegate void PropertyValueUIItemInvokeHandler(ITypeDescriptorContext ^ context, PropertyDescriptor ^ descriptor, PropertyValueUIItem ^ invokedItem);
public delegate void PropertyValueUIItemInvokeHandler(ITypeDescriptorContext context, PropertyDescriptor descriptor, PropertyValueUIItem invokedItem);
type PropertyValueUIItemInvokeHandler = delegate of ITypeDescriptorContext * PropertyDescriptor * PropertyValueUIItem -> unit
Public Delegate Sub PropertyValueUIItemInvokeHandler(context As ITypeDescriptorContext, descriptor As PropertyDescriptor, invokedItem As PropertyValueUIItem)

參數

context
ITypeDescriptorContext

屬性的 ITypeDescriptorContext,與按兩下的圖示相關。

descriptor
PropertyDescriptor

與按兩下的圖示相關的屬性。

invokedItem
PropertyValueUIItem

PropertyValueUIItem,與按兩下的圖示相關。

範例

下列程式碼範例會針對名為 HorizontalMarginVerticalMargin 之元件的任何屬性提供 PropertyValueUIItem 物件。 這些屬性的 提供 PropertyValueUIItem 影像、工具提示和事件處理常式,可在按一下屬性的影像時顯示訊息方塊。 此程式碼範例是介面所提供較大範例的 IPropertyValueUIService 一部分。

// PropertyValueUIHandler delegate that provides PropertyValueUIItem
// objects to any properties named horizontalMargin or verticalMargin.
void marginPropertyValueUIHandler( System::ComponentModel::ITypeDescriptorContext^ /*context*/, System::ComponentModel::PropertyDescriptor^ propDesc, ArrayList^ itemList )
{
   // A PropertyValueUIHandler added to the IPropertyValueUIService
   // is queried once for each property of a component and passed
   // a PropertyDescriptor that represents the characteristics of
   // the property when the Properties window is set to a new
   // component. A PropertyValueUIHandler can determine whether
   // to add a PropertyValueUIItem for the object to its ValueUIItem
   // list depending on the values of the PropertyDescriptor.
   if ( propDesc->DisplayName->Equals( "horizontalMargin" ) )
   {
      Image^ img = DeserializeFromBase64Text( imageBlob1 );
      itemList->Add( gcnew PropertyValueUIItem( img,gcnew PropertyValueUIItemInvokeHandler( this, &PropertyUIComponent::marginInvoke ),"Test ToolTip" ) );
   }

   if ( propDesc->DisplayName->Equals( "verticalMargin" ) )
   {
      Image^ img = DeserializeFromBase64Text( imageBlob1 );
      img->RotateFlip( RotateFlipType::Rotate90FlipNone );
      itemList->Add( gcnew PropertyValueUIItem( img,gcnew PropertyValueUIItemInvokeHandler( this, &PropertyUIComponent::marginInvoke ),"Test ToolTip" ) );
   }
}
// PropertyValueUIHandler delegate that provides PropertyValueUIItem
// objects to any properties named HorizontalMargin or VerticalMargin.
private void marginPropertyValueUIHandler(System.ComponentModel.ITypeDescriptorContext context, System.ComponentModel.PropertyDescriptor propDesc, ArrayList itemList)
{
    // A PropertyValueUIHandler added to the IPropertyValueUIService
    // is queried once for each property of a component and passed
    // a PropertyDescriptor that represents the characteristics of 
    // the property when the Properties window is set to a new 
    // component. A PropertyValueUIHandler can determine whether 
    // to add a PropertyValueUIItem for the object to its ValueUIItem 
    // list depending on the values of the PropertyDescriptor.
    if( propDesc.DisplayName.Equals( "HorizontalMargin" ) )
    {
        Image img = DeserializeFromBase64Text(imageBlob1);
        itemList.Add( new PropertyValueUIItem( img, new PropertyValueUIItemInvokeHandler(this.marginInvoke), "Test ToolTip") );
    }
    if( propDesc.DisplayName.Equals( "VerticalMargin" ) )
    {
        Image img = DeserializeFromBase64Text(imageBlob1);
        img.RotateFlip(RotateFlipType.Rotate90FlipNone);
        itemList.Add( new PropertyValueUIItem( img, new PropertyValueUIItemInvokeHandler(this.marginInvoke), "Test ToolTip") );
    }
}
' PropertyValueUIHandler delegate that provides PropertyValueUIItem
' objects to any properties named HorizontalMargin or VerticalMargin.
Private Sub marginPropertyValueUIHandler(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal propDesc As System.ComponentModel.PropertyDescriptor, ByVal itemList As ArrayList)
    ' A PropertyValueUIHandler added to the IPropertyValueUIService
    ' is queried once for each property of a component and passed
    ' a PropertyDescriptor that represents the characteristics of 
    ' the property when the Properties window is set to a new 
    ' component. A PropertyValueUIHandler can determine whether 
    ' to add a PropertyValueUIItem for the object to its ValueUIItem 
    ' list depending on the values of the PropertyDescriptor.
    If propDesc.DisplayName.Equals("HorizontalMargin") Then
        Dim img As Image = DeserializeFromBase64Text(imageBlob1)
        itemList.Add(New PropertyValueUIItem(img, New PropertyValueUIItemInvokeHandler(AddressOf Me.marginInvoke), "Test ToolTip"))
    End If
    If propDesc.DisplayName.Equals("VerticalMargin") Then
        Dim img As Image = DeserializeFromBase64Text(imageBlob1)
        img.RotateFlip(RotateFlipType.Rotate90FlipNone)
        itemList.Add(New PropertyValueUIItem(img, New PropertyValueUIItemInvokeHandler(AddressOf Me.marginInvoke), "Test ToolTip"))
    End If
End Sub

備註

按兩下屬性視窗中的圖示將會引發 InvokeHandler 與圖示相關聯的 事件 PropertyValueUIItem 。 此 InvokeHandler 事件通常會啟動使用者介面, (UI) 編輯屬性值。 PropertyValueUIItemInvokeHandler將 加入 至 InvokeHandlerPropertyValueUIItem 屬性,以指派事件處理常式,以在按兩下屬性名稱旁的圖示時執行適當的行為。

建立 PropertyValueUIItemInvokeHandler 委派時,必須識別處理事件的方法。 若要使事件與您的事件處理常式產生關聯,請將委派的執行個體 (Instance) 加入至事件。 除非您移除委派,否則每當事件發生時就會呼叫事件處理常式。 如需事件處理常式委派的詳細資訊,請參閱 處理和引發事件

擴充方法

GetMethodInfo(Delegate)

取得表示特定委派所代表之方法的物件。

適用於

另請參閱