Files
2022-06-30 19:01:07 +02:00

548 lines
21 KiB
VB.net

Imports System.Collections.ObjectModel
Imports EgtUILib
Imports EgtWPFLib5
' Componenti interni
Public Class CompoListPageVM
Inherits VMBase
#Region "FIELDS & PROPERTIES"
Private m_CompoList As New ObservableCollection(Of CompoItem)
Public ReadOnly Property CompoList As ObservableCollection(Of CompoItem)
Get
Return m_CompoList
End Get
End Property
Private m_CompoListVisibility As Visibility
Public ReadOnly Property CompoListVisibility As Visibility
Get
Return m_CompoListVisibility
End Get
End Property
Private m_CompoManagerControl As CompoManagerV
Public Property CompoManagerControl As CompoManagerV
Get
Return m_CompoManagerControl
End Get
Set(value As CompoManagerV)
m_CompoManagerControl = value
NotifyPropertyChanged("CompoManagerControl")
End Set
End Property
Private m_CompoBackVisibility As Visibility
Public ReadOnly Property CompoBackVisibility As Visibility
Get
Return m_CompoBackVisibility
End Get
End Property
Private m_BackVisibility As Visibility
Public ReadOnly Property BackVisibility As Visibility
Get
Return m_BackVisibility
End Get
End Property
Private m_SideEntity_Visibility As Visibility
Public Property SideEntity_Visibility As Visibility
Get
Return m_SideEntity_Visibility
End Get
Set(value As Visibility)
m_SideEntity_Visibility = value
NotifyPropertyChanged("SideEntity_Visibility")
End Set
End Property
Private m_SideAngle_IsChecked As Boolean
Private m_SideEntityControlVM As SideEntityControlVM
Public Property SideAngle_IsChecked As Boolean
Get
Return m_SideAngle_IsChecked
End Get
Set(value As Boolean)
If m_Drip_IsChecked OrElse m_FiloTop_IsChecked Then Return
m_SideAngle_IsChecked = value
If value Then
' Se non ci sono loop interni, imposto quello esterno
If EgtGetFirstNameInGroup(EgtGetFirstPart(), NAME_INLOOP) = GDB_ID.NULL Then
CompoWindowMap.refCompoSceneHostV.SelectedLayer = EgtGetFirstNameInGroup(EgtGetFirstPart(), NAME_OUTLOOP)
Else
SetOutputMessage(EgtMsg(MSG_DRAWPAGEUC + 6), MSG_TYPE.INFO) ' Selezionare un contorno
' Aggiungo testi su lati già inclinati
SideEntityControlVM.WriteSideAngleForNest(CompoWindowMap.refCompoSceneHostV.CompoScene.GetCtx())
End If
m_SideEntityControlVM = New SideEntityControlVM(SideEntityControlVM.CallingWindowOpt.COMPO,
CompoWindowMap.refCompoSceneHostV.CompoScene,
SideEntityControlVM.ModeOpt.SIDEANGLE)
SideEntityControl = New SideEntityControlV(m_SideEntityControlVM)
m_CompoListVisibility = Visibility.Collapsed
m_CompoBackVisibility = Visibility.Collapsed
Else
m_SideEntityControlVM.Close()
m_SideEntityControlVM = Nothing
SideEntityControl = Nothing
m_CompoListVisibility = Visibility.Visible
m_CompoBackVisibility = Visibility.Visible
' Deseleziono tutto
EgtDeselectAll()
CompoWindowMap.refCompoSceneHostV.SelectedLayer = GDB_ID.NULL
' Pulisco area messaggi
ClearOutputMessage()
End If
NotifyPropertyChanged("SideAngle_IsChecked")
NotifyPropertyChanged("CompoListVisibility")
NotifyPropertyChanged("CompoBackVisibility")
EgtZoom(ZM.ALL)
End Set
End Property
Private m_FiloTop_IsChecked As Boolean
Public Property FiloTop_IsChecked As Boolean
Get
Return m_FiloTop_IsChecked
End Get
Set(value As Boolean)
If m_SideAngle_IsChecked OrElse m_Drip_IsChecked Then Return
CompoWindowMap.refCompoSceneHostV.m_SelListHole.Clear()
CompoWindowMap.refCompoSceneHostV.m_DeselectListHole.Clear()
m_FiloTop_IsChecked = value
If value Then
' Se non ci sono loop interni, imposto quello esterno
If EgtGetFirstNameInGroup(EgtGetFirstPart(), NAME_INLOOP) = GDB_ID.NULL Then
CompoWindowMap.refCompoSceneHostV.SelectedLayer = EgtGetFirstNameInGroup(EgtGetFirstPart(), NAME_OUTLOOP)
Else
SetOutputMessage(EgtMsg(MSG_DRAWPAGEUC + 6), MSG_TYPE.INFO) ' Selezionare un contorno
End If
m_SideEntityControlVM = New SideEntityControlVM(SideEntityControlVM.CallingWindowOpt.COMPO,
CompoWindowMap.refCompoSceneHostV.CompoScene,
SideEntityControlVM.ModeOpt.FILOTOP)
SideEntityControl = New SideEntityControlV(m_SideEntityControlVM)
m_CompoListVisibility = Visibility.Collapsed
m_CompoBackVisibility = Visibility.Collapsed
CompoWindowMap.refCompoSceneHostV.SetRefSideEntityControlVM(m_SideEntityControlVM)
Else
m_SideEntityControlVM.Close()
m_SideEntityControlVM = Nothing
SideEntityControl = Nothing
m_CompoListVisibility = Visibility.Visible
m_CompoBackVisibility = Visibility.Visible
' Deseleziono tutto
EgtDeselectAll()
CompoWindowMap.refCompoSceneHostV.SelectedLayer = GDB_ID.NULL
' Pulisco area messaggi
ClearOutputMessage()
End If
NotifyPropertyChanged("Drip_IsChecked")
NotifyPropertyChanged("CompoListVisibility")
NotifyPropertyChanged("CompoBackVisibility")
EgtZoom(ZM.ALL)
End Set
End Property
Private m_FiloTop_IsEnabled As Boolean = True
Public Property FiloTop_IsEnabled As Boolean
Get
Return m_FiloTop_IsEnabled
End Get
Set(value As Boolean)
m_FiloTop_IsEnabled = value
NotifyPropertyChanged("FiloTop_IsEnabled")
End Set
End Property
Private m_Drip_IsChecked As Boolean
Public Property Drip_IsChecked As Boolean
Get
Return m_Drip_IsChecked
End Get
Set(value As Boolean)
If m_SideAngle_IsChecked OrElse m_FiloTop_IsChecked Then Return
m_Drip_IsChecked = value
If value Then
' Se non ci sono loop interni, imposto quello esterno
If EgtGetFirstNameInGroup(EgtGetFirstPart(), NAME_INLOOP) = GDB_ID.NULL Then
CompoWindowMap.refCompoSceneHostV.SelectedLayer = EgtGetFirstNameInGroup(EgtGetFirstPart(), NAME_OUTLOOP)
Else
SetOutputMessage(EgtMsg(MSG_DRAWPAGEUC + 6), MSG_TYPE.INFO) ' Selezionare un contorno
End If
m_SideEntityControlVM = New SideEntityControlVM(SideEntityControlVM.CallingWindowOpt.COMPO,
CompoWindowMap.refCompoSceneHostV.CompoScene,
SideEntityControlVM.ModeOpt.DRIP)
SideEntityControl = New SideEntityControlV(m_SideEntityControlVM)
m_CompoListVisibility = Visibility.Collapsed
m_CompoBackVisibility = Visibility.Collapsed
Else
m_SideEntityControlVM.Close()
m_SideEntityControlVM = Nothing
SideEntityControl = Nothing
m_CompoListVisibility = Visibility.Visible
m_CompoBackVisibility = Visibility.Visible
' Deseleziono tutto
EgtDeselectAll()
CompoWindowMap.refCompoSceneHostV.SelectedLayer = GDB_ID.NULL
' Pulisco area messaggi
ClearOutputMessage()
End If
NotifyPropertyChanged("Drip_IsChecked")
NotifyPropertyChanged("CompoListVisibility")
NotifyPropertyChanged("CompoBackVisibility")
EgtZoom(ZM.ALL)
End Set
End Property
Private m_Drip_IsEnabled As Boolean
Public Property Drip_IsEnabled As Boolean
Get
Return m_Drip_IsEnabled
End Get
Set(value As Boolean)
m_Drip_IsEnabled = value
NotifyPropertyChanged("Drip_IsEnabled")
End Set
End Property
Private m_SideEntityControl As SideEntityControlV
Public Property SideEntityControl As SideEntityControlV
Get
Return m_SideEntityControl
End Get
Set(value As SideEntityControlV)
m_SideEntityControl = value
NotifyPropertyChanged("SideEntityControl")
End Set
End Property
Private m_OutputMessage As String
Public Property OutputMessage As String
Get
Return m_OutputMessage
End Get
Set(value As String)
m_OutputMessage = value
NotifyPropertyChanged("OutputMessage")
End Set
End Property
Private m_MsgColor As Brush = Brushes.Black
Public Property MsgColor As Brush
Get
Return m_MsgColor
End Get
Set(value As Brush)
m_MsgColor = value
NotifyPropertyChanged("MsgColor")
End Set
End Property
#Region "Messages"
Public ReadOnly Property SideAngleMsg As String
Get
Return EgtMsg(MSG_DRAWPAGEUC + 3)
End Get
End Property
Public ReadOnly Property DripMsg As String
Get
Return EgtMsg(MSG_IMPORTPAGEUC + 8)
End Get
End Property
Public ReadOnly Property FiloTopMsg As String
Get
Return EgtMsg(90400) ' FiloTop
End Get
End Property
#End Region 'Messages
' definizione comandi
Private m_cmdCompoBtn As ICommand
Private m_cmdBack As ICommand
#End Region ' FIELDS & PROPERTIES
#Region "CONSTRUCTOR"
Sub New()
' Creo riferimento a questa classe in CompoWindowMap
CompoWindowMap.SetRefCompoListPageVM(Me)
End Sub
#End Region ' CONSTRUCTOR
#Region "METHODS"
Friend Sub InitCompoListPage()
RefreshCompoList()
' porto in CompoParam il CompoManager
If IsNothing(CompoWindowMap.refCompoWindowVM.m_SelCompo) Then
CompoWindowMap.refCompoParamPageVM.CompoManagerControl = Nothing
CompoManagerControl = Nothing
Else
CompoWindowMap.refCompoParamPageVM.CompoManagerControl = Nothing
CompoManagerControl = CompoWindowMap.refCompoWindowVM.CompoManagerV
End If
' lancio inizializzazione CompoManager
CompoWindowMap.refCompoManagerVM.InitCompoManager()
Drip_IsEnabled = OmagOFFICEMap.refMainWindowVM.MainWindowM.GetKeyOption( KEY_OPT.UNDER_CUT) And
Not String.IsNullOrWhiteSpace( CurrentMachine.sCurrDripSaw)
End Sub
Private Sub RefreshCompoList()
m_CompoList.Clear()
If IsNothing(CompoWindowMap.refCompoWindowVM.m_SelCompoFamily) Then
LoadMainCompoList()
m_BackVisibility = Visibility.Collapsed
m_SideEntity_Visibility = Visibility.Collapsed
ElseIf IsNothing(CompoWindowMap.refCompoWindowVM.m_SelCompo) Then
LoadSelCompoList()
m_BackVisibility = Visibility.Visible
m_SideEntity_Visibility = Visibility.Collapsed
Else
' differenzio il caso di AlzAndFront
If CompoWindowMap.refCompoWindowVM.m_bSelAlzAndFront Then
' carico la pagina per la definizione delle componenti Alette
m_BackVisibility = Visibility.Visible
m_SideEntity_Visibility = Visibility.Hidden
Else
LoadInternalCompoList()
m_BackVisibility = Visibility.Visible
m_SideEntity_Visibility = Visibility.Visible
End If
End If
NotifyPropertyChanged("BackVisibility")
NotifyPropertyChanged("SideEntity_Visibility")
End Sub
Private Sub LoadMainCompoList()
Dim CompoNumber As Integer = GetMainPrivateProfileInt("Compo", "Count", 0)
Dim sCompoImage As String = String.Empty
For CompoIndex = 1 To CompoNumber
Dim nCompoName As Integer = GetMainPrivateProfileInt("Compo" & CompoIndex, "Name", 0)
GetMainPrivateProfileString("Compo" & CompoIndex, "Image", "", sCompoImage)
If GetMainPrivateProfileInt("Compo" & CompoIndex, "Count", 1) = 1 Then
' Recupero path del Lua
Dim sLuaPath As String = GetPrivateProfileCompo("Compo" & CompoIndex, "Compo1").LuaPath
m_CompoList.Add(New CompoItem(CompoIndex, nCompoName, sLuaPath, sCompoImage))
Else
m_CompoList.Add(New CompoItem(CompoIndex, nCompoName, sCompoImage))
End If
Next
End Sub
Private Sub LoadSelCompoList()
Dim SelCompoIndex As Integer = CompoWindowMap.refCompoWindowVM.m_SelCompoFamily.Index
Dim CompoNumber As Integer = GetMainPrivateProfileInt("Compo" & SelCompoIndex, "Count", 0)
For CompoIndex = 1 To CompoNumber
m_CompoList.Add(GetPrivateProfileCompo("Compo" & SelCompoIndex, "Compo" & CompoIndex))
Next
End Sub
Private Sub LoadInternalCompoList()
Dim CompoNumber As Integer = GetMainPrivateProfileInt("InternalCompo", "Count", 0)
For CompoIndex = 1 To CompoNumber
Dim Compo As CompoItem = GetPrivateProfileCompo("InternalCompo" & CompoIndex, "InternalCompo" & CompoIndex)
' Se foro da sotto, lo carico solo se abilitato dalla chiave e con utensile definito
If String.Compare( Compo.LuaPath, "IntDownHole.lua", True) = 0 AndAlso
( Not OmagOFFICEMap.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.UNDER_CUT) Or
String.IsNullOrWhiteSpace( CurrentMachine.sCurrDripDrill)) Then
Continue For
End If
m_CompoList.Add( Compo)
Next
End Sub
Public Function GetPrivateProfileCompo( lpAppName As String, lpKeyName As String) As CompoItem
Dim sVal As String = String.Empty
GetMainPrivateProfileString(lpAppName, lpKeyName, "", sVal)
Dim sItems() As String = sVal.Split(",".ToCharArray)
If sItems.Count() >= 2 Then
Dim nName As Integer = 0
StringToInt(sItems(0), nName)
Dim sImagePath As String = String.Empty
If sItems.Count() >= 3 Then
sImagePath = sItems(2)
End If
Return New CompoItem(nName, sItems(1), sImagePath)
End If
Return Nothing
End Function
Friend Sub SelectedPartChanged()
' Se sono in modalità inclinazioni o gocciolatoio calcolo lati inclinabili e creo testi
If SideAngle_IsChecked() Or Drip_IsChecked() Then
m_SideEntityControlVM.ReLoadSideAnglePage(SideEntityControlVM.CallingWindowOpt.COMPO)
End If
End Sub
Friend Overloads Sub SetOutputMessage(sMessage As String, Optional nMsgType As MSG_TYPE = MSG_TYPE.INFO)
SetMsgColor(nMsgType)
m_OutputMessage = sMessage
NotifyPropertyChanged("OutputMessage")
End Sub
Friend Sub ClearOutputMessage()
m_MsgColor = Brushes.Black
NotifyPropertyChanged("MsgColor")
m_OutputMessage = String.Empty
NotifyPropertyChanged("OutputMessage")
End Sub
Private Sub SetMsgColor(nMsgType As MSG_TYPE)
Select Case nMsgType
Case MSG_TYPE.INFO
m_MsgColor = Brushes.Black
Case MSG_TYPE.WARNING
m_MsgColor = Brushes.SaddleBrown
Case MSG_TYPE.ERROR_
m_MsgColor = Brushes.Red
End Select
NotifyPropertyChanged("MsgColor")
End Sub
#End Region ' METHODS
#Region "COMMANDS"
#Region "CompoBtnCommand"
' Returns a command that manage the MainWindow_Unloaded command
Public ReadOnly Property CompoBtnCommand() As ICommand
Get
If m_cmdCompoBtn Is Nothing Then
m_cmdCompoBtn = New Command(AddressOf CompoBtn)
End If
Return m_cmdCompoBtn
End Get
End Property
' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded.
Public Sub CompoBtn(ByVal param As Object)
If IsNothing(CompoWindowMap.refCompoWindowVM.m_SelCompoFamily) Then
CompoWindowMap.refCompoWindowVM.m_SelCompoFamily = DirectCast(param, CompoItem)
Dim SubCompoCount As Integer = GetMainPrivateProfileInt("Compo" & CompoWindowMap.refCompoWindowVM.m_SelCompoFamily.Index, "Count", 1)
If SubCompoCount = 1 Then
CompoWindowMap.refCompoWindowVM.m_SelCompo = CompoWindowMap.refCompoWindowVM.m_SelCompoFamily
CompoWindowMap.refCompoWindowVM.CompoPage = CompoWindowVM.CompoPageOpt.PARAM
Else
RefreshCompoList()
End If
ElseIf IsNothing(CompoWindowMap.refCompoWindowVM.m_SelCompo) Then
CompoWindowMap.refCompoWindowVM.m_SelCompo = DirectCast(param, CompoItem)
CompoWindowMap.refCompoWindowVM.CompoPage = CompoWindowVM.CompoPageOpt.PARAM
Else
CompoWindowMap.refCompoWindowVM.m_SelInternalCompo = DirectCast(param, CompoItem)
CompoWindowMap.refCompoWindowVM.CompoPage = CompoWindowVM.CompoPageOpt.PARAM
End If
End Sub
#End Region ' CompoBtnCommand
#Region "BackCommand"
' Returns a command that manage the MainWindow_Unloaded command
Public ReadOnly Property BackCommand() As ICommand
Get
If m_cmdBack Is Nothing Then
m_cmdBack = New Command(AddressOf Back)
End If
Return m_cmdBack
End Get
End Property
' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded.
Public Sub Back(ByVal param As Object)
If IsNothing(CompoWindowMap.refCompoWindowVM.m_SelCompo) Then
CompoWindowMap.refCompoWindowVM.m_SelCompoFamily = Nothing
InitCompoListPage()
ElseIf CompoWindowMap.refCompoWindowVM.m_bSelInternalCompo Then
'CompoWindowMap.refCompoWindowVM.CompoPage = CompoWindowVM.CompoPageOpt.PARAM
CompoWindowMap.refCompoWindowVM.SetCompoPage(CompoWindowVM.CompoPageOpt.PARAM)
CompoWindowMap.refCompoParamPageVM.MyInitCompoParamPage()
Dim PartId As Integer = EgtGetFirstPart()
EgtSetStatus(EgtGetFirstNameInGroup(PartId, CompoParamPageVM.COMPO_LAYER_AUX), GDB_ST.OFF)
EgtSetStatus(EgtGetFirstNameInGroup(PartId, CompoParamPageVM.COMPO_LAYER_QUOTATURE), GDB_ST.OFF)
EgtSetStatus(EgtGetFirstNameInGroup(PartId, CompoParamPageVM.COMPO_LAYER_ETICHETTE), GDB_ST.OFF)
EgtZoom(ZM.ALL)
CompoWindowMap.refCompoWindowVM.m_bSelInternalCompo = False
' aggiorno la lista dei parametri da visualizzare a schermo
CompoWindowMap.refCompoParamPageVM.SetCompoParamList(CompoWindowMap.refCompoParamPageVM.CompoParamOutLoopList)
' disbilito la modifica del componente piano cucicna/bagno corrente
For Each Item In CompoWindowMap.refCompoParamPageVM.CompoParamList
If TypeOf (Item) Is TextParamItem Then
Dim TxtParam As TextParamItem = DirectCast(Item, TextParamItem)
TxtParam.IsEnable = False
ElseIf TypeOf (Item) Is CheckParamItem Then
Dim ChkParam As CheckParamItem = DirectCast(Item, CheckParamItem)
ChkParam.IsEnable = False
End If
Next
CompoWindowMap.refCompoParamPageVM.ListParamIsEnable = False
Else
CompoWindowMap.refCompoWindowVM.m_SelCompo = Nothing
CompoWindowMap.refCompoParamPageVM.ListParamIsEnable = True
InitCompoListPage()
EgtNewFile()
EgtDraw()
End If
End Sub
#End Region ' BackCommand
#End Region ' COMMANDS
End Class
Public Class CompoItem
Private m_nIndex As Integer
Friend ReadOnly Property Index As Integer
Get
Return m_nIndex
End Get
End Property
Private m_sName As String
Public ReadOnly Property Name As String
Get
Return m_sName
End Get
End Property
Private m_sLuaPath As String
Public ReadOnly Property LuaPath As String
Get
Return m_sLuaPath
End Get
End Property
Private m_sImagePath As String
Public ReadOnly Property ImagePath As String
Get
Return m_sImagePath
End Get
End Property
Sub New(nIndex As Integer, nName As Integer, sImagePath As String)
m_nIndex = nIndex
m_sName = EgtMsg(MSG_COMPONENTPAGEUC + nName)
m_sImagePath = sImagePath
End Sub
Sub New(nIndex As Integer, nName As Integer, sLuaPath As String, sImagePath As String)
m_nIndex = nIndex
m_sName = EgtMsg(MSG_COMPONENTPAGEUC + nName)
m_sLuaPath = sLuaPath
m_sImagePath = sImagePath
End Sub
Sub New(nName As Integer, sLuaPath As String, sImagePath As String)
m_sName = EgtMsg(MSG_COMPONENTPAGEUC + nName)
m_sLuaPath = sLuaPath
m_sImagePath = sImagePath
End Sub
End Class