Imports System.Collections.ObjectModel Imports EgtWPFLib5 Public Class LicenceBoxVM Inherits VMBase Private m_LicFileContentText As String Public Property LicFileContentText As String Get Return m_LicFileContentText End Get Set(value As String) m_LicFileContentText = value End Set End Property Private m_LicNoteText As String Public Property LicNoteText As String Get Return m_LicNoteText End Get Set(value As String) m_LicNoteText = value End Set End Property Private m_Option1 As New ObservableCollection(Of KeyOption) Public ReadOnly Property Option1 As ObservableCollection(Of KeyOption) Get Return m_Option1 End Get End Property Private m_Option2 As New ObservableCollection(Of KeyOption) Public Event m_CloseWindow(bDialogResult As Boolean) Public ReadOnly Property Option2 As ObservableCollection(Of KeyOption) Get Return m_Option2 End Get End Property Private m_ProductDeadline As String Public Property ProductDeadline As String Get Return m_ProductDeadline End Get Set(value As String) m_ProductDeadline = value End Set End Property Private m_OptionDeadline As String Public Property OptionDeadline As String Get Return m_OptionDeadline End Get Set(value As String) m_OptionDeadline = value End Set End Property Private m_NestDeadline As String Public Property NestDeadline As String Get Return m_NestDeadline End Get Set(value As String) m_NestDeadline = value End Set End Property Private m_NestDlTxBl_Visibility As Visibility Public Property NestDlTxBl_Visibility As Visibility Get Return m_NestDlTxBl_Visibility End Get Set(value As Visibility) m_NestDlTxBl_Visibility = value NotifyPropertyChanged("NestDlTxBl_Visibility") End Set End Property Private m_NestDlTxBx_Visibility As Visibility Public Property NestDlTxBx_Visibility As Visibility Get Return m_NestDlTxBx_Visibility End Get Set(value As Visibility) m_NestDlTxBx_Visibility = value NotifyPropertyChanged("NestDlTxBx_Visibility") End Set End Property Public ReadOnly Property Option1Msg As String Get Return "Option 1" End Get End Property Public ReadOnly Property Option2Msg As String Get Return "Option 2" End Get End Property Public ReadOnly Property ProductDeadlineMsg As String Get Return "Product deadline" End Get End Property Public ReadOnly Property OptionDeadlineMsg As String Get Return "Option deadline" End Get End Property Public ReadOnly Property NestDeadlineMsg As String Get Return "Nesting deadline" End Get End Property Public ReadOnly Property DownloadMsg As String Get Return "Download" End Get End Property Public ReadOnly Property ExitMsg As String Get Return "Close" End Get End Property #Region "CONSTRUCTOR" Sub New() ' Imposto riferimento nella mappa Map.SetRefLicenceBoxVM(Me) InitLicenceBox() End Sub #End Region ' CONSTRUCTOR #Region "METHODS" Friend Sub InitLicenceBox() LicFileContentText = CType(Map.refSearchLicencePageVM.Row.Item, Licence).LicFile LicNoteText = CType(Map.refSearchLicencePageVM.Row.Item, Licence).Note m_ProductDeadline = CType(Map.refSearchLicencePageVM.Row.Item, Licence).ProductDeadline.ToShortDateString() NotifyPropertyChanged("ProductDeadline") m_OptionDeadline = CType(Map.refSearchLicencePageVM.Row.Item, Licence).OptionDeadline.ToShortDateString() NotifyPropertyChanged("OptionDeadline") m_NestDlTxBl_Visibility = Visibility.Hidden m_NestDlTxBx_Visibility = Visibility.Hidden ' Cerco NestDeadline associato alla Licenza, se presente lo visualizzo Dim licId As String = CType(Map.refSearchLicencePageVM.Row.Item, Licence).LicenceID Dim Query As String = "SELECT " & DB_NESTDEADLINE & " FROM " & DB_LICENCE & " WHERE " & DB_LICENCEID & " = " & licId Dim m_NestKeyDict As Dictionary(Of String, String) = ManageDb.ExecuteStringDictionaryQuery(Query) Dim NestDl As String = m_NestKeyDict(DB_NESTDEADLINE) If Not String.IsNullOrWhiteSpace(NestDl) Then m_NestDlTxBl_Visibility = Visibility.Visible m_NestDlTxBx_Visibility = Visibility.Visible m_NestDeadline = NestDl NotifyPropertyChanged("NestDeadline") End If ' Inizializzo liste opzioni LoadOptions(1, m_Option1) LoadOptions(2, m_Option2) End Sub #End Region ' METHODS Private Sub LoadOptions(nIndex As Integer, OptionList As ObservableCollection(Of KeyOption)) Dim SelectedLicence = CType(Map.refSearchLicencePageVM.Row.Item, Licence) 'Cerco ProductName associato a ProductID Dim Query As String = "SELECT " & DB_PRODUCTNAME & " FROM " & DB_PRODUCT & " WHERE " & DB_PRODUCTID & " = " & SelectedLicence.ProductID Dim m_ProductNameDict As Dictionary(Of String, String) = ManageDb.ExecuteStringDictionaryQuery(Query) Dim ProductName As String = m_ProductNameDict(DB_PRODUCTNAME) ' Cancello opzioni OptionList.Clear() ' Carico opzioni Dim OptionIndex As Integer = 1 Dim OptionName As String = String.Empty GetMainPrivateProfileString(ProductName & " - Option" & nIndex, "Option" & OptionIndex, "", OptionName) While Not String.IsNullOrWhiteSpace(OptionName) OptionList.Add(New KeyOption(False, True, OptionName)) OptionIndex += 1 GetMainPrivateProfileString(ProductName & " - Option" & nIndex, "Option" & OptionIndex, "", OptionName) End While ' Se ho caricato delle opzioni If OptionList.Count > 0 Then ' Verifico se ci sono opzioni del prodotto Dim ProductOption As Integer = If(nIndex = 1, SelectedLicence.Option1, SelectedLicence.Option2) Dim nBinaryIndex As Integer = 1 For I = 0 To OptionList.Count - 1 If (ProductOption And nBinaryIndex) <> 0 Then OptionList(I).IsChecked = True OptionList(I).IsEnabled = True End If If nIndex = 2 Then If (OptionList(I).Msg.Equals("XXX")) Then OptionList(I).IsChecked = False OptionList(I).IsEnabled = False End If End If nBinaryIndex *= 2 Next End If End Sub End Class