IPropertyValueUIService 인터페이스

정의

속성 브라우저에 표시된 구성 요소의 속성에 대한 이미지, 도구 설명 및 이벤트 처리기를 관리할 수 있는 인터페이스를 제공합니다.

public interface class IPropertyValueUIService
public interface IPropertyValueUIService
type IPropertyValueUIService = interface
Public Interface IPropertyValueUIService

예제

다음 코드 예제에서는 인터페이스의 IPropertyValueUIService 인스턴스를 가져오고 서비스에 추가 하는 PropertyValueUIHandler 구성 요소를 만듭니다. 처리기는 명명 HorizontalMarginPropertyValueUIItem 구성 요소 또는 VerticalMargin.의 모든 속성에 대한 개체를 제공합니다. 이러한 속성에 PropertyValueUIItem 대 한 이미지, 도구 설명 및 속성에 대 한 이미지를 클릭할 때 메시지 상자를 표시 하는 이벤트 처리기를 제공 합니다. 이미지와 도구 설명은 그리드에 PropertyGrid 구성 요소의 이러한 속성이 표시될 때 표시됩니다.

#using <System.Windows.Forms.dll>
#using <System.Drawing.dll>
#using <System.dll>

using namespace System;
using namespace System::Collections;
using namespace System::ComponentModel;
using namespace System::ComponentModel::Design;
using namespace System::Drawing;
using namespace System::Drawing::Design;
using namespace System::IO;
using namespace System::Runtime::Serialization;
using namespace System::Runtime::Serialization::Formatters::Binary;
using namespace System::Windows::Forms;
using namespace System::Windows::Forms::Design;

namespace PropertyValueUIServiceExample
{

   // This component obtains the IPropertyValueUIService and adds a
   // PropertyValueUIHandler that provides PropertyValueUIItem objects
   // which provide an image, ToolTip, and invoke event handler to
   // any properties named horizontalMargin and verticalMargin,
   // such as the example integer properties on this component.
   public ref class PropertyUIComponent: public System::ComponentModel::Component
   {
   public:

      property int horizontalMargin 
      {
         // Example property for which to provide a PropertyValueUIItem.
         int get()
         {
            return hMargin;
         }

         void set( int value )
         {
            hMargin = value;
         }

      }

      property int verticalMargin 
      {
         // Example property for which to provide a PropertyValueUIItem.
         int get()
         {
            return vMargin;
         }

         void set( int value )
         {
            vMargin = value;
         }

      }

   private:

      // Field storing the value of the horizontalMargin property.
      int hMargin;

      // Field storing the value of the verticalMargin property.
      int vMargin;

      // Base64-encoded serialized image data for image icon.
      String^ imageBlob1;

   public:

      // Constructor.
      PropertyUIComponent( System::ComponentModel::IContainer^ container )
      {
         imageBlob1 = "AAEAAAD/////AQAAAAAAAAAMAgAAAFRTeXN0ZW0uRHJhd2luZywgVmVyc2lvbj0xLjAuMzMwMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWIwM2Y1ZjdmMTFkNTBhM2EFAQAAABVTeXN0ZW0uRHJhd2luZy5CaXRtYXABAAAABERhdGEHAgIAAAAJAwAAAA8DAAAA9gAAAAJCTfYAAAAAAAAANgAAACgAAAAIAAAACAAAAAEAGAAAAAAAAAAAAMQOAADEDgAAAAAAAAAAAAD///////////////////////////////////8AAAD///////////////8AAAD///////8AAAD///////////////8AAAD///////8AAAD///8AAAAAAAD///8AAAD///////8AAAD///8AAAAAAAD///8AAAD///////8AAAD///////////////8AAAD///////8AAAD///////////////8AAAD///////////////////////////////////8L";
         if ( container != nullptr )
                  container->Add( this );

         hMargin = 0;
         vMargin = 0;
      }


      // Default component constructor that specifies no container.
      PropertyUIComponent()
      {
         imageBlob1 = "AAEAAAD/////AQAAAAAAAAAMAgAAAFRTeXN0ZW0uRHJhd2luZywgVmVyc2lvbj0xLjAuMzMwMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWIwM2Y1ZjdmMTFkNTBhM2EFAQAAABVTeXN0ZW0uRHJhd2luZy5CaXRtYXABAAAABERhdGEHAgIAAAAJAwAAAA8DAAAA9gAAAAJCTfYAAAAAAAAANgAAACgAAAAIAAAACAAAAAEAGAAAAAAAAAAAAMQOAADEDgAAAAAAAAAAAAD///////////////////////////////////8AAAD///////////////8AAAD///////8AAAD///////////////8AAAD///////8AAAD///8AAAAAAAD///8AAAD///////8AAAD///8AAAAAAAD///8AAAD///////8AAAD///////////////8AAAD///////8AAAD///////////////8AAAD///////////////////////////////////8L";
         hMargin = 0;
         vMargin = 0;
      }


   private:

      // 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" ) );
         }
      }

      // Invoke handler associated with the PropertyValueUIItem objects
      // provided by the marginPropertyValueUIHandler.
      void marginInvoke( System::ComponentModel::ITypeDescriptorContext^ /*context*/, System::ComponentModel::PropertyDescriptor^ /*propDesc*/, PropertyValueUIItem^ /*item*/ )
      {
         MessageBox::Show( "Test invoke message box" );
      }

   public:

      property System::ComponentModel::ISite^ Site 
      {
         // Component::Site  to add the marginPropertyValueUIHandler
         // when the component is sited, and to remove it when the site is
         // set to 0.
         virtual System::ComponentModel::ISite^ get() override
         {
            return __super::Site;
         }

         virtual void set( System::ComponentModel::ISite^ value ) override
         {
            if ( value != nullptr )
            {
               __super::Site = value;
               IPropertyValueUIService^ uiService = dynamic_cast<IPropertyValueUIService^>(this->GetService( IPropertyValueUIService::typeid ));
               if ( uiService != nullptr )
                              uiService->AddPropertyValueUIHandler( gcnew PropertyValueUIHandler( this, &PropertyUIComponent::marginPropertyValueUIHandler ) );
            }
            else
            {
               IPropertyValueUIService^ uiService = dynamic_cast<IPropertyValueUIService^>(this->GetService( IPropertyValueUIService::typeid ));
               if ( uiService != nullptr )
                              uiService->RemovePropertyValueUIHandler( gcnew PropertyValueUIHandler( this, &PropertyUIComponent::marginPropertyValueUIHandler ) );
               __super::Site = value;
            }
         }
      }

   private:

      // This method can be used to retrieve an Image from a block
      // of Base64-encoded text.
      Image^ DeserializeFromBase64Text( String^ text )
      {
         Image^ img = nullptr;
         array<Byte>^memBytes = Convert::FromBase64String( text );
         IFormatter^ formatter = gcnew BinaryFormatter;
         MemoryStream^ stream = gcnew MemoryStream( memBytes );
         img = dynamic_cast<Image^>(formatter->Deserialize( stream ));
         stream->Close();
         return img;
      }
   };
}
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Drawing.Design;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Windows.Forms;
using System.Windows.Forms.Design;

namespace PropertyValueUIServiceExample
{
    // This component obtains the IPropertyValueUIService and adds a
    // PropertyValueUIHandler that provides PropertyValueUIItem objects
    // which provide an image, ToolTip, and invoke event handler to
    // any properties named HorizontalMargin and VerticalMargin, 
    // such as the example integer properties on this component.    
    public class PropertyUIComponent : System.ComponentModel.Component
    {
        // Example property for which to provide a PropertyValueUIItem.
        public int HorizontalMargin 
        {
            get
            {
                return hMargin;
            }
            set
            {
                hMargin = value;
            }
        }
        // Example property for which to provide a PropertyValueUIItem.
        public int VerticalMargin
        {
            get
            {
                return vMargin;
            }
            set
            {
                vMargin = value;
            }
        }

        // Field storing the value of the HorizontalMargin property.
        private int hMargin;

        // Field storing the value of the VerticalMargin property.
        private int vMargin;        

        // Base64-encoded serialized image data for image icon.
        private string imageBlob1 = "AAEAAAD/////AQAAAAAAAAAMAgAAAFRTeXN0ZW0uRHJhd2luZywgVmVyc2lvbj0xLjAuMzMwMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWIwM2Y1ZjdmMTFkNTBhM2EFAQAAABVTeXN0ZW0uRHJhd2luZy5CaXRtYXABAAAABERhdGEHAgIAAAAJAwAAAA8DAAAA9gAAAAJCTfYAAAAAAAAANgAAACgAAAAIAAAACAAAAAEAGAAAAAAAAAAAAMQOAADEDgAAAAAAAAAAAAD///////////////////////////////////8AAAD///////////////8AAAD///////8AAAD///////////////8AAAD///////8AAAD///8AAAAAAAD///8AAAD///////8AAAD///8AAAAAAAD///8AAAD///////8AAAD///////////////8AAAD///////8AAAD///////////////8AAAD///////////////////////////////////8L";
                
        // Constructor.
        public PropertyUIComponent(System.ComponentModel.IContainer container)
        {
            if( container != null )
                container.Add(this);
            hMargin = 0;		
            vMargin = 0;
        }

        // Default component constructor that specifies no container.
        public PropertyUIComponent() : this(null)
        {}

        // 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") );
            }
        }

        // Invoke handler associated with the PropertyValueUIItem objects 
        // provided by the marginPropertyValueUIHandler.
        private void marginInvoke(System.ComponentModel.ITypeDescriptorContext context, System.ComponentModel.PropertyDescriptor propDesc, PropertyValueUIItem item)
        {
            MessageBox.Show("Test invoke message box");
        }

        // Component.Site override to add the marginPropertyValueUIHandler
        // when the component is sited, and to remove it when the site is 
        // set to null.
        public override System.ComponentModel.ISite Site
        {
            get
            {
                return base.Site;
            }
            set
            {                
                if( value != null )
                {
                    base.Site = value;
                    IPropertyValueUIService uiService = (IPropertyValueUIService)this.GetService(typeof(IPropertyValueUIService));
                    if( uiService != null )                    
                        uiService.AddPropertyValueUIHandler( new PropertyValueUIHandler(this.marginPropertyValueUIHandler) );                                        
                }
                else
                {
                    IPropertyValueUIService uiService = (IPropertyValueUIService)this.GetService(typeof(IPropertyValueUIService));
                    if( uiService != null )                    
                        uiService.RemovePropertyValueUIHandler( new PropertyValueUIHandler(this.marginPropertyValueUIHandler) );                                        
                    base.Site = value;
                }
            }
        }

        // This method can be used to retrieve an Image from a block 
        // of Base64-encoded text.
        private Image DeserializeFromBase64Text(string text)
        {
            Image img = null;
            byte[] memBytes = Convert.FromBase64String(text);
            IFormatter formatter = new BinaryFormatter();
            MemoryStream stream = new MemoryStream(memBytes);
            img = (Image)formatter.Deserialize(stream);
            stream.Close();
            return img;
        }
    }
}
Imports System.Collections
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Drawing
Imports System.Drawing.Design
Imports System.IO
Imports System.Runtime.Serialization
Imports System.Runtime.Serialization.Formatters.Binary
Imports System.Windows.Forms
Imports System.Windows.Forms.Design

' This component obtains the IPropertyValueUIService and adds a
' PropertyValueUIHandler that provides PropertyValueUIItem objects
' which provide an image, tooltip and invoke event handler to
' any properties named HorizontalMargin and VerticalMargin, 
' such as the example integer properties on this component.    
Public Class PropertyUIComponent
    Inherits System.ComponentModel.Component

    ' Example property for which to provide PropertyValueUIItem.
    Public Property HorizontalMargin() As Integer
        Get
            Return hMargin
        End Get
        Set(ByVal Value As Integer)
            hMargin = Value
        End Set
    End Property

    ' Example property for which to provide PropertyValueUIItem.       
    Public Property VerticalMargin() As Integer
        Get
            Return vMargin
        End Get
        Set(ByVal Value As Integer)
            vMargin = Value
        End Set
    End Property

    ' Field storing the value of the HorizontalMargin property
    Private hMargin As Integer

    ' Field storing the value of the VerticalMargin property
    Private vMargin As Integer

    ' Base64-encoded serialized image data for image icon.
    Private imageBlob1 As String = "AAEAAAD/////AQAAAAAAAAAMAgAAAFRTeXN0ZW0uRHJhd2luZywgVmVyc2lvbj0xLjAuMzMwMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWIwM2Y1ZjdmMTFkNTBhM2EFAQAAABVTeXN0ZW0uRHJhd2luZy5CaXRtYXABAAAABERhdGEHAgIAAAAJAwAAAA8DAAAA9gAAAAJCTfYAAAAAAAAANgAAACgAAAAIAAAACAAAAAEAGAAAAAAAAAAAAMQOAADEDgAAAAAAAAAAAAD///////////////////////////////////8AAAD///////////////8AAAD///////8AAAD///////////////8AAAD///////8AAAD///8AAAAAAAD///8AAAD///////8AAAD///8AAAAAAAD///8AAAD///////8AAAD///////////////8AAAD///////8AAAD///////////////8AAAD///////////////////////////////////8L"

    ' Constructor.
    Public Sub New(ByVal container As System.ComponentModel.IContainer)
        If (container IsNot Nothing) Then
            container.Add(Me)
        End If
        hMargin = 0
        vMargin = 0
    End Sub

    ' Default component constructor that specifies no container.
    Public Sub New()
        MyClass.New(Nothing)
    End Sub

    ' 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

    ' Invoke handler associated with the PropertyValueUIItem objects 
    ' provided by the marginPropertyValueUIHandler.
    Private Sub marginInvoke(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal propDesc As System.ComponentModel.PropertyDescriptor, ByVal item As PropertyValueUIItem)
        MessageBox.Show("Test invoke message box")
    End Sub

    ' Component.Site override to add the marginPropertyValueUIHandler
    ' when the component is sited, and to remove it when the site is 
    ' set to null.
    Public Overrides Property Site() As System.ComponentModel.ISite
        Get
            Return MyBase.Site
        End Get
        Set(ByVal Value As System.ComponentModel.ISite)
            If (Value IsNot Nothing) Then
                MyBase.Site = Value
                Dim uiService As IPropertyValueUIService = CType(Me.GetService(GetType(IPropertyValueUIService)), IPropertyValueUIService)
                If (uiService IsNot Nothing) Then
                    uiService.AddPropertyValueUIHandler(New PropertyValueUIHandler(AddressOf Me.marginPropertyValueUIHandler))
                End If
            Else
                Dim uiService As IPropertyValueUIService = CType(Me.GetService(GetType(IPropertyValueUIService)), IPropertyValueUIService)
                If (uiService IsNot Nothing) Then
                    uiService.RemovePropertyValueUIHandler(New PropertyValueUIHandler(AddressOf Me.marginPropertyValueUIHandler))
                End If
                MyBase.Site = Value
            End If
        End Set
    End Property

    ' This method can be used to retrieve an Image from a block 
    ' of Base64-encoded text.
    Private Function DeserializeFromBase64Text(ByVal [text] As String) As Image
        Dim img As Image = Nothing
        Dim memBytes As Byte() = Convert.FromBase64String([text])
        Dim formatter As New BinaryFormatter()
        Dim stream As New MemoryStream(memBytes)
        img = CType(formatter.Deserialize(stream), Image)
        stream.Close()
        Return img
    End Function

End Class

설명

구성 요소는 인터페이스를 IPropertyValueUIService 사용하여 구성 요소의 모든 속성에 대한 개체를 제공할 PropertyValueUIItem 수 있습니다. PropertyValueUIItem 속성과 연결된 이미지, 도구 설명 및 속성과 연결된 이미지를 클릭할 때 발생하는 이벤트에 대한 이벤트 처리기를 제공할 수 있습니다.

인터페이스는 IPropertyValueUIService 내부 목록에서 대리자를 추가, 제거 및 검색 PropertyValueUIHandler 하는 메서드를 제공합니다. 구성 요소의 속성이 속성 브라우저에 표시되면 목록의 각 PropertyValueUIHandler 속성에 대한 속성을 제공할 PropertyValueUIItem 수 있는 기회가 제공됩니다.

속성 브라우저가 개체의 속성을 표시하도록 설정된 경우 구성 요소의 각 속성에 대해 이 인터페이스의 메서드를 호출 GetPropertyUIValueItems 하여 속성을 나타내는 메서드를 PropertyDescriptor 전달합니다. 메서드는 GetPropertyUIValueItems 서비스에 추가된 각 PropertyValueUIHandler 호출을 호출합니다. 각각 PropertyValueUIHandlerArrayList PropertyValueUIItem 매개 변수에 전달된 매개 변수에 valueUIItemList 전달된 속성 PropertyDescriptor 에 대해 UI 항목을 제공하는 매개 변수에 추가할 수 있습니다propDesc.

속성 PropertyValueUIItem 이름 옆에 표시할 이미지, 도구 설명 문자열 및 속성과 연결된 이미지를 두 번 클릭할 때 호출할 이벤트 처리기를 포함할 수 있습니다.

메서드

AddPropertyValueUIHandler(PropertyValueUIHandler)

지정된 PropertyValueUIHandler를 이 서비스에 추가합니다.

GetPropertyUIValueItems(ITypeDescriptorContext, PropertyDescriptor)

지정된 컨텍스트 및 속성 설명자 특징과 일치하는 PropertyValueUIItem 개체를 가져옵니다.

NotifyPropertyValueUIItemsChanged()

IPropertyValueUIService 개체의 글로벌 목록이 수정되었음을 PropertyValueUIItem 구현에 알립니다.

RemovePropertyValueUIHandler(PropertyValueUIHandler)

지정된 PropertyValueUIHandler를 속성 값 UI 서비스에서 제거합니다.

이벤트

PropertyUIValueItemsChanged

PropertyValueUIItem 개체의 목록이 수정된 경우에 발생합니다.

적용 대상

추가 정보