Imports System.Windows.Forms.Integration
Imports System.Collections.ObjectModel
Imports EgtUILib
Public Class ToolDbWindowVM
Inherits VMBase
#Region "NEW INTERFACE PROPERTIES"
Private m_bPersonalInterface As Boolean = False
Public Property bPersonalInterface As Boolean
Get
Return m_bPersonalInterface
End Get
Set(value As Boolean)
m_bPersonalInterface = value
End Set
End Property
Private m_BorderBrushIsMouseOver As Brush
Public Property BorderBrushIsMouseOver As Brush
Get
Return m_BorderBrushIsMouseOver
End Get
Set(value As Brush)
m_BorderBrushIsMouseOver = value
End Set
End Property
Private m_GeneralBorderBrush As Brush
Public Property GeneralBorderBrush As Brush
Get
Return m_GeneralBorderBrush
End Get
Set(value As Brush)
m_GeneralBorderBrush = value
End Set
End Property
Private m_BorderBrushIsFocused As Brush
Public Property BorderBrushIsFocused As Brush
Get
Return m_BorderBrushIsFocused
End Get
Set(value As Brush)
m_BorderBrushIsFocused = value
End Set
End Property
Private m_BackgroundBrdEnable As Brush
Public Property BackgroundBrdEnable As Brush
Get
Return m_BackgroundBrdEnable
End Get
Set(value As Brush)
m_BackgroundBrdEnable = value
End Set
End Property
Private m_BackgroundBrdDisable As Brush
Public Property BackgroundBrdDisable As Brush
Get
Return m_BackgroundBrdDisable
End Get
Set(value As Brush)
m_BackgroundBrdDisable = value
End Set
End Property
Private m_BackgroundTxBlDisable As Brush
Public Property BackgroundTxBlDisable As Brush
Get
Return m_BackgroundTxBlDisable
End Get
Set(value As Brush)
m_BackgroundTxBlDisable = value
End Set
End Property
Private m_ForegroundTxBlEnable As Brush
Public Property ForegroundTxBlEnable As Brush
Get
Return m_ForegroundTxBlEnable
End Get
Set(value As Brush)
m_ForegroundTxBlEnable = value
End Set
End Property
Private m_ForegroundTxBlDisable As Brush
Public Property ForegroundTxBlDisable As Brush
Get
Return m_ForegroundTxBlDisable
End Get
Set(value As Brush)
m_ForegroundTxBlDisable = value
End Set
End Property
Private m_GeneralForeground As Brush
Public Property GeneralForeground As Brush
Get
Return m_GeneralForeground
End Get
Set(value As Brush)
m_GeneralForeground = value
End Set
End Property
Private m_GeneralBackground As Brush
Public Property GeneralBackground As Brush
Get
Return m_GeneralBackground
End Get
Set(value As Brush)
m_GeneralBackground = value
End Set
End Property
Private m_MyBorderGrbThickness As Double
Public Property MyBorderGrbThickness As Double
Get
Return m_MyBorderGrbThickness
End Get
Set(value As Double)
m_MyBorderGrbThickness = value
End Set
End Property
Private m_MyForegroundGrbColor As Brush
Public Property MyForegroundGrbColor As Brush
Get
Return m_MyForegroundGrbColor
End Get
Set(value As Brush)
m_MyForegroundGrbColor = value
End Set
End Property
Private m_BackgroundCmBxTxBl As Brush
Public Property BackgroundCmBxTxBl As Brush
Get
Return m_BackgroundCmBxTxBl
End Get
Set(value As Brush)
m_BackgroundCmBxTxBl = value
End Set
End Property
Private m_ForegroundCmBxTxBl As Brush
Public Property ForegroundCmBxTxBl As Brush
Get
Return m_ForegroundCmBxTxBl
End Get
Set(value As Brush)
m_ForegroundCmBxTxBl = value
End Set
End Property
Private m_BorderThicknessCmBxTxBl As Thickness
Public Property BorderThicknessCmBxTxBl As Thickness
Get
Return m_BorderThicknessCmBxTxBl
End Get
Set(value As Thickness)
m_BorderThicknessCmBxTxBl = value
End Set
End Property
Private m_VerticalContentAlignmentCmBxTxBl As String
Public Property VerticalContentAlignmentCmBxTxBl As String
Get
Return m_VerticalContentAlignmentCmBxTxBl
End Get
Set(value As String)
m_VerticalContentAlignmentCmBxTxBl = value
End Set
End Property
Private m_HeightCmBxTxBl As String
Public Property HeightCmBxTxBl As String
Get
Return m_HeightCmBxTxBl
End Get
Set(value As String)
m_HeightCmBxTxBl = value
End Set
End Property
Private m_WidthCmBxTxBl As String
Public Property WidthCmBxTxBl As String
Get
Return m_WidthCmBxTxBl
End Get
Set(value As String)
m_WidthCmBxTxBl = value
End Set
End Property
Private m_ForegroundTextBoxCmBxTxBl As Brush
Public Property ForegroundTextBoxCmBxTxBl As Brush
Get
Return m_ForegroundTextBoxCmBxTxBl
End Get
Set(value As Brush)
m_ForegroundTextBoxCmBxTxBl = value
End Set
End Property
Private m_BackgroundButton As Brush
Public Property BackgroundButton As Brush
Get
Return m_BackgroundButton
End Get
Set(value As Brush)
m_BackgroundButton = value
End Set
End Property
Private m_ForegroundButton As Brush
Public Property ForegroundButton As Brush
Get
Return m_ForegroundButton
End Get
Set(value As Brush)
m_ForegroundButton = value
End Set
End Property
Private m_BorderBrushButton As Brush
Public Property BorderBrushButton As Brush
Get
Return m_BorderBrushButton
End Get
Set(value As Brush)
m_BorderBrushButton = value
End Set
End Property
Private m_BorderThicknessButton As Thickness
Public Property BorderThicknessButton As Thickness
Get
Return m_BorderThicknessButton
End Get
Set(value As Thickness)
m_BorderThicknessButton = value
End Set
End Property
Private m_HeaderVisibility As DataGridHeadersVisibility = DataGridHeadersVisibility.Column
Public Property HeaderVisibility As DataGridHeadersVisibility
Get
Return m_HeaderVisibility
End Get
Set(value As DataGridHeadersVisibility)
m_HeaderVisibility = value
End Set
End Property
Private m_BackgroundDataGrid As Brush = Brushes.White
Public Property BackgroundDataGrid As Brush
Get
Return m_BackgroundDataGrid
End Get
Set(value As Brush)
m_BackgroundDataGrid = value
End Set
End Property
Private m_BackGroundHeader As Brush = Brushes.White
Public Property BackGroundHeader As Brush
Get
Return m_BackGroundHeader
End Get
Set(value As Brush)
m_BackGroundHeader = value
End Set
End Property
Private m_ForegroundHeader As Brush = Brushes.White
Public Property ForegroundHeader As Brush
Get
Return m_ForegroundHeader
End Get
Set(value As Brush)
m_ForegroundHeader = value
End Set
End Property
Private m_BorderBrushHeader As Brush = Brushes.DarkGray
Public Property BorderBrushHeader As Brush
Get
Return m_BorderBrushHeader
End Get
Set(value As Brush)
m_BorderBrushHeader = value
End Set
End Property
Private m_BorderThicknessHeader As Double = 1.0
Public Property BorderThicknessHeader As Double
Get
Return m_BorderThicknessHeader
End Get
Set(value As Double)
m_BorderThicknessHeader = value
End Set
End Property
Private m_FontWeightHeader As FontWeight = FontWeights.Normal
Public Property FontWeightHeader As FontWeight
Get
Return m_FontWeightHeader
End Get
Set(value As FontWeight)
m_FontWeightHeader = value
End Set
End Property
Private m_BorderBrushDataGrid As Brush = Brushes.DarkGray
Public Property BorderBrushDataGrid As Brush
Get
Return m_BorderBrushDataGrid
End Get
Set(value As Brush)
m_BorderBrushDataGrid = value
End Set
End Property
Private m_BackgroundDataGridRow As Brush = Brushes.White
Public Property BackgroundDataGridRow As Brush
Get
Return m_BackgroundDataGridRow
End Get
Set(value As Brush)
m_BackgroundDataGridRow = value
End Set
End Property
Private m_ForegroundDataGridRow As Brush = Brushes.White
Public Property ForegroundDataGridRow As Brush
Get
Return m_ForegroundDataGridRow
End Get
Set(value As Brush)
m_ForegroundDataGridRow = value
End Set
End Property
Private m_BorderBrushDataGridRow As Brush = Brushes.DarkGray
Public Property BorderBrushDataGridRow As Brush
Get
Return m_BorderBrushDataGridRow
End Get
Set(value As Brush)
m_BorderBrushDataGridRow = value
End Set
End Property
Private m_BorderThicknessDataGridRow As String = "0 0 0 1"
Public Property BorderThicknessDataGridRow As String
Get
Return m_BorderThicknessDataGridRow
End Get
Set(value As String)
m_BorderThicknessDataGridRow = value
End Set
End Property
Private m_BorderBrushDataGridCell As Brush = Brushes.DarkGray
Public Property BorderBrushDataGridCell As Brush
Get
Return m_BorderBrushDataGridCell
End Get
Set(value As Brush)
m_BorderBrushDataGridCell = value
End Set
End Property
Private m_BorderThicknessDataGridCell As String = "0 0 0 1"
Public Property BorderThicknessDataGridCell As String
Get
Return m_BorderThicknessDataGridCell
End Get
Set(value As String)
m_BorderThicknessDataGridCell = value
End Set
End Property
Private m_BorderBrushCmBxTxBl As Brush
Public Property BorderBrushCmBxTxBl As Brush
Get
Return m_BorderBrushCmBxTxBl
End Get
Set(value As Brush)
m_BorderBrushCmBxTxBl = value
End Set
End Property
Private m_BackgroundListCmBxTxBl As Brush
Public Property BackgroundListCmBxTxBl As Brush
Get
Return m_BackgroundListCmBxTxBl
End Get
Set(value As Brush)
m_BackgroundListCmBxTxBl = value
End Set
End Property
#End Region ' New interface properties
Public Event m_CloseWindow(bDialogResult As Boolean)
Private Const SETUP_FILEEXTENSION As String = ".stu"
Friend Shared m_bActive As Boolean = False
Friend Shared m_ProjectSceneContext As Integer = 0
Public Shared ReadOnly Property ProjectSceneContext As Integer
Get
Return m_ProjectSceneContext
End Get
End Property
Friend Shared m_ToolDbSceneContext As Integer = 0
Public Shared ReadOnly Property ToolDbSceneContext As Integer
Get
Return m_ToolDbSceneContext
End Get
End Property
Friend Shared m_sToolMakersDirPath As String = String.Empty
Friend Shared m_sMachineIniPath As String = String.Empty
Friend Shared m_sScriptDirPath As String = String.Empty
Friend Shared m_sToolDirPath As String = String.Empty
Friend Shared m_MatType As MaterialType = Nothing
Friend Shared m_bVisibleSysNotes As Boolean = False
Public Property MatType As MaterialType
Get
Return m_MatType
End Get
Set(value As MaterialType)
m_MatType = value
End Set
End Property
Private m_Title As String
Public ReadOnly Property Title As String
Get
Return EgtMsg(5003) ' Db Utensili
End Get
End Property
' Lista degli utensili
Private m_ToolsList As New ObservableCollection(Of FamilyToolTreeViewItem)
Public Property ToolsList As ObservableCollection(Of FamilyToolTreeViewItem)
Get
Return m_ToolsList
End Get
Set(value As ObservableCollection(Of FamilyToolTreeViewItem))
m_ToolsList = value
End Set
End Property
Public ReadOnly Property SelFamily As FamilyToolTreeViewItem
Get
Return m_ToolsList.FirstOrDefault(Function(x) x.IsSelected)
End Get
End Property
Public ReadOnly Property SelTool As ToolTreeViewItem
Get
For Each Family In m_ToolsList
Dim Tool As InheritableTreeViewItem = Family.Items.FirstOrDefault(Function(x) x.IsSelected)
If Not IsNothing(Tool) Then
Return DirectCast(Tool, ToolTreeViewItem)
End If
Next
Return Nothing
End Get
End Property
Private m_IsEnabledNewBtn As Boolean
Public ReadOnly Property IsEnabledNewBtn As Boolean
Get
Return m_IsEnabledNewBtn
End Get
End Property
Private m_IsEnabledSaveBtn As Boolean
Public ReadOnly Property IsEnabledSaveBtn As Boolean
Get
Return m_IsEnabledSaveBtn
End Get
End Property
Private m_IsEnabledRemoveBtn As Boolean
Public ReadOnly Property IsEnabledRemoveBtn As Boolean
Get
Return m_IsEnabledRemoveBtn
End Get
End Property
Public ReadOnly Property IsEnabledImpExpBtn As Boolean
Get
Return IsNothing(SelTool) OrElse SelTool.IsValid()
End Get
End Property
Private StoneDrillToolParamPageV As StoneDrillParamPageV
Private WoodDrillToolParamPageV As WoodDrillParamPageV
Private StoneSawToolParamPageV As StoneSawParamPageV
Private WoodSawToolParamPageV As WoodSawParamPageV
Private StoneMillToolParamPageV As StoneMillParamPageV
Private WoodMillToolParamPageV As WoodMillParamPageV
Private BeamMillToolParamPageV As BeamMillParamPageV
Private ChiselToolParamPageV As ChiselParamPageV
Private MortiseToolParamPageV As MortiseParamPageV
Private WaterjetToolParamPageV As WaterjetParamPageV
Private ProbeToolParamPageV As ProbeParamPageV
Public ReadOnly Property ParamPageV As ContentControl
Get
Dim selToolFamily As FamilyToolTreeViewItem = Nothing
Dim selTool As ToolTreeViewItem = Nothing
Dim selToolFamilyType As Integer = 0
For Each ToolFamily In ToolsList
For Each Tool In ToolFamily.Items
If Tool.IsSelected Then
selTool = DirectCast(Tool, ToolTreeViewItem)
Exit For
End If
Next
If Not IsNothing(selTool) Then
selToolFamilyType = ToolFamily.ToolType
Exit For
End If
Next
' disattivo disegno utensile
ToolTreeViewItem.SuspendToolDrawUpdate = True
Select Case selToolFamilyType
Case MCH_TF.DRILLBIT
If m_MatType = MaterialType.STONE Then
If IsNothing(StoneDrillToolParamPageV) Then StoneDrillToolParamPageV = New StoneDrillParamPageV
StoneDrillToolParamPageV.DataContext = selTool
' Recupero lo stile da programma chiamante, Altrienti imposto i colori di Default
If Not m_bPersonalInterface Then
'texbox
m_GeneralBackground = StoneDrillParamPageV.GetGeneralBackground(StoneDrillToolParamPageV)
m_GeneralForeground = StoneDrillParamPageV.GetGeneralForeground(StoneDrillToolParamPageV)
m_GeneralBorderBrush = StoneDrillParamPageV.GetGeneralBorderBrush(StoneDrillToolParamPageV)
m_BorderBrushIsMouseOver = StoneDrillParamPageV.GetBorderBrushIsMouseOver(StoneDrillToolParamPageV)
m_BorderBrushIsFocused = StoneDrillParamPageV.GetBorderBrushIsFocused(StoneDrillToolParamPageV)
m_BackgroundBrdEnable = StoneDrillParamPageV.GetBackgroundBrdEnable(StoneDrillToolParamPageV)
m_BackgroundBrdDisable = StoneDrillParamPageV.GetBackgroundBrdDisable(StoneDrillToolParamPageV)
m_ForegroundTxBlEnable = StoneDrillParamPageV.GetForegroundTxBlEnable(StoneDrillToolParamPageV)
m_ForegroundTxBlDisable = StoneDrillParamPageV.GetForegroundTxBlDisable(StoneDrillToolParamPageV)
m_BackgroundTxBlDisable = StoneDrillParamPageV.GetBackgroundTxBlDisable(StoneDrillToolParamPageV)
'combobox
m_BackgroundCmBxTxBl = StoneDrillParamPageV.GetBackgroundCmBxTxBl(StoneDrillToolParamPageV)
m_BackgroundListCmBxTxBl = StoneDrillParamPageV.GetBackgroundListCmBxTxBl(StoneDrillToolParamPageV)
m_ForegroundCmBxTxBl = StoneDrillParamPageV.GetForegroundCmBxTxBl(StoneDrillToolParamPageV)
m_BorderBrushCmBxTxBl = StoneDrillParamPageV.GetBorderBrushCmBxTxBl(StoneDrillToolParamPageV)
m_BorderThicknessCmBxTxBl = StoneDrillParamPageV.GetBorderThicknessCmBxTxBl(StoneDrillToolParamPageV)
m_VerticalContentAlignmentCmBxTxBl = StoneDrillParamPageV.GetVerticalContentAlignmentCmBxTxBl(StoneDrillToolParamPageV)
m_HeightCmBxTxBl = StoneDrillParamPageV.GetHeightCmBxTxBl(StoneDrillToolParamPageV)
m_WidthCmBxTxBl = StoneDrillParamPageV.GetWidthCmBxTxBl(StoneDrillToolParamPageV)
m_ForegroundTextBoxCmBxTxBl = StoneDrillParamPageV.GetForegroundTextBoxCmBxTxBl(StoneDrillToolParamPageV)
'groupbox
m_MyBorderGrbThickness = StoneDrillParamPageV.GetMyBorderGrbThickness(StoneDrillToolParamPageV)
m_MyForegroundGrbColor = StoneDrillParamPageV.GetMyForegroundGrbColor(StoneDrillToolParamPageV)
'button
m_BackgroundButton = StoneDrillParamPageV.GetBackgroundButton(StoneDrillToolParamPageV)
m_ForegroundButton = StoneDrillParamPageV.GetForegroundButton(StoneDrillToolParamPageV)
m_BorderBrushButton = StoneDrillParamPageV.GetBorderBrushButton(StoneDrillToolParamPageV)
m_BorderThicknessButton = StoneDrillParamPageV.GetBorderThicknessButton(StoneDrillToolParamPageV)
End If
'Imposto stile groupbox
StoneDrillToolParamPageV.MyBorderGrbThickness = m_MyBorderGrbThickness
StoneDrillToolParamPageV.MyForegroundGrbColor = m_MyForegroundGrbColor
' Imposto il colore delle TextBlock (definito nel programma chiamante)
StoneDrillToolParamPageV.BorderBrushIsMouseOver = m_BorderBrushIsMouseOver
StoneDrillToolParamPageV.GeneralBorderBrush = m_GeneralBorderBrush
StoneDrillToolParamPageV.BorderBrushIsFocused = m_BorderBrushIsFocused
StoneDrillToolParamPageV.BackgroundBrdEnable = m_BackgroundBrdEnable
StoneDrillToolParamPageV.BackgroundBrdDisable = m_BackgroundBrdDisable
StoneDrillToolParamPageV.BackgroundTxBlDisable = m_BackgroundTxBlDisable
StoneDrillToolParamPageV.ForegroundTxBlEnable = m_ForegroundTxBlEnable
StoneDrillToolParamPageV.ForegroundTxBlDisable = m_ForegroundTxBlDisable
StoneDrillToolParamPageV.GeneralForeground = m_GeneralForeground
StoneDrillToolParamPageV.GeneralBackground = m_GeneralBackground
'Imposto stile combobox
StoneDrillToolParamPageV.BackgroundCmBxTxBl = m_BackgroundCmBxTxBl
StoneDrillToolParamPageV.BackgroundListCmBxTxBl = m_BackgroundListCmBxTxBl
StoneDrillToolParamPageV.ForegroundCmBxTxBl = m_ForegroundCmBxTxBl
StoneDrillToolParamPageV.BorderBrushCmBxTxBl = m_BorderBrushCmBxTxBl
StoneDrillToolParamPageV.BorderThicknessCmBxTxBl = m_BorderThicknessCmBxTxBl
StoneDrillToolParamPageV.VerticalContentAlignmentCmBxTxBl = m_VerticalContentAlignmentCmBxTxBl
StoneDrillToolParamPageV.HeightCmBxTxBl = m_HeightCmBxTxBl
StoneDrillToolParamPageV.WidthCmBxTxBl = m_WidthCmBxTxBl
StoneDrillToolParamPageV.ForegroundTextBoxCmBxTxBl = m_ForegroundTextBoxCmBxTxBl
'Imposto stile button
StoneDrillToolParamPageV.BackgroundButton = m_BackgroundButton
StoneDrillToolParamPageV.ForegroundButton = m_ForegroundButton
StoneDrillToolParamPageV.BorderBrushButton = m_BorderBrushButton
StoneDrillToolParamPageV.BorderThicknessButton = m_BorderThicknessButton
Return StoneDrillToolParamPageV
ElseIf m_MatType = MaterialType.WOOD Or m_MatType = MaterialType.BEAM Then
If IsNothing(WoodDrillToolParamPageV) Then WoodDrillToolParamPageV = New WoodDrillParamPageV
WoodDrillToolParamPageV.DataContext = selTool
Return WoodDrillToolParamPageV
End If
Case MCH_TF.SAWBLADE
If m_MatType = MaterialType.STONE Then
If IsNothing(StoneSawToolParamPageV) Then StoneSawToolParamPageV = New StoneSawParamPageV
StoneSawToolParamPageV.DataContext = selTool
' Recupero lo stile da programma chiamante, Altrienti imposto i colori di Default
If Not m_bPersonalInterface Then
'texbox
m_GeneralBackground = StoneSawParamPageV.GetGeneralBackground(StoneSawToolParamPageV)
m_GeneralForeground = StoneSawParamPageV.GetGeneralForeground(StoneSawToolParamPageV)
m_GeneralBorderBrush = StoneSawParamPageV.GetGeneralBorderBrush(StoneSawToolParamPageV)
m_BorderBrushIsMouseOver = StoneSawParamPageV.GetBorderBrushIsMouseOver(StoneSawToolParamPageV)
m_BorderBrushIsFocused = StoneSawParamPageV.GetBorderBrushIsFocused(StoneSawToolParamPageV)
m_BackgroundBrdEnable = StoneSawParamPageV.GetBackgroundBrdEnable(StoneSawToolParamPageV)
m_BackgroundBrdDisable = StoneSawParamPageV.GetBackgroundBrdDisable(StoneSawToolParamPageV)
m_ForegroundTxBlEnable = StoneSawParamPageV.GetForegroundTxBlEnable(StoneSawToolParamPageV)
m_ForegroundTxBlDisable = StoneSawParamPageV.GetForegroundTxBlDisable(StoneSawToolParamPageV)
m_BackgroundTxBlDisable = StoneSawParamPageV.GetBackgroundTxBlDisable(StoneSawToolParamPageV)
'combobox
m_BackgroundCmBxTxBl = StoneSawParamPageV.GetBackgroundCmBxTxBl(StoneSawToolParamPageV)
m_BackgroundListCmBxTxBl = StoneSawParamPageV.GetBackgroundListCmBxTxBl(StoneSawToolParamPageV)
m_ForegroundCmBxTxBl = StoneSawParamPageV.GetForegroundCmBxTxBl(StoneSawToolParamPageV)
m_BorderBrushCmBxTxBl = StoneSawParamPageV.GetBorderBrushCmBxTxBl(StoneSawToolParamPageV)
m_BorderThicknessCmBxTxBl = StoneSawParamPageV.GetBorderThicknessCmBxTxBl(StoneSawToolParamPageV)
m_VerticalContentAlignmentCmBxTxBl = StoneSawParamPageV.GetVerticalContentAlignmentCmBxTxBl(StoneSawToolParamPageV)
m_HeightCmBxTxBl = StoneSawParamPageV.GetHeightCmBxTxBl(StoneSawToolParamPageV)
m_WidthCmBxTxBl = StoneSawParamPageV.GetWidthCmBxTxBl(StoneSawToolParamPageV)
m_ForegroundTextBoxCmBxTxBl = StoneSawParamPageV.GetForegroundTextBoxCmBxTxBl(StoneSawToolParamPageV)
'groupbox
m_MyBorderGrbThickness = StoneSawParamPageV.GetMyBorderGrbThickness(StoneSawToolParamPageV)
m_MyForegroundGrbColor = StoneSawParamPageV.GetMyForegroundGrbColor(StoneSawToolParamPageV)
'button
m_BackgroundButton = StoneSawParamPageV.GetBackgroundButton(StoneSawToolParamPageV)
m_ForegroundButton = StoneSawParamPageV.GetForegroundButton(StoneSawToolParamPageV)
m_BorderBrushButton = StoneSawParamPageV.GetBorderBrushButton(StoneSawToolParamPageV)
m_BorderThicknessButton = StoneSawParamPageV.GetBorderThicknessButton(StoneSawToolParamPageV)
End If
'Imposto stile groupbox
StoneSawToolParamPageV.MyBorderGrbThickness = m_MyBorderGrbThickness
StoneSawToolParamPageV.MyForegroundGrbColor = m_MyForegroundGrbColor
' Imposto il colore delle TextBlock (definito nel programma chimamante)
StoneSawToolParamPageV.BorderBrushIsMouseOver = m_BorderBrushIsMouseOver
StoneSawToolParamPageV.GeneralBorderBrush = m_GeneralBorderBrush
StoneSawToolParamPageV.BorderBrushIsFocused = m_BorderBrushIsFocused
StoneSawToolParamPageV.BackgroundBrdEnable = m_BackgroundBrdEnable
StoneSawToolParamPageV.BackgroundBrdDisable = m_BackgroundBrdDisable
StoneSawToolParamPageV.BackgroundTxBlDisable = m_BackgroundTxBlDisable
StoneSawToolParamPageV.ForegroundTxBlEnable = m_ForegroundTxBlEnable
StoneSawToolParamPageV.ForegroundTxBlDisable = m_ForegroundTxBlDisable
StoneSawToolParamPageV.GeneralForeground = m_GeneralForeground
StoneSawToolParamPageV.GeneralBackground = m_GeneralBackground
'Imposto stile combobox
StoneSawToolParamPageV.BackgroundCmBxTxBl = m_BackgroundCmBxTxBl
StoneSawToolParamPageV.BackgroundListCmBxTxBl = m_BackgroundListCmBxTxBl
StoneSawToolParamPageV.ForegroundCmBxTxBl = m_ForegroundCmBxTxBl
StoneSawToolParamPageV.BorderBrushCmBxTxBl = m_BorderBrushCmBxTxBl
StoneSawToolParamPageV.BorderThicknessCmBxTxBl = m_BorderThicknessCmBxTxBl
StoneSawToolParamPageV.VerticalContentAlignmentCmBxTxBl = m_VerticalContentAlignmentCmBxTxBl
StoneSawToolParamPageV.HeightCmBxTxBl = m_HeightCmBxTxBl
StoneSawToolParamPageV.WidthCmBxTxBl = m_WidthCmBxTxBl
StoneSawToolParamPageV.ForegroundTextBoxCmBxTxBl = m_ForegroundTextBoxCmBxTxBl
'Imposto stile button
StoneSawToolParamPageV.BackgroundButton = m_BackgroundButton
StoneSawToolParamPageV.ForegroundButton = m_ForegroundButton
StoneSawToolParamPageV.BorderBrushButton = m_BorderBrushButton
StoneSawToolParamPageV.BorderThicknessButton = m_BorderThicknessButton
Return StoneSawToolParamPageV
ElseIf m_MatType = MaterialType.WOOD Or m_MatType = MaterialType.BEAM Then
If IsNothing(WoodSawToolParamPageV) Then WoodSawToolParamPageV = New WoodSawParamPageV
WoodSawToolParamPageV.DataContext = selTool
Return WoodSawToolParamPageV
End If
Case MCH_TF.MILL
If m_MatType = MaterialType.STONE Then
If IsNothing(StoneMillToolParamPageV) Then StoneMillToolParamPageV = New StoneMillParamPageV
StoneMillToolParamPageV.DataContext = selTool
' Recupero lo stile da programma chiamante, Altrienti imposto i colori di Default
If Not m_bPersonalInterface Then
'texbox
m_GeneralBackground = StoneMillParamPageV.GetGeneralBackground(StoneMillToolParamPageV)
m_GeneralForeground = StoneMillParamPageV.GetGeneralForeground(StoneMillToolParamPageV)
m_GeneralBorderBrush = StoneMillParamPageV.GetGeneralBorderBrush(StoneMillToolParamPageV)
m_BorderBrushIsMouseOver = StoneMillParamPageV.GetBorderBrushIsMouseOver(StoneMillToolParamPageV)
m_BorderBrushIsFocused = StoneMillParamPageV.GetBorderBrushIsFocused(StoneMillToolParamPageV)
m_BackgroundBrdEnable = StoneMillParamPageV.GetBackgroundBrdEnable(StoneMillToolParamPageV)
m_BackgroundBrdDisable = StoneMillParamPageV.GetBackgroundBrdDisable(StoneMillToolParamPageV)
m_ForegroundTxBlEnable = StoneMillParamPageV.GetForegroundTxBlEnable(StoneMillToolParamPageV)
m_ForegroundTxBlDisable = StoneMillParamPageV.GetForegroundTxBlDisable(StoneMillToolParamPageV)
m_BackgroundTxBlDisable = StoneMillParamPageV.GetBackgroundTxBlDisable(StoneMillToolParamPageV)
'combobox
m_BackgroundCmBxTxBl = StoneMillParamPageV.GetBackgroundCmBxTxBl(StoneMillToolParamPageV)
m_BackgroundListCmBxTxBl = StoneMillParamPageV.GetBackgroundListCmBxTxBl(StoneMillToolParamPageV)
m_ForegroundCmBxTxBl = StoneMillParamPageV.GetForegroundCmBxTxBl(StoneMillToolParamPageV)
m_BorderBrushCmBxTxBl = StoneMillParamPageV.GetBorderBrushCmBxTxBl(StoneMillToolParamPageV)
m_BorderThicknessCmBxTxBl = StoneMillParamPageV.GetBorderThicknessCmBxTxBl(StoneMillToolParamPageV)
m_VerticalContentAlignmentCmBxTxBl = StoneMillParamPageV.GetVerticalContentAlignmentCmBxTxBl(StoneMillToolParamPageV)
m_HeightCmBxTxBl = StoneMillParamPageV.GetHeightCmBxTxBl(StoneMillToolParamPageV)
m_WidthCmBxTxBl = StoneMillParamPageV.GetWidthCmBxTxBl(StoneMillToolParamPageV)
m_ForegroundTextBoxCmBxTxBl = StoneMillParamPageV.GetForegroundTextBoxCmBxTxBl(StoneMillToolParamPageV)
'groupbox
m_MyBorderGrbThickness = StoneMillParamPageV.GetMyBorderGrbThickness(StoneMillToolParamPageV)
m_MyForegroundGrbColor = StoneMillParamPageV.GetMyForegroundGrbColor(StoneMillToolParamPageV)
'button
m_BackgroundButton = StoneMillParamPageV.GetBackgroundButton(StoneMillToolParamPageV)
m_ForegroundButton = StoneMillParamPageV.GetForegroundButton(StoneMillToolParamPageV)
m_BorderBrushButton = StoneMillParamPageV.GetBorderBrushButton(StoneMillToolParamPageV)
m_BorderThicknessButton = StoneMillParamPageV.GetBorderThicknessButton(StoneMillToolParamPageV)
End If
'Imposto stile groupbox
StoneMillToolParamPageV.MyBorderGrbThickness = m_MyBorderGrbThickness
StoneMillToolParamPageV.MyForegroundGrbColor = m_MyForegroundGrbColor
' Imposto il colore delle TextBlock (definito nel programma chimamante)
StoneMillToolParamPageV.BorderBrushIsMouseOver = m_BorderBrushIsMouseOver
StoneMillToolParamPageV.GeneralBorderBrush = m_GeneralBorderBrush
StoneMillToolParamPageV.BorderBrushIsFocused = m_BorderBrushIsFocused
StoneMillToolParamPageV.BackgroundBrdEnable = m_BackgroundBrdEnable
StoneMillToolParamPageV.BackgroundBrdDisable = m_BackgroundBrdDisable
StoneMillToolParamPageV.BackgroundTxBlDisable = m_BackgroundTxBlDisable
StoneMillToolParamPageV.ForegroundTxBlEnable = m_ForegroundTxBlEnable
StoneMillToolParamPageV.ForegroundTxBlDisable = m_ForegroundTxBlDisable
StoneMillToolParamPageV.GeneralForeground = m_GeneralForeground
StoneMillToolParamPageV.GeneralBackground = m_GeneralBackground
'Imposto stile combobox
StoneMillToolParamPageV.BackgroundCmBxTxBl = m_BackgroundCmBxTxBl
StoneMillToolParamPageV.BackgroundListCmBxTxBl = m_BackgroundListCmBxTxBl
StoneMillToolParamPageV.ForegroundCmBxTxBl = m_ForegroundCmBxTxBl
StoneMillToolParamPageV.BorderBrushCmBxTxBl = m_BorderBrushCmBxTxBl
StoneMillToolParamPageV.BorderThicknessCmBxTxBl = m_BorderThicknessCmBxTxBl
StoneMillToolParamPageV.VerticalContentAlignmentCmBxTxBl = m_VerticalContentAlignmentCmBxTxBl
StoneMillToolParamPageV.HeightCmBxTxBl = m_HeightCmBxTxBl
StoneMillToolParamPageV.WidthCmBxTxBl = m_WidthCmBxTxBl
StoneMillToolParamPageV.ForegroundTextBoxCmBxTxBl = m_ForegroundTextBoxCmBxTxBl
'Imposto stile togglebutton
StoneMillToolParamPageV.BackgroundButton = m_BackgroundButton
StoneMillToolParamPageV.ForegroundButton = m_ForegroundButton
StoneMillToolParamPageV.BorderBrushButton = m_BorderBrushButton
StoneMillToolParamPageV.BorderThicknessButton = m_BorderThicknessButton
Return StoneMillToolParamPageV
ElseIf m_MatType = MaterialType.WOOD Then
If IsNothing(WoodMillToolParamPageV) Then WoodMillToolParamPageV = New WoodMillParamPageV
WoodMillToolParamPageV.DataContext = selTool
Return WoodMillToolParamPageV
ElseIf m_MatType = MaterialType.BEAM Then
If IsNothing(BeamMillToolParamPageV) Then BeamMillToolParamPageV = New BeamMillParamPageV
BeamMillToolParamPageV.DataContext = selTool
Return BeamMillToolParamPageV
End If
Case MCH_TF.MORTISE
If IsNothing(MortiseToolParamPageV) Then MortiseToolParamPageV = New MortiseParamPageV
MortiseToolParamPageV.DataContext = selTool
Return MortiseToolParamPageV
Case MCH_TF.CHISEL
If IsNothing(ChiselToolParamPageV) Then ChiselToolParamPageV = New ChiselParamPageV
ChiselToolParamPageV.DataContext = selTool
Return ChiselToolParamPageV
Case MCH_TF.WATERJET
If IsNothing(WaterjetToolParamPageV) Then WaterjetToolParamPageV = New WaterjetParamPageV
WaterjetToolParamPageV.DataContext = selTool
' Recupero lo stile da programma chiamante, Altrienti imposto i colori di Default
If Not m_bPersonalInterface Then
'texbox
m_GeneralBackground = WaterjetParamPageV.GetGeneralBackground(WaterjetToolParamPageV)
m_GeneralForeground = WaterjetParamPageV.GetGeneralForeground(WaterjetToolParamPageV)
m_GeneralBorderBrush = WaterjetParamPageV.GetGeneralBorderBrush(WaterjetToolParamPageV)
m_BorderBrushIsMouseOver = WaterjetParamPageV.GetBorderBrushIsMouseOver(WaterjetToolParamPageV)
m_BorderBrushIsFocused = WaterjetParamPageV.GetBorderBrushIsFocused(WaterjetToolParamPageV)
m_BackgroundBrdEnable = WaterjetParamPageV.GetBackgroundBrdEnable(WaterjetToolParamPageV)
m_BackgroundBrdDisable = WaterjetParamPageV.GetBackgroundBrdDisable(WaterjetToolParamPageV)
m_ForegroundTxBlEnable = WaterjetParamPageV.GetForegroundTxBlEnable(WaterjetToolParamPageV)
m_ForegroundTxBlDisable = WaterjetParamPageV.GetForegroundTxBlDisable(WaterjetToolParamPageV)
m_BackgroundTxBlDisable = WaterjetParamPageV.GetBackgroundTxBlDisable(WaterjetToolParamPageV)
'combobox
m_BackgroundCmBxTxBl = WaterjetParamPageV.GetBackgroundCmBxTxBl(WaterjetToolParamPageV)
m_BackgroundListCmBxTxBl = WaterjetParamPageV.GetBackgroundListCmBxTxBl(WaterjetToolParamPageV)
m_ForegroundCmBxTxBl = WaterjetParamPageV.GetForegroundCmBxTxBl(WaterjetToolParamPageV)
m_BorderBrushCmBxTxBl = WaterjetParamPageV.GetBorderBrushCmBxTxBl(WaterjetToolParamPageV)
m_BorderThicknessCmBxTxBl = WaterjetParamPageV.GetBorderThicknessCmBxTxBl(WaterjetToolParamPageV)
m_VerticalContentAlignmentCmBxTxBl = WaterjetParamPageV.GetVerticalContentAlignmentCmBxTxBl(WaterjetToolParamPageV)
m_HeightCmBxTxBl = WaterjetParamPageV.GetHeightCmBxTxBl(WaterjetToolParamPageV)
m_WidthCmBxTxBl = WaterjetParamPageV.GetWidthCmBxTxBl(WaterjetToolParamPageV)
m_ForegroundTextBoxCmBxTxBl = WaterjetParamPageV.GetForegroundTextBoxCmBxTxBl(WaterjetToolParamPageV)
'groupbox
m_MyBorderGrbThickness = WaterjetParamPageV.GetMyBorderGrbThickness(WaterjetToolParamPageV)
m_MyForegroundGrbColor = WaterjetParamPageV.GetMyForegroundGrbColor(WaterjetToolParamPageV)
'button
m_BackgroundButton = WaterjetParamPageV.GetBackgroundButton(WaterjetToolParamPageV)
m_ForegroundButton = WaterjetParamPageV.GetForegroundButton(WaterjetToolParamPageV)
m_BorderBrushButton = WaterjetParamPageV.GetBorderBrushButton(WaterjetToolParamPageV)
m_BorderThicknessButton = WaterjetParamPageV.GetBorderThicknessButton(WaterjetToolParamPageV)
End If
'Imposto stile groupbox
WaterjetToolParamPageV.MyBorderGrbThickness = m_MyBorderGrbThickness
WaterjetToolParamPageV.MyForegroundGrbColor = m_MyForegroundGrbColor
' Imposto il colore delle TextBlock (definito nel programma chimamante)
WaterjetToolParamPageV.BorderBrushIsMouseOver = m_BorderBrushIsMouseOver
WaterjetToolParamPageV.GeneralBorderBrush = m_GeneralBorderBrush
WaterjetToolParamPageV.BorderBrushIsFocused = m_BorderBrushIsFocused
WaterjetToolParamPageV.BackgroundBrdEnable = m_BackgroundBrdEnable
WaterjetToolParamPageV.BackgroundBrdDisable = m_BackgroundBrdDisable
WaterjetToolParamPageV.BackgroundTxBlDisable = m_BackgroundTxBlDisable
WaterjetToolParamPageV.ForegroundTxBlEnable = m_ForegroundTxBlEnable
WaterjetToolParamPageV.ForegroundTxBlDisable = m_ForegroundTxBlDisable
WaterjetToolParamPageV.GeneralForeground = m_GeneralForeground
WaterjetToolParamPageV.GeneralBackground = m_GeneralBackground
'Imposto stile combobox
WaterjetToolParamPageV.BackgroundCmBxTxBl = m_BackgroundCmBxTxBl
WaterjetToolParamPageV.BackgroundListCmBxTxBl = m_BackgroundListCmBxTxBl
WaterjetToolParamPageV.ForegroundCmBxTxBl = m_ForegroundCmBxTxBl
WaterjetToolParamPageV.BorderBrushCmBxTxBl = m_BorderBrushCmBxTxBl
WaterjetToolParamPageV.BorderThicknessCmBxTxBl = m_BorderThicknessCmBxTxBl
WaterjetToolParamPageV.VerticalContentAlignmentCmBxTxBl = m_VerticalContentAlignmentCmBxTxBl
WaterjetToolParamPageV.HeightCmBxTxBl = m_HeightCmBxTxBl
WaterjetToolParamPageV.WidthCmBxTxBl = m_WidthCmBxTxBl
WaterjetToolParamPageV.ForegroundTextBoxCmBxTxBl = m_ForegroundTextBoxCmBxTxBl
'Imposto stile togglebutton
WaterjetToolParamPageV.BackgroundButton = m_BackgroundButton
WaterjetToolParamPageV.ForegroundButton = m_ForegroundButton
WaterjetToolParamPageV.BorderBrushButton = m_BorderBrushButton
WaterjetToolParamPageV.BorderThicknessButton = m_BorderThicknessButton
Return WaterjetToolParamPageV
Case MCH_TF.PROBE
If IsNothing(ProbeToolParamPageV) Then ProbeToolParamPageV = New ProbeParamPageV
ProbeToolParamPageV.DataContext = selTool
Return ProbeToolParamPageV
End Select
' riattivo disegno utensile
ToolTreeViewItem.SuspendToolDrawUpdate = False
Return Nothing
End Get
End Property
'PROJECT PAGE'S SCENE FIELDS AND PROPERTIES
' Reference to the ProjectScene
Private WithEvents m_ToolScene As New Scene
' Reference to the ProjectSceneHost
Private SceneHost As WindowsFormsHost
' Property used to bind the scene to the WindowsFormsHost in XAML
Private m_bfirst As Boolean = True
Public ReadOnly Property ToolSceneHost As WindowsFormsHost
Get
If m_bfirst Then
SceneHost = New WindowsFormsHost() With {.Child = m_ToolScene}
If Not m_ToolScene.Init() Then
EgtOutLog("Error in Tool scene creation")
'Application.Msn.NotifyColleagues(Application.CLOSEAPPLICATION)
End If
m_ToolDbSceneContext = m_ToolScene.GetCtx()
' inibisco selezione diretta da Scene
m_ToolScene.SetStatusNull()
m_bfirst = False
End If
Return SceneHost
End Get
End Property
Public Sub SetBackgroundColor(BackTopColor As Color3d, BackBotColor As Color3d)
If Not IsNothing(m_ToolScene) Then
m_ToolScene.SetViewBackground(BackTopColor, BackBotColor)
End If
End Sub
' visibilità parametro Active
Private m_Active_Visibility As Boolean
Public ReadOnly Property Active_Visibility As Visibility
Get
Return If(m_Active_Visibility, Visibility.Visible, Visibility.Collapsed)
End Get
End Property
Public Overridable Sub OnCursorPos(ByVal sender As Object, ByVal sCursorPos As String) Handles m_ToolScene.OnCursorPos
LibMap.refStatusBarVM.SetCurrPos(sCursorPos)
End Sub
' Definizione comandi
Private m_cmdNew As ICommand
Private m_cmdSave As ICommand
Private m_cmdRemove As ICommand
Private m_cmdImport As ICommand
Private m_cmdExport As ICommand
Private m_cmdReloadTool As ICommand
Private m_cmdCloseToolsDb As ICommand
#Region "MESSAGES"
'Definizione dei messaggi della pagina
Public ReadOnly Property NewMsg As String
Get
Return EgtMsg(31701) ' Nuovo
End Get
End Property
Public ReadOnly Property SaveMsg As String
Get
Return EgtMsg(31702) ' Salva
End Get
End Property
Public ReadOnly Property RemoveMsg As String
Get
Return EgtMsg(31703) ' Rimuovi
End Get
End Property
Public ReadOnly Property ImportMsg As String
Get
Return EgtMsg(31161) ' Importa
End Get
End Property
Public ReadOnly Property ExportMsg As String
Get
Return EgtMsg(31162) ' Esporta
End Get
End Property
Public ReadOnly Property ResetMsg As String
Get
Return EgtMsg(31167) ' Reset
End Get
End Property
Public ReadOnly Property CorrTxBl As String
Get
Return EgtMsg(31051) ' Correttore
End Get
End Property
Public ReadOnly Property ExitParTxBl As String
Get
Return EgtMsg(31052) ' Uscita
End Get
End Property
Public ReadOnly Property TypeTxBl As String
Get
Return EgtMsg(31053) ' Tipo
End Get
End Property
Public ReadOnly Property CoolantTxBl As String
Get
Return EgtMsg(31054) ' Refrigerante
End Get
End Property
Public ReadOnly Property CornRadTxBl As String
Get
Return EgtMsg(31055) ' Raggio Corner
End Get
End Property
Public ReadOnly Property DiamTxBl As String
Get
Return EgtMsg(31056) ' Diametro
End Get
End Property
Public ReadOnly Property TotDiamTxBl As String
Get
Return EgtMsg(31057) ' Diametro Totale
End Get
End Property
Public ReadOnly Property FeedTxBl As String
Get
Return EgtMsg(31058) ' Avanzamento
End Get
End Property
Public ReadOnly Property EndFeedTxBl As String
Get
Return EgtMsg(31059) ' Avanzamento Finale
End Get
End Property
Public ReadOnly Property StartFeedTxBl As String
Get
Return EgtMsg(31060) ' Avanzamento Iniziale
End Get
End Property
Public ReadOnly Property LenTxBl As String
Get
Return EgtMsg(31062) ' Lunghezza
End Get
End Property
Public ReadOnly Property TotLenTxBl As String
Get
Return EgtMsg(31063) ' Lunghezza Totale
End Get
End Property
Public ReadOnly Property MaxMatTxBl As String
Get
Return EgtMsg(31064) ' Massimo Materiale
End Get
End Property
Public ReadOnly Property LonOffsetTxBl As String
Get
Return EgtMsg(31065) ' Offset Longitudinale
End Get
End Property
Public ReadOnly Property RadOffsetTxBl As String
Get
Return EgtMsg(31066) ' Offset Radiale
End Get
End Property
Public ReadOnly Property SpeedTxBl As String
Get
Return EgtMsg(31067) ' Rotazione
End Get
End Property
Public ReadOnly Property SideAngTxBl As String
Get
Return EgtMsg(31068) ' Angolo di Lato
End Get
End Property
Public ReadOnly Property MaxSpeedTxBl As String
Get
Return EgtMsg(31069) ' Rotazione Massima
End Get
End Property
Public ReadOnly Property ThickTxBl As String
Get
Return EgtMsg(31070) ' Spessore
End Get
End Property
Public ReadOnly Property StemDiamTxBl As String
Get
Return EgtMsg(31081) ' Diametro del Gambo
End Get
End Property
Public ReadOnly Property MaxAbsorptionTxBl As String
Get
Return EgtMsg(31071) ' Assorbimento Massimo
End Get
End Property
Public ReadOnly Property MinFeedTxBl As String
Get
Return EgtMsg(31072) ' Avanzamento Minimo
End Get
End Property
Public ReadOnly Property DrawTxBl As String
Get
Return EgtMsg(31073) ' Disegno
End Get
End Property
Public ReadOnly Property HeadTxBl As String
Get
Return EgtMsg(31074) ' Testa
End Get
End Property
Public ReadOnly Property NameParTxBl As String
Get
Return EgtMsg(31075) ' Nome
End Get
End Property
Public ReadOnly Property UserNotesTxBl As String
Get
Return EgtMsg(31076) ' Note
End Get
End Property
Public ReadOnly Property TcPosTxBl As String
Get
Return EgtMsg(31077) ' Posiz. Cambio Utensile
End Get
End Property
#End Region
#Region "CONSTRUCTOR"
Sub New(sMachineDirPath As String, sMachineIniPath As String, ProjectSceneContext As Integer, Optional sMatType As String = "Wood", Optional bVisibleSysNotes As Boolean = False)
m_bActive = True
m_ProjectSceneContext = ProjectSceneContext
m_sMachineIniPath = sMachineIniPath
m_sScriptDirPath = sMachineDirPath & "\Scripts"
m_sToolDirPath = sMachineDirPath & "\Tools"
' leggo direttorio toolmakers
GetMainPrivateProfileString(S_MACH, K_TOOLMAKERSDIR, "", m_sToolMakersDirPath)
m_bVisibleSysNotes = bVisibleSysNotes
EgtUILib.GetPrivateProfileString(S_GENERAL, K_MATERIAL, sMatType, sMatType, sMachineIniPath)
Select Case sMatType
Case "Stone"
m_MatType = MaterialType.STONE
Case "Wood"
m_MatType = MaterialType.WOOD
Case "Beam"
m_MatType = MaterialType.BEAM
Case "Additive"
m_MatType = MaterialType.WOOD
Case Else
' Se il materiale spcificato nel file INI della macchina non corrisponde ai 3 sopracitati viene emesso un messaggio di errore
m_MatType = Nothing
MsgBox(EgtMsg(31409), MsgBoxStyle.Exclamation, EgtMsg(31551))
'EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(31409), EgtMsg(31551), MessageBoxButton.YesNo, MessageBoxImage.Exclamation) ' Materiale della macchina non riconosciuto Errore
Exit Sub
End Select
' Passo all'item della lista il delegato alla funzione che permette di cancellare una lavorazione
ToolTreeViewItem.m_delRemoveTool = AddressOf RemoveTool
' Passo all'item della lista il delegato alla funzione che permette di disattivare la lista delle lavorazioni
ToolTreeViewItem.m_delErrorOnTool = AddressOf ErrorOnTool
FamilyToolTreeViewItem.m_delErrorOnTool = AddressOf ErrorOnTool
' Passo all'item della lista il delegato alla funzione che permette di disattivare la lista delle lavorazioni
ToolTreeViewItem.m_delIsEnabledBtns = AddressOf IsEnabledBtns
FamilyToolTreeViewItem.m_delIsEnabledBtns = AddressOf IsEnabledBtns
ToolTreeViewItem.m_delNotifyPropertyChanged = AddressOf ccc
FamilyToolTreeViewItem.m_delNotifyPropertyChanged = AddressOf ccc
' Passo all'item della lista il delegato alla funzione che restituisce l'utensile selezionato
ToolTreeViewItem.m_delGetSelectedTool = AddressOf GetSelectedTool
LoadSelectedMachineTools()
' carico Lua che contiene le funzioni di attrezzaggio
EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext)
Dim bScriptFileExec As Boolean = EgtLuaExecFile(m_sScriptDirPath & "\SetUp.lua")
' carico lista teste
ToolTreeViewItem.m_OrigHeadList.Clear()
Dim sHeads As String = String.Empty
EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext)
If EgtGetAllHeadsNames(sHeads) Then
Dim sHeadList() As String = sHeads.Split(","c)
For HeadIndex = 0 To sHeadList.Count - 1
If bScriptFileExec Then
' Verifico che la testa sia valida
EgtLuaSetGlobStringVar("STU.HEAD", sHeadList(HeadIndex))
If EgtLuaExistsFunction("STU.IsValidHead") AndAlso EgtLuaCallFunction("STU.IsValidHead") Then
' Leggo variabili
Dim IsValidHead As Boolean = False
EgtLuaGetGlobBoolVar("STU.ISVALID", IsValidHead)
If Not IsValidHead Then Continue For
End If
End If
' Cerco messaggio per questa testa
Dim sHText As String = String.Empty
EgtUILib.GetPrivateProfileString(S_HEADS, sHeadList(HeadIndex), "", sHText, m_sMachineIniPath)
Dim sHTextMsg As String = String.Empty
If IsNumeric(sHText) Then
sHTextMsg = EgtMsg(CInt(sHText))
If sHTextMsg = ("Msg" & CInt(sHText)) Then
sHTextMsg = sHText
End If
Else
sHTextMsg = sHText
End If
sHTextMsg &= " (" & sHeadList(HeadIndex) & ")"
ToolTreeViewItem.m_OrigHeadList.Add(New HeadItem(sHeadList(HeadIndex), sHTextMsg))
Next
Else
MessageBox.Show("Impossible loading Head list from machine!", "Error", MessageBoxButton.OK, MessageBoxImage.Error)
'EgtMessageBoxV.Show(Application.Current.MainWindow, "Impossible loading Head list from machine!", "Error", MessageBoxButton.OK, MessageBoxImage.Error)
EgtOutLog("Error: Impossible loading Head list from machine!")
End If
ToolTreeViewItem.m_OrigTcPosList.Clear()
If bScriptFileExec Then
' creo lista di tutti i TcPos
Dim nPosIndex As Integer = 1
Dim sTcPos As String = String.Empty
Dim nErr As Integer = 0
While nErr = 0
EgtLuaSetGlobIntVar("STU.INDEX", nPosIndex)
If Not EgtLuaCallFunction("STU.GetTcPosFromPos") Then Exit While
' Leggo variabili
EgtLuaGetGlobStringVar("STU.TCPOS", sTcPos)
If Not EgtLuaGetGlobIntVar("STU.ERR", nErr) Then nErr = 999
If nErr = 0 Then
ToolTreeViewItem.m_OrigTcPosList.Add(sTcPos)
End If
nPosIndex += 1
End While
End If
If Not bScriptFileExec Then
MessageBox.Show(EgtMsg(31125), EgtMsg(31126), MessageBoxButton.OK, MessageBoxImage.Error)
'EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(31125), EgtMsg(31126), MessageBoxButton.OK, MessageBoxImage.Error) ' File di configurazione attrezzaggio non trovato! - Errore
EgtOutLog("Error: SetUp configuration file not found!")
End If
' leggo da ini se parametro Active è attivo
m_Active_Visibility = (EgtUILib.GetPrivateProfileInt(S_TOOLS, K_ACTIVE, 0, m_sMachineIniPath) <> 0)
LibMap.SetRefToolDbWindowVM(Me)
NotifyPropertyChanged(NameOf(ParamPageV))
End Sub
#End Region ' Constructor
#Region "METHODS"
Private Sub ccc()
NotifyPropertyChanged(NameOf(ParamPageV))
End Sub
Private Sub IsEnabledBtns(bIsEnabledNewBtn As Boolean, bIsEnabledSaveBtn As Boolean, bIsEnabledDeleteBtn As Boolean)
m_IsEnabledNewBtn = bIsEnabledNewBtn
m_IsEnabledSaveBtn = bIsEnabledSaveBtn
m_IsEnabledRemoveBtn = bIsEnabledDeleteBtn
NotifyPropertyChanged(NameOf(IsEnabledNewBtn))
NotifyPropertyChanged(NameOf(IsEnabledSaveBtn))
NotifyPropertyChanged(NameOf(IsEnabledRemoveBtn))
NotifyPropertyChanged(NameOf(IsEnabledImpExpBtn))
End Sub
' Quando chiamato, disattiva tutti gli item dell'albero o li riattiva a seconda che ci sia o meno un errore
Private Sub ErrorOnTool(bIsEnabled As Boolean)
For Each FamilyToolItem In ToolsList
FamilyToolItem.IsEnabled = Not bIsEnabled
Next
End Sub
'''
''' Method that search tools for the currently selected Machine and add it to the ToolsList.
'''
Private Sub LoadSelectedMachineTools()
' Creo la lista degli utensili (leggo tutti gli utensili)
Dim ActiveToolsFamilies() As ToolsFamily = MachineUtility.ReadToolFamilies(m_sMachineIniPath)
For Each ToolsFamily In ActiveToolsFamilies
Dim FamilyTreeView As New FamilyToolTreeViewItem(ToolsFamily.Name, ToolsFamily.Id)
ToolsList.Add(FamilyTreeView)
Dim nType As Integer = 0
Dim ToolName As String = String.Empty
EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext)
' distinguo il tipo di fresa
If ToolsFamily.Id = MCH_TF.MILL And MatType = MaterialType.STONE Then
If ToolsFamily.Name = EgtMsg(90754) Then
' MOLA SCASSO
nType = 0
If EgtTdbGetFirstTool(ToolsFamily.Id, ToolName, nType) Then
If nType = MCH_TY.MILL_NOTIP Then
FamilyTreeView.Items.Add(New ToolTreeViewItem(ToolName))
End If
While EgtTdbGetNextTool(ToolsFamily.Id, ToolName, nType)
If nType = MCH_TY.MILL_NOTIP Then
FamilyTreeView.Items.Add(New ToolTreeViewItem(ToolName))
End If
End While
End If
ElseIf ToolsFamily.Name = EgtMsg(90756) Then
' MOLA LUCIDANTE
nType = 0
If EgtTdbGetFirstTool(ToolsFamily.Id, ToolName, nType) Then
If nType = MCH_TY.MILL_POLISHING Then
FamilyTreeView.Items.Add(New ToolTreeViewItem(ToolName))
End If
While EgtTdbGetNextTool(ToolsFamily.Id, ToolName, nType)
If nType = MCH_TY.MILL_POLISHING Then
FamilyTreeView.Items.Add(New ToolTreeViewItem(ToolName))
End If
End While
End If
Else
nType = 0
If EgtTdbGetFirstTool(ToolsFamily.Id, ToolName, nType) Then
If nType = MCH_TY.MILL_STD Then
FamilyTreeView.Items.Add(New ToolTreeViewItem(ToolName))
End If
While EgtTdbGetNextTool(ToolsFamily.Id, ToolName, nType)
If nType = MCH_TY.MILL_STD Then
FamilyTreeView.Items.Add(New ToolTreeViewItem(ToolName))
End If
End While
End If
End If
' riparto con il ciclo for
Continue For
End If
If EgtTdbGetFirstTool(ToolsFamily.Id, ToolName, nType) Then
FamilyTreeView.Items.Add(New ToolTreeViewItem(ToolName))
While EgtTdbGetNextTool(ToolsFamily.Id, ToolName, nType)
FamilyTreeView.Items.Add(New ToolTreeViewItem(ToolName))
End While
End If
Next
' Se esiste almeno una famiglia di utensili, la seleziono
If ToolsList.Count > 0 Then
ToolsList(0).IsSelected = True
ToolsList(0).NotifyPropertyChanged("IsSelected")
End If
End Sub
Private Function GetSelectedTool() As ToolTreeViewItem
For Each ToolFamily In m_ToolsList
For Each Tool In ToolFamily.Items
If Tool.m_IsSelected Then
Return DirectCast(Tool, ToolTreeViewItem)
End If
Next
Next
Return Nothing
End Function
' Funzione che aggiorna setup default con tool che hanno parametro Active
' (deve essere sovrascitta se il programma prevede l'uso del parametro Active)
Public Overridable Function UpdateDefSetup() As Boolean
Return True
End Function
' Funzione che verifica modifica utensile selezionato ed eventualmente chiede se salvarlo
Public Function VerifySelectedToolModification() As Boolean
' Se non c'è utensile selezionato, esco con continuazione
If IsNothing(SelTool) Then Return True
' Se utensile selezionato non valido, esco con blocco
If Not SelTool.IsValid() Then Return False
' Verifico salvataggio
SelTool.WriteToolParam()
If EgtTdbIsCurrToolModified() Or SelTool.m_IsModifiedName Or SelTool.NewTool Then
Select Case MsgBox(EgtMsg(31100), MsgBoxStyle.YesNoCancel, EgtMsg(31101))
'Select Case EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(31100), EgtMsg(31101), MessageBoxButton.YesNo) ' Salvare l'utensile modificato ? - SALVA
Case MsgBoxResult.Yes
SelTool.NewTool = False
SelTool.m_Name = SelTool.m_Name.Trim()
SelTool.WriteToolName()
EgtTdbSaveCurrTool()
Case MsgBoxResult.No
If SelTool.NewTool Then
RemoveTool(SelTool)
ElseIf SelTool.m_IsModifiedName Then
Dim DbName As String = String.Empty
EgtTdbGetCurrToolParam(MCH_TP.NAME, DbName)
SelTool.NamePar = DbName
End If
Case MsgBoxResult.Cancel
Return False
End Select
End If
Return True
End Function
'''
''' Method that search imported tools for the currently selected Machine and add it to the ToolsList.
'''
Private Sub LoadImportedMachineTools(vsImportedTools As String())
' Leggo tutti gli utensili presenti nella Macchina (quindi anche quelli appena importati).
Dim ActiveToolsFamilies() As ToolsFamily = MachineUtility.ReadToolFamilies(m_sMachineIniPath)
Dim ToolsFamilyIndex As Integer = 0
For Each ToolsFamily In ActiveToolsFamilies
Dim FamilyTreeView As New FamilyToolTreeViewItem(ToolsFamily.Name, ToolsFamily.Id)
Dim ToolFamilyItem = ToolsList.FirstOrDefault(Function(ToolFamily) ToolFamily.ToolType = FamilyTreeView.ToolType)
If IsNothing(ToolFamilyItem) Then
ToolsList.Insert(ToolsFamilyIndex, FamilyTreeView)
End If
Dim nType As Integer = 0
Dim ToolName As String = String.Empty
Dim ToolIndex As Integer = 0
EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext)
If EgtTdbGetFirstTool(ToolsFamily.Id, ToolName, nType) Then
Dim ToolItem = ToolsList(ToolsFamilyIndex).Items.FirstOrDefault(Function(Tool) Tool.Name = ToolName)
If IsNothing(ToolItem) Then
' Se leggo un utensile non presente nella ToolsList visualizzata lo aggiungo ad essa.
ToolsList(ToolsFamilyIndex).Items.Insert(ToolIndex, New ToolTreeViewItem(ToolName))
ElseIf vsImportedTools.Contains(ToolName) Then
' Se un utensile è presente nella ToolsList visualizzata ma nel contempo è nell'array vsImported
' vuol dire che è stato sovrascritto perciò lo rimuovo e lo riaggiungo alla ToolsList.
ToolsList(ToolsFamilyIndex).Items.Remove(ToolsList(ToolsFamilyIndex).Items.FirstOrDefault(Function(Tool) Tool.Name = ToolName))
ToolsList(ToolsFamilyIndex).Items.Insert(ToolIndex, New ToolTreeViewItem(ToolName))
End If
ToolIndex += 1
While EgtTdbGetNextTool(ToolsFamily.Id, ToolName, nType)
ToolItem = ToolsList(ToolsFamilyIndex).Items.FirstOrDefault(Function(Tool) Tool.Name = ToolName)
If IsNothing(ToolItem) Then
' Se leggo un utensile non presente nella ToolsList visualizzata lo aggiungo ad essa.
ToolsList(ToolsFamilyIndex).Items.Insert(ToolIndex, New ToolTreeViewItem(ToolName))
ElseIf vsImportedTools.Contains(ToolName) Then
' Se un utensile è presente nella ToolsList visualizzata ma nel contempo è nell'array vsImported
' vuol dire che è stato sovrascritto perciò lo rimuovo e lo riaggiungo alla ToolsList.
ToolsList(ToolsFamilyIndex).Items.Remove(ToolsList(ToolsFamilyIndex).Items.FirstOrDefault(Function(Tool) Tool.Name = ToolName))
ToolsList(ToolsFamilyIndex).Items.Insert(ToolIndex, New ToolTreeViewItem(ToolName))
End If
ToolIndex += 1
End While
End If
ToolsFamilyIndex += 1
Next
End Sub
#End Region ' Methods
#Region "COMMANDS"
#Region "NewCommand"
'''
''' Returns a command that create a new tool.
'''
Public ReadOnly Property NewCommand As ICommand
Get
If m_cmdNew Is Nothing Then
m_cmdNew = New Command(AddressOf NewPar)
End If
Return m_cmdNew
End Get
End Property
'''
''' Creata the new tool. This method is invoked by the NewCommand.
'''
Public Overridable Sub NewPar(ByVal param As Object)
EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext)
' Verifico se sia selezionata una famiglia
Dim NewToolItem As ToolTreeViewItem
If TypeOf param Is FamilyToolTreeViewItem Then
Dim ToolFamily As FamilyToolTreeViewItem = DirectCast(param, FamilyToolTreeViewItem)
Dim NewName As String = ToolFamily.Name
EgtTdbGetToolNewName(NewName)
If EgtTdbAddTool(NewName, ToolFamily.ToolType) Then
NewToolItem = New ToolTreeViewItem(NewName)
ToolFamily.Items.Add(NewToolItem)
EgtTdbSaveCurrTool()
NewToolItem.NewTool = True
' Determino il tipo di utensile
Dim nType As Integer
EgtTdbGetCurrToolParam(MCH_TP.TYPE, nType)
Dim bSaw As Boolean = ((nType And MCH_TF.SAWBLADE) <> 0)
' Imposto testa e uscita
' Sempre lame su H1.1 e altri utensili su H1.2
EgtTdbSetCurrToolParam(MCH_TP.HEAD, "H1")
EgtTdbSetCurrToolParam(MCH_TP.EXIT_, If(bSaw, 1, 2))
' Per macchine senza ToolChanger, resetto la posizione su questo
If CurrentMachine.ShowToolChanger = 0 Then
EgtTdbSetCurrToolParam(MCH_TP.TCPOS, "")
End If
' Imposto dimensioni standard
If (nType And MCH_TF.DRILLBIT) <> 0 Then
EgtTdbSetCurrToolParam(MCH_TP.LEN, 80.0)
EgtTdbSetCurrToolParam(MCH_TP.TOTLEN, 80.0)
EgtTdbSetCurrToolParam(MCH_TP.DIAM, 20.0)
EgtTdbSetCurrToolParam(MCH_TP.TOTDIAM, 20.0)
EgtTdbSetCurrToolParam(MCH_TP.MAXMAT, 40.0)
ElseIf (nType And MCH_TF.SAWBLADE) <> 0 Then
EgtTdbSetCurrToolParam(MCH_TP.LEN, 80.0)
EgtTdbSetCurrToolParam(MCH_TP.TOTLEN, 80.0)
EgtTdbSetCurrToolParam(MCH_TP.DIAM, 600.0)
EgtTdbSetCurrToolParam(MCH_TP.TOTDIAM, 600.0)
EgtTdbSetCurrToolParam(MCH_TP.THICK, 5.0)
EgtTdbSetCurrToolParam(MCH_TP.MAXMAT, 40.0)
ElseIf (nType And MCH_TF.MILL) <> 0 Then
EgtTdbSetCurrToolParam(MCH_TP.LEN, 80.0)
EgtTdbSetCurrToolParam(MCH_TP.TOTLEN, 80.0)
EgtTdbSetCurrToolParam(MCH_TP.DIAM, 20.0)
EgtTdbSetCurrToolParam(MCH_TP.TOTDIAM, 20.0)
EgtTdbSetCurrToolParam(MCH_TP.MAXMAT, 40.0)
End If
' Salvo e aggiorno interfaccia utente
EgtTdbSaveCurrTool()
' Seleziono il nuovo utensile
If Not ToolFamily.IsExpanded Then ToolFamily.IsExpanded = True
NewToolItem.IsSelected = True
NewToolItem.NotifyPropertyChanged("IsSelected")
End If
' Verifico se sia selezionato un utensile
ElseIf TypeOf param Is ToolTreeViewItem Then
Dim ToolCopied As ToolTreeViewItem = DirectCast(param, ToolTreeViewItem)
Dim NewName As String = ToolCopied.Name
EgtTdbGetToolNewName(NewName)
If EgtTdbCopyTool(ToolCopied.Name, NewName) Then
' Elimino disegno che non deve essere copiato
EgtTdbSetCurrToolParam(MCH_TP.DRAW, String.Empty)
Dim CurrType As Integer
EgtTdbGetCurrToolParam(MCH_TP.TYPE, CurrType)
For Each ToolFamily In ToolsList
If (ToolFamily.ToolType And CurrType) <> 0 Then
NewToolItem = New ToolTreeViewItem(NewName)
ToolFamily.Items.Add(NewToolItem)
EgtTdbSaveCurrTool()
NewToolItem.NewTool = True
' Reimposto l'utensile vecchio nel Db per deselezionarlo e fare le verifiche correttamente
EgtTdbSetCurrTool(ToolCopied.Name)
ToolCopied.IsSelected = False
ToolCopied.NotifyPropertyChanged("IsSelected")
NewToolItem.IsSelected = True
Exit For
End If
Next
End If
End If
End Sub
#End Region ' NewCommand
#Region "SaveCommand"
'''
''' Returns a command that save the current selected tool.
'''
Public ReadOnly Property SaveCommand() As ICommand
Get
If m_cmdSave Is Nothing Then
m_cmdSave = New Command(AddressOf Save)
End If
Return m_cmdSave
End Get
End Property
'''
''' Saves the current tool. This method is invoked by the SaveCommand.
'''
Public Sub Save(ByVal param As Object)
Dim CurrTool As ToolTreeViewItem = DirectCast(param, ToolTreeViewItem)
CurrTool.WriteToolParam()
CurrTool.m_Name = CurrTool.m_Name.Trim()
CurrTool.WriteToolName()
EgtTdbSaveCurrTool()
' La funzione di salvataggio utensile forza lo stato di modificato allo stesso per poi salvare il disegno e il DB
CurrTool.NewTool = False
CurrTool.IsModifiedReset()
IsEnabledBtns(CurrTool.IsValid And Not CurrTool.IsModified, CurrTool.IsValid, True)
End Sub
#End Region ' SaveCommand
#Region "RemoveCommand"
'''
''' Returns a command that remove the current selected tool.
'''
Public ReadOnly Property RemoveCommand() As ICommand
Get
If m_cmdRemove Is Nothing Then
m_cmdRemove = New Command(AddressOf Remove)
End If
Return m_cmdRemove
End Get
End Property
'''
''' Remove the current selected tools from Db and TreeView. This method is invoked by the RemoveCommand.
'''
Public Sub Remove(ByVal param As Object)
EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext)
Dim ToolToRemove As ToolTreeViewItem = DirectCast(param, ToolTreeViewItem)
' Verifico se questo utensile viene utilizzato da qualche lavorazione
Dim UsingMachining As New List(Of String)
Dim ActiveMachiningsTypes() As MachiningsType = MachineUtility.ReadMachiningFamilies(m_sMachineIniPath)
For Each MachiningsType In ActiveMachiningsTypes
Dim MachiningName As String = String.Empty
EgtMdbGetFirstMachining(MachiningsType.Id, MachiningName)
While Not String.IsNullOrWhiteSpace(MachiningName)
' recupero tuuid
EgtMdbSetCurrMachining(MachiningName)
Dim sCurrMachTUUID As String = String.Empty
EgtMdbGetCurrMachiningParam(MCH_MP.TUUID, sCurrMachTUUID)
If sCurrMachTUUID = ToolToRemove.Uuid Then
UsingMachining.Add(MachiningName)
End If
EgtMdbGetNextMachining(MachiningsType.Id, MachiningName)
End While
Next
Dim MessageBoxText As String = EgtMsg(31122) & " " & ToolToRemove.Name & EgtMsg(31123) ' Sei sicuro di voler cancellare l'utensile ?
If UsingMachining.Count > 0 Then
MessageBoxText &= "This is the list of Machining that use this tool:" & Environment.NewLine
For MachiningIndex = 0 To UsingMachining.Count - 1
MessageBoxText &= "- " & UsingMachining(MachiningIndex) & Environment.NewLine
Next
End If
' Chiedo conferma cancellazione lavorazione
If MessageBox.Show(MessageBoxText, EgtMsg(31124), MessageBoxButton.YesNo, MessageBoxImage.Question) <> MessageBoxResult.Yes Then Return
'If EgtMessageBoxV.Show(Application.Current.MainWindow, MessageBoxText, EgtMsg(31124), MessageBoxButton.YesNo, MessageBoxImage.Question) <> MessageBoxResult.Yes Then Return ' CANCELLA
RemoveTool(ToolToRemove)
End Sub
Private Sub RemoveTool(ToolToRemove As ToolTreeViewItem)
EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext)
' Salvo il tipo di utensile per poterlo cancellare
Dim ToolType As Integer = ToolToRemove.Type
' Cancello l'utensile
Dim CurrToolOriginalName As String = String.Empty
EgtTdbGetToolFromUUID(ToolToRemove.Uuid, CurrToolOriginalName)
EgtTdbRemoveTool(CurrToolOriginalName)
' Rimuovo il nome dell'albero
For Each ToolFamily In ToolsList
If (ToolFamily.ToolType And ToolType) <> 0 Then
ToolFamily.Items.Remove(ToolToRemove)
End If
Next
ErrorOnTool(False)
End Sub
#End Region ' RemoveCommand
#Region "ImportCommand"
'''
''' Returns a command that remove the current selected machining.
'''
Public ReadOnly Property ImportCommand() As ICommand
Get
If m_cmdImport Is Nothing Then
m_cmdImport = New Command(AddressOf ImportTool)
End If
Return m_cmdImport
End Get
End Property
'''
''' Manage the MachiningDb closing. This method is invoked by the CloseMachiningDbCommand.
'''
Public Sub ImportTool(param As Object)
EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext)
' Se c'è utensile selezionato, ne verifico salvataggio
If Not VerifySelectedToolModification() Then Return
' apro dialogo di scelta file
Dim ImportFileDlg As New Microsoft.Win32.OpenFileDialog() With {
.Title = EgtMsg(31161) & " " & EgtMsg(31163),
.DefaultExt = ".data",
.Filter = "Tools (.data)|*.data",
.CheckFileExists = True,
.ValidateNames = True
}
If ImportFileDlg.ShowDialog() <> True Then Return
'Dim ImportFileDlg As New EgtManageFileDialogV(Application.Current.MainWindow, New EgtManageFileDialogVM()) With {
' .Title = EgtMsg(31161) & " " & EgtMsg(31163), ' Importa Utensili
' .Filter = "Tools (.data)|*.data",
' .CheckFileExists = True,
' .ValidateNames = True
'}
'If ImportFileDlg.ShowDialog() <> Windows.Forms.DialogResult.OK Then Return
Dim ImportFilePath As String = ImportFileDlg.FileName
' recupero liste utensili da importare
Dim ImportFileToolNameList As String() = Nothing
Dim ImportFileToolFamilyList As Integer() = Nothing
EgtTdbToBeImported(ImportFilePath, ImportFileToolNameList, ImportFileToolFamilyList)
' li inserisco in lista per finestra di scelta
Dim ToolToImportList As New ObservableCollection(Of ImpExpToolFamily)
' creo famiglie di utensili in base a quelle trovate in lista importata
If Not IsNothing(ImportFileToolNameList) AndAlso Not IsNothing(ImportFileToolFamilyList) Then
For ToolIndex As Integer = 0 To ImportFileToolNameList.Count - 1
Dim ToolName As String = ImportFileToolNameList(ToolIndex)
Dim ToolFamily As Integer = ImportFileToolFamilyList(ToolIndex)
ToolFamily = ToolFamily And
(MCH_TF.DRILLBIT Or
MCH_TF.SAWBLADE Or
MCH_TF.MILL Or
MCH_TF.MORTISE Or
MCH_TF.CHISEL Or
MCH_TF.WATERJET Or
MCH_TF.COMPO)
Dim bFounded As Boolean = False
For Each ToolToImportFamily In ToolToImportList
If (ToolFamily = ToolToImportFamily.FamilyType) Then
ToolToImportFamily.ToolList.Add(New ImpExpToolItem(ToolName, AlreadyExist(ToolName)))
bFounded = True
Exit For
End If
Next
If Not bFounded Then
Dim NewFamily As New ImpExpToolFamily(GetToolFamilyName(ToolFamily), ToolFamily)
NewFamily.ToolList.Add(New ImpExpToolItem(ToolName, AlreadyExist(ToolName)))
ToolToImportList.Add(NewFamily)
End If
Next
End If
Dim ImportWndVM As New ImportExportToolWindowVM(ToolToImportList, False, ImportFilePath, ImportFileToolNameList)
Dim ImportWnd As New ImportExportToolWindowV(Application.Current.MainWindow, ImportWndVM)
If ImportWnd.ShowDialog() Then
' Aggiungo all'albero visualizzato gli utensili appena importati
LoadImportedMachineTools(ImportWndVM.vsImported)
End If
End Sub
Private Function AlreadyExist(ToolName As String) As Boolean
For Each ToolFamily In m_ToolsList
For Each ToolItem As ToolTreeViewItem In ToolFamily.Items
If ToolName = ToolItem.Name Then
Return True
End If
Next
Next
Return False
End Function
Private Function GetToolFamilyName(NewToolFamily As Integer) As String
For Each ToolFamily In m_ToolsList
If NewToolFamily = ToolFamily.ToolType Then
Return ToolFamily.Name
End If
Next
Return ""
End Function
#End Region ' ImportCommand
#Region "ExportCommand"
'''
''' Returns a command that remove the current selected machining.
'''
Public ReadOnly Property ExportCommand() As ICommand
Get
If m_cmdExport Is Nothing Then
m_cmdExport = New Command(AddressOf ExportTool)
End If
Return m_cmdExport
End Get
End Property
'''
''' Manage the MachiningDb closing. This method is invoked by the CloseMachiningDbCommand.
'''
Public Sub ExportTool(param As Object)
EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext)
' Se c'è utensile selezionato, ne verifico salvataggio
If Not VerifySelectedToolModification() Then Return
' Creo lista utensili per esportazione
Dim ToolToExportList As New ObservableCollection(Of ImpExpToolFamily)
For Each Family In m_ToolsList
Dim ImpExpToolFamily As New ImpExpToolFamily(Family.Name, Family.ToolType)
For Each Tool In Family.Items
ImpExpToolFamily.ToolList.Add(New ImpExpToolItem(Tool.Name, False))
Next
ToolToExportList.Add(ImpExpToolFamily)
Next
Dim ExportWndVM As New ImportExportToolWindowVM(ToolToExportList, True)
Dim ExportWnd As New ImportExportToolWindowV(Application.Current.MainWindow, ExportWndVM)
ExportWnd.ShowDialog()
End Sub
#End Region ' ExportCommand
#Region "ReloadToolCommand"
'''
''' Returns a command that reload the current selected tool.
'''
Public ReadOnly Property ReloadToolCommand() As ICommand
Get
If m_cmdReloadTool Is Nothing Then
m_cmdReloadTool = New Command(AddressOf ReloadTool)
End If
Return m_cmdReloadTool
End Get
End Property
'''
''' Reload the current selected tools. This method is invoked by the RemoveCommand.
'''
Public Sub ReloadTool(ByVal param As Object)
If TypeOf param Is FamilyToolTreeViewItem Then
Return
' Verifico se sia selezionato un utensile
ElseIf TypeOf param Is ToolTreeViewItem Then
Dim ToolToReload As ToolTreeViewItem = DirectCast(param, ToolTreeViewItem)
EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext)
ToolToReload.ReadToolParam()
ToolToReload.ReadToolName()
ToolToReload.IsModifiedReset()
End If
End Sub
#End Region ' ReloadToolCommand
#Region "CloseToolDbCommand"
'''
''' Returns a command that close ToolDB Window.
'''
Public ReadOnly Property CloseToolsDbCommand() As ICommand
Get
If m_cmdCloseToolsDb Is Nothing Then
m_cmdCloseToolsDb = New Command(AddressOf CloseToolsDb)
End If
Return m_cmdCloseToolsDb
End Get
End Property
'''
''' Manage the ToolDb closing. This method is invoked by the CloseToolDbCommand.
'''
Public Sub CloseToolsDb(param As Object)
Dim bSkipSaving As Boolean = ((Keyboard.Modifiers And ModifierKeys.Control) = ModifierKeys.Control)
m_bActive = False
' Imposto contesto di progetto
EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext)
' Se c'è utensile selezionato, ne verifico salvataggio
If Not bSkipSaving AndAlso Not VerifySelectedToolModification() Then
If Not SelTool.IsValid() Then
'Utensile non valido, correggerlo o cancellarlo prima di uscire dal Db Utensili. - Errore
MessageBox.Show(EgtMsg(31129), EgtMsg(31126))
'EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(31129), EgtMsg(31126)) ' Utensile non valido, correggerlo o cancellarlo prima di uscire dal Db Utensili. - Errore
End If
Return
End If
' Salvataggio DB utensili
If Not bSkipSaving Then EgtTdbSave()
' Reset lua
EgtLuaResetGlobVar("STU")
' Dichiaro utensile non più selezionato
If Not IsNothing(SelTool) Then SelTool.ResetSelected()
' Se c'è il parametro Active sugli utensili
If Not bSkipSaving And m_Active_Visibility Then
' aggiorno setup di default
UpdateDefSetup()
End If
' Chiusura finestra
ToolTreeViewItem.m_delRemoveTool = Nothing
ToolTreeViewItem.m_delErrorOnTool = Nothing
ToolTreeViewItem.m_delIsEnabledBtns = Nothing
FamilyToolTreeViewItem.m_delIsEnabledBtns = Nothing
For Each Window In Application.Current.Windows
If TypeOf Window Is ToolDbWindowV Then
Dim ToolDbWindow As ToolDbWindowV = DirectCast(Window, ToolDbWindowV)
ToolDbWindow.DataContext = Nothing
ToolDbWindow.Close()
End If
Next
RaiseEvent m_CloseWindow(True)
End Sub
#End Region ' CloseToolsDbCommand
#End Region ' Commands
End Class