498 lines
14 KiB
VB.net
498 lines
14 KiB
VB.net
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Public Class SceneButtonVM
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Public Shared m_nIndexList As Integer = 0
|
|
Public Shared m_nIndexListConverter As Integer = 0
|
|
|
|
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
|
|
|
|
Private m_TopPanelListGroupBtn As New List(Of GroupSceneBtn)
|
|
Public Property TopPanelListGroupBtn As List(Of GroupSceneBtn)
|
|
Get
|
|
Return m_TopPanelListGroupBtn
|
|
End Get
|
|
Set(value As List(Of GroupSceneBtn))
|
|
m_TopPanelListGroupBtn = value
|
|
End Set
|
|
End Property
|
|
|
|
#End Region ' Fields & Properties
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
Map.SetRefSceneButtonVM(Me)
|
|
LoadButtons()
|
|
LoadGroupButtons()
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
#Region "METHODS"
|
|
|
|
''' <summary>
|
|
''' Funzione che carica i bottoni
|
|
''' </summary>
|
|
Private Sub LoadButtons()
|
|
SetButtonsLocation(TOPLIST_BTN, m_TopListBtn)
|
|
SetButtonsLocation(LEFTLIST_BTN, m_LeftListBtn)
|
|
SetButtonsLocation(RIGHTLIST_BTN, m_RightListBtn)
|
|
SetButtonsLocation(BOTTOMLIST_BTN, m_BottomListBtn)
|
|
SetButtonsLocation(BOTTOMCENTERLIST_BTN, m_BottomCenterListBtn)
|
|
End Sub
|
|
|
|
Private Sub LoadGroupButtons()
|
|
Dim Index As Integer = 1
|
|
Dim SubTitle As String = String.Empty
|
|
Dim sKeyTitle As String = TOPPANELLIST_BTN & "_" & Index.ToString()
|
|
While GetMainPrivateProfileString(sKeyTitle, "SubTitle", "", SubTitle) > 0
|
|
SetGroupButtonsLocation(sKeyTitle, m_TopPanelListGroupBtn)
|
|
Index += 1
|
|
sKeyTitle = TOPPANELLIST_BTN & "_" & Index.ToString()
|
|
End While
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Funzione che permette di posizionare i bottoni letti da file ini
|
|
''' </summary>
|
|
''' <param name="PositionList"></param>
|
|
''' <param name="ListBtn"></param>
|
|
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
|
|
|
|
Private Sub SetGroupButtonsLocation(PositionList As String, ListGroupBtn As List(Of GroupSceneBtn))
|
|
Dim LocalListSceneBtn As New List(Of SceneBtn)
|
|
Dim SubTitle As String = String.Empty
|
|
SetButtonsLocation(PositionList, LocalListSceneBtn)
|
|
GetMainPrivateProfileString(PositionList, "SubTitle", "", SubTitle)
|
|
ListGroupBtn.Add(New GroupSceneBtn(LocalListSceneBtn, SubTitle))
|
|
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 GroupSceneBtn
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Private m_SubTitle As String
|
|
Public Property SubTitle As String
|
|
Get
|
|
Return m_SubTitle
|
|
End Get
|
|
Set(value As String)
|
|
m_SubTitle = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_TopPanelListBtn As New List(Of SceneBtn)
|
|
Public Property TopPanelListBtn As List(Of SceneBtn)
|
|
Get
|
|
Return m_TopPanelListBtn
|
|
End Get
|
|
Set(value As List(Of SceneBtn))
|
|
m_TopPanelListBtn = value
|
|
End Set
|
|
End Property
|
|
|
|
#End Region ' Fields & Properties
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New(TopPanelListBtn As List(Of SceneBtn), sSubTitle As String)
|
|
m_TopPanelListBtn = TopPanelListBtn
|
|
m_SubTitle = sSubTitle
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
End Class
|
|
|
|
Public Class SceneBtn
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPETIES"
|
|
|
|
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
|
|
|
|
#End Region ' Fields & Properties
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New(_Name As String, _Img As String, _Flag As String)
|
|
m_Name = _Name
|
|
m_Img = m_ResourcesDir & _Img
|
|
m_Flag = _Flag
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "CmdBtn"
|
|
|
|
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
|
|
|
|
Private Sub MethodBtn()
|
|
SceneCmd.Exec(m_Flag)
|
|
End Sub
|
|
|
|
#End Region ' CmdBtn
|
|
|
|
#End Region ' Commands
|
|
|
|
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 "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 _ButtonComboBox
|
|
Inherits SceneBtn
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
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
|
|
|
|
#End Region ' Fields & Properties
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
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 EGT_PAIR
|
|
Map.refSceneButtonV.LoadPairUC()
|
|
Case "ResetInters"
|
|
SolidManagerM.ResetInters()
|
|
Case EGT_ROTATE
|
|
Map.refSceneButtonV.LoadRotateUC()
|
|
Case EGT_MOVE
|
|
Map.refSceneButtonV.LoadMoveUC()
|
|
Case "Undo"
|
|
' se con questa operazione torno all'inizio disattivo il bottone undo
|
|
SolidManagerM.UndoEvent()
|
|
SolidManagerM.ManageUndoRedo()
|
|
EgtDraw()
|
|
Case "Redo"
|
|
' se con questa operazione ho finito la storia disponibile disattivo il bottone redo
|
|
SolidManagerM.RedoEvent()
|
|
SolidManagerM.ManageUndoRedo()
|
|
EgtDraw()
|
|
Case "SelType"
|
|
Map.refSceneButtonV.MenuSelType.IsOpen = True
|
|
Case "ImportLoop"
|
|
'ImportLoop()
|
|
EgtInsertFile("D:\Temp\marmo\Vein3D\OutLoop.nge")
|
|
Case "CreateSolidFromLoop"
|
|
SolidManagerM.CreateSolidFromLoop(Map.refSceneHostV.m_nIdPart)
|
|
Case EGT_ALZ
|
|
Map.refSceneHostV.m_SelType = GDB_TY.CRV_LINE
|
|
SolidManagerM.ShowLoopEdges()
|
|
Case EGT_FRO
|
|
Map.refSceneHostV.m_SelType = GDB_TY.CRV_LINE
|
|
SolidManagerM.ShowLoopEdges()
|
|
Case Else
|
|
Dim x As Boolean = False
|
|
End Select
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Funzione che permette di importare un file nge
|
|
''' </summary>
|
|
Private Sub ImportLoop()
|
|
Dim ImportDialog As New EgtManageFileDialogV(Application.Current.MainWindow, New EgtManageFileDialogVM()) With {
|
|
.Title = EgtMsg(91127),
|
|
.Filter = "nge files (*.nge)|*.nge",
|
|
.FilterIndex = 1,
|
|
.InitialDirectory = "C:\EgtData\EgtStone3D\Temp",
|
|
.Mode = 1
|
|
}
|
|
If Not ImportDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then Return
|
|
If String.IsNullOrEmpty(ImportDialog.FileName) Then Return
|
|
|
|
Dim sFilePath As String = ImportDialog.FileName
|
|
EgtInsertFile(sFilePath)
|
|
End Sub
|
|
|
|
Public Sub EnableActionButtons()
|
|
'If (m_nIdPart = GDB_ID.NULL) Then Return
|
|
|
|
''abilito i bottoni che possono eseguire delle azioni
|
|
'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
|
|
'UnpairBtn.IsEnabled = False
|
|
'ExplodeBtn.IsEnabled = False
|
|
'ExplodeNormalsBtn.IsEnabled = 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
|
|
|
|
Public Class SplitConverter
|
|
Implements IValueConverter
|
|
|
|
Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.Convert
|
|
Dim dValue As Double = CDbl(value)
|
|
Dim dParam As Double = Map.refSceneButtonVM.TopPanelListGroupBtn(SceneButtonVM.m_nIndexListConverter).TopPanelListBtn.Count
|
|
SceneButtonVM.m_nIndexListConverter += 1
|
|
Return (Math.Floor(dParam / 2) + 1) * 35
|
|
End Function
|
|
|
|
Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack
|
|
Throw New NotImplementedException
|
|
End Function
|
|
|
|
End Class |