- Inizio implementazione finestra di import export

This commit is contained in:
Emmanuele Sassi
2022-10-28 08:33:03 +02:00
parent 5152600fd9
commit 98628b887e
9 changed files with 527 additions and 4 deletions
+12 -1
View File
@@ -123,6 +123,10 @@
<DependentUpon>DispositionPanelV.xaml</DependentUpon>
</Compile>
<Compile Include="DispositionPanel\DispositionPanelVM.vb" />
<Compile Include="ImportExportMachiningPanel\ImportExportMachiningPanelV.xaml.vb">
<DependentUpon>ImportExportMachiningPanelV.xaml</DependentUpon>
</Compile>
<Compile Include="ImportExportMachiningPanel\ImportExportMachiningPanelVM.vb" />
<Compile Include="ImportPanel\ImportPanelV.xaml.vb">
<DependentUpon>ImportPanelV.xaml</DependentUpon>
</Compile>
@@ -301,6 +305,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="ImportExportMachiningPanel\ImportExportMachiningPanelV.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="ImportPanel\ImportPanelV.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -633,7 +641,10 @@
<ItemGroup>
<Resource Include="Resources\TopPanel\Edit.png" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Resource Include="Resources\MachiningDb\Export.png" />
<Resource Include="Resources\MachiningDb\Import.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
<PropertyGroup>
<PostBuildEvent>IF "$(PlatformName)"=="x64" IF "$(ConfigurationName)" == "Release" copy $(TargetPath) c:\EgtProg\Icarus\IcarusR64.exe
@@ -0,0 +1,56 @@
<EgtWPFLib5:EgtCustomWindow x:Class="ImportExportMachiningPanelV"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:EgtWPFLib5="clr-namespace:EgtWPFLib5;assembly=EgtWPFLib5"
Title="{Binding OkMsg}"
Style="{DynamicResource {x:Type EgtWPFLib5:EgtCustomWindow}}"
WindowStyle="None" ResizeMode="NoResize" TitleBarHeight="30" IsResizable="False"
IsMinimizable="False" WindowStartupLocation="CenterOwner" ShowInTaskbar="False"
Width="400">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="7*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<ListBox ItemsSource="{Binding MachiningList}">
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type EgtWPFLib5:ImpExpMachiningItem}">
<Grid Height="20">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<CheckBox Name="ActiveTxBx"
Grid.Column="0"
IsChecked="{Binding Active}"
Height="15"
Width="15"
Margin="0,0,5,0"
VerticalContentAlignment="Center"
Visibility="{Binding Path=DataContext.Active_Visibility,
RelativeSource={RelativeSource AncestorType={x:Type EgtWPFLib5:EgtCustomWindow}}}"/>
<TextBlock Grid.Column="1"
Text="{Binding sName}"
FontSize="15"
Margin="0,0,0,0"
VerticalAlignment="Center" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Button Command="{Binding OkCommand}"
Content="{Binding OkMsg}"
IsEnabled="{Binding IsEnabledOkBtn, Mode=OneWay}"
Grid.Row="1"
Height="30" Width="100"
Margin="10" />
</Grid>
</EgtWPFLib5:EgtCustomWindow>
@@ -0,0 +1,18 @@
Public Class ImportExportMachiningPanelV
Private WithEvents m_ImportExportMachiningPanelVM As ImportExportMachiningPanelVM
Sub New(Owner As Window, ImportExportMachiningPanelVM As ImportExportMachiningPanelVM)
MyBase.New(Owner)
' This call is required by the designer.
InitializeComponent()
Me.DataContext = ImportExportMachiningPanelVM
' Assegno al riferimento locale al VM il VM preso dal DataContext
m_ImportExportMachiningPanelVM = ImportExportMachiningPanelVM
End Sub
Private Sub CloseWindow(bDialogResult As Boolean) Handles m_ImportExportMachiningPanelVM.m_CloseWindow
Me.DialogResult = bDialogResult
End Sub
End Class
@@ -0,0 +1,378 @@
Imports System.Collections.ObjectModel
Imports EgtUILib
Imports EgtWPFLib5
Public Class ImportExportMachiningPanelVM
Inherits VMBase
' Modalita' di apertura della finestra
Public Enum WindowModeEnum As Integer
IMPORT
EXPORT
End Enum
Private m_WindowMode As WindowModeEnum
Public ReadOnly Property WindowMode As WindowModeEnum
Get
Return m_WindowMode
End Get
End Property
' Lista delle lavorazioni
Private m_MachiningList As New ObservableCollection(Of ImpExpMachiningItem)
Public Property MachiningList As ObservableCollection(Of ImpExpMachiningItem)
Get
Return m_MachiningList
End Get
Set(value As ObservableCollection(Of ImpExpMachiningItem))
m_MachiningList = value
End Set
End Property
' Percorso del file da cui importare le lavorazioni
Private m_ImportFilePath As String
Public ReadOnly Property ImportFilePath As String
Get
Return m_ImportFilePath
End Get
End Property
' Lista delle lavorazioni presenti nel file da cui importare
Private m_ImportFileMachiningNameList As String()
Public ReadOnly Property ImportFileMachiningNameList As String()
Get
Return m_ImportFileMachiningNameList
End Get
End Property
' Lista delle lavorazioni importate con successo
Private m_vsImported As String()
Public ReadOnly Property vsImported As String()
Get
Return m_vsImported
End Get
End Property
Public ReadOnly Property IsEnabledOkBtn As Boolean
Get
For Each Machining In MachiningList
If Machining.Active Then Return True
Next
Return False
End Get
End Property
Friend Event m_CloseWindow(bDialogResult As Boolean)
#Region "MESSAGES"
Public ReadOnly Property OkMsg As String
Get
If WindowMode = WindowModeEnum.IMPORT Then
Return EgtMsg(31450)
Else
Return EgtMsg(31451)
End If
End Get
End Property
#End Region ' Messages
#Region "COMMANDS"
' Definizione comandi
Private m_cmdOk As ICommand
#Region "OkCommand"
''' <summary>
''' Returns a command that remove the current selected machining.
''' </summary>
Public ReadOnly Property OkCommand() As ICommand
Get
If m_cmdOk Is Nothing Then
m_cmdOk = New Command(AddressOf ConfirmImpExpMachinings)
End If
Return m_cmdOk
End Get
End Property
''' <summary>
''' Manage the MachiningDb closing. This method is invoked by the CloseMachiningDbCommand.
''' </summary>
Public Sub ConfirmImpExpMachinings(param As Object)
Select Case WindowMode
Case WindowModeEnum.IMPORT
Dim FinalNameList As New List(Of String)
Dim ImportMachiningNameList As New List(Of String)(ImportFileMachiningNameList)
For Each Machining In MachiningList
If Machining.Active Then
FinalNameList.Add(Machining.sName)
Else
ImportMachiningNameList.Remove(Machining.sName)
End If
Next
Dim vsFinalName = FinalNameList.ToArray()
Dim vsImportMachiningName = ImportMachiningNameList.ToArray()
' Eseguo importazione
EgtMdbImport(ImportFilePath, vsImportMachiningName, vsFinalName, m_vsImported)
' Report
Dim ImportedMachiningList As New List(Of String)(vsImported)
MessageBox.Show(EgtMsg(31455) & " " & vbCrLf &
String.Join(vbCrLf, ImportedMachiningList.ToArray()), "", MessageBoxButton.OK)
Case WindowModeEnum.EXPORT
' recupero le lavorazioni checkate
Dim FinalNameList As New List(Of String)
For Each Machining In MachiningList
If Machining.Active Then
FinalNameList.Add(Machining.sName)
End If
Next
If FinalNameList.Count() = 0 Then Return
Dim FinalNameArray = FinalNameList.ToArray()
' chiedo il nome con cui salvare il file .data
Dim SaveFileDlg As New System.Windows.Forms.SaveFileDialog() With {
.Title = EgtMsg(31451) & " " & EgtMsg(31452),
.Filter = "File data (*.data)|*.data|Tutti i file (*.*)|*.*",
.FileName = String.Empty
}
If SaveFileDlg.ShowDialog() <> System.Windows.Forms.DialogResult.OK Then Return
Dim sFilePath As String = String.Empty
sFilePath = SaveFileDlg.FileName
' Eseguo esportazione
EgtMdbExport(FinalNameArray, sFilePath)
End Select
' Chiusura finestra
RaiseEvent m_CloseWindow(True)
End Sub
#End Region ' OkCommand
#End Region ' Commands
#Region "CONSTRUCTOR"
' export
Sub New()
m_WindowMode = WindowModeEnum.EXPORT
' carico lista lavorazioni
MachiningList.Clear()
' leggo ed aggiungo le altre
Dim nIndex As Integer = 1
Dim sGUID As String = ""
Dim sName As String = ""
Dim sMaterials As String = ""
While ReadMachiningParamString(nIndex, MAC_GUID, "", sGUID) > 0
Dim Guid As Guid = Guid.Empty
Guid.TryParse(sGUID, Guid)
ReadMachiningParamString(nIndex, MAC_NAME, "", sName)
MachiningList.Add(New ImpExpMachiningItem(nIndex, Guid, sName))
nIndex += 1
End While
' ImpExpMachiningItem.m_delEnableOkBtn = AddressOf EnableOkBtn
End Sub
' import
Sub New(sImportFilePath As String)
m_WindowMode = WindowModeEnum.IMPORT
m_ImportFilePath = sImportFilePath
'' carico lista
'' leggo ed aggiungo le altre
'Dim nIndex As Integer = 1
'Dim sGUID As String = ""
'Dim sName As String = ""
'Dim sMaterials As String = ""
'While ReadMachiningParamString(nIndex, MAC_GUID, "", sGUID) > 0
' Dim Guid As Guid = Guid.Empty
' Guid.TryParse(sGUID, Guid)
' ReadMachiningParamString(nIndex, MAC_NAME, "", sName)
' MachiningList.Add(New ImpExpMachiningItem(nIndex, Guid, sName))
' nIndex += 1
'End While
' ImpExpMachiningItem.m_delEnableOkBtn = AddressOf EnableOkBtn
End Sub
#End Region ' Constructor
#Region "METHODS"
Private Sub EnableOkBtn()
NotifyPropertyChanged(NameOf(IsEnabledOkBtn))
End Sub
#End Region ' Methods
End Class
Public Class ImpExpMachiningItem
Inherits VMBase
Private Shared m_Empty As New MachiningIndex(-1, Guid.Empty, "None")
Private m_nIndex As Integer
Public ReadOnly Property nIndex As Integer
Get
Return m_nIndex
End Get
End Property
Private m_sGUID As Guid
Public ReadOnly Property sGUID As Guid
Get
Return m_sGUID
End Get
End Property
Private m_sName As String
Public ReadOnly Property sName As String
Get
Return m_sName
End Get
End Property
Private m_Active As Boolean
Public Property Active As Boolean
Get
Return m_Active
End Get
Set(value As Boolean)
' se esiste gia' chiedo se sovrascriverla
If value Then
If m_AlreadyExist Then
Select Case System.Windows.MessageBox.Show(EgtMsg(31453), "", MessageBoxButton.YesNoCancel)
Case MessageBoxResult.Yes
m_ChangeName = False
m_Active = True
Case MessageBoxResult.No
System.Windows.MessageBox.Show(EgtMsg(31454), "", MessageBoxButton.OK)
m_ChangeName = True
m_Active = True
Case Else
m_Active = False
End Select
NotifyPropertyChanged("Active")
Else
m_Active = True
End If
Else
m_ChangeName = False
m_Active = False
End If
'If Not IsNothing(m_delEnableOkBtn) Then m_delEnableOkBtn()
End Set
End Property
' Parametro che indica se questo item da importare esiste gia'
Private m_AlreadyExist As Boolean
Friend ReadOnly Property AlreadyExist As Boolean
Get
Return m_AlreadyExist
End Get
End Property
' Parametro che indica se cambiare il nome di un item che esiste gia' o sovrascriverlo
Private m_ChangeName As Boolean
Friend Property ChangeName As Boolean
Get
Return m_ChangeName
End Get
Set(value As Boolean)
m_ChangeName = value
NotifyPropertyChanged("Name")
End Set
End Property
Sub New(nIndex As Integer, GUID As Guid, sName As String)
m_nIndex = nIndex
m_sGUID = GUID
m_sName = sName
m_Active = False
End Sub
Friend Shared Function Empty() As MachiningIndex
Return m_Empty
End Function
End Class
Public Class MachiningItem
Inherits VMBase
' Actions
Friend Shared m_delEnableOkBtn As Action
Private m_Name As String
Public Property Name As String
Get
If m_ChangeName Then
Return m_Name & "_imp"
Else
Return m_Name
End If
End Get
Set(value As String)
m_Name = value
End Set
End Property
Private m_Active As Boolean
Public Property Active As Boolean
Get
Return m_Active
End Get
Set(value As Boolean)
' se esiste gia' chiedo se sovrascriverla
If value Then
If m_AlreadyExist Then
Select Case System.Windows.MessageBox.Show(EgtMsg(31453), "", MessageBoxButton.YesNoCancel)
Case MessageBoxResult.Yes
m_ChangeName = False
m_Active = True
Case MessageBoxResult.No
System.Windows.MessageBox.Show(EgtMsg(31454), "", MessageBoxButton.OK)
m_ChangeName = True
m_Active = True
Case Else
m_Active = False
End Select
NotifyPropertyChanged("Active")
Else
m_Active = True
End If
Else
m_ChangeName = False
m_Active = False
End If
If Not IsNothing(m_delEnableOkBtn) Then m_delEnableOkBtn()
End Set
End Property
' Parametro che indica se questo item da importare esiste gia'
Private m_AlreadyExist As Boolean
Friend ReadOnly Property AlreadyExist As Boolean
Get
Return m_AlreadyExist
End Get
End Property
' Parametro che indica se cambiare il nome di un item che esiste gia' o sovrascriverlo
Private m_ChangeName As Boolean
Friend Property ChangeName As Boolean
Get
Return m_ChangeName
End Get
Set(value As Boolean)
m_ChangeName = value
NotifyPropertyChanged("Name")
End Set
End Property
Sub New(Name As String, AlreadyExist As Boolean)
m_Name = Name
m_AlreadyExist = AlreadyExist
End Sub
End Class
+25 -2
View File
@@ -14,20 +14,43 @@
<RowDefinition Height="1*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<UniformGrid Rows="1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Button Content="New"
Command="{Binding New_Command}"
IsEnabled="{Binding IsEnabled}"
Style="{StaticResource ToolBar_TextButton}"/>
<Button Content="Save"
Grid.Column="1"
Command="{Binding Save_Command}"
IsEnabled="{Binding IsEnabled}"
Style="{StaticResource ToolBar_TextButton}"/>
<Button Content="Delete"
Grid.Column="2"
Command="{Binding Delete_Command}"
IsEnabled="{Binding IsEnabled}"
Style="{StaticResource ToolBar_TextButton}"/>
</UniformGrid>
<Button Grid.Column="3"
Command="{Binding Import_Command}"
ToolTip="{Binding ImportToolTip}"
IsEnabled="{Binding ProjCmd_IsEnabled}"
Style="{StaticResource ToolBar_Button}">
<Image Source="/Resources/MachiningDB/Import.png" Stretch="Uniform"/>
</Button>
<Button Grid.Column="4"
Command="{Binding Export_Command}"
ToolTip="{Binding ImportToolTip}"
IsEnabled="{Binding ProjCmd_IsEnabled}"
Style="{StaticResource ToolBar_Button}">
<Image Source="/Resources/MachiningDB/Export.png" Stretch="Uniform"/>
</Button>
</Grid>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
+36
View File
@@ -111,6 +111,8 @@ Public Class MachiningDbVM
Private m_cmdSave As ICommand
Private m_cmdDelete As ICommand
Private m_cmdEditName As ICommand
Private m_cmdImport As ICommand
Private m_cmdExport As ICommand
#End Region ' FIELDS & PROPERTIES
@@ -305,6 +307,40 @@ Public Class MachiningDbVM
#End Region ' EditName
#Region "Import"
Public ReadOnly Property Import_Command As ICommand
Get
If m_cmdImport Is Nothing Then
m_cmdImport = New Command(AddressOf Import)
End If
Return m_cmdImport
End Get
End Property
Public Sub Import()
End Sub
#End Region ' Import
#Region "Export"
Public ReadOnly Property Export_Command As ICommand
Get
If m_cmdExport Is Nothing Then
m_cmdExport = New Command(AddressOf Export)
End If
Return m_cmdExport
End Get
End Property
Public Sub Export()
Dim ExportWindow As New ImportExportMachiningPanelV(Application.Current.MainWindow, New ImportExportMachiningPanelVM)
ExportWindow.Show()
End Sub
#End Region ' Export
#End Region ' COMMANDS
End Class
Binary file not shown.

After

Width:  |  Height:  |  Size: 603 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 671 B

+2 -1
View File
@@ -206,7 +206,8 @@ Public Class TopPanelVM
' salvo materiale selezionato come ultimo utilizzato
If Not IsNothing(value) Then WriteMainPrivateProfileString(S_PRINTING3D, K_CURRMATERIAL, value.sGUID)
' salvo lavorazione selezionata per riselezionarlo
Dim PrevMachiningGuid As Guid = m_SelMachining.sGUID
Dim PrevMachiningGuid As Guid = Guid.Empty
If Not IsNothing(m_SelMachining) Then PrevMachiningGuid = m_SelMachining.sGUID
' seleziono materiale
m_SelMaterial = value
' scrivo materiale sulla tavola