Imports Microsoft.VisualBasic
Imports System
Imports System.Linq
Imports System.Text
Imports DevExpress.ExpressApp
Imports DevExpress.Data.Filtering
Imports System.Collections.Generic
Imports DevExpress.Persistent.Base
Imports DevExpress.ExpressApp.Utils
Imports DevExpress.ExpressApp.Layout
Imports DevExpress.ExpressApp.Actions
Imports DevExpress.ExpressApp.Editors
Imports DevExpress.ExpressApp.Templates
Imports DevExpress.Persistent.Validation
Imports DevExpress.ExpressApp.SystemModule
Imports DevExpress.ExpressApp.Model.NodeGenerators
Imports DevExpress.ExpressApp.ViewVariantsModule

' For more typical usage scenarios, be sure to check out http://documentation.devexpress.com/#Xaf/clsDevExpressExpressAppWindowControllertopic.
Partial Public Class GLReportRowsWC
    Inherits WindowController
    Public Sub New()
        InitializeComponent()
        RegisterActions(components)
        ' Target required Windows (via the TargetXXX properties) and create their Actions.
    End Sub
    Protected Overrides Sub OnActivated()
        MyBase.OnActivated()
        ' Perform various tasks depending on the target Window.
    End Sub
    Protected Overrides Sub OnDeactivated()
        ' Unsubscribe from previously subscribed events and release other references and resources.
        MyBase.OnDeactivated()
    End Sub
    Protected Overrides Sub OnFrameAssigned()
        MyBase.OnFrameAssigned()
        Dim controller As ChangeVariantController = Frame.GetController(Of ChangeVariantController)()
        'AddHandler controller.ChangeVariantActionItemsCreated, AddressOf VariantsController_ChangeVariantActionItemsCreated
    End Sub

    Private Sub VariantsController_ChangeVariantActionItemsCreated(sender As Object, e As EventArgs)
        'Beep()

        'If View.Id = "GLReport_DetailView" Then
        '    Dim _GLReport As GLReport = TryCast(View.SelectedObjects(0), GLReport)
        '    Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
        '    If _GLReport IsNot Nothing Then
        '        _MasterKey = _GLReport.Oid
        '        If _ocur.IsNewObject(_GLReport) = False Then
        '            If _GLReport.VariantSelectedItemID <> "" Then
        '                Dim _ListPropertyEditor As ListPropertyEditor = TryCast(View, DetailView).FindItem("GLReportRows")
        '                If _ListPropertyEditor.Frame IsNot Nothing Then
        '                    Dim _ChangeVariantController As ChangeVariantController = Frame.GetController(Of ChangeVariantController)()
        '                    _ChangeVariantController.ChangeVariantAction.DoExecute(_ChangeVariantController.ChangeVariantAction.FindItemByIdPath(_GLReport.VariantSelectedItemID))
        '                End If
        '            End If
        '        End If
        '    End If
        'End If
        If Frame.View.Id Like "GLReport_GLRep*" Then
            'TryCast(sender, ChangeVariantController).ChangeVariantAction.DoExecute(TryCast(sender, ChangeVariantController).ChangeVariantAction.FindItemByIdPath(TryCast(TryCast(TryCast(Frame.View, ListView).CollectionSource, PropertyCollectionSource).MasterObject, GLReport).VariantSelectedItemID))
        End If
    End Sub

End Class
