68ee9ec34f
- Primo rilascio.
322 lines
11 KiB
VB.net
322 lines
11 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Public Class OptionPanelVM
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Public ReadOnly Property SelSlab As Slab
|
|
Get
|
|
Return Map.refProjectVM.SelSlab
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property StateList As List(Of IdNameStruct)
|
|
Get
|
|
Return Map.refProjectVM.StateList
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property MaterialList As List(Of String)
|
|
Get
|
|
Return Map.refProjectVM.MaterialList
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PhotoCommand_Visibility As Visibility
|
|
Get
|
|
Select Case Map.refProjectVM.SelProjectMode
|
|
Case ProjectVM.ProjectModeOpt.DETAIL
|
|
Return Visibility.Collapsed
|
|
Case ProjectVM.ProjectModeOpt.NEWSLAB
|
|
Return Visibility.Visible
|
|
End Select
|
|
Return Visibility.Collapsed
|
|
End Get
|
|
End Property
|
|
|
|
Private m_Ok_IsEnabled As Boolean = True
|
|
Public Property Ok_IsEnabled As Boolean
|
|
Get
|
|
Return m_Ok_IsEnabled
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_Ok_IsEnabled = value
|
|
NotifyPropertyChanged("Ok_IsEnabled")
|
|
End Set
|
|
End Property
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property IdMsg As String
|
|
Get
|
|
Return "Id"
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ImagePathMsg As String
|
|
Get
|
|
Return "Image Path"
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property StateMsg As String
|
|
Get
|
|
Return "State"
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ProjectAssignedToMsg As String
|
|
Get
|
|
Return "Project Assigned To"
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property MaterialMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_RAWPARTPAGEUC + 9)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ThicknessMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_RAWPARTPAGEUC + 5)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property WarehousePositionMsg As String
|
|
Get
|
|
Return "Warehouse position"
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property OkMsg As String
|
|
Get
|
|
Select Case Map.refProjectVM.SelProjectMode
|
|
Case ProjectVM.ProjectModeOpt.DETAIL
|
|
Return "Salva"
|
|
Case ProjectVM.ProjectModeOpt.NEWSLAB
|
|
Return "Aggiungi"
|
|
End Select
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CancelMsg As String
|
|
Get
|
|
Return "Annulla"
|
|
End Get
|
|
End Property
|
|
#End Region ' Messages
|
|
|
|
#Region "ToolTip"
|
|
|
|
Public ReadOnly Property PhotoToolTip As String
|
|
Get
|
|
Return "Importa fotografia"
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' ToolTip
|
|
|
|
' Definizione comandi
|
|
Private m_cmdPhoto As ICommand
|
|
Private m_cmdOk As ICommand
|
|
Private m_cmdCancel As ICommand
|
|
|
|
#End Region ' FIELDS & PROPERTIES
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
' Creo riferimento a questa classe in Map
|
|
Map.SetRefOptionPanelVM(Me)
|
|
' Assegno funzione per disabilitare bottone di conferma alla lista
|
|
Slab.m_IsEnabledBtn = AddressOf IsEnabledBtn
|
|
'CreateDbFile()
|
|
'CreateTable()
|
|
'ManageDb.CreateTable()
|
|
'ManageDb.ExecuteQuery("INSERT INTO Slabs (Id, Path, State, ProjectAssignedTo, Material, Thickness, WarehousePosition)" &
|
|
'"VALUES ('ID1234567896', 'Slab04.jpg', 2, NULL, 'Marble2', 33.50, 'C9L43')")
|
|
'ManageDb.ExecuteQuery("UPDATE Slabs SET Path = 'Img1.jpg'")
|
|
'Dim Query As String = "SELECT * FROM Slabs WHERE "
|
|
'Map.refProjectVM.SlabList = New ObservableCollection(Of Slab)(ManageDb.ExecuteReaderQuery(Query))
|
|
'ManageDb.ExecuteQuery("DELETE FROM Slabs WHERE Id = 'ID1234567891'")
|
|
End Sub
|
|
|
|
#End Region ' CONSTRUCTOR
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Sub InitOptionPanel()
|
|
Select Case Map.refProjectVM.SelProjectMode
|
|
Case ProjectVM.ProjectModeOpt.DETAIL
|
|
SelSlab.SetOrigValues()
|
|
SelSlab.ResetIsModified()
|
|
Case ProjectVM.ProjectModeOpt.NEWSLAB
|
|
' Creo nuova lastra corrente con valori di default
|
|
Map.refProjectVM.SelSlab = New Slab(String.Empty, String.Empty, Slab.StateOpt.AVAILABLE, String.Empty, String.Empty, 0, String.Empty)
|
|
' Creo nuovo progetto
|
|
EgtNewFile()
|
|
EgtZoom(ZM.ALL)
|
|
End Select
|
|
' Aggiorno visualizzazione bottone foto perchè potrei essere passato da mod detail a newslab
|
|
NotifyPropertyChanged("PhotoCommand_Visibility")
|
|
NotifyPropertyChanged("OkMsg")
|
|
NotifyPropertyChanged("SelSlab")
|
|
' Aggiorno stato bottone di conferma
|
|
IsEnabledBtn(SelSlab.IsValid)
|
|
End Sub
|
|
|
|
Private Sub IsEnabledBtn(IsEnabled As Boolean)
|
|
Ok_IsEnabled = IsEnabled
|
|
End Sub
|
|
|
|
#End Region ' METHODS
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "PhotoCommand"
|
|
|
|
Public ReadOnly Property PhotoCommand As ICommand
|
|
Get
|
|
If m_cmdPhoto Is Nothing Then
|
|
m_cmdPhoto = New Command(AddressOf Photo)
|
|
End If
|
|
Return m_cmdPhoto
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Photo(ByVal param As Object)
|
|
' Se macchina fotografica collegata, faccio una foto
|
|
If Map.refMainWindowVM.m_Camera.GetCameraLink() Then
|
|
If Not Map.refMainWindowVM.m_Camera.CameraClick() Then
|
|
Map.refStatusBarVM.SetOutputMessage(EgtMsg(90313), 5, MSG_TYPE.ERROR_) 'Fotografia non riuscita
|
|
End If
|
|
' Altrimenti lancio browser di immagini
|
|
Else
|
|
PhotoFromFile()
|
|
End If
|
|
End Sub
|
|
|
|
Friend Sub PostPhoto(sPath As String, sContour As String)
|
|
' Carico la foto
|
|
Map.refDetailPageVM.LoadPhoto(sPath)
|
|
' Se richiesto il riconoscimento del contorno
|
|
'If Not String.IsNullOrEmpty(sContour) Then
|
|
' If Not m_MainWindow.m_CurrentProjectPageUC.LoadContour(sContour) Then
|
|
' m_MainWindow.m_CurrentProjectPageUC.SetWarningMessage(EgtMsg(90324)) 'Riconoscimento contorno non riuscito
|
|
' End If
|
|
'End If
|
|
' Aggiorno visualizzazione
|
|
EgtZoom(ZM.ALL)
|
|
End Sub
|
|
|
|
Friend Sub PhotoFromFile()
|
|
' Apro dialogo per scelta immagine
|
|
Dim PhotoDlg As New Microsoft.Win32.OpenFileDialog
|
|
PhotoDlg.Title = "Open"
|
|
PhotoDlg.Filter = "Image file(*.jpg;*.png;*.bmp)|*.jpg;*.png;*.bmp"
|
|
PhotoDlg.FilterIndex = 1
|
|
GetMainPrivateProfileString(S_GENERAL, K_IMAGEDIR, "", PhotoDlg.InitialDirectory)
|
|
If Not PhotoDlg.ShowDialog Then Return
|
|
Dim sPhoto As String = PhotoDlg.FileName
|
|
' Assegno la path dell'immagine selezionata
|
|
SelSlab.ImagePath = sPhoto
|
|
' Altri dati foto
|
|
' Carico immagine
|
|
If Not Map.refDetailPageVM.LoadPhoto(sPhoto) Then
|
|
' Errore nel caricamento della fotografia
|
|
MessageBox.Show(EgtMsg(MSG_RAWPARTTAB + 1), EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
Return
|
|
End If
|
|
'' Carico contorno
|
|
'EstPhoto.LoadContour(sPhoto)
|
|
'Dim nCntId As Integer = EstPhoto.GetContour()
|
|
'' Se disponibile, imposto possibilità di contorno da foto
|
|
'If nCntId = GDB_ID.NULL Then
|
|
' If m_TypeList.Count = 3 Then m_TypeList.Remove(2)
|
|
'Else
|
|
' If m_TypeList.Count = 2 Then m_TypeList.Add(EgtMsg(MSG_RAWPARTPAGEUC + 35))
|
|
' SelType = Type.FROM_PHOTO
|
|
' NotifyPropertyChanged("SelType")
|
|
'End If
|
|
'' Se sporge dalla tavola, lo centro sulla stessa
|
|
'If nCntId <> GDB_ID.NULL Then
|
|
' Dim b3Cnt As New BBox3d
|
|
' EgtGetBBoxGlob(nCntId, GDB_BB.STANDARD, b3Cnt)
|
|
' Dim b3Tab As New BBox3d(m_ptTableMin, m_ptTableMin + New Vector3d(m_dTableLength, m_dTableWidth, 0))
|
|
' If Not b3Tab.EnclosesXY(b3Cnt) Then ModifyPhoto(b3Tab.Center() - b3Cnt.Center())
|
|
'End If
|
|
' Aggiorno visualizzazione
|
|
EgtZoom(ZM.ALL)
|
|
End Sub
|
|
|
|
#End Region ' PhotoCommand
|
|
|
|
#Region "Ok"
|
|
|
|
Public ReadOnly Property Ok_Command As ICommand
|
|
Get
|
|
If m_cmdOk Is Nothing Then
|
|
m_cmdOk = New Command(AddressOf Ok)
|
|
End If
|
|
Return m_cmdOk
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Ok(ByVal param As Object)
|
|
Select Case Map.refProjectVM.SelProjectMode
|
|
Case ProjectVM.ProjectModeOpt.DETAIL
|
|
If SelSlab.IsModified Then
|
|
' Aggiorno la lastra con le modifiche
|
|
Dim Query As String = "UPDATE " & Slab.DB_SLABS & " SET " &
|
|
If(SelSlab.IsModifiedId, Slab.DB_ID & " = '" & SelSlab.Id & "', ", "") &
|
|
If(SelSlab.IsModifiedState, Slab.DB_STATE & " = '" & SelSlab.State & "', ", "") &
|
|
If(SelSlab.IsModifiedProjectAssignedTo, Slab.DB_PROJASSIGNEDTO & " = '" & SelSlab.ProjectAssignedTo & "', ", "") &
|
|
If(SelSlab.IsModifiedMaterial, Slab.DB_MATERIAL & " = '" & SelSlab.Material & "', ", "") &
|
|
If(SelSlab.IsModifiedThickness, Slab.DB_THICKNESS & " = '" & SelSlab.Thickness & "', ", "") &
|
|
If(SelSlab.IsModifiedWarehousePosition, Slab.DB_WAREHOUSEPOS & " = '" & SelSlab.WarehousePosition & "'", "")
|
|
Query = Query.TrimEnd(","c, " "c)
|
|
Query &= "WHERE Id = '" & SelSlab.Id & "'"
|
|
ManageDb.ExecuteQuery(Query)
|
|
End If
|
|
Case ProjectVM.ProjectModeOpt.NEWSLAB
|
|
' Aggiungo la nuova lastra al Db
|
|
Dim Query As String = "INSERT INTO " & Slab.DB_SLABS & " (" & Slab.DB_ID & ", " & Slab.DB_IMAGEPATH & ", " & Slab.DB_STATE & ", " & Slab.DB_PROJASSIGNEDTO & ", " & Slab.DB_MATERIAL & ", " & Slab.DB_THICKNESS & ", " & Slab.DB_WAREHOUSEPOS & ")" &
|
|
"VALUES ('" & SelSlab.Id & "', " &
|
|
"'" & SelSlab.ImagePath & "', " &
|
|
SelSlab.State & ", " &
|
|
"'" & SelSlab.ProjectAssignedTo & "', " &
|
|
"'" & SelSlab.Material & "', " &
|
|
SelSlab.Thickness & ", " &
|
|
"'" & SelSlab.WarehousePosition & "')"
|
|
ManageDb.ExecuteQuery(Query)
|
|
End Select
|
|
Map.refProjectVM.SelProjectMode = ProjectVM.ProjectModeOpt.LIST
|
|
End Sub
|
|
|
|
#End Region ' Ok
|
|
|
|
#Region "Cancel"
|
|
|
|
Public ReadOnly Property Cancel_Command As ICommand
|
|
Get
|
|
If m_cmdCancel Is Nothing Then
|
|
m_cmdCancel = New Command(AddressOf Cancel)
|
|
End If
|
|
Return m_cmdCancel
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Cancel(ByVal param As Object)
|
|
Map.refProjectVM.SelProjectMode = ProjectVM.ProjectModeOpt.LIST
|
|
End Sub
|
|
|
|
#End Region ' Cancel
|
|
|
|
#End Region ' COMMANDS
|
|
|
|
End Class
|