LicenceManager 2.1k2 :

- Corretto DatePickerYears: se si cancella la data e poi si perde il focus viene reimpostato con la data di oggi
- Corretto filtro ricerca Licenze: LicenceTable.LockID e LicenceTable.Date in modo che non risultino ambigui
- Sostituito "For I = 0 To 15" nei vari metodi LoadOptions() con "For I = 0 To OptionList.Count - 1".
- Modificata LicenceBox: ora contiene anche le Options1/2 della Licenza ed è stata riscritta seguendo i criteri MVVM
This commit is contained in:
Renzo Lanza
2019-11-29 11:17:47 +00:00
parent d4c08f226a
commit 9ae5219393
15 changed files with 309 additions and 99 deletions
+104
View File
@@ -0,0 +1,104 @@
<Window x:Class="LicenceBoxV"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:LicenseManager"
mc:Ignorable="d"
Title="LicenceBoxV" Height="650" Width="700" WindowStyle="None" ResizeMode="NoResize"
WindowStartupLocation="CenterOwner" ShowInTaskbar="False" HorizontalAlignment="Center">
<!-- Definizione dell'AboutBox -->
<Border BorderThickness="2" BorderBrush="LightBlue">
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.15*"/>
<ColumnDefinition Width="5*"/>
<ColumnDefinition Width="0.15*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0.25*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.25*"/>
<RowDefinition Height="3*"/>
<RowDefinition Height="0.15*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="0.35*"/>
<RowDefinition Height="0.6*"/>
<RowDefinition Height="0.35*"/>
</Grid.RowDefinitions>
<Grid Grid.Column="1" Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Border Name="LogoBrd" Grid.Column="0" Background="White">
<Image Source="/Resources/LogoLicenceManager.ico" Stretch="Uniform" HorizontalAlignment="Left"/>
</Border>
<TextBlock Grid.Column="1" Text="Licence File Content"
HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20">
</TextBlock>
</Grid>
<TextBox Name="InfoLbl" Text="{Binding LicFileContentText}" Grid.Column="1" Grid.Row="3" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" IsReadOnly="True" FontSize="12" TextWrapping="Wrap"/>
<Grid Grid.Column="1" Grid.Row="8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.6*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="0.2*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="0.6*"/>
</Grid.ColumnDefinitions>
<Button Name="DownloadBtn" Content="{Binding DownloadMsg}" Grid.Column="1" Grid.Row="8" Margin="1,0"/>
<Button Name="ExitBtn" Content="{Binding ExitMsg}" Grid.Column="3" Grid.Row="8" IsCancel="True" Margin="1,0"/>
</Grid>
<GroupBox Header="{Binding Option1Msg}"
Grid.Row="5" Grid.Column="1" IsEnabled="False">
<ItemsControl ItemsSource="{Binding Option1}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding IsChecked}"
Content="{Binding Msg}"
IsEnabled="{Binding IsEnabled}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="4"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</GroupBox>
<GroupBox Header="{Binding Option2Msg}"
Grid.Row="6" Grid.Column="1" IsEnabled="False">
<ItemsControl ItemsSource="{Binding Option2}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding IsChecked}"
Content="{Binding Msg}"
IsEnabled="{Binding IsEnabled}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="4"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</GroupBox>
</Grid>
</Border>
</Window>
+45
View File
@@ -0,0 +1,45 @@
Imports System.Collections.ObjectModel
Imports EgtUILib
Imports EgtWPFLib5
Public Class LicenceBoxV
Private WithEvents m_LicenceBoxVM As LicenceBoxVM
Sub New(Owner As Window, LicenceBoxVM As LicenceBoxVM)
MyBase.New()
' This call is required by the designer.
InitializeComponent()
Me.DataContext = LicenceBoxVM
' Assegno al riferimento locale al VM il VM preso dal DataContext
m_LicenceBoxVM = LicenceBoxVM
End Sub
Private Sub CloseWindow(bDialogResult As Boolean) Handles m_LicenceBoxVM.m_CloseWindow
Me.DataContext = Nothing
Me.DialogResult = bDialogResult
End Sub
'Private Sub LicenceBoxV_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized
' Me.Owner = Application.Current.MainWindow
' InfoLbl.Text = CType(Map.refSearchLicencePageVM.Row.Item, Licence).LicFile
' '' Inizializzo liste opzioni
' 'LoadOptions(1, m_Option1)
' 'LoadOptions(2, m_Option2)
' DownloadBtn.Content = "Download"
' ExitBtn.Content = "Close"
'End Sub
Private Sub DownloadBtn_Click(sender As Object, e As RoutedEventArgs) Handles DownloadBtn.Click
Dim lines As String() = InfoLbl.Text.Split(New String() {Environment.NewLine},
StringSplitOptions.None)
IO.File.WriteAllLines(IO.Path.ChangeExtension(CType(Map.refSearchLicencePageVM.Row.Item, Licence).File, ".lic"),
lines, Text.Encoding.UTF8)
MessageBox.Show("Licenza scaricata correttamente")
End Sub
End Class
+117
View File
@@ -0,0 +1,117 @@
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_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
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 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
' 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 ProductName = ManageDb.ExecuteStringQuery(Query, DB_PRODUCTNAME)(0)
' 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
+3 -2
View File
@@ -110,6 +110,7 @@
<DependentUpon>KeyPageV.xaml</DependentUpon>
</Compile>
<Compile Include="KeyPage\KeyPageVM.vb" />
<Compile Include="LicenceBox\LicenceBoxVM.vb" />
<Compile Include="MainMenu\MainMenuV.xaml.vb">
<DependentUpon>MainMenuV.xaml</DependentUpon>
</Compile>
@@ -199,7 +200,7 @@
<DependentUpon>Dictionary.xaml</DependentUpon>
</Compile>
<Compile Include="Utility\IniManager.vb" />
<Compile Include="Utility\LicenceBoxV.xaml.vb">
<Compile Include="LicenceBox\LicenceBoxV.xaml.vb">
<DependentUpon>LicenceBoxV.xaml</DependentUpon>
</Compile>
<Compile Include="Utility\ManageDb.vb" />
@@ -368,7 +369,7 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Utility\LicenceBoxV.xaml">
<Page Include="LicenceBox\LicenceBoxV.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
+5 -1
View File
@@ -154,8 +154,12 @@ Public Class MainWindowM
m_nUserLevel = Math.Min(m_nKeyLevel, GetMainPrivateProfileInt(S_GENERAL, K_USERLEVEL, 1))
' Info su opzioni chiave
EgtOutLog("KeyOptions : " & bKey.ToString() & " " & m_nKeyOptions.ToString())
' Semanca la licenza si esce
' Se manca la licenza si esce
If Not bKey Then
' Box di avviso chiave/licenza mancante
Dim sText As String = "Chiave o Licenza non presente." & vbCrLf & "Inserirla e riavviare il programma."
Dim sTitle As String = "Errore"
MessageBox.Show(sText, sTitle, MessageBoxButton.OK, MessageBoxImage.Error)
End
End If
End Sub
+2 -2
View File
@@ -59,5 +59,5 @@ Imports System.Windows
' usando l'asterisco '*' come illustrato di seguito:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("2.1.11.1")>
<Assembly: AssemblyFileVersion("2.1.11.1")>
<Assembly: AssemblyVersion("2.1.11.2")>
<Assembly: AssemblyFileVersion("2.1.11.2")>
+4 -4
View File
@@ -381,7 +381,7 @@ Public Class NewLicencePageVM
' Verifico se ci sono opzioni del prodotto
Dim ProductOption As Integer = If(nIndex = 1, m_SelProduct.ProductOption1, m_SelProduct.ProductOption2)
Dim nBinaryIndex As Integer = 1
For I = 0 To 15
For I = 0 To OptionList.Count - 1
If (ProductOption And nBinaryIndex) <> 0 Then
OptionList(I).IsChecked = True
OptionList(I).IsEnabled = False
@@ -486,7 +486,7 @@ Public Class NewLicencePageVM
Try
IO.File.WriteAllLines(fileName, StringFile, Text.Encoding.UTF8)
Catch ex As Exception
MessageBox.Show("Errore nella scrittura del file dati per licenza", "KeyGenerator Error")
MessageBox.Show("Errore nella scrittura del file dati per licenza", "LicenceManager Error")
Return
End Try
@@ -503,7 +503,7 @@ Public Class NewLicencePageVM
' Errore nella generazione della licenza
If proc.ExitCode <> 0 Then
Dim sOut As String = "La Licenza non è stata generata correttamente (" & proc.ExitCode.ToString() & ")"
MessageBox.Show(sOut, "LicenceManager")
MessageBox.Show(sOut, "KeyGenerator Error")
Return
Else
Try
@@ -529,7 +529,7 @@ Public Class NewLicencePageVM
ManageDb.ExecuteQuery(Query)
Catch ex As Exception
MessageBox.Show("Errore nella scrittura del file dati per licenza", "LicenceManager Error")
MessageBox.Show("Errore nell'aggiunta della licenza al DB", "LicenceManager Error")
Return
End Try
+9 -3
View File
@@ -5,9 +5,15 @@
Private Sub Row_MouseDoubleClick(sender As Object, e As MouseButtonEventArgs)
Map.refSearchLicencePageVM.Row = CType(ItemsControl.ContainerFromElement(CType(sender, DataGrid), CType(e.OriginalSource, DependencyObject)), DataGridRow)
If (Not IsNothing(Map.refSearchLicencePageVM.Row)) AndAlso (Not IsNothing(CType(Map.refSearchLicencePageVM.Row.Item, Licence).LicFile)) Then
Dim LicenceBox As New LicenceBoxV
LicenceBox.Owner = Application.Current.MainWindow
LicenceBox.ShowDialog()
'Dim LicenceBox As New LicenceBoxV
'LicenceBox.Owner = Application.Current.MainWindow
'LicenceBox.ShowDialog()
Dim LicBox As New LicenceBoxV(Application.Current.MainWindow, New LicenceBoxVM())
LicBox.Height = 700
LicBox.Width = 1100
LicBox.HorizontalAlignment = HorizontalAlignment.Center
LicBox.ShowDialog()
End If
End Sub
+3 -3
View File
@@ -412,7 +412,7 @@ Public Class SearchLicencePageVM
' Verifico se ci sono opzioni del prodotto
Dim ProductOption As Integer = If(nIndex = 1, m_SelProduct.ProductOption1, m_SelProduct.ProductOption2)
Dim nBinaryIndex As Integer = 1
For I = 0 To 15
For I = 0 To OptionList.Count - 1
If (ProductOption And nBinaryIndex) <> 0 Then
OptionList(I).IsChecked = True
OptionList(I).IsEnabled = False
@@ -538,7 +538,7 @@ Public Class SearchLicencePageVM
End If
If Not String.IsNullOrWhiteSpace(LockID) Then
EvalWhere(bFirstWhere, Query)
Query &= DB_LOCKID & " LIKE '%" & LockID & "%' "
Query &= DB_LICENCE & "." & DB_LOCKID & " LIKE '%" & LockID & "%' "
End If
If Not String.IsNullOrWhiteSpace(File) Then
EvalWhere(bFirstWhere, Query)
@@ -546,7 +546,7 @@ Public Class SearchLicencePageVM
End If
If Not IsNothing(LicenseDate) Then
EvalWhere(bFirstWhere, Query)
Query &= DB_DATE & " LIKE '%" & Format(LicenseDate, "yyyy-MM-dd") & "%' "
Query &= DB_LICENCE & "." & DB_DATE & " LIKE '%" & Format(LicenseDate, "yyyy-MM-dd") & "%' "
End If
If Not IsNothing(m_SelIsDongle) Then
If m_SelIsDongle <> 2 Then
+1 -1
View File
@@ -699,7 +699,7 @@ Public Class UpdateLicencePageVM
"'" & m_Note & "')"
Catch ex As Exception
MessageBox.Show("Errore nella scrittura del file dati per licenza", "LicenceManager Error")
MessageBox.Show("Errore nella lettura dei dati per la scrittura su DB", "LicenceManager Error")
Return
End Try
End If
+1 -1
View File
@@ -158,7 +158,7 @@ Public Class UpdateProductPageVM
' Verifico se ci sono opzioni del prodotto
Dim ProductOption As Integer = If(nIndex = 1, m_Product.ProductOption1, m_Product.ProductOption2)
Dim nBinaryIndex As Integer = 1
For I = 0 To 15
For I = 0 To OptionList.Count - 1
If (ProductOption And nBinaryIndex) <> 0 Then
OptionList(I).IsChecked = True
OptionList(I).IsEnabled = True
+3 -1
View File
@@ -15,10 +15,12 @@
Private Sub CustomDP_SelectedDateChanged(ByVal sender As Object,
ByVal e As System.Windows.Controls.SelectionChangedEventArgs) Handles CustomDP.SelectedDateChanged
If IsNothing(SelectedDate) Then
SelectedDate = Date.Now
End If
SelectedDate = New Date(Year(CDate(CustomDP.SelectedDate)),
Month(CDate(CustomDP.SelectedDate)),
Day(CDate(CustomDP.SelectedDate)))
End Sub
Private Sub Plus1Y_Click(sender As Object, e As RoutedEventArgs) Handles Plus1Y.Click
-60
View File
@@ -1,60 +0,0 @@
<Window x:Class="LicenceBoxV"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:LicenseManager"
mc:Ignorable="d"
Title="LicenceBoxV" Height="450" Width="500" WindowStyle="None" ResizeMode="NoResize"
WindowStartupLocation="CenterOwner" ShowInTaskbar="False">
<!-- Definizione dell'AboutBox -->
<Border BorderThickness="2" BorderBrush="LightBlue">
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="5*"/>
<ColumnDefinition Width="0.5*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0.25*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.25*"/>
<RowDefinition Height="4*"/>
<RowDefinition Height="0.35*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.35*"/>
</Grid.RowDefinitions>
<Grid Grid.Column="1" Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Border Name="LogoBrd" Grid.Column="0" Background="White">
<Image Source="/Resources/LogoLicenceManager.ico" Stretch="Uniform"/>
</Border>
<TextBlock Grid.Column="1" Text="Licence File Content"
HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20">
</TextBlock>
</Grid>
<TextBox Name="InfoLbl" Grid.Column="1" Grid.Row="3" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" FontSize="12" IsReadOnly="True" TextWrapping="Wrap"/>
<Grid Grid.Column="1" Grid.Row="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="0.1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Button Name="DownloadBtn" Grid.Column="0"
Margin="1,0,0.8,0" Height="36" VerticalAlignment="Top"/>
<Button Name="ExitBtn" Grid.Column="2" Grid.Row="8" IsCancel="True"
Margin="1,0"/>
</Grid>
</Grid>
</Border>
</Window>
-21
View File
@@ -1,21 +0,0 @@
Imports EgtUILib
Public Class LicenceBoxV
Private Sub LicenceBoxV_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized
Me.Owner = Application.Current.MainWindow
InfoLbl.Text = CType(Map.refSearchLicencePageVM.Row.Item, Licence).LicFile
DownloadBtn.Content = "Download"
ExitBtn.Content = "Close"
End Sub
Private Sub DownloadBtn_Click(sender As Object, e As RoutedEventArgs) Handles DownloadBtn.Click
Dim lines As String() = InfoLbl.Text.Split(New String() {Environment.NewLine},
StringSplitOptions.None)
IO.File.WriteAllLines(IO.Path.ChangeExtension(CType(Map.refSearchLicencePageVM.Row.Item, Licence).File, ".lic"),
lines, Text.Encoding.UTF8)
MessageBox.Show("Licenza scaricata correttamente")
End Sub
End Class
+12
View File
@@ -21,6 +21,7 @@ Module Map
Private m_refUpdateProductPageVM As UpdateProductPageVM
Private m_refUpdateVersionPageVM As UpdateVersionPageVM
Private m_refUpdateResellerPageVM As UpdateResellerPageVM
Private m_refLicenceBoxVM As LicenceBoxVM
#Region "Get"
@@ -138,6 +139,12 @@ Module Map
End Get
End Property
Public ReadOnly Property refLicenceBoxVM As LicenceBoxVM
Get
Return m_refLicenceBoxVM
End Get
End Property
#End Region ' Get
@@ -233,6 +240,11 @@ Module Map
Return Not IsNothing(m_refUpdateResellerPageVM)
End Function
Friend Function SetRefLicenceBoxVM(LicenceBoxVM As LicenceBoxVM) As Boolean
m_refLicenceBoxVM = LicenceBoxVM
Return Not IsNothing(m_refLicenceBoxVM)
End Function
#End Region ' Set
#Region "Init"