254 lines
8.9 KiB
VB.net
254 lines
8.9 KiB
VB.net
Imports System.IO
|
|
Imports System.Windows.Threading
|
|
Imports EgtUILib
|
|
|
|
Public Class SpecialPanelVM
|
|
Inherits VMBase
|
|
|
|
Private m_ButtonList As New List(Of ButtonListItem)
|
|
Public ReadOnly Property ButtonList As List(Of ButtonListItem)
|
|
Get
|
|
Return m_ButtonList
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property ButtonCount As Integer
|
|
Get
|
|
Return m_ButtonList.Count()
|
|
End Get
|
|
End Property
|
|
|
|
Private m_SpecialPanel_Visibility As Visibility
|
|
Public ReadOnly Property SpecialPanel_Visibility As Visibility
|
|
Get
|
|
Return m_SpecialPanel_Visibility
|
|
End Get
|
|
End Property
|
|
Friend Sub SetSpecialPanelVisibility(bValue As Boolean)
|
|
m_SpecialPanel_Visibility = If(bValue, Visibility.Visible, Visibility.Collapsed)
|
|
NotifyPropertyChanged(NameOf(SpecialPanel_Visibility))
|
|
End Sub
|
|
|
|
Sub New()
|
|
' Creo riferimento a questa classe in Map
|
|
Map.SetRefSpecialPanelVM(Me)
|
|
' se attivo, inizializzo i bottoni leggendoli da file ini
|
|
If IniFile.IsActiveSpecialPanel(False) Then
|
|
Dim BtlIndexMax As Integer = If(IniFile.m_nUserLevel > 5, 199, 99)
|
|
For BtnIndex As Integer = 1 To BtlIndexMax
|
|
Dim CurrBtn As ButtonListItem = Nothing
|
|
If GetPrivateProfileButton(S_SPECIAL, K_BUTTON & BtnIndex, "", CurrBtn) Then
|
|
m_ButtonList.Add(CurrBtn)
|
|
End If
|
|
Next
|
|
End If
|
|
End Sub
|
|
|
|
#Region "METHODS"
|
|
|
|
Public Function SetSpecialPanelButtonsVisibility(IsMachMode As Boolean) As Boolean
|
|
Dim bSpecialPanel_Visible As Boolean = False
|
|
For Each BtnItemList In m_ButtonList
|
|
If BtnItemList.Type = ButtonListItem.ButtonListItemTypes.BUTTON Then
|
|
Dim BtnItem As ButtonItem = DirectCast(BtnItemList, ButtonItem)
|
|
' verifico il valore di nDrawMachOrBoth del bottone e IsMachMode per rendere visibile o meno il bottone in ButtonList
|
|
Select Case BtnItem.nDrawMachOrBoth
|
|
Case 0 ' bottone nascosto
|
|
BtnItem.m_Btn_Visibility = Visibility.Collapsed
|
|
Case 1 ' bottone visibile solo in Draw
|
|
BtnItem.m_Btn_Visibility = If(Not IsMachMode, Visibility.Visible, Visibility.Collapsed)
|
|
Case 2 ' bottone visibile solo in Machining
|
|
BtnItem.m_Btn_Visibility = If(IsMachMode, Visibility.Visible, Visibility.Collapsed)
|
|
Case 3 ' bottone visibile sia in Draw che in Machining
|
|
BtnItem.m_Btn_Visibility = Visibility.Visible
|
|
End Select
|
|
' se anche uno solo è visibile anche lo SpecialPanel dovrà esserlo
|
|
If BtnItem.Btn_Visibility = Visibility.Visible Then bSpecialPanel_Visible = True
|
|
BtnItem.NotifyPropertyChanged(NameOf(BtnItem.Btn_Visibility))
|
|
End If
|
|
Next
|
|
Return bSpecialPanel_Visible
|
|
End Function
|
|
|
|
Friend Sub SpecialPanelIsEnabled(SpecialPanelBtn_IsEnabled As Boolean)
|
|
For Each BtnItemList In m_ButtonList
|
|
If BtnItemList.Type = ButtonListItem.ButtonListItemTypes.BUTTON Then
|
|
Dim BtnItem As ButtonItem = DirectCast(BtnItemList, ButtonItem)
|
|
BtnItem.m_Btn_IsEnabled = SpecialPanelBtn_IsEnabled
|
|
BtnItem.NotifyPropertyChanged(NameOf(BtnItem.Btn_IsEnabled))
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
#End Region ' Methods
|
|
|
|
End Class
|
|
|
|
Public Class ButtonItem
|
|
Inherits ButtonListItem
|
|
|
|
Friend Shared WithEvents m_ProjectVM As ProjectVM
|
|
Private Shared m_sCurrBarName As String
|
|
|
|
Private m_sBarName As String
|
|
Private m_sImagePath As String
|
|
Public ReadOnly Property ImagePath As String
|
|
Get
|
|
Return m_sImagePath
|
|
End Get
|
|
End Property
|
|
Private m_sLuaCmdPath As String
|
|
Public ReadOnly Property sLuaCmdPath As String
|
|
Get
|
|
Return m_sLuaCmdPath
|
|
End Get
|
|
End Property
|
|
Private m_sToolTip As String
|
|
Public ReadOnly Property ToolTip As String
|
|
Get
|
|
Return m_sToolTip
|
|
End Get
|
|
End Property
|
|
Private m_nDrawMachOrBoth As Integer
|
|
Public ReadOnly Property nDrawMachOrBoth As Integer
|
|
Get
|
|
Return m_nDrawMachOrBoth
|
|
End Get
|
|
End Property
|
|
Friend m_Btn_Visibility As Visibility
|
|
Public ReadOnly Property Btn_Visibility As Visibility
|
|
Get
|
|
Return m_Btn_Visibility
|
|
End Get
|
|
End Property
|
|
|
|
Friend m_Btn_IsEnabled As Boolean = True
|
|
Public Property Btn_IsEnabled As Boolean
|
|
Get
|
|
Return m_Btn_IsEnabled
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_Btn_IsEnabled = value
|
|
End Set
|
|
End Property
|
|
|
|
' Definizione comandi
|
|
Private m_cmdLuaExec As ICommand
|
|
|
|
Sub New(sBarName As String, sLuaCmdPath As String, sImagePath As String, sToolTip As String, sDrawMachOrBoth As String)
|
|
MyBase.New(ButtonListItemTypes.BUTTON)
|
|
m_sBarName = sBarName
|
|
If File.Exists(sImagePath) Then
|
|
' per lasciare libere le immagini le copio (potrebbe fallire perchè bloccate da altro eseguibile)
|
|
Dim sNewPath As String = Path.Combine(IniFile.m_sResourcesRoot, sBarName & "_" & Path.GetFileName(sImagePath))
|
|
Try
|
|
File.Copy(sImagePath, sNewPath, True)
|
|
Catch ex As Exception
|
|
End Try
|
|
m_sImagePath = sNewPath
|
|
Else
|
|
m_sImagePath = IniFile.m_sResourcesRoot & "\" & sImagePath
|
|
End If
|
|
m_sLuaCmdPath = sLuaCmdPath
|
|
m_sToolTip = sToolTip
|
|
If Not Integer.TryParse(sDrawMachOrBoth, m_nDrawMachOrBoth) Then m_nDrawMachOrBoth = 0
|
|
End Sub
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "LuaExecCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that do New.
|
|
''' </summary>
|
|
Public ReadOnly Property LuaExecCommand As ICommand
|
|
Get
|
|
If m_cmdLuaExec Is Nothing Then
|
|
m_cmdLuaExec = New Command(AddressOf LuaExec)
|
|
End If
|
|
Return m_cmdLuaExec
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the New. This method is invoked by the NewCommand.
|
|
''' </summary>
|
|
Public Sub LuaExec(ByVal param As Object)
|
|
If String.IsNullOrWhiteSpace(m_sLuaCmdPath) Then Return
|
|
' se trovo costante di apertura file lavorazioni travi
|
|
If m_sLuaCmdPath = BeamPanelVM.BEAM_MACHININGS Then
|
|
Beam.BeamMachDb()
|
|
Return
|
|
' se altrimenti per pareti
|
|
ElseIf m_sLuaCmdPath = WallPanelVM.WALL_MACHININGS Then
|
|
Wall.WallMachDb()
|
|
Return
|
|
End If
|
|
If Not File.Exists(m_sLuaCmdPath) Then Return
|
|
If Not Path.GetExtension(m_sLuaCmdPath).ToLower = ".lua" Then Return
|
|
' Abilito eventi se comando lua lanciato da Beam o Wall
|
|
m_sCurrBarName = m_sBarName
|
|
Dim bRaiseEvent As Boolean = (m_sBarName = "Beam" OrElse m_sBarName = "Wall")
|
|
' eseguo file Lua
|
|
Map.refProjectVM.PreExecScript(False)
|
|
Map.refProjectVM.ExecScript(m_sLuaCmdPath, bRaiseEvent)
|
|
m_sCurrBarName = Nothing
|
|
' Carico se presenti le dimensioni della griglia
|
|
DynamicGridModule.RestoreDrawGridLayout(Map.refDrawOptionPanelV.DrawGrid, "ManageLayer", 0, If(IniFile.IsActivePlugin(), DynamicGridModule.PROJECT_DRAW_PLUGIN, DynamicGridModule.PROJECT_DRAW))
|
|
DynamicGridModule.RestoreDrawGridLayout(Map.refDrawOptionPanelV.DrawGrid, "Info", 1, If(IniFile.IsActivePlugin(), DynamicGridModule.PROJECT_DRAW_PLUGIN, DynamicGridModule.PROJECT_DRAW))
|
|
End Sub
|
|
|
|
Private Shared Sub OnPreControllerExec(sFilePath As String) Handles m_ProjectVM.OnPreControllerExec
|
|
If m_sCurrBarName = "Beam" Then
|
|
EgtLuaCreateGlobTable("BEAM")
|
|
EgtLuaSetGlobStringVar("BEAM.BASEDIR", IniFile.m_sBeamDirPath)
|
|
If EgtGetUserLevel() >= 9 AndAlso GetPrivateProfileInt(S_LUA, K_BWSIM, 0) = 1 Then EgtLuaSetGlobBoolVar("BEAM.BW", True)
|
|
ElseIf m_sCurrBarName = "Wall" Then
|
|
EgtLuaCreateGlobTable("WALL")
|
|
EgtLuaSetGlobStringVar("WALL.BASEDIR", IniFile.m_sWallDirPath)
|
|
If EgtGetUserLevel() >= 9 AndAlso GetPrivateProfileInt(S_LUA, K_BWSIM, 0) = 1 Then EgtLuaSetGlobBoolVar("WALL.BW", True)
|
|
End If
|
|
End Sub
|
|
|
|
Private Shared Sub OnPostControllerExec() Handles m_ProjectVM.OnPostControllerExec
|
|
If m_sCurrBarName = "Beam" Then
|
|
EgtLuaResetGlobVar("BEAM")
|
|
ElseIf m_sCurrBarName = "Wall" Then
|
|
EgtLuaResetGlobVar("WALL")
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' LuaExecCommand
|
|
|
|
#End Region ' Commands
|
|
|
|
End Class
|
|
|
|
Public Class ButtonListItem
|
|
Inherits VMBase
|
|
|
|
Public Enum ButtonListItemTypes As Integer
|
|
BUTTON = 1
|
|
SEPARATOR = 2
|
|
End Enum
|
|
|
|
Private m_Type As ButtonListItemTypes
|
|
Public ReadOnly Property Type As ButtonListItemTypes
|
|
Get
|
|
Return m_Type
|
|
End Get
|
|
End Property
|
|
|
|
Sub New(Type As ButtonListItemTypes)
|
|
m_Type = Type
|
|
End Sub
|
|
|
|
End Class
|
|
|
|
Public Class SeparatorItem
|
|
Inherits ButtonListItem
|
|
|
|
Sub New()
|
|
MyBase.New(ButtonListItemTypes.SEPARATOR)
|
|
End Sub
|
|
|
|
End Class |