- aggiunta grafica
This commit is contained in:
@@ -161,4 +161,7 @@ Public Module ConstIni
|
||||
Public Const K_TYPE As String = "Type"
|
||||
Public Const K_DEFAULTQUANTITY As String = "DefaultQuantity"
|
||||
|
||||
Public Const S_BACKUPANDRESTORE As String = "Backup&Restore"
|
||||
Public Const K_FILEPATH As String = "FilePath"
|
||||
|
||||
End Module
|
||||
|
||||
@@ -71,6 +71,38 @@
|
||||
<CheckBox IsChecked="{Binding bPrintLabel_IsChecked}"
|
||||
Margin="0,5,0,0"/>
|
||||
</UniformGrid>
|
||||
<GroupBox Header="Backup And Restore">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Text="File path:"/>
|
||||
<Grid Margin="0,2,0,5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox Text="{Binding BackupFilePath}"
|
||||
Margin="0,0,2.5,0"/>
|
||||
<Button Grid.Column="1"
|
||||
Content="..."
|
||||
Width="18"
|
||||
Command="{Binding ChooseBackupFilePath_Command}"
|
||||
Margin="2.5,0,0,0"/>
|
||||
</Grid>
|
||||
<StackPanel Grid.Row="1"
|
||||
Orientation="Horizontal">
|
||||
<Button Content="Backup"
|
||||
Command="{Binding Backup_Command}"
|
||||
Style="{StaticResource ToolBar_TextButton}"/>
|
||||
<Button Content="Restore"
|
||||
Command="{Binding Restore_Command}"
|
||||
Style="{StaticResource ToolBar_TextButton}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</TabItem.Content>
|
||||
|
||||
@@ -3,6 +3,8 @@ Imports System.IO
|
||||
Imports EgtUILib
|
||||
Imports EgtWPFLib5
|
||||
Imports EgtBEAMWALL.Core
|
||||
Imports MS.Internal
|
||||
Imports Org.BouncyCastle.X509
|
||||
|
||||
Public Class ConfigurationPageVM
|
||||
Inherits VMBase
|
||||
@@ -36,8 +38,6 @@ Public Class ConfigurationPageVM
|
||||
' flag modifica parametri Macchina
|
||||
Friend bModifyMachParam As Boolean
|
||||
|
||||
' Definizione comandi
|
||||
Private m_cmdSave As ICommand
|
||||
|
||||
Public ReadOnly Property MachinePanelVM As MachinePanelVM
|
||||
Get
|
||||
@@ -160,6 +160,23 @@ Public Class ConfigurationPageVM
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_BackupFilePath As String
|
||||
Public Property BackupFilePath As String
|
||||
Get
|
||||
Return m_BackupFilePath
|
||||
End Get
|
||||
Set(value As String)
|
||||
m_BackupFilePath = value
|
||||
WriteMainPrivateProfileString(S_BACKUPANDRESTORE, K_FILEPATH, m_BackupFilePath)
|
||||
End Set
|
||||
End Property
|
||||
|
||||
' Definizione comandi
|
||||
Private m_cmdSave As ICommand
|
||||
Private m_cmdChooseBackupFilePath As ICommand
|
||||
Private m_cmdBackup As ICommand
|
||||
Private m_cmdRestore As ICommand
|
||||
|
||||
#Region "Messages"
|
||||
|
||||
Public ReadOnly Property L_Msg As String
|
||||
@@ -327,7 +344,7 @@ Public Class ConfigurationPageVM
|
||||
' leggo SectionTime e PartTime
|
||||
GetMainPrivateProfileString(S_NEST, K_SECTIONTIME, "", SectionTime)
|
||||
GetMainPrivateProfileString(S_NEST, K_PARTTIME, "", PartTime)
|
||||
m_bPrintLabel_IsChecked = ( GetMainPrivateProfileInt(S_PRINTER, K_ENABLE, 0) <> 0)
|
||||
m_bPrintLabel_IsChecked = (GetMainPrivateProfileInt(S_PRINTER, K_ENABLE, 0) <> 0)
|
||||
' assegno le liste dei parametri della macchina corrente alla ConfigMachTableList alla pagina di Configurazione
|
||||
ConfigMachTableList = CurrentMachine.MachTableList
|
||||
' carico i parametri Q dei Process letti dall'ini
|
||||
@@ -346,10 +363,14 @@ Public Class ConfigurationPageVM
|
||||
m_QBTLParamVMList_View = CollectionViewSource.GetDefaultView(m_QBTLParamVMList)
|
||||
m_QBTLParamVMList_View.GroupDescriptions.Add(New PropertyGroupDescription(NameOf(QBTLParamVM.GroupType)))
|
||||
m_QBTLParamVMList_View.GroupDescriptions.Add(New PropertyGroupDescription(NameOf(QBTLParamVM.ghDesc)))
|
||||
' leggo path per backup
|
||||
GetMainPrivateProfileString(S_BACKUPANDRESTORE, K_FILEPATH, "", m_BackupFilePath)
|
||||
End Sub
|
||||
|
||||
#End Region ' Constructor
|
||||
|
||||
#Region "COMMANDS"
|
||||
|
||||
#Region "SaveCommand"
|
||||
|
||||
''' <summary>
|
||||
@@ -373,6 +394,123 @@ Public Class ConfigurationPageVM
|
||||
|
||||
#End Region ' SaveCommand
|
||||
|
||||
#Region "ChooseBackupFilePath"
|
||||
|
||||
''' <summary>
|
||||
''' Returns a command that do Save.
|
||||
''' </summary>
|
||||
Public ReadOnly Property ChooseBackupFilePath_Command As ICommand
|
||||
Get
|
||||
If m_cmdChooseBackupFilePath Is Nothing Then
|
||||
m_cmdChooseBackupFilePath = New Command(AddressOf ChooseBackupFilePath)
|
||||
End If
|
||||
Return m_cmdChooseBackupFilePath
|
||||
End Get
|
||||
End Property
|
||||
|
||||
''' <summary>
|
||||
''' Execute the Save. This method is invoked by the SaveCommand.
|
||||
''' </summary>
|
||||
Public Sub ChooseBackupFilePath()
|
||||
Dim FileDialog As New Microsoft.Win32.SaveFileDialog() With {.FileName = m_BackupFilePath,
|
||||
.CheckFileExists = False,
|
||||
.CheckPathExists = False,
|
||||
.OverwritePrompt = False,
|
||||
.Title = "Backup & Restore File Path"}
|
||||
If FileDialog.ShowDialog() Then
|
||||
m_BackupFilePath = FileDialog.FileName
|
||||
NotifyPropertyChanged(NameOf(BackupFilePath))
|
||||
End If
|
||||
End Sub
|
||||
|
||||
#End Region ' ChooseBackupFilePath
|
||||
|
||||
#Region "Backup"
|
||||
|
||||
''' <summary>
|
||||
''' Returns a command that do Save.
|
||||
''' </summary>
|
||||
Public ReadOnly Property Backup_Command As ICommand
|
||||
Get
|
||||
If m_cmdBackup Is Nothing Then
|
||||
m_cmdBackup = New Command(AddressOf Backup)
|
||||
End If
|
||||
Return m_cmdBackup
|
||||
End Get
|
||||
End Property
|
||||
|
||||
''' <summary>
|
||||
''' Execute the Save. This method is invoked by the SaveCommand.
|
||||
''' </summary>
|
||||
Public Sub Backup()
|
||||
If Not String.IsNullOrWhiteSpace(m_BackupFilePath) AndAlso Directory.Exists(Path.GetDirectoryName(m_BackupFilePath)) Then
|
||||
If File.Exists(m_BackupFilePath) Then
|
||||
If MessageBox.Show("Are you sure you want to overwrite the file?", "Info", MessageBoxButton.OKCancel, MessageBoxImage.Warning) = MessageBoxResult.OK Then
|
||||
' rinomino ed elimino file gia' esistente
|
||||
Try
|
||||
File.Move(m_BackupFilePath, m_BackupFilePath & ".old")
|
||||
File.Delete(m_BackupFilePath)
|
||||
Catch ex As Exception
|
||||
MessageBox.Show("Backup failed! Impossible to move or delete previous file!", "Error", MessageBoxButton.OK, MessageBoxImage.Error)
|
||||
End Try
|
||||
' backup del corrente
|
||||
Try
|
||||
|
||||
Catch ex As Exception
|
||||
MessageBox.Show("Backup failed! Impossible to create the backup package!", "Error", MessageBoxButton.OK, MessageBoxImage.Error)
|
||||
End Try
|
||||
Else Return
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
#End Region ' Backup
|
||||
|
||||
#Region "Restore"
|
||||
|
||||
''' <summary>
|
||||
''' Returns a command that do Save.
|
||||
''' </summary>
|
||||
Public ReadOnly Property Restore_Command As ICommand
|
||||
Get
|
||||
If m_cmdRestore Is Nothing Then
|
||||
m_cmdRestore = New Command(AddressOf Restore)
|
||||
End If
|
||||
Return m_cmdRestore
|
||||
End Get
|
||||
End Property
|
||||
|
||||
''' <summary>
|
||||
''' Execute the Save. This method is invoked by the SaveCommand.
|
||||
''' </summary>
|
||||
Public Sub Restore()
|
||||
If Not String.IsNullOrWhiteSpace(m_BackupFilePath) AndAlso Directory.Exists(Path.GetDirectoryName(m_BackupFilePath)) Then
|
||||
If File.Exists(m_BackupFilePath) Then
|
||||
If MessageBox.Show("Are you sure you want to restore this file?", "Warning", MessageBoxButton.OKCancel, MessageBoxImage.Warning) = MessageBoxResult.OK Then
|
||||
' backup del corrente
|
||||
Try
|
||||
File.Move(m_BackupFilePath, m_BackupFilePath & ".old")
|
||||
File.Delete(m_BackupFilePath)
|
||||
Catch ex As Exception
|
||||
MessageBox.Show("Backup failed! Impossible to move or delete previous file!", "Error", MessageBoxButton.OK, MessageBoxImage.Error)
|
||||
End Try
|
||||
' restore di quello indicato
|
||||
Try
|
||||
|
||||
Catch ex As Exception
|
||||
MessageBox.Show("Backup failed! Impossible to create the backup package!", "Error", MessageBoxButton.OK, MessageBoxImage.Error)
|
||||
End Try
|
||||
Else Return
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
#End Region ' Restore
|
||||
|
||||
#End Region ' COMMANDS
|
||||
|
||||
#Region "Methods"
|
||||
|
||||
' funzione che scrive i parametri modificati sul file INI
|
||||
|
||||
Reference in New Issue
Block a user