Imports System
Imports System.ComponentModel
Imports System.Collections.Generic
Imports System.Diagnostics
Imports System.Text

Imports DevExpress.ExpressApp
Imports DevExpress.ExpressApp.Actions
Imports DevExpress.Persistent.Base

Imports DevExpress.ExpressApp.PivotGrid.Win
Imports DevExpress.XtraPivotGrid
Imports DevExpress.ExpressApp.Utils

Public Class CRMEstateStatisticsVC
    Inherits Nuvolar.Module.CRMEstateStatisticsVC
    Dim _WaitFormClass as New WaitFormClass
    Private _PivotGridListEditor As PivotGridListEditor
    Private _PivotGrdidControl As PivotGridControl
    Public Sub New()
        MyBase.New()

        'This call is required by the Component Designer.
        InitializeComponent()
        RegisterActions(components)

    End Sub
    Protected Overrides Sub OnActivated()
        MyBase.OnActivated()

        AddHandler DoWork, AddressOf _WaitFormClass.DoWork
        AddHandler InitWork, AddressOf _WaitFormClass.Initwork
        AddHandler FinalWork, AddressOf _WaitFormClass.Finalwork
    End Sub
    Protected Overrides Sub OnDeactivated()
        MyBase.OnDeactivated()
        RemoveHandler DoWork, AddressOf _WaitFormClass.DoWork
        RemoveHandler InitWork, AddressOf _WaitFormClass.Initwork
        RemoveHandler FinalWork, AddressOf _WaitFormClass.Finalwork
    End Sub
    Protected Overrides Sub OnViewControlsCreated()
        MyBase.OnViewControlsCreated()
        If View.Id = "CRMEstateStatistics_ListView_Pivot" Then
            _PivotGridListEditor = TryCast(TryCast(View, ListView).Editor, PivotGridListEditor)

            If _PivotGridListEditor IsNot Nothing Then
                _PivotGrdidControl = _PivotGridListEditor.PivotGridControl
                AddHandler _PivotGrdidControl.FieldValueDisplayText, AddressOf PivotGridControl_FieldValueDisplayText
            End If
        End If
    End Sub
    Private Sub PivotGridControl_FieldValueDisplayText(sender As Object, e As PivotFieldDisplayTextEventArgs)
        If e.Field IsNot Nothing Then
            If e.Field.Name = "Field_Immovables.ImmovablesTypes" Then
                e.DisplayText = CaptionHelper.GetLocalizedText("Enums\Nuvolar.Module.eImmovablesTypes", e.DisplayText.ToString)
            End If
            If e.Field.Name = "Field_Immovables.ImmovableSoldState" Then
                e.DisplayText = CaptionHelper.GetLocalizedText("Enums\Nuvolar.Module.eImmovableSoldState", e.DisplayText.ToString)
            End If

        End If
    End Sub

End Class
