IPropertyValueUIService 인터페이스

정의

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

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

예제

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

using System.Collections;
using System.Drawing;
using System.Drawing.Design;
using System.Windows.Forms;

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; set; }

        // Example property for which to provide a PropertyValueUIItem.
        public int VerticalMargin { get; set; }

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

        // Constructor.
        public PropertyUIComponent(System.ComponentModel.IContainer container)
        {
            if (container != null)
                container.Add(this);
            HorizontalMargin = 0;
            VerticalMargin = 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 = Image.FromFile("SampImag.jpg");
                itemList.Add(new PropertyValueUIItem(img, new PropertyValueUIItemInvokeHandler(this.marginInvoke), "Test ToolTip"));
            }
            if (propDesc.DisplayName.Equals("VerticalMargin"))
            {
                Image img = Image.FromFile("SampImag.jpg");
                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;
                }
            }
        }
    }
}

설명

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

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

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

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

메서드

AddPropertyValueUIHandler(PropertyValueUIHandler)

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

GetPropertyUIValueItems(ITypeDescriptorContext, PropertyDescriptor)

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

NotifyPropertyValueUIItemsChanged()

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

RemovePropertyValueUIHandler(PropertyValueUIHandler)

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

이벤트

PropertyUIValueItemsChanged

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

적용 대상

추가 정보