731 lines
27 KiB
VB.net
731 lines
27 KiB
VB.net
Imports System.Globalization
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib
|
|
|
|
Public Class AlzFrontUC
|
|
Private Const NUM_VAR As Integer = 10
|
|
Private Const LUA_CMP_VARS As String = "CMP"
|
|
Private Const LUA_CMP_DRAW As String = "CMP_Draw"
|
|
Private Const INFO_VAR As String = "Var"
|
|
Private Const INFO_CMP As String = "CMP"
|
|
Private Const INFO_ID As String = "ID"
|
|
Friend Const LUA_CMP_INDEX As String = LUA_CMP_VARS & ".Ind"
|
|
Friend Const LUA_CMP_INTERNAL As String = LUA_CMP_VARS & ".Int"
|
|
Friend Const LUA_REMOVEHOLE As String = "RemoveHole"
|
|
' Costanti layer componenti
|
|
Friend Const COMPO_LAYER_AUX As String = "LayAux"
|
|
Friend Const COMPO_LAYER_QUOTATURE As String = "Quotature"
|
|
Friend Const COMPO_LAYER_ETICHETTE As String = "Etichette"
|
|
|
|
' Properties
|
|
Private m_sCompoDir As String = String.Empty
|
|
Private m_sCompoName As String = String.Empty
|
|
Friend m_bDrawOk As Boolean = False
|
|
Private m_bFirst As Boolean = True
|
|
|
|
' Riferimento alla MainWindow
|
|
Private m_MainWindow As MainWindow = DirectCast(Application.Current.MainWindow, MainWindow)
|
|
' Riferimento alla pagina che ha aperto SideAngleUC
|
|
Private m_CallingPage As MainWindow.Pages
|
|
|
|
' Gestione pagine
|
|
Private Const MAX_LINES As Integer = 10
|
|
' lista dei lati, in cui indico il tipo di entità da associare
|
|
Private AlzFrontEntityList As New List(Of AlzFrontEntity)
|
|
|
|
' numero di lati presenti nella figura
|
|
Private m_nCount As Integer = 0
|
|
' numero di righe rese disponibili nella pagina -> m_nShow = min(m_nCount, MAX_LINE)
|
|
Private m_nShow As Integer = MAX_LINES
|
|
|
|
' layer per inserire le descrizione dei lati
|
|
Private m_AlzLayer As Integer
|
|
Private m_Frontlayer As Integer
|
|
Private m_dBBoxRad As Double
|
|
|
|
Private Sub AlzFrontPage_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
|
|
|
|
m_MainWindow.m_DrawPageUC.m_ActiveComponentPage = DrawPageUC.Pages.AlzFront
|
|
|
|
' numero di elemnti presenti nella lista SideAngle/DripEntity
|
|
m_nCount = 0
|
|
' numero di righe rese disponibili nella pagina -> m_nShow = min(m_nCount, MAX_LINE)
|
|
m_nShow = 0
|
|
|
|
' carico la lista dei lati della figura
|
|
InitSides()
|
|
' aggiorno la visualizzazione delle TextBox e dei CheckBox
|
|
TxBlChBxView()
|
|
|
|
' nascondo il bottone Back della pagina Draw
|
|
m_MainWindow.m_DrawPageUC.BackBtn.Visibility = Visibility.Hidden
|
|
m_MainWindow.m_DrawPageUC.MessageGrid.Visibility = Visibility.Hidden
|
|
' Abilito bottoni angoli di fianco e lavorazioni da sotto
|
|
m_MainWindow.m_DrawPageUC.SideAngleBtn.IsEnabled = m_MainWindow.m_DrawPageUC.bEnableSideAngle
|
|
m_MainWindow.m_DrawPageUC.FiloTopBtn.IsEnabled = m_MainWindow.m_CurrentMachine.bMilling
|
|
m_MainWindow.m_DrawPageUC.EngraveBtn.IsEnabled = True
|
|
m_MainWindow.m_DrawPageUC.DripCutBtn.IsEnabled = m_MainWindow.GetKeyOption(MainWindow.KEY_OPT.UNDER_CUT) And
|
|
Not String.IsNullOrWhiteSpace(m_MainWindow.m_CurrentMachine.sCurrDripSaw)
|
|
|
|
' nome dei parametri condivisi
|
|
Parameter1TxBl.Text = "Altezza"
|
|
Parameter2TxBl.Text = "Delta angolo"
|
|
|
|
EgtZoom(ZM.ALL)
|
|
End Sub
|
|
|
|
' carico la lista dei lati della figura corrente
|
|
Private Sub InitSides()
|
|
' pulisco la lista dei lati
|
|
AlzFrontEntityList.Clear()
|
|
' Id del pezzo
|
|
Dim PartId As Integer = GDB_ID.NULL
|
|
' Id del loop eseterno
|
|
Dim LoopId As Integer = GDB_ID.NULL
|
|
|
|
' definisco i valori delle altezza e degli angoli di spoglia per le alzatine e i frontalini
|
|
GetPrivateProfileString("Alz&Front", "A_Height", "0", Parameter1ATxBx.Text, m_MainWindow.GetIniFile)
|
|
GetPrivateProfileString("Alz&Front", "F_Height", "0", Parameter1FTxBx.Text, m_MainWindow.GetIniFile)
|
|
GetPrivateProfileString("Alz&Front", "A_DeltaAng", "0", Parameter2ATxBx.Text, m_MainWindow.GetIniFile)
|
|
GetPrivateProfileString("Alz&Front", "F_DeltaAng", "0", Parameter2FTxBx.Text, m_MainWindow.GetIniFile)
|
|
|
|
' Imposto contesto corrente
|
|
EgtSetCurrentContext(m_MainWindow.m_DrawPageUC.DrawScene.GetCtx())
|
|
' Ricavo nome primo pezzo
|
|
PartId = EgtGetFirstPart()
|
|
' Recupero nome layer con geometria di contorno (esterno o interno) del pezzo
|
|
LoopId = EgtGetFirstNameInGroup(EgtGetFirstPart(), NAME_OUTLOOP)
|
|
|
|
'Determino se loop esterno o interno
|
|
Dim sLoopName As String = ""
|
|
Dim bOutLoop As Boolean = (EgtGetName(LoopId, sLoopName) AndAlso sLoopName = NAME_OUTLOOP)
|
|
' Calcolo dimensione ingombro Loop
|
|
Dim ptMin, ptMax As Point3d
|
|
EgtGetBBoxGlob(LoopId, GDB_BB.STANDARD, ptMin, ptMax)
|
|
' utilizzato per definire la dimensione dei caratteri delle label per i lati
|
|
m_dBBoxRad = 0.5 * Point3d.DistXY(ptMin, ptMax)
|
|
|
|
' Creo layer per testi ALZATINE, se non esiste
|
|
m_AlzLayer = EgtGetFirstNameInGroup(PartId, "AuxAlzatina")
|
|
If m_AlzLayer = GDB_ID.NULL And PartId <> GDB_ID.NULL Then
|
|
m_AlzLayer = EgtCreateGroup(PartId)
|
|
EgtSetName(m_AlzLayer, "AuxAlzatina")
|
|
EgtSetColor(m_AlzLayer, New Color3d(0, 0, 0))
|
|
End If
|
|
|
|
' Creo layer per testi FRONTALINI, se non esiste
|
|
m_Frontlayer = EgtGetFirstNameInGroup(PartId, "AuxFrontalino")
|
|
If m_Frontlayer = GDB_ID.NULL And PartId <> GDB_ID.NULL Then
|
|
m_Frontlayer = EgtCreateGroup(PartId)
|
|
EgtSetName(m_Frontlayer, "AuxFrontalino")
|
|
EgtSetColor(m_Frontlayer, New Color3d(250, 0, 0))
|
|
End If
|
|
|
|
' Recupero Id della curva del Loop Esterno
|
|
Dim PrevLine As Integer = EgtGetLastInGroup(LoopId)
|
|
Dim CurrLine As Integer = EgtGetFirstInGroup(LoopId)
|
|
' Creo indice per numerare le entità in ImportPage
|
|
Dim nEntityIndex As Integer = 1
|
|
Dim nOtherIndex As Integer = 1
|
|
|
|
' inserisco la linea nella lista
|
|
While CurrLine <> GDB_ID.NULL
|
|
' scludo tutte le formo che non sono delle linee
|
|
If EgtGetType(CurrLine) = GDB_TY.CRV_LINE Then
|
|
' Aggiungo il lato alla lista di quelli su cui è possibile mettere il gocciolatoio
|
|
Dim sNameCurrLine As String = String.Empty
|
|
Dim nInfo As Integer = 0
|
|
EgtSetName(CurrLine, "A" & nEntityIndex.ToString)
|
|
EgtGetName(CurrLine, sNameCurrLine)
|
|
' recupero l'informazione
|
|
EgtGetInfo(CurrLine, "AF", nInfo)
|
|
If nInfo = 1 Then
|
|
AlzFrontEntityList.Add(New AlzFrontEntity(sNameCurrLine, CurrLine, AlzFrontEntity.AlzFront.ALZATINA))
|
|
ElseIf nInfo = 2 Then
|
|
AlzFrontEntityList.Add(New AlzFrontEntity(sNameCurrLine, CurrLine, AlzFrontEntity.AlzFront.FRONTALINO))
|
|
Else
|
|
AlzFrontEntityList.Add(New AlzFrontEntity(sNameCurrLine, CurrLine))
|
|
End If
|
|
nEntityIndex += 1
|
|
Else
|
|
EgtSetName(CurrLine, "B" & nOtherIndex.ToString)
|
|
nOtherIndex = nOtherIndex + 1
|
|
End If
|
|
|
|
PrevLine = CurrLine
|
|
CurrLine = EgtGetNext(CurrLine)
|
|
End While
|
|
|
|
' Aggiorno numero di lati carciati
|
|
m_nCount = AlzFrontEntityList.Count()
|
|
' Aggiorno numero item visualizzati nella pagina iniziale
|
|
m_nShow = Math.Min(m_nCount, MAX_LINES)
|
|
|
|
' Se non ci sono lati su cui operare, messaggio utente
|
|
If LoopId <> GDB_ID.NULL Then
|
|
If m_nCount = 0 Then
|
|
If m_CallingPage = MainWindow.Pages.Draw Then
|
|
m_MainWindow.m_DrawPageUC.MessageTxBx.Text = EgtMsg(MSG_DRAWPAGEUC + 7) ' Non ci sono lati modificabili
|
|
m_MainWindow.m_DrawPageUC.MessageBrd.Background = Application.Current.FindResource("OmagCut_Yellow")
|
|
Else
|
|
m_MainWindow.m_ImportPageUC.MessageTxBx.Text = EgtMsg(MSG_DRAWPAGEUC + 7) ' Non ci sono lati modificabili
|
|
m_MainWindow.m_ImportPageUC.MessageBrd.Background = Application.Current.FindResource("OmagCut_Yellow")
|
|
End If
|
|
Else
|
|
If m_CallingPage = MainWindow.Pages.Draw Then
|
|
m_MainWindow.m_DrawPageUC.MessageTxBx.Text = ""
|
|
m_MainWindow.m_DrawPageUC.MessageBrd.Background = Brushes.Transparent
|
|
Else
|
|
m_MainWindow.m_ImportPageUC.MessageTxBx.Text = ""
|
|
m_MainWindow.m_ImportPageUC.MessageBrd.Background = Brushes.Transparent
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
End Sub
|
|
|
|
' Imposto la visibilità degli oggetti nella pagina: qui eseguo l'impaginazione
|
|
Private Sub TxBlChBxView()
|
|
|
|
If m_nCount = 0 Then
|
|
' nascondo il nome delle colonne
|
|
SideAngleBl.Visibility = Windows.Visibility.Hidden
|
|
HeelBl.Visibility = Windows.Visibility.Hidden
|
|
Else
|
|
' definisco il posizionamento del nome (Alz.) delle colonne all'interno della grigia
|
|
Grid.SetRow(SideAngleBl, MAX_LINES - m_nShow)
|
|
SideAngleBl.Text = "Alz."
|
|
SideAngleBl.Visibility = Windows.Visibility.Visible
|
|
' definisco il posizionamento del nome (Front.) delle colonne all'interno della grigia
|
|
Grid.SetRow(HeelBl, MAX_LINES - m_nShow)
|
|
HeelBl.Text = "Front."
|
|
HeelBl.Visibility = Windows.Visibility.Visible
|
|
End If
|
|
|
|
' Lati visibili
|
|
For nI As Integer = 1 To m_nShow
|
|
Dim Index As Integer = MAX_LINES - m_nShow + nI
|
|
' definisco la visibilità della label
|
|
GetTxBlFromIndex(Index).Visibility = Windows.Visibility.Visible
|
|
GetTxBlFromIndex(Index).Text = "A" & nI.ToString
|
|
GetChBxAlzFromIndex(Index).Visibility = Windows.Visibility.Visible
|
|
GetChBxFrontFromIndex(Index).Visibility = Windows.Visibility.Visible
|
|
|
|
' aggiungo i campi per allungare e accorciare i lati (adesso sostituito con le CheckBox)
|
|
'GetAngleTxBxFromIndex(Index).Visibility = Windows.Visibility.Visible
|
|
'GetHeelTxBxFromIndex(Index).Visibility = Windows.Visibility.Visible
|
|
Next
|
|
|
|
' Lati nascosti: nascondo i lati partendo dall'alto (se ho 4 lati la prima TextBx disponibile è la settima -> 11-4 = 7 lati nascosti)
|
|
For Index As Integer = 1 To MAX_LINES - m_nShow
|
|
' definisco la visibilità della label
|
|
GetTxBlFromIndex(Index).Visibility = Windows.Visibility.Hidden
|
|
GetChBxAlzFromIndex(Index).Visibility = Windows.Visibility.Hidden
|
|
GetChBxFrontFromIndex(Index).Visibility = Windows.Visibility.Hidden
|
|
'GetAngleTxBxFromIndex(Index).Visibility = Windows.Visibility.Hidden
|
|
'GetHeelTxBxFromIndex(Index).Visibility = Windows.Visibility.Hidden
|
|
|
|
Next
|
|
End Sub
|
|
|
|
' Permette di aggiugere accanto alla linea passata
|
|
Friend Function AddTextToLine(sText As String, TextLayer As Integer, CurrLine As Integer, dDistance As Double,
|
|
dBBoxRad As Double, bTextExt As Boolean, Optional bRot As Boolean = False) As Integer
|
|
' Calcolo altezza testo
|
|
Dim dH As Double = 0.05 * dBBoxRad
|
|
' Creo testo
|
|
Dim nText As Integer = EgtCreateTextAdv(TextLayer, Point3d.ORIG(), 0, sText, "", 500, False, dH, 1, 0, INS_POS.MC)
|
|
' Calcolo posizionamento
|
|
' BBox del testo e suo centro
|
|
Dim ptMinBBox As Point3d
|
|
Dim ptMaxBBox As Point3d
|
|
EgtGetBBox(nText, GDB_BB.STANDARD, ptMinBBox, ptMaxBBox)
|
|
Dim ptMidBBox As Point3d
|
|
ptMidBBox = Point3d.Media(ptMinBBox, ptMaxBBox)
|
|
' Punto medio della curva
|
|
Dim ptMid As Point3d
|
|
EgtMidPoint(CurrLine, nText, ptMid)
|
|
' Versore sul punto medio della curva
|
|
Dim vtMid As Vector3d
|
|
EgtMidVector(CurrLine, nText, vtMid)
|
|
' versore perpendicolare alla CurrLine che punta verso il testo
|
|
Dim vtOrto As New Vector3d(vtMid)
|
|
If bTextExt Then
|
|
vtOrto.Rotate(Vector3d.Z_AX(), -90)
|
|
Else
|
|
vtOrto.Rotate(Vector3d.Z_AX(), 90)
|
|
End If
|
|
' eventuale rotazione del testo
|
|
Dim dRotAng As Double = 0
|
|
If bRot Then
|
|
dRotAng = Math.Atan2(vtMid.y, vtMid.x) * 180 / Math.PI
|
|
Dim dSpecRotAng = dRotAng
|
|
If dSpecRotAng > 91 Then
|
|
dSpecRotAng -= 180
|
|
ElseIf dSpecRotAng < -89 Then
|
|
dSpecRotAng += 180
|
|
End If
|
|
EgtRotate(nText, Point3d.ORIG(), Vector3d.Z_AX(), dSpecRotAng)
|
|
End If
|
|
' vettore dal centro del BBox all'estremo più vicino
|
|
Dim vtptExtptMC As Vector3d
|
|
If bRot Then
|
|
vtptExtptMC = New Vector3d(0, ptMidBBox.y - ptMinBBox.y, 0)
|
|
vtptExtptMC.Rotate(Vector3d.Z_AX(), dRotAng)
|
|
Else
|
|
If bTextExt Then
|
|
If vtMid.x > 0 Then
|
|
If vtMid.y > 0 Then
|
|
vtptExtptMC = ptMidBBox - New Point3d(ptMinBBox.x, ptMaxBBox.y, 0)
|
|
Else
|
|
vtptExtptMC = ptMidBBox - ptMaxBBox
|
|
End If
|
|
Else
|
|
If vtMid.y > 0 Then
|
|
vtptExtptMC = ptMidBBox - ptMinBBox
|
|
Else
|
|
vtptExtptMC = ptMidBBox - New Point3d(ptMaxBBox.x, ptMinBBox.y, 0)
|
|
End If
|
|
End If
|
|
Else
|
|
If vtMid.x > 0 Then
|
|
If vtMid.y > 0 Then
|
|
vtptExtptMC = ptMidBBox - New Point3d(ptMaxBBox.x, ptMinBBox.y, 0)
|
|
Else
|
|
vtptExtptMC = ptMidBBox - ptMinBBox
|
|
End If
|
|
Else
|
|
If vtMid.y > 0 Then
|
|
vtptExtptMC = ptMidBBox - ptMaxBBox
|
|
Else
|
|
vtptExtptMC = ptMidBBox - New Point3d(ptMinBBox.x, ptMaxBBox.y, 0)
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
' Calcolo il centro del testo
|
|
Dim ptTextMC As Point3d = ptMid + vtOrto * (dDistance + (vtOrto * vtptExtptMC))
|
|
EgtMove(nText, (ptTextMC - Point3d.ORIG()))
|
|
Return nText
|
|
End Function
|
|
|
|
#Region "CHIAMATA ALLE TEXT/CHECK/LABEL"
|
|
Private Function GetChBxAlzFromIndex(Index As Integer) As CheckBox
|
|
Select Case Index
|
|
Case 1
|
|
Return A1
|
|
Case 2
|
|
Return A2
|
|
Case 3
|
|
Return A3
|
|
Case 4
|
|
Return A4
|
|
Case 5
|
|
Return A5
|
|
Case 6
|
|
Return A6
|
|
Case 7
|
|
Return A7
|
|
Case 8
|
|
Return A8
|
|
Case 9
|
|
Return A9
|
|
Case Else
|
|
Return A10
|
|
End Select
|
|
End Function
|
|
|
|
Private Function GetChBxAalZFromName(sName As String) As CheckBox
|
|
Select Case sName
|
|
Case "A1"
|
|
Return A1
|
|
Case "A2"
|
|
Return A2
|
|
Case "A3"
|
|
Return A3
|
|
Case "A4"
|
|
Return A4
|
|
Case "A5"
|
|
Return A5
|
|
Case "A6"
|
|
Return A6
|
|
Case "A7"
|
|
Return A7
|
|
Case "A8"
|
|
Return A8
|
|
Case "A9"
|
|
Return A9
|
|
Case Else
|
|
Return A10
|
|
End Select
|
|
End Function
|
|
|
|
Private Function GetChBxFrontFromIndex(Index As Integer) As CheckBox
|
|
Select Case Index
|
|
Case 1
|
|
Return F1
|
|
Case 2
|
|
Return F2
|
|
Case 3
|
|
Return F3
|
|
Case 4
|
|
Return F4
|
|
Case 5
|
|
Return F5
|
|
Case 6
|
|
Return F6
|
|
Case 7
|
|
Return F7
|
|
Case 8
|
|
Return F8
|
|
Case 9
|
|
Return F9
|
|
Case Else
|
|
Return F10
|
|
End Select
|
|
End Function
|
|
|
|
Private Function GetChBxFrontFromName(sName As String) As CheckBox
|
|
Select Case sName
|
|
Case "F1"
|
|
Return F1
|
|
Case "F2"
|
|
Return F2
|
|
Case "F3"
|
|
Return F3
|
|
Case "F4"
|
|
Return F4
|
|
Case "F5"
|
|
Return F5
|
|
Case "F6"
|
|
Return F6
|
|
Case "F7"
|
|
Return F7
|
|
Case "F8"
|
|
Return F8
|
|
Case "F9"
|
|
Return F9
|
|
Case Else
|
|
Return F10
|
|
End Select
|
|
End Function
|
|
|
|
'Private Function GetAngleTxBxFromIndex(Index As Integer) As EgtWPFLib.EgtTextBox
|
|
' Select Case Index
|
|
' Case 1
|
|
' Return A1TxBx
|
|
' Case 2
|
|
' Return A2TxBx
|
|
' Case 3
|
|
' Return A3TxBx
|
|
' Case 4
|
|
' Return A4TxBx
|
|
' Case 5
|
|
' Return A5TxBx
|
|
' Case 6
|
|
' Return A6TxBx
|
|
' Case 7
|
|
' Return A7TxBx
|
|
' Case 8
|
|
' Return A8TxBx
|
|
' Case 9
|
|
' Return A9TxBx
|
|
' Case Else
|
|
' Return A10TxBx
|
|
' End Select
|
|
'End Function
|
|
|
|
'Private Function GetHeelTxBxFromIndex(Index As Integer) As EgtWPFLib.EgtTextBox
|
|
' Select Case Index
|
|
' Case 1
|
|
' Return H1TxBx
|
|
' Case 2
|
|
' Return H2TxBx
|
|
' Case 3
|
|
' Return H3TxBx
|
|
' Case 4
|
|
' Return H4TxBx
|
|
' Case 5
|
|
' Return H5TxBx
|
|
' Case 6
|
|
' Return H6TxBx
|
|
' Case 7
|
|
' Return H7TxBx
|
|
' Case 8
|
|
' Return H8TxBx
|
|
' Case 9
|
|
' Return H9TxBx
|
|
' Case Else
|
|
' Return H10TxBx
|
|
' End Select
|
|
'End Function
|
|
|
|
Private Function GetTxBlFromIndex(Index As Integer) As TextBlock
|
|
Select Case Index
|
|
Case 1
|
|
Return Entity1
|
|
Case 2
|
|
Return Entity2
|
|
Case 3
|
|
Return Entity3
|
|
Case 4
|
|
Return Entity4
|
|
Case 5
|
|
Return Entity5
|
|
Case 6
|
|
Return Entity6
|
|
Case 7
|
|
Return Entity7
|
|
Case 8
|
|
Return Entity8
|
|
Case 9
|
|
Return Entity9
|
|
Case Else
|
|
Return Entity10
|
|
End Select
|
|
End Function
|
|
|
|
#End Region ' Chiamata elle Text/Check/Label
|
|
|
|
' Per gestire la selezione delle Alzatine
|
|
Private Sub A_Checked(sender As Object, e As RoutedEventArgs) Handles A1.Checked, A2.Checked, A3.Checked, A4.Checked, A5.Checked, A6.Checked, A7.Checked, A8.Checked, A9.Checked, A10.Checked
|
|
' recupero il nome della Check selezionata
|
|
Dim bIsAlzatina As Boolean = True
|
|
Dim sChName As String = DirectCast(sender, CheckBox).Name
|
|
Dim bIsChecked As Boolean = DirectCast(sender, CheckBox).IsChecked
|
|
Dim sSideName As String = GetSideFromCheck(sChName, bIsAlzatina)
|
|
Dim sOppositeCheckBox As String = GetOppositeCheck(sChName, bIsAlzatina)
|
|
RefreshList(sSideName, sOppositeCheckBox, bIsAlzatina, bIsChecked)
|
|
|
|
EgtZoom(ZM.ALL)
|
|
End Sub
|
|
|
|
' Per gestire la selezione dei Frontalini
|
|
Private Sub F_Checked(sender As Object, e As RoutedEventArgs) Handles F1.Checked, F2.Checked, F3.Checked, F4.Checked, F5.Checked, F6.Checked, F7.Checked, F8.Checked, F9.Checked, F10.Checked
|
|
' recupero il nome della Check selezionata
|
|
Dim bIsAlzatina As Boolean = False
|
|
Dim sChName As String = DirectCast(sender, CheckBox).Name
|
|
Dim bIsChecked As Boolean = DirectCast(sender, CheckBox).IsChecked
|
|
Dim sSideName As String = GetSideFromCheck(sChName, bIsAlzatina)
|
|
Dim sOppositeCheckBox As String = GetOppositeCheck(sChName, bIsAlzatina)
|
|
RefreshList(sSideName, sOppositeCheckBox, bIsAlzatina, bIsChecked)
|
|
|
|
EgtZoom(ZM.ALL)
|
|
End Sub
|
|
|
|
Private Sub ParameterA1TxBx_EgtClosed(sender As Object, e As EventArgs) Handles Parameter1ATxBx.EgtClosed
|
|
' Nuovo angolo di inclinazione
|
|
Dim dValue As Double
|
|
StringToDouble(Parameter1ATxBx.Text, dValue)
|
|
' salvo il valore nel file ini e inserisco il valore nel file lua
|
|
WritePrivateProfileString("Alz&Front", "A_Height", Parameter1ATxBx.Text, m_MainWindow.GetIniFile())
|
|
End Sub
|
|
|
|
Private Sub Parameter1FTxBx_EgtClosed(sender As Object, e As EventArgs) Handles Parameter1FTxBx.EgtClosed
|
|
' Nuovo angolo di inclinazione
|
|
Dim dValue As Double
|
|
StringToDouble(Parameter1FTxBx.Text, dValue)
|
|
' salvo il valore nel file ini e inserisco il valore nel file lua
|
|
WritePrivateProfileString("Alz&Front", "F_Height", Parameter1FTxBx.Text, m_MainWindow.GetIniFile())
|
|
End Sub
|
|
|
|
Private Sub ParameterA2TxBx_EgtClosed(sender As Object, e As EventArgs) Handles Parameter2ATxBx.EgtClosed
|
|
' Nuovo angolo di inclinazione
|
|
Dim dValue As Double
|
|
StringToDouble(Parameter2ATxBx.Text, dValue)
|
|
' salvo il valore nel file ini e inserisco il valore nel file lua
|
|
WritePrivateProfileString("Alz&Front", "A_DeltaAng", Parameter2ATxBx.Text, m_MainWindow.GetIniFile())
|
|
End Sub
|
|
|
|
Private Sub Parameter2FTxBx_EgtClosed(sender As Object, e As EventArgs) Handles Parameter2FTxBx.EgtClosed
|
|
' Nuovo angolo di inclinazione
|
|
Dim dValue As Double
|
|
StringToDouble(Parameter2FTxBx.Text, dValue)
|
|
' salvo il valore nel file ini e inserisco il valore nel file lua
|
|
WritePrivateProfileString("Alz&Front", "F_DeltaAng", Parameter2FTxBx.Text, m_MainWindow.GetIniFile())
|
|
End Sub
|
|
|
|
' noto il nome della checkbox selezionata restituisce il nome del lato
|
|
Private Function GetSideFromCheck(sNameCheck As String, bIsAlz As Boolean) As String
|
|
Dim sSideName As String = String.Empty
|
|
Dim sTypeCheck As String = "A"
|
|
If Not bIsAlz Then
|
|
sTypeCheck = "F"
|
|
End If
|
|
' separo il nome in due
|
|
Dim sItems As String() = Split(sNameCheck, sTypeCheck)
|
|
Dim nIndex As Integer
|
|
' costruisco il nome del lato
|
|
If sItems.Count > 1 Then
|
|
nIndex = CInt(sItems(1))
|
|
nIndex = nIndex - (MAX_LINES - m_nShow)
|
|
sSideName = "A" & nIndex.ToString
|
|
End If
|
|
|
|
Return sSideName
|
|
End Function
|
|
|
|
' restituisce il nome del check opposto (Se passo una alzaztina restituisco il nome della check associata alla
|
|
Private Function GetOppositeCheck(sNameCheck As String, bIsAlz As Boolean) As String
|
|
Dim sSideName As String = String.Empty
|
|
Dim sTypeCheck As String = "A"
|
|
If Not bIsAlz Then
|
|
sTypeCheck = "F"
|
|
End If
|
|
' separo il nome in due
|
|
Dim sItems As String() = Split(sNameCheck, sTypeCheck)
|
|
|
|
' estraggo l'indice del lato selezionato e costruisco il nome del CheckBox opposto
|
|
If sItems.Count > 1 Then
|
|
If bIsAlz Then
|
|
sSideName = "F" & sItems(1).Trim
|
|
Else
|
|
sSideName = "A" & sItems(1).Trim
|
|
End If
|
|
|
|
End If
|
|
|
|
Return sSideName
|
|
End Function
|
|
|
|
' aggiorno lo stato della dell'oggetto
|
|
Private Sub RefreshList(sSideName As String, sOppositeNameCheck As String, bIsAlz As Boolean, bIsChecked As Boolean)
|
|
For j = 0 To AlzFrontEntityList.Count() - 1
|
|
If AlzFrontEntityList(j).SideName = sSideName Then
|
|
' se deseleziono
|
|
If Not bIsChecked Then
|
|
AlzFrontEntityList(j).Type = AlzFrontEntity.AlzFront.NONE
|
|
Exit For
|
|
End If
|
|
' se selezione di Alz. o Front.
|
|
If bIsAlz Then
|
|
AlzFrontEntityList(j).Type = AlzFrontEntity.AlzFront.ALZATINA
|
|
AddTextToLine(AlzFrontEntityList(j).SideName, m_AlzLayer, AlzFrontEntityList(j).Id, 20, m_dBBoxRad, True)
|
|
' deseleziono il Check opposto
|
|
GetChBxFrontFromName(sOppositeNameCheck).IsChecked = False
|
|
Else
|
|
AddTextToLine(AlzFrontEntityList(j).SideName, m_Frontlayer, AlzFrontEntityList(j).Id, 20, m_dBBoxRad, True)
|
|
AlzFrontEntityList(j).Type = AlzFrontEntity.AlzFront.FRONTALINO
|
|
' deseleziono il Check opposto
|
|
GetChBxAalZFromName(sOppositeNameCheck).IsChecked = False
|
|
End If
|
|
' termino il ciclo
|
|
Exit For
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
' metodo utilizzato per tornare indietro alla pagina di selezione "CompoInterni/Alz&Front"
|
|
Private Sub BackBtn_Click(sender As Object, e As RoutedEventArgs) Handles BackBtn.Click
|
|
m_MainWindow.m_DrawPageUC.m_SceneButtons.MeasureBtn.IsChecked = False
|
|
|
|
' torno alla pagina iniziale di selezione del piano (Compo)
|
|
'm_MainWindow.m_DrawPageUC.BackBtn_Click(sender, e)
|
|
|
|
'--------- NUOVA GESTIONE ---------
|
|
' rimuovo l'elenco di bottoni per selezionare il tipo di componente interna
|
|
m_MainWindow.m_DrawPageUC.LeftButtonGrd.Children.Remove(Me)
|
|
' inserisco nella Grid VaribalsesGrid lo UeserControl per definire le dimensioni della componente
|
|
m_MainWindow.m_DrawPageUC.VariablesGrd.Children.Add(m_MainWindow.m_DrawPageUC.m_CompoDimension)
|
|
' nascondo la lista dei parametri
|
|
m_MainWindow.m_DrawPageUC.m_CompoDimension.CollapsedAllParam()
|
|
' sto uscendo dalla componente interna (quindi comunico il cambio di componente)
|
|
m_MainWindow.m_DrawPageUC.m_bInternalCompo = False
|
|
' comunico che sto arrivando da una componente interna
|
|
m_MainWindow.m_DrawPageUC.m_bBackFromInternalCompo = True
|
|
|
|
'm_MainWindow.m_DrawPageUC.SelectedComponent(m_MainWindow.m_DrawPageUC.m_sMainCompo)
|
|
'm_MainWindow.m_DrawPageUC.m_ActiveComponentPage = DrawPageUC.Pages.CompoDimension
|
|
End Sub
|
|
|
|
Private Sub LoadCurrentCompo()
|
|
' Pulisco l'ambiente lua
|
|
EgtLuaResetGlobVar(LUA_CMP_VARS)
|
|
EgtLuaResetGlobVar(LUA_CMP_DRAW)
|
|
Dim sCompoDir As String = String.Empty
|
|
GetPrivateProfileString(S_COMPO, K_COMPODIR, "", sCompoDir, m_MainWindow.GetIniFile())
|
|
Dim sCompo As String = String.Empty
|
|
GetPrivateProfileString(S_COMPO, "Alz&Front", "", sCompoDir, m_MainWindow.GetIniFile())
|
|
' Costruisco path completa del componente
|
|
Dim sPath = sCompoDir & "\" & sCompo & ".lua"
|
|
' Carico il file
|
|
EgtLuaExecFile(sPath)
|
|
|
|
Dim sMsg As String = String.Empty
|
|
' Verifico se compo interno o esterno
|
|
Dim InternalCompo As Integer = -1
|
|
EgtLuaGetGlobIntVar(LUA_CMP_INTERNAL, InternalCompo)
|
|
|
|
If Not EgtLuaExecLine(LUA_CMP_DRAW & "(true)") Then
|
|
sMsg = "Error in component execution"
|
|
m_bDrawOk = False
|
|
Else
|
|
EgtLuaGetGlobStringVar(LUA_CMP_VARS & ".MSG", sMsg)
|
|
Dim nErr As Integer = 0
|
|
EgtLuaGetGlobIntVar(LUA_CMP_VARS & ".ERR", nErr)
|
|
m_bDrawOk = (nErr = 0)
|
|
End If
|
|
|
|
EgtAdjustFlatPart(EgtGetFirstPart())
|
|
'Return m_bDrawOk
|
|
|
|
'If Not bOk And InternalCompo <> 1 Then
|
|
' EgtNewFile()
|
|
'End If
|
|
'MessageTxBl.Text = sMsg
|
|
'MessageGrid.Background = If(m_bDrawOk, Brushes.Transparent, Application.Current.FindResource("OmagCut_Red"))
|
|
'DrawScene.ZoomAll()
|
|
'' leggo variabili e aggiorno griglia
|
|
'ReadAndShowVariables()
|
|
'' abilito bottoni Vista e Inserisci
|
|
'OkBtn.IsEnabled = True
|
|
End Sub
|
|
|
|
End Class
|
|
|
|
Public Class AlzFrontEntity
|
|
Public Enum AlzFront
|
|
ALZATINA
|
|
FRONTALINO
|
|
NONE
|
|
End Enum
|
|
|
|
Private m_SideName As String
|
|
Private m_Id As Integer
|
|
Private m_Type As AlzFront = AlzFront.NONE
|
|
|
|
' nome del lato scritto nel file nge (il nome deve avere la forma: A1, A2, .., An)
|
|
Public Property SideName As String
|
|
Get
|
|
Return m_SideName
|
|
End Get
|
|
Set(value As String)
|
|
m_SideName = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property Type As AlzFront
|
|
Get
|
|
Return m_Type
|
|
End Get
|
|
Set(value As AlzFront)
|
|
m_Type = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property Id As Integer
|
|
Get
|
|
Return m_Id
|
|
End Get
|
|
Set(value As Integer)
|
|
m_Id = value
|
|
End Set
|
|
End Property
|
|
|
|
Sub New(Name As String, CurrId As Integer, Optional CurrType As AlzFront = AlzFront.NONE)
|
|
m_SideName = Name
|
|
m_Id = CurrId
|
|
m_Type = CurrType
|
|
End Sub
|
|
|
|
End Class |