バージョン

OnSubObjectPropChanged メソッド (DayLook)

サブオブジェクトによって行われる通知を渡します。
シンタックス
'宣言
 
Protected Overrides Sub OnSubObjectPropChanged( _
   ByVal propChange As Infragistics.Shared.PropChangeInfo _
) 
protected override void OnSubObjectPropChanged( 
   Infragistics.Shared.PropChangeInfo propChange
)

パラメータ

propChange
プロパティ変更に関する情報を含むPropChangeInfoオブジェクト。
使用例
Imports Infragistics.Shared
Imports Infragistics.Win

Public Class ExampleClass
    Inherits SubObjectBase

    Private appearanceHolder As appearanceHolder
    Private enabledValue As Boolean

    ' Listens for property change notifications of the object's sub objects.
    Protected Overrides Sub OnSubObjectPropChanged(ByVal pci As Infragistics.Shared.PropChangeInfo)

        ' Check if the source is our appearance object.
        If Not Me.appearanceHolder Is Nothing _
        AndAlso pci.Source.Equals(Me.appearanceHolder.RootAppearance) Then

            ' Do what needs to be done (if anything) based on the 
            ' nature of the change
            Dim propId As AppearancePropIds

            propId = pci.PropId

            If propId = AppearancePropIds.Image _
            OrElse propId = AppearancePropIds.ImageHAlign _
            OrElse propId = AppearancePropIds.ImageVAlign Then
                Me.DirtyImage()
            Else
                Me.DirtyText()
            End If

            ' Call NotifyPropChange with the appropriate property id
            ' and the PropChangeInfo instance that was passed into
            ' this method.
            Me.NotifyPropChange(StatusBarPropertyIds.Appearance, pci)

            ' Note: If there are any listeners to our 'SubObjectPropChanged' 
            ' event, the event will be raised with a new PropChangeInfo
            ' event argument whose properties will be set as follows:
            ' 1. The Source property will refer to this object.
            ' 2. The PropId property will be StatusBarPropertyIds.Appearance.
            ' 3. The Trigger property will be the passed in PropChangeInfo.
            '
            ' This will effectively create a chain of PropChangeInfo
            ' objects, with the new one at the head, that exposes
            ' complete context information regarding the change. 
            Return
        End If

        ' There is an overload to the 'NotifyPropChange' method
        ' that just takes the passed in PropChangeInfo object.
        ' This is useful if you want to pass the notification
        ' along to this object's listeners 'as is'. In other words,
        ' without creating a new PropChangeInfo to add to the 
        ' head of the chain (refer to above comments).
        Me.NotifyPropChange(pci)

        Dim sb As System.Text.StringBuilder

        ' The following code walks up the PropChangeInfo chain
        ' and writes out the source and property id of each
        ' object.
        While Not pci Is Nothing

            sb = New System.Text.StringBuilder()

            sb.Append("Property Id: ")
            sb.Append(pci.PropId.ToString())
            sb.Append(", source: ")
            sb.Append(pci.Source.ToString())
            sb.Append(". type: ")
            sb.Append(pci.Source.GetType().ToString())

            Debug.WriteLine(sb.ToString())
            Debug.Indent()
        End While

        ' Get the next PropChangeInfo object in the chain 
        pci = pci.Trigger

        ' Reset the indent level of the Debug object
        Debug.IndentLevel = 0

        ' Alternatively there are 'Find...' methods that
        ' will walk up the chain until they find the 
        ' requested PropChangeInfo object to return or
        ' they will return null.
        pci = pci.FindPropId(AppearancePropIds.BackGradientStyle)
        pci = pci.FindTrigger(Me.appearanceHolder.RootAppearance)

        ' There is also a 'FindSource' method which will
        ' return the source object based on the passed
        ' in type. If no source object of that type is
        ' found in the chain this method will return null.
        Dim source As Object
        source = pci.FindSource(GetType(Infragistics.Win.Appearance))

    End Sub

    Public Property Enabled() As Boolean

        Get
            Return Me.enabledValue
        End Get

        Set(ByVal Value As Boolean)
            If Not Me.enabledValue = Value Then
                Me.enabledValue = Value

                ' Call the overload to the 'NotifyPropChange' method
                ' that just takes a property id. 
                Me.NotifyPropChange(StatusBarPropertyIds.Enabled)

                ' Note: If there are any listeners to our 'SubObjectPropChanged' 
                ' event, the event will be raised with a PropChangeInfo
                ' event argument whose properties will be` set as follows:
                ' 1. The Source property will refer to this object.
                ' 2. The PropId property will be StatusBarPropertyIds.Enabled.
                ' 3. The Trigger property will be null.
            End If
        End Set

    End Property

    Public ReadOnly Property Appearance() As AppearanceBase

        Get
            ' Lazily create the appearance holder
            If Me.appearanceHolder Is Nothing Then

                Me.appearanceHolder = New AppearanceHolder()

                ' Listen in to property changes generated by the
                ' object. When one of its properties changes our 
                ' 'OnSubObjectPropChanged' method will be called.
                AddHandler Me.appearanceHolder.SubObjectPropChanged, Me.SubObjectPropChangeHandler
            End If

            Return Me.appearanceHolder.Appearance

        End Get

    End Property

    Protected Overrides Sub OnDispose()

        If Not Me.appearanceHolder Is Nothing Then
            ' Remove ourselves as a listener
            RemoveHandler Me.appearanceHolder.SubObjectPropChanged, Me.SubObjectPropChangeHandler
        End If

    End Sub

    Private Sub DirtyImage()
    End Sub

    Private Sub DirtyText()
    End Sub
End Class

Public Enum StatusBarPropertyIds
    Appearance = 1
    Enabled = 2
End Enum
using System;
using System.Diagnostics;
using Infragistics.Shared;
using Infragistics.Win;

namespace SharedSnippets
{
	public class ExampleClass : SubObjectBase
	{
		private AppearanceHolder appearanceHolder = null;
		private bool			 enabled = true;

		// Listens for property change notifications of the object's sub objects.
		protected override void OnSubObjectPropChanged( PropChangeInfo pci )
		{
			// Check if the source is our appearance object.
			if (this.appearanceHolder != null && 
				pci.Source == this.appearanceHolder.RootAppearance)
			{
				// Do what needs to be done (if anything) based on the 
				// nature of the change
				switch ( (AppearancePropIds)pci.PropId )
				{
					case AppearancePropIds.Image:
					case AppearancePropIds.ImageHAlign:
					case AppearancePropIds.ImageVAlign:
					{
						this.DirtyImage();
						break;
					}
					default:
						this.DirtyText();
						break;
				}

				// Call NotifyPropChange with the appropriate property id
				// and the PropChangeInfo instance that was passed into
				// this method.
				this.NotifyPropChange( StatusBarPropertyIds.Appearance, pci );

				// Note: If there are any listeners to our 'SubObjectPropChanged' 
				// event, the event will be raised with a new PropChangeInfo
				// event argument whose properties will be set as follows:
				// 1. The Source property will refer to this object.
				// 2. The PropId property will be StatusBarPropertyIds.Appearance.
				// 3. The Trigger property will be the passed in PropChangeInfo.
				//
				// This will effectively create a chain of PropChangeInfo
				// objects, with the new one at the head, that exposes
				// complete context information regarding the change. 
				
				return;
			}

			// There is an overload to the 'NotifyPropChange' method
			// that just takes the passed in PropChangeInfo object.
			// This is useful if you want to pass the notification
			// along to this object's listeners 'as is'. In other words,
			// without creating a new PropChangeInfo to add to the 
			// head of the chain (refer to above comments).
			this.NotifyPropChange( pci );
			
			// The following code walks up the PropChangeInfo chain
			// and writes out the source and property id of each
			// object.
			while ( pci != null )
			{
				System.Text.StringBuilder sb = new System.Text.StringBuilder();
				
				sb.Append("Property Id: ");
				sb.Append(pci.PropId.ToString());
				sb.Append(", source: ");
				sb.Append(pci.Source.ToString());
				sb.Append(". type: ");
				sb.Append(pci.Source.GetType().ToString());

				Debug.WriteLine( sb.ToString() );
				Debug.Indent();

				// Get the next PropChangeInfo object in the chain 
				pci = pci.Trigger;
			}

			// Reset the indent level of the Debug object
			Debug.IndentLevel = 0;

			// Alternatively there are 'Find...' methods that
			// will walk up the chain until they find the 
			// requested PropChangeInfo object to return or
			// they will return null.
			pci = pci.FindPropId( AppearancePropIds.BackGradientStyle );
			pci = pci.FindTrigger( this.appearanceHolder.RootAppearance );

			// There is also a 'FindSource' method which will
			// return the source object based on the passed
			// in type. If no source object of that type is
			// found in the chain this method will return null.
			object source = pci.FindSource( typeof(Infragistics.Win.Appearance ) );

		}

		public bool Enabled
		{

			get { return this.enabled; }

			set
			{
				if (this.enabled != value)
				{
					this.enabled = value;

					// Call the overload to the 'NotifyPropChange' method
					// that just takes a property id. 
					this.NotifyPropChange( StatusBarPropertyIds.Enabled );

					// Note: If there are any listeners to our 'SubObjectPropChanged' 
					// event, the event will be raised with a PropChangeInfo
					// event argument whose properties will be` set as follows:
					// 1. The Source property will refer to this object.
					// 2. The PropId property will be StatusBarPropertyIds.Enabled.
					// 3. The Trigger property will be null.
				}
			}

		}

		public AppearanceBase Appearance
		{

			get
			{
				// Lazily create the appearance holder
				if (this.appearanceHolder == null)
				{
					this.appearanceHolder = new AppearanceHolder();

					// Listen in to property changes generated by the
					// object. When one of its properties changes our 
					// 'OnSubObjectPropChanged' method will be called.
					this.appearanceHolder.SubObjectPropChanged += this.SubObjectPropChangeHandler;
				}
				return this.appearanceHolder.Appearance;
			}

		}

		protected override void OnDispose()
		{

			if ( this.appearanceHolder != null )
			{
				// Remove ourselves as a listener
				this.appearanceHolder.SubObjectPropChanged -= this.SubObjectPropChangeHandler;
			}

		} 

		private void DirtyImage(){} 
		private void DirtyText(){} 
	}

	public enum StatusBarPropertyIds
	{
		Appearance = 1,
		Enabled = 2
	}
}
参照