Imports System.ComponentModel Imports EgtUILib Imports EgtWPFLib5 Public Class SceneButtonVM #Region "FIELDS & PROPERTIES" Private m_TopListBtn As New List(Of SceneBtn) Public Property TopListBtn As List(Of SceneBtn) Get Return m_TopListBtn End Get Set(value As List(Of SceneBtn)) m_TopListBtn = value End Set End Property Private m_LeftListBtn As New List(Of SceneBtn) Public Property LeftListBtn As List(Of SceneBtn) Get Return m_LeftListBtn End Get Set(value As List(Of SceneBtn)) m_LeftListBtn = value End Set End Property Private m_RightListBtn As New List(Of SceneBtn) Public Property RightListBtn As List(Of SceneBtn) Get Return m_RightListBtn End Get Set(value As List(Of SceneBtn)) m_RightListBtn = value End Set End Property Private m_BottomListBtn As New List(Of SceneBtn) Public Property BottomListBtn As List(Of SceneBtn) Get Return m_BottomListBtn End Get Set(value As List(Of SceneBtn)) m_BottomListBtn = value End Set End Property Private m_BottomCenterListBtn As New List(Of SceneBtn) Public Property BottomCenterListBtn As List(Of SceneBtn) Get Return m_BottomCenterListBtn End Get Set(value As List(Of SceneBtn)) m_BottomCenterListBtn = value End Set End Property #End Region ' Fields & Properties #Region "CONSTRUCTOR" Sub New() SetButtonsLocation("TopListBtn", m_TopListBtn) SetButtonsLocation("LeftListBtn", m_LeftListBtn) SetButtonsLocation("RightListBtn", m_RightListBtn) SetButtonsLocation("BottomListBtn", m_BottomListBtn) SetButtonsLocation("BottomCenterListBtn", m_BottomCenterListBtn) End Sub #End Region ' Constructor #Region "METHODS" Private Sub SetButtonsLocation(PositionList As String, ListBtn As List(Of SceneBtn)) Dim Index As Integer = 1 Dim sBtnString As String = String.Empty While GetMainPrivateProfileString(PositionList, "Btn_" & Index.ToString, "", sBtnString) > 0 Dim sItems As String() = Split(sBtnString, ",") If sItems.Count < 3 Then ' Errore di configurazione comando: mancano dei parametri EgtOutLog("") Else Dim nType As Integer = 0 If sItems(0) = "Button" Then ' Button ListBtn.Add(New _Button(sItems(1), sItems(2), sItems(3))) ElseIf sItems(0) = "ToggleButton" Then ' ToggelButton ListBtn.Add(New _ToggleButton(sItems(1), sItems(2), sItems(3))) ElseIf sItems(0) = "ButtonComboBox" And sItems.Count >= 4 Then ' Button che apre una combo box ListBtn.Add(New _ButtonComboBox(sItems(1), sItems(2), sItems(3), sItems(4))) End If End If Index = Index + 1 sBtnString = String.Empty End While End Sub Public Function IsTgBtnChecked(Flag As String) As Boolean ' cerco il bottone con il flag richiesto Dim Btn As _ToggleButton = m_BottomListBtn.FirstOrDefault(Function(x) x.Flag = Flag) If IsNothing(Btn) Then Btn = m_RightListBtn.FirstOrDefault(Function(x) x.Flag = Flag) If IsNothing(Btn) Then Btn = m_TopListBtn.FirstOrDefault(Function(x) x.Flag = Flag) If IsNothing(Btn) Then Btn = m_LeftListBtn.FirstOrDefault(Function(x) x.Flag = Flag) End If End If End If ' restituisco la sua proprietà IsChecked Return Btn.IsChecked End Function Public Function GetButton(Flag As String) As SceneBtn ' cerco il bottone con il flag richiesto Dim Btn As SceneBtn = m_BottomListBtn.FirstOrDefault(Function(x) x.Flag = Flag) If Not IsNothing(Btn) Then Return Btn Btn = m_RightListBtn.FirstOrDefault(Function(x) x.Flag = Flag) If Not IsNothing(Btn) Then Return Btn Btn = m_TopListBtn.FirstOrDefault(Function(x) x.Flag = Flag) If Not IsNothing(Btn) Then Return Btn Btn = m_LeftListBtn.FirstOrDefault(Function(x) x.Flag = Flag) If Not IsNothing(Btn) Then Return Btn Btn = m_BottomCenterListBtn.FirstOrDefault(Function(x) x.Flag = Flag) Return Btn End Function #End Region ' Methods End Class Public Class SceneBtn Implements INotifyPropertyChanged #Region "Fields & Properties" Private m_ResourcesDir As String = "C:\EgtData\EgtSTONE3D\Resources\" Private m_Name As String = String.Empty Public Property Name As String Get Return m_Name End Get Set(value As String) m_Name = value End Set End Property Private m_Img As String = String.Empty Public Property Img As String Get Return m_Img End Get Set(value As String) m_Img = value End Set End Property Private m_Flag As String = String.Empty Public Property Flag As String Get Return m_Flag End Get Set(value As String) m_Flag = value End Set End Property Private m_IsEnabled As Boolean = True Public Property IsEnabled As Boolean Get Return m_IsEnabled End Get Set(value As Boolean) m_IsEnabled = value End Set End Property Sub New(_Name As String, _Img As String, _Flag As String) m_Name = _Name m_Img = m_ResourcesDir & _Img m_Flag = _Flag End Sub Private m_CmdBtn As ICommand Public ReadOnly Property CmdBtn As ICommand Get If m_CmdBtn Is Nothing Then m_CmdBtn = New Command(AddressOf MethodBtn) End If Return m_CmdBtn End Get End Property #End Region ' Fields & Properties #Region "Methods" Private Sub MethodBtn() SceneCmd.Exec(m_Flag) End Sub #End Region ' Methods Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged Public Sub NotifyPropertyChanged(propName As String) RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName)) End Sub End Class Public Class _Button Inherits SceneBtn #Region "Constructor" Sub New(_Name As String, _Img As String, _Flag As String) MyBase.New(_Name, _Img, _Flag) End Sub #End Region ' Constructor End Class Public Class _ToggleButton Inherits SceneBtn #Region "Fields & Properties" Private m_IsChecked As Boolean = False Public Property IsChecked As Boolean Get Return m_IsChecked End Get Set(value As Boolean) m_IsChecked = value NotifyPropertyChanged(NameOf(IsChecked)) End Set End Property #End Region 'Fields & Properties #Region "Construcor" Sub New(_Name As String, _Img As String, _Flag As String) MyBase.New(_Name, _Img, _Flag) End Sub #End Region ' Constructor End Class Public Class _ButtonComboBox Inherits SceneBtn Private m_SourceList As New List(Of String) Public Property SourceList As List(Of String) Get Return m_SourceList End Get Set(value As List(Of String)) m_SourceList = value End Set End Property #Region "Construcor" Sub New(_Name As String, _Img As String, _Flag As String, _PrototypeList As String) MyBase.New(_Name, _Img, _Flag) 'conversione da _PrototypeList a _List ''''' da implementare m_SourceList = New List(Of String)({"Becca", "Bacca", "Bionda", "Mora"}) 'm_SourceList = _List End Sub #End Region ' Constructor End Class Module SceneCmd #Region "Methods" Public Sub Exec(Flag) Dim _SceneHostVM As SceneHostVM = DirectCast(Map.refSceneHostV.DataContext, SceneHostVM) Dim nVeinCtx As Integer = _SceneHostVM.MainScene.GetCtx() Select Case Flag Case "AutoPair" EgtSetCurrentContext(nVeinCtx) EgtLuaSetGlobIntVar("ASS.nVeinCtx", nVeinCtx) EgtLuaCallFunction("ASS.PairAll") Case "Unpair" SolidManagerM.Unpair(Map.refSceneHostV.m_nIdPart) Case "Pair" Map.refSceneButtonV.LoadPairUC() Case "ResetInters" SolidManagerM.ResetInters() Case "Rotate" Map.refSceneButtonV.LoadRotateUC() Case "Undo" ' se con questa operazione torno all'inizio disattivo il bottone undo Dim RedoBtn As SceneBtn = Map.refSceneButtonVM.GetButton("Redo") RedoBtn.IsEnabled = SolidManagerM.UndoEvent() Dim nTime As Integer = -1 EgtLuaGetGlobIntVar("ASS.nTransf", nTime) Dim UndoBtn As SceneBtn = Map.refSceneButtonVM.GetButton("Undo") If nTime = 0 Then UndoBtn.IsEnabled = False EgtDraw() Case "Redo" ' se con questa operazione ho finito la storia disponibile disattivo il bottone redo Dim UndoBtn As SceneBtn = Map.refSceneButtonVM.GetButton("Undo") UndoBtn.IsEnabled = SolidManagerM.RedoEvent() Dim nTime As Integer = -1 EgtLuaGetGlobIntVar("ASS.nTransf", nTime) Dim bRedoPossible As Boolean = False EgtLuaGetGlobBoolVar("ASS.bRedoPossible", bRedoPossible) Dim RedoBtn As SceneBtn = Map.refSceneButtonVM.GetButton("Redo") If Not bRedoPossible Then RedoBtn.IsEnabled = False EgtDraw() Case "SelType" Map.refSceneButtonV.MenuSelType.IsOpen = True Case Else Dim x As Boolean = False End Select End Sub Public Sub EnableActionButtons() 'If (m_nIdPart = GDB_ID.NULL) Then Return ''abilito i bottoni che possono eseguire delle azioni 'MoveExpander.IsEnabled = True 'MoveExpander.IsExpanded = True 'TgBtn_Rotation.IsEnabled = True 'Dim PartSolidSel As PartSolid = GetPartSolid(m_nIdPart) 'If Not IsNothing(PartSolidSel) And PartSolidSel.IsPaired() Then ' UnpairBtn.IsEnabled = True ' ExplodeBtn.IsEnabled = True ' ExplodeNormalsBtn.IsEnabled = True 'End If End Sub Public Sub DisableActionButtons() ''disabilito tutti i bottoni che eseguono azioni sul pezzo selezionato ''TgBtn_Rotation.IsEnabled = False 'ResetRotationBtn.IsEnabled = False 'UnpairBtn.IsEnabled = False 'ExplodeBtn.IsEnabled = False 'ExplodeNormalsBtn.IsEnabled = False 'MoveExpander.IsEnabled = False 'MoveExpander.IsExpanded = False End Sub Public Function DeselectAll() As Boolean Dim bDeselected As Boolean = True Dim nOriId As Integer = GDB_ID.NULL For Each PartSolidSel In m_PartSolidList '' deseleziono nel nesting 'EgtGetInfo(PartSolidSel.PartId, KEY_ORI_ID, nOriId) 'If EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx()) AndAlso EgtExistsObj(nOriId) Then ' If Not (OmagOFFICEMap.refNestingTabVM.DeselectPart(nOriId, False)) Then ' bDeselected = False ' End If 'End If EgtSetCurrentContext(m_nVeinCtx) PartSolidSel.DeselectPart() Next Map.refSceneHostV.m_nIdPart = GDB_ID.NULL DisableActionButtons() Return bDeselected End Function #End Region ' Methods End Module