6495cc8730
- Aggiunta bottone "Altri" nella lista dei Componenti Interni che visualizza gli elementi restanti (se sono più di 8). Nella seconda parte della lista rimane il bottone "Altri" per tornare alla prima parte della lista. La lista dei Componenti Principali è stata risistemata con questa logica.
364 lines
14 KiB
VB.net
364 lines
14 KiB
VB.net
Imports EgtUILib
|
|
|
|
Public Class InternalComponentPageUC
|
|
|
|
'Riferimento alla MainWindow
|
|
Private m_MainWindow As MainWindow = DirectCast(Application.Current.MainWindow, MainWindow)
|
|
|
|
' Flag che indica se è attiva la prima o la seconda pagina
|
|
Friend m_bIsFirstPage As Boolean
|
|
|
|
Friend CurrentBtn As Button = Nothing
|
|
|
|
' Variabile che contiene il nome del componente selezionato
|
|
Friend m_sCurrCompoFam As String = String.Empty
|
|
|
|
Private Sub InternalComponentPage_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
|
|
m_bIsFirstPage = True
|
|
LoadPage()
|
|
CurrentBtn = Nothing
|
|
Compo9.SetValue(Grid.ColumnProperty, 0)
|
|
Compo9.SetValue(Grid.ColumnSpanProperty, 2)
|
|
LabelCompo9.Text = EgtMsg(MSG_COMPONENTPAGEUC + 9)
|
|
ImageCompo9.Visibility = Windows.Visibility.Hidden
|
|
LabelCompo9.Visibility = Windows.Visibility.Visible
|
|
' Se i componenti interni sono più di 8 viene visualizzato il bottone "Altri" altrimenti no
|
|
Dim nCount As Integer = GetPrivateProfileInt("InternalCompo", "Count", 0, m_MainWindow.GetIniFile())
|
|
If nCount > 8 Then
|
|
Compo9.Visibility = Windows.Visibility.Visible
|
|
Else
|
|
Compo9.Visibility = Windows.Visibility.Hidden
|
|
End If
|
|
m_MainWindow.m_DrawPageUC.m_ActiveComponentPage = DrawPageUC.Pages.InternalComponent
|
|
' Abilito bottoni angoli di fianco e lavorazioni da sotto
|
|
m_MainWindow.m_DrawPageUC.SideAngleBtn.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)
|
|
End Sub
|
|
|
|
Private Function GetButton(ByVal nInd As Integer) As Button
|
|
Select Case nInd
|
|
Case 1
|
|
Return Compo1
|
|
Case 2
|
|
Return Compo2
|
|
Case 3
|
|
Return Compo3
|
|
Case 4
|
|
Return Compo4
|
|
Case 5
|
|
Return Compo5
|
|
Case 6
|
|
Return Compo6
|
|
Case 7
|
|
Return Compo7
|
|
Case 8
|
|
Return Compo8
|
|
Case Else
|
|
Return Compo9
|
|
End Select
|
|
End Function
|
|
|
|
Private Function GetLabel(ByVal nInd As Integer) As TextBlock
|
|
Select Case nInd
|
|
Case 1
|
|
Return LabelCompo1
|
|
Case 2
|
|
Return LabelCompo2
|
|
Case 3
|
|
Return LabelCompo3
|
|
Case 4
|
|
Return LabelCompo4
|
|
Case 5
|
|
Return LabelCompo5
|
|
Case 6
|
|
Return LabelCompo6
|
|
Case 7
|
|
Return LabelCompo7
|
|
Case 8
|
|
Return LabelCompo8
|
|
Case Else
|
|
Return LabelCompo9
|
|
End Select
|
|
End Function
|
|
|
|
Private Function GetImage(ByVal nInd As Integer) As Image
|
|
Select Case nInd
|
|
Case 1
|
|
Return ImageCompo1
|
|
Case 2
|
|
Return ImageCompo2
|
|
Case 3
|
|
Return ImageCompo3
|
|
Case 4
|
|
Return ImageCompo4
|
|
Case 5
|
|
Return ImageCompo5
|
|
Case 6
|
|
Return ImageCompo6
|
|
Case 7
|
|
Return ImageCompo7
|
|
Case 8
|
|
Return ImageCompo8
|
|
Case Else
|
|
Return ImageCompo9
|
|
End Select
|
|
End Function
|
|
|
|
Friend Function GetIndexFromButton(Button As Button) As Integer
|
|
Select Case Button.Name
|
|
Case "Compo1"
|
|
If m_bIsFirstPage Then
|
|
Return 1
|
|
Else
|
|
Return 9
|
|
End If
|
|
Case "Compo2"
|
|
If m_bIsFirstPage Then
|
|
Return 2
|
|
Else
|
|
Return 10
|
|
End If
|
|
Case "Compo3"
|
|
If m_bIsFirstPage Then
|
|
Return 3
|
|
Else
|
|
Return 11
|
|
End If
|
|
Case "Compo4"
|
|
If m_bIsFirstPage Then
|
|
Return 4
|
|
Else
|
|
Return 12
|
|
End If
|
|
Case "Compo5"
|
|
If m_bIsFirstPage Then
|
|
Return 5
|
|
Else
|
|
Return 13
|
|
End If
|
|
Case "Compo6"
|
|
If m_bIsFirstPage Then
|
|
Return 6
|
|
Else
|
|
Return 14
|
|
End If
|
|
Case "Compo7"
|
|
If m_bIsFirstPage Then
|
|
Return 7
|
|
Else
|
|
Return 15
|
|
End If
|
|
Case Else
|
|
If m_bIsFirstPage Then
|
|
Return 8
|
|
Else
|
|
Return 16
|
|
End If
|
|
End Select
|
|
End Function
|
|
|
|
Private Sub Compo_Click(sender As Object, e As RoutedEventArgs) Handles Compo1.Click, Compo2.Click, Compo3.Click, Compo4.Click, Compo5.Click, Compo6.Click, Compo7.Click, Compo8.Click
|
|
CurrentBtn = e.Source
|
|
Dim CompoName As String = "InternalCompo" & GetIndexFromButton(CurrentBtn).ToString
|
|
m_sCurrCompoFam = CompoName
|
|
' m_SecondaryComponentPage.m_sCurrCompo = String.Empty
|
|
Dim nCount As Integer = GetPrivateProfileInt(CompoName, "Count", 0, m_MainWindow.GetIniFile())
|
|
If nCount > 1 Then
|
|
m_MainWindow.m_DrawPageUC.LeftButtonGrd.Children.Remove(Me)
|
|
m_MainWindow.m_DrawPageUC.m_ActiveComponentPage = DrawPageUC.Pages.SecondaryComponent
|
|
' m_MainWindow.m_DrawPageUC.LeftButtonGrd.Children.Add(m_SecondaryComponentPage)
|
|
Else
|
|
Dim nCompoName As Integer
|
|
Dim sCompo As String = String.Empty
|
|
Dim sCompoImage As String = String.Empty
|
|
GetPrivateProfileCompo(CompoName, CompoName, nCompoName, sCompo, sCompoImage, m_MainWindow.GetIniFile())
|
|
|
|
'm_MainWindow.m_DrawPageUC.DimensionBtn.IsChecked = True
|
|
m_MainWindow.m_DrawPageUC.SideAngleBtn.IsChecked = False
|
|
m_MainWindow.m_DrawPageUC.DripCutBtn.IsChecked = False
|
|
m_MainWindow.m_DrawPageUC.SideAngleBtn.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)
|
|
m_MainWindow.m_DrawPageUC.MessageGrid.Visibility = Windows.Visibility.Visible
|
|
m_MainWindow.m_DrawPageUC.BackBtn.Visibility = Windows.Visibility.Visible
|
|
m_MainWindow.m_DrawPageUC.PartNameGrd.Visibility = Windows.Visibility.Visible
|
|
m_MainWindow.m_DrawPageUC.PartNumberGrd.Visibility = Windows.Visibility.Visible
|
|
' Carico componente
|
|
m_MainWindow.m_DrawPageUC.SelectedComponent(sCompo)
|
|
|
|
'Attivo Bottoni aggiungi e rimuovi
|
|
m_MainWindow.m_DrawPageUC.m_CompoDimension.AddBtn.Visibility = Windows.Visibility.Visible
|
|
m_MainWindow.m_DrawPageUC.m_CompoDimension.CancelBtn.Visibility = Windows.Visibility.Visible
|
|
m_MainWindow.m_DrawPageUC.m_CompoDimension.InternComponentBtn.Visibility = Windows.Visibility.Hidden
|
|
m_MainWindow.m_DrawPageUC.LeftButtonGrd.Children.Remove(Me)
|
|
m_MainWindow.m_DrawPageUC.VariablesGrd.Children.Add(m_MainWindow.m_DrawPageUC.m_CompoDimension)
|
|
End If
|
|
End Sub
|
|
|
|
Public Function GetPrivateProfileCompo(
|
|
ByVal lpAppName As String,
|
|
ByVal lpKeyName As String,
|
|
ByRef lpCompoName As Integer,
|
|
ByRef lpCompo As String,
|
|
ByRef lpCompoImage As String,
|
|
ByVal lpFileName As String) As Boolean
|
|
|
|
Dim sVal As String = String.Empty
|
|
GetPrivateProfileString(lpAppName, lpKeyName, "", sVal, lpFileName)
|
|
Dim sItems() As String = sVal.Split(",".ToCharArray)
|
|
If sItems.Count() >= 2 Then
|
|
lpCompoName = 0
|
|
StringToInt(sItems(0), lpCompoName)
|
|
lpCompo = sItems(1)
|
|
If sItems.Count() >= 3 Then
|
|
lpCompoImage = sItems(2)
|
|
Else
|
|
lpCompoImage = String.Empty
|
|
End If
|
|
Return True
|
|
End If
|
|
Return False
|
|
|
|
End Function
|
|
|
|
Private Sub ClearButton(nCount As Integer)
|
|
Dim nEndIndex As Integer
|
|
If m_bIsFirstPage Then
|
|
nEndIndex = If(nCount < 8, nCount, 8)
|
|
Else
|
|
nEndIndex = If(nCount < 16, nCount - 8, 8)
|
|
End If
|
|
For index As Integer = 1 To nEndIndex
|
|
GetLabel(index).Text = String.Empty
|
|
GetImage(index).Source = Nothing
|
|
GetButton(index).Visibility = Windows.Visibility.Visible
|
|
Next
|
|
For index As Integer = nEndIndex + 1 To 8
|
|
GetLabel(index).Text = String.Empty
|
|
GetImage(index).Source = Nothing
|
|
GetButton(index).Visibility = Windows.Visibility.Hidden
|
|
Next
|
|
End Sub
|
|
|
|
Private Sub LoadPage()
|
|
Dim nDeltaSecondPage As Integer = 8
|
|
' Leggo numero di componenti presenti
|
|
Dim nCompoNumber As Integer = GetPrivateProfileInt("InternalCompo", "Count", 0, m_MainWindow.GetIniFile())
|
|
' Calcolo indici a seconda della pagina in cui sono
|
|
If m_bIsFirstPage Then
|
|
ClearButton(nCompoNumber)
|
|
nDeltaSecondPage = 0
|
|
Else
|
|
ClearButton(nCompoNumber)
|
|
nDeltaSecondPage = 8
|
|
End If
|
|
|
|
' Creazione converter da String a ImageSource
|
|
Dim ImageConverter As New ImageSourceConverter
|
|
Dim ThicknessConverter As New ThicknessConverter
|
|
|
|
' Assegnazione immagine e testo ai Button
|
|
For index = 1 To 8
|
|
Dim CustomThickness As Thickness = ThicknessConverter.ConvertFromString("0")
|
|
Dim nCompoName As Integer
|
|
Dim sCompo As String = ""
|
|
Dim sCompoImage As String = ""
|
|
|
|
m_MainWindow.m_DrawPageUC.m_MainComponentPage.GetPrivateProfileCompo("InternalCompo" & index + nDeltaSecondPage, "InternalCompo" & index + nDeltaSecondPage, nCompoName, sCompo, sCompoImage, m_MainWindow.GetIniFile())
|
|
Dim sCompoImageSource As ImageSource
|
|
|
|
' Se foro da sotto, lo carico solo se abilitato dalla chiave e dalla macchina
|
|
If String.Compare(sCompo, "IntDownHole.lua", True) = 0 AndAlso
|
|
(Not m_MainWindow.GetKeyOption(MainWindow.KEY_OPT.UNDER_CUT) Or String.IsNullOrWhiteSpace(m_MainWindow.m_CurrentMachine.sCurrDripDrill)) Then
|
|
GetButton(index).IsEnabled = False
|
|
End If
|
|
|
|
' Verifico presenza immagine e la aggiungo
|
|
If sCompoImage.Length <> 0 Then
|
|
Try
|
|
sCompoImageSource = ImageConverter.ConvertFromString(m_MainWindow.GetResourcesDir() & "\" & sCompoImage)
|
|
GetImage(index).Height = 65
|
|
GetImage(index).Width = 65
|
|
GetImage(index).Source = sCompoImageSource
|
|
GetLabel(index).SetValue(Grid.ColumnProperty, 1)
|
|
GetLabel(index).SetValue(Grid.ColumnSpanProperty, 1)
|
|
Catch ex As Exception
|
|
EgtOutLog("Error loading image " & sCompoImage)
|
|
sCompoImage = String.Empty
|
|
GetImage(index).Height = 0
|
|
GetImage(index).Width = 0
|
|
CustomThickness.Right = 0
|
|
GetImage(index).Margin = CustomThickness
|
|
GetLabel(index).SetValue(Grid.ColumnProperty, 0)
|
|
GetLabel(index).SetValue(Grid.ColumnSpanProperty, 2)
|
|
End Try
|
|
Else
|
|
'Se non c'è l'immagine azzero la distanza tra testo e immagine
|
|
CustomThickness.Right = 0
|
|
GetImage(index).Margin = CustomThickness
|
|
GetLabel(index).SetValue(Grid.ColumnProperty, 0)
|
|
GetLabel(index).SetValue(Grid.ColumnSpanProperty, 2)
|
|
End If
|
|
|
|
' Verifico presenza testo
|
|
If nCompoName > 0 Then
|
|
Dim sCompoName As String = EgtMsg(MSG_COMPONENTPAGEUC + nCompoName)
|
|
' verifico presenza immagine
|
|
If sCompoImage.Length > 0 Then
|
|
' se la lunghezza del testo è maggiore di 20 lo taglio
|
|
If sCompoName.Length > 20 Then
|
|
sCompoName = sCompoName.Substring(0, 20)
|
|
End If
|
|
GetLabel(index).Text = sCompoName
|
|
' Se ci sono sia testo che immagine imposto un margine di 10
|
|
CustomThickness.Right = 10
|
|
GetImage(index).Margin = CustomThickness
|
|
Else
|
|
' se l'immagine non c'è e il testo è maggiore di 30 lo taglio
|
|
If sCompoName.Length > 30 Then
|
|
sCompoName = sCompoName.Substring(0, 30)
|
|
End If
|
|
GetLabel(index).Text = sCompoName
|
|
End If
|
|
Else
|
|
'Se non c'è testo azzero la distanza tra testo e immagine
|
|
CustomThickness.Right = 0
|
|
GetImage(index).Margin = CustomThickness
|
|
End If
|
|
|
|
Next
|
|
|
|
End Sub
|
|
|
|
' Gestione bottone altri componenti
|
|
Private Sub Compo9_Click(sender As Object, e As RoutedEventArgs) Handles Compo9.Click
|
|
If m_bIsFirstPage Then
|
|
m_bIsFirstPage = False
|
|
LoadPage()
|
|
'Compo9.SetValue(Grid.ColumnProperty, 1)
|
|
'Compo9.SetValue(Grid.ColumnSpanProperty, 1)
|
|
'ImageCompo9.Source = New System.Windows.Media.Imaging.BitmapImage(New Uri("/Resources/NumericKeyboardArrow.png", UriKind.Relative))
|
|
'ImageCompo9.Visibility = Windows.Visibility.Visible
|
|
'LabelCompo9.Visibility = Windows.Visibility.Hidden
|
|
Compo9.SetValue(Grid.ColumnProperty, 0)
|
|
Compo9.SetValue(Grid.ColumnSpanProperty, 2)
|
|
ImageCompo9.Visibility = Windows.Visibility.Hidden
|
|
LabelCompo9.Visibility = Windows.Visibility.Visible
|
|
Else
|
|
m_bIsFirstPage = True
|
|
LoadPage()
|
|
Compo9.SetValue(Grid.ColumnProperty, 0)
|
|
Compo9.SetValue(Grid.ColumnSpanProperty, 2)
|
|
ImageCompo9.Visibility = Windows.Visibility.Hidden
|
|
LabelCompo9.Visibility = Windows.Visibility.Visible
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub BackBtn_Click(sender As Object, e As RoutedEventArgs) Handles BackBtn.Click
|
|
m_MainWindow.m_DrawPageUC.m_SceneButtons.MeasureBtn.IsChecked = False
|
|
m_MainWindow.m_DrawPageUC.BackBtn_Click(sender, e)
|
|
End Sub
|
|
|
|
End Class
|