Imports Microsoft.VisualBasic
Imports DevExpress.Data
Imports System.ComponentModel
Imports DevExpress.ExpressApp.DC
Imports DevExpress.ExpressApp.Model
Imports DevExpress.ExpressApp.Editors
Imports DevExpress.ExpressApp

#Region "INTERFACE"

Public Interface IModelOptionsExtender
    <Category("SIS"), DefaultValue(False)> Property RequreMinimumPriceCheck As Boolean
    <Category("SIS"), DefaultValue("C:\Users\Public\Documents\")> Property DefaultCustomersFileFolder As String
    <Category("SIS"), DefaultValue("C:\Users\Public\Documents\")> Property DefaultproductsFileFolder As String
    <Category("SIS")> Property NAVProgramPath As String
    <Category("SIS")> Property ExternalBrowserPath As String

    <Category("GridPrint"), DefaultValue("{0}"), Localizable(True)> Property HeaderLeft As String
    <Category("GridPrint"), DefaultValue("{1}"), Localizable(True)> Property HeaderCenter As String
    <Category("GridPrint"), DefaultValue("[Lap # / Összes lap #]"), Localizable(True)> Property HeaderRight As String
    <Category("GridPrint"), DefaultValue(""), Localizable(True)> Property FooterLeft As String
    <Category("GridPrint"), DefaultValue(""), Localizable(True)> Property FooterCenter As String
    <Category("GridPrint"), DefaultValue(""), Localizable(True)> Property FooterRight As String

End Interface
Public Interface IModelListViewExtender
    <DefaultValue(True)> Property IsGroupFooterVisible() As Boolean
    <CriteriaOptionsAttribute("ModelClass.TypeInfo"), Editor("DevExpress.ExpressApp.Win.Core.ModelEditor.CriteriaModelEditorControl, DevExpress.ExpressApp.Win" & XafApplication.CurrentVersion, GetType(System.Drawing.Design.UITypeEditor))> Property AdditionalCriteria As String
    <DefaultValue(False)> Property RequireCriteriaBeforeView As Boolean
    <DefaultValue("Filter for the {0} ListView")> Property RequireCriteriaBeforeViewCaption As String
    <CriteriaOptionsAttribute("ModelClass.TypeInfo"), Editor("DevExpress.ExpressApp.Win.Core.ModelEditor.CriteriaModelEditorControl, DevExpress.ExpressApp.Win" & XafApplication.CurrentVersion, GetType(System.Drawing.Design.UITypeEditor))> Property RequireCriteriaBeforeViewCriteria As String
    <DefaultValue("{0}: [#image]{1} {2}")> Property GridViewGroupFormat As String
    <DefaultValue(False), Category("Misc")> Property IsCentralListView As Boolean
    <DefaultValue(True), Category("TreeList")> Property TreeListEnableFiltering As Boolean
    <Category("DateYearInFilter"), DefaultValue(False)> Property DefaultDateYearInFilter As Boolean 'Az a képesség, hogy ListView esetén van-e automatikusan adott évre filter szűrő
    <Category("DateYearInFilter")> Property DefaultDateYearInFilterProperty As String 'Az a képesség, hogy ListView esetén van-e automatikusan adott évre szűrő és melyik a dátum szűrése !
    <DefaultValue(True)> Overloads Property IsFooterVisible As Boolean
    <DefaultValue("")> Property Hints As String

    '// Grid nyomtatáshoz
    '// {0} CustomersFrom.FullName alapértelmezettből !
    <Category("GridPrint"), DefaultValue(""), Localizable(True)> Property HeaderLeft As String
    <Category("GridPrint"), DefaultValue(""), Localizable(True)> Property HeaderCenter As String
    <Category("GridPrint"), DefaultValue(""), Localizable(True)> Property HeaderRight As String
    <Category("GridPrint"), DefaultValue(""), Localizable(True)> Property FooterLeft As String
    <Category("GridPrint"), DefaultValue(""), Localizable(True)> Property FooterCenter As String
    <Category("GridPrint"), DefaultValue(""), Localizable(True)> Property FooterRight As String
End Interface
Public Interface IModelDetailViewExtender
    <DefaultValue("")> Property Hints As String
End Interface
Public Interface IModelColumnExtender
    <DefaultValue(SummaryItemType.None)> _
    Property GroupFooterSummaryType() As SummaryItemType
    <Category("Appearance"), DefaultValue(False)> _
    Property InLineEdit As Boolean
    <Category("Appearance"), CriteriaOptionsAttribute("ParentView.ModelClass.TypeInfo"), Editor("DevExpress.ExpressApp.Win.Core.ModelEditor.CriteriaModelEditorControl, DevExpress.ExpressApp.Win" & XafApplication.CurrentVersion, GetType(System.Drawing.Design.UITypeEditor))>
    Property InLineCriteria As String
    <DefaultValue(False)> _
    <Category("Appearance")> _
    Property InLineEditAutoCommit As Boolean
    <Category("Appearance"), DefaultValue(False)> _
    Property HideValueIfZero As Boolean
    '// ModelMember.Type -> a mező tipusára vonatkoztatva
    '// ParentView.ModelClass.TypeInfo -> a ListView objektumára vonatkoztatva
End Interface
Public Enum DefaultDateYearInCriteriaEnum
    CurrentYearOnly = 0
    CurrentYearAndPrevYear = 1
    NotSet = -1
End Enum
Public Interface IModelClassAllowSort
    <Category("Behavior")> Property DefaultListViewAllowSort() As Boolean

    <Category("SIS"), DefaultValue(False)> Property NonPersistent As Boolean
    <Category("SIS"), DefaultValue(False)> Property IsPopup As Boolean
    <Category("SIS")> Property SISGroup1 As String
    <Category("SIS")> Property SISGroup2 As String
    <Category("SIS"), Editor(GetType(SISBusiness.Module.SISHtmlEditor), GetType(System.Drawing.Design.UITypeEditor))> Property SISDescription As String

    <Category("ObjectLocking"), DefaultValue(False)> Property LockObjectBeforeEdit As Boolean ' 
    <Category("ObjectLocking"), Localizable(True)> Property LockObjectBeforeEditErrorString As String

    <Category("DateYearInFilter"), DefaultValue(False)> Property DefaultDateYearInFilter As Boolean 'Az a képesség, hogy ListView esetén van-e automatikusan adott évre filter szűrő
    <Category("DateYearInFilter")> Property DefaultDateYearInFilterProperty As String 'Az a képesség, hogy ListView esetén van-e automatikusan adott évre szűrő és melyik a dátum szűrése !
End Interface
Public Interface IModelMemberAllowSort
    <Category("Behavior")> Property AllowSort() As Boolean

    <Category("Format"), DefaultValue(False)> Property AllowRounding() As Boolean
    <Category("Format"), DefaultValue(4)> Property RoundingTo() As Long

    <Category("Appearance"), DefaultValue(False)> Property HideValueIfZero As Boolean
End Interface
Public Interface IModelListViewAllowSort
    <Category("Behavior")> Property AllowSort() As Boolean

    <Category("SIS"), DefaultValue(True)> Property IsListViewProcess As Boolean
    <Category("SIS"), DefaultValue(False)> Property RowAutoHeight As Boolean

   
End Interface
Public Interface IModelColumnAllowSort
    <Category("Behavior")> Property AllowSort() As Boolean
End Interface
Public Interface IModelActionExtender
    <Category("SIS")> Property SISGroup1 As String
    <Category("SIS")> Property SISGroup2 As String
    <Category("SIS")> Property SISDescription As String
    Property FocusItem As String
End Interface
#End Region
#Region "DOMAIN LOGIC"


<DomainLogic(GetType(IModelClassAllowSort))> _
Public NotInheritable Class ModelClassAllowSortLogic
    Public Shared Function Get_DefaultListViewAllowSort(ByVal modelClass As IModelClass) As Boolean
        If modelClass Is Nothing Then
            Return True
        End If
        If modelClass.TypeInfo Is Nothing Then
            Return True
        End If
        Dim attribute As AllowSortAttribute = modelClass.TypeInfo.FindAttribute(Of AllowSortAttribute)()
        If attribute IsNot Nothing Then
            Return attribute.AllowSort
        Else
            Return True
        End If
    End Function
End Class
<DomainLogic(GetType(IModelMemberAllowSort))> _
Public NotInheritable Class ModelMemberAllowSortLogic
    Public Shared Function Get_AllowSort(ByVal modelMember As IModelMember) As Boolean
        If modelMember Is Nothing Then
            Return True
        Else
            If modelMember.MemberInfo Is Nothing Then
                Return True
            End If
            Dim attribute As AllowSortAttribute = modelMember.MemberInfo.FindAttribute(Of AllowSortAttribute)()
            If attribute IsNot Nothing Then
                Return attribute.AllowSort
            Else
                Return True
            End If
        End If
    End Function
End Class
<DomainLogic(GetType(IModelListViewAllowSort))> _
Public NotInheritable Class ModelListViewAllowSortLogic
    Public Shared Function Get_AllowSort(ByVal modelListView As IModelListView) As Boolean
        Return (CType(modelListView.ModelClass, IModelClassAllowSort)).DefaultListViewAllowSort
    End Function
End Class
<DomainLogic(GetType(IModelColumnAllowSort))> _
Public NotInheritable Class ModelColumnAllowSortLogic
    Public Shared Function Get_AllowSort(ByVal modelColumn As IModelColumn) As Boolean
        If modelColumn.ModelMember IsNot Nothing Then
            Return (CType(modelColumn.ModelMember, IModelMemberAllowSort)).AllowSort
        Else
            Return True
        End If
    End Function
End Class
<DomainLogic(GetType(IModelColumnExtender))> _
Public NotInheritable Class IModelColumnExtenderLogic
    Public Shared Function Get_HideValueIfZero(ByVal modelColumn As IModelColumn) As Boolean
        If modelColumn.ModelMember IsNot Nothing Then
            Return (CType(modelColumn.ModelMember, IModelMemberAllowSort)).HideValueIfZero
        Else
            Return False
        End If
    End Function
End Class
<DomainLogic(GetType(IModelListViewExtender))> _
Public NotInheritable Class IModelListViewExtenderLogic
    Public Shared Function Get_DefaultDateYearInFilter(ByVal modelListView As IModelListView) As Boolean
        If modelListView.ModelClass IsNot Nothing Then
            Return (CType(modelListView.ModelClass, IModelClassAllowSort)).DefaultDateYearInFilter
        Else
            Return False
        End If
    End Function
    Public Shared Function Get_DefaultDateYearInFilterProperty(ByVal modelListView As IModelListView) As String
        If modelListView.ModelClass IsNot Nothing Then
            Return (CType(modelListView.ModelClass, IModelClassAllowSort)).DefaultDateYearInFilterProperty
        Else
            Return ""
        End If
    End Function
    Public Shared Function Get_HeaderLeft(ByVal modelListView As IModelListView) As String
        If modelListView.Application IsNot Nothing Then
            If modelListView.Application.Options IsNot Nothing Then
                Return TryCast(modelListView.Application.Options, IModelOptionsExtender).HeaderLeft
            Else
                Return ""
            End If
        Else
            Return ""
        End If
    End Function
    Public Shared Function Get_HeaderCenter(ByVal modelListView As IModelListView) As String
        If modelListView.Application IsNot Nothing Then
            If modelListView.Application.Options IsNot Nothing Then
                Return TryCast(modelListView.Application.Options, IModelOptionsExtender).HeaderCenter
            Else
                Return ""
            End If
        Else
            Return ""
        End If
    End Function
    Public Shared Function Get_HeaderRight(ByVal modelListView As IModelListView) As String
        If modelListView.Application IsNot Nothing Then
            If modelListView.Application.Options IsNot Nothing Then
                Return TryCast(modelListView.Application.Options, IModelOptionsExtender).HeaderRight
            Else
                Return ""
            End If
        Else
            Return ""
        End If
    End Function
    Public Shared Function Get_FooterLeft(ByVal modelListView As IModelListView) As String
        If modelListView.Application IsNot Nothing Then
            If modelListView.Application.Options IsNot Nothing Then
                Return TryCast(modelListView.Application.Options, IModelOptionsExtender).FooterLeft
            Else
                Return ""
            End If
        Else
            Return ""
        End If
    End Function
    Public Shared Function Get_FooterCenter(ByVal modelListView As IModelListView) As String
        If modelListView.Application IsNot Nothing Then
            If modelListView.Application.Options IsNot Nothing Then
                Return TryCast(modelListView.Application.Options, IModelOptionsExtender).FooterCenter
            Else
                Return ""
            End If
        Else
            Return ""
        End If
    End Function
    Public Shared Function Get_FooterRight(ByVal modelListView As IModelListView) As String
        If modelListView.Application IsNot Nothing Then
            If modelListView.Application.Options IsNot Nothing Then
                Return TryCast(modelListView.Application.Options, IModelOptionsExtender).FooterRight
            Else
                Return ""
            End If
        Else
            Return ""
        End If
    End Function

End Class

#End Region
