' Developer Express Code Central Example:
' How to show filter dialog before showing ListView
' 
' When the ListView contains a large amount of data, it is useful to provide a
' capability for the end-user to set a filter for this View before loading it. To
' accomplish this task, I've performed the following actions in this example:
' 1.
' Extended the Application Model with the AdditionalCriteria attribute for the
' ListView node via the WinSampleModule.GetSchema overridden method. This
' attribute should store the filter, selected by the user.
' 2. Implemented the
' ViewFilterContainer class, whose DetailView is used as a filter dialog.
' 3.
' Implemented the ViewFilterObject class, which is used to store filters.
' 4.
' Implemented a ShowFilterDialogController, which shows the DetailView of the
' ViewFilterContainer object before showing ListView, and then shows the filtered
' ListView.
' 5. Implemented the ViewFilterContainerModificationsController, which
' sets the ObjectType property of the ViewFilterObject class, created by the
' lookup's New action.
' 
' See Also:
' How to: Use Criteria Property Editors
' (ms-help://DevExpress.Xaf/CustomDocument3014.htm)
' How to: Extend the
' Application Model and Schema
' (ms-help://DevExpress.Xaf/CustomDocument2785.htm)
' ShowNavigationItemController
' Class
' (ms-help://DevExpress.Xaf/clsDevExpressExpressAppSystemModuleShowNavigationItemControllertopic.htm)
' Dialog
' Controller
' (ms-help://DevExpress.Xaf/clsDevExpressExpressAppSystemModuleDialogControllertopic.htm)
' 
' You can find sample updates and versions for different programming languages here:
' http://www.devexpress.com/example=E1554

Imports Microsoft.VisualBasic
Imports System
Imports DevExpress.Persistent.BaseImpl
Imports DevExpress.Xpo
Imports DevExpress.ExpressApp.Editors
Imports System.ComponentModel
Imports DevExpress.Persistent.Base
Imports DevExpress.ExpressApp
Imports DevExpress.Data.Filtering

<DefaultProperty("FilterName")> _
    Public Class ViewFilterObject
    Inherits BaseObject
    Public Sub New(ByVal session As Session)
        MyBase.New(session)
    End Sub
    Private _ObjectTypeName As String
    <MemberDesignTimeVisibility(False)> _
    Public Property ObjectTypeName() As String
        Get
            Return _ObjectTypeName
        End Get
        Set(ByVal value As String)
            SetPropertyValue(Of String)("ObjectTypeName", _ObjectTypeName, value)
        End Set
    End Property
    <NonPersistent(), MemberDesignTimeVisibility(False)> _
    Public Property ObjectType() As Type
        Get
            If ObjectTypeName IsNot Nothing Then
                Return XafTypesInfo.Instance.FindTypeInfo(ObjectTypeName).Type
            Else
                Return Nothing
            End If
        End Get
        Set(ByVal value As Type)
            Dim stringValue As String
            If value Is Nothing Then
                stringValue = Nothing
            Else
                stringValue = value.FullName
            End If
            Dim savedObjectTypeName As String = ObjectTypeName
            Try
                If stringValue <> ObjectTypeName Then
                    ObjectTypeName = stringValue
                End If
            Catch e1 As Exception
                ObjectTypeName = savedObjectTypeName
            End Try
            Criteria = String.Empty
        End Set
    End Property
    Private _Criteria As String
    <CriteriaOptionsAttribute("ObjectType")> _
    Public Property Criteria() As String
        Get
            Return _Criteria
        End Get
        Set(ByVal value As String)
            SetPropertyValue("Criteria", _Criteria, value)
        End Set
    End Property
    Private _FilterName As String
    Public Property FilterName() As String
        Get
            Return _FilterName
        End Get
        Set(ByVal value As String)
            SetPropertyValue("FilterName", _FilterName, value)
        End Set
    End Property
End Class
