See Also

UIElement Class  | UIElement Members

Language

Visual Basic

C#

Show All

See Also Languages Infragistics2.Win.v7.2

IsDrawing Property

Infragistics.Win Namespace > UIElement Class : IsDrawing Property

True if this element is in a drawing operation (read-only).

[Visual Basic]
Public ReadOnly Property IsDrawing As Boolean
[C#]
public bool IsDrawing {get;}

Example

This sample initializes the appearance of a UIElement based on the mouse position within the element. It also exemplifies the use of mouse hover notifications.

[Visual Basic] 

    Imports Infragistics.Win

    Private mouseEnteredElement As Boolean = False
    Private mouseHoveringOnElement As Boolean = False

    Protected Overrides Sub InitAppearance(ByRef appearance As AppearanceData, ByRef requestedProps As AppearancePropFlags)

        MyBase.InitAppearance(appearance, requestedProps)

        ' Set BackColor based on whether or not mouse is over
        ' the element.
        If (Me.mouseHoveringOnElement) Then
            appearance.BackColor = Color.Green
        ElseIf (Me.mouseEnteredElement) Then
            appearance.BackColor = Color.Red
        Else
            appearance.BackColor = Color.Transparent
        End If

    End Sub


    Protected Overrides Sub OnMouseEnter()

        Me.mouseEnteredElement = True

            ' Call when sub UIElements need to simply be repainted (color change etc).
            If Not Me.IsDrawing then
            Me.Invalidate()
            End If

    End Sub

    Protected Overrides Sub OnMouseHover()

        Me.mouseHoveringOnElement = True

            ' Call when sub UIElements need to be repositioned or sized.
        Me.DirtyChildElements()

    End Sub

    Protected Overrides Sub OnMouseLeave()

        Me.mouseHoveringOnElement = False
        Me.mouseEnteredElement = False

        If Not Me.IsDrawing then
            Me.Invalidate()
            End If

    End Sub

    Protected Overrides ReadOnly Property WantsMouseHoverNotification() As Boolean

        Get
            Return True
        End Get

    End Property

[C#] 

        using Infragistics.Win; 
 
        private bool mouseEnteredElement = false; 
        private bool mouseHoveringOnElement = false; 
 
        protected override void OnMouseHover() 
        { 
 
            this.mouseHoveringOnElement = true; 
 
            // Call when sub UIElements need to be repositioned or sized. 
            this.DirtyChildElements(); 
 
        } 
 
        protected override bool WantsMouseHoverNotification 
        { 
 
            get 
            { 
                return true; 
            } 
 
        } 
 
 
        protected override void OnMouseEnter() 
        { 
 
            this.mouseEnteredElement = true; 
 
            // Call when sub UIElements need to simply be repainted (color change etc). 
            if (!this.IsDrawing) 
                this.Invalidate(); 
 
        } 
 
 
        protected override void OnMouseLeave() 
        { 
 
            this.mouseHoveringOnElement = false; 
            this.mouseEnteredElement = false; 
 
            // Call when sub UIElements need to simply be repainted (color change etc). 
            if (!this.IsDrawing) 
                this.Invalidate(); 
 
        } 
 
 
        protected override void InitAppearance(ref AppearanceData appearance, ref AppearancePropFlags requestedProps) 
        { 
 
            base.InitAppearance(ref appearance, ref  requestedProps); 
 
            // Set BackColor based on whether or not mouse is over 
            // the element. 
            if(this.mouseHoveringOnElement) 
                appearance.BackColor = Color.Green; 
            else if(this.mouseEnteredElement) 
                appearance.BackColor = Color.Red; 
            else 
                appearance.BackColor = Color.Transparent ; 
 
        }

See Also

UIElement Class  | UIElement Members

E-mail your feedback on this topic.

Opinion about our help? Take our survey.

Copyright © 1996-2007 Infragistics, Inc. All rights reserved.

Build Version: 7.2.20072.1063