936eb5ba44
- migliorie per macchina con DB utensili e lavorazioni al cambio progetto.
381 lines
15 KiB
VB.net
381 lines
15 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.IO
|
|
Imports EgtUILib
|
|
|
|
Namespace EgtCAM5
|
|
|
|
Public Class StatusBarViewModel
|
|
Inherits ViewModelBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
' GRAPHICAL ELEMENTS
|
|
Private m_StatusOutput As String
|
|
Public Property StatusOutput As String
|
|
Get
|
|
Return m_StatusOutput
|
|
End Get
|
|
Set(value As String)
|
|
m_StatusOutput = value
|
|
OnPropertyChanged("StatusOutput")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_StatusCurrPos As String
|
|
Public Property StatusCurrPos As String
|
|
Get
|
|
Return m_StatusCurrPos
|
|
End Get
|
|
Set(value As String)
|
|
m_StatusCurrPos = value
|
|
OnPropertyChanged("StatusCurrPos")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_StatusProgress As Integer
|
|
Public Property StatusProgress As Integer
|
|
Get
|
|
Return m_StatusProgress
|
|
End Get
|
|
Set(value As Integer)
|
|
m_StatusProgress = value
|
|
OnPropertyChanged("StatusProgress")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_StatusStopIsEnabled As Boolean
|
|
Public Property StatusStopIsEnabled As Boolean
|
|
Get
|
|
Return m_StatusStopIsEnabled
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_StatusStopIsEnabled = value
|
|
OnPropertyChanged("StatusStopIsEnabled")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_StatusGridText As String
|
|
Public Property StatusGridText As String
|
|
Get
|
|
Return m_StatusGridText
|
|
End Get
|
|
Set(value As String)
|
|
m_StatusGridText = value
|
|
OnPropertyChanged("StatusGridText")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_CurrPosTypeText As String
|
|
Public Property CurrPosTypeText As String
|
|
Get
|
|
Return m_CurrPosTypeText
|
|
End Get
|
|
Set(value As String)
|
|
m_CurrPosTypeText = value
|
|
OnPropertyChanged("CurrPosTypeText")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_StatusUnitsText As String
|
|
Public Property StatusUnitsText As String
|
|
Get
|
|
Return m_StatusUnitsText
|
|
End Get
|
|
Set(value As String)
|
|
m_StatusUnitsText = value
|
|
OnPropertyChanged("StatusUnitsText")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_SnapPointTypeText As String
|
|
Public Property SnapPointTypeText As String
|
|
Get
|
|
Return m_SnapPointTypeText
|
|
End Get
|
|
Set(value As String)
|
|
m_SnapPointTypeText = value
|
|
OnPropertyChanged("SnapPointTypeText")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_SnapPointTypeBackground As SolidColorBrush
|
|
Public Property SnapPointTypeBackground As SolidColorBrush
|
|
Get
|
|
Return m_SnapPointTypeBackground
|
|
End Get
|
|
Set(value As SolidColorBrush)
|
|
m_SnapPointTypeBackground = value
|
|
OnPropertyChanged("SnapPointTypeBackground")
|
|
End Set
|
|
End Property
|
|
|
|
' Lista delle macchine disponibili nel programma
|
|
Private m_MachinesList As New ObservableCollection(Of Machine)
|
|
Public Property MachinesList As ObservableCollection(Of Machine)
|
|
Get
|
|
Return m_MachinesList
|
|
End Get
|
|
Set(value As ObservableCollection(Of Machine))
|
|
m_MachinesList = value
|
|
End Set
|
|
End Property
|
|
' Macchina correntemente selezionata e quindi attiva
|
|
Private m_SelectedMachine As Machine
|
|
Public Property SelectedMachine As Machine
|
|
Get
|
|
Return m_SelectedMachine
|
|
End Get
|
|
Set(value As Machine)
|
|
If value IsNot m_SelectedMachine Then
|
|
m_SelectedMachine = value
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
EgtSetCurrMachine(m_SelectedMachine.Name)
|
|
IniFile.m_sDbsCurrMachIniFilePath = m_SelectedMachine.MachineDirPath & "\" & m_SelectedMachine.Name & ".ini"
|
|
IniFile.m_sTdbCurrMachToolsDirPath = m_SelectedMachine.MachineDirPath & "\Tools"
|
|
Application.Msn.NotifyColleagues(Application.LOADSELECTEDMACHINE)
|
|
OnPropertyChanged("SelectedMachine")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
' Commands definition
|
|
Private m_cmdStatusGrid As ICommand
|
|
Private m_cmdCurrPosType As ICommand
|
|
Private m_cmdStatusUnits As ICommand
|
|
Private m_cmdStatusStop As ICommand
|
|
|
|
#End Region ' Fields & Properties
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
Application.Msn.Register(Application.NOTIFYCURRPOS, Sub(sCursorPos As String)
|
|
StatusCurrPos = sCursorPos
|
|
End Sub)
|
|
Application.Msn.Register(Application.NOTIFYSTATUSOUTPUT, Sub(sStatusOutput As String)
|
|
StatusOutput = sStatusOutput
|
|
End Sub)
|
|
Application.Msn.Register(Application.NOTIFYSTATUSPROGRESS, Sub(sStatusProgress As Integer)
|
|
StatusProgress = sStatusProgress
|
|
End Sub)
|
|
Application.Msn.Register(Application.NOTIFYSTATUSSTOP, Sub(sStatusStop As Boolean)
|
|
StatusStopIsEnabled = sStatusStop
|
|
End Sub)
|
|
Application.Msn.Register(Application.UPDATESTATUSGRID, Sub(UpdateStatusGridParam As UpdateStatusGridParam)
|
|
UpdateStatusGrid(UpdateStatusGridParam.m_bShowGrid, UpdateStatusGridParam.m_bShowGridFrame)
|
|
End Sub)
|
|
Application.Msn.Register(Application.STATUSCURRPOSTYPETEXT, Sub(sString As String)
|
|
CurrPosTypeText = sString
|
|
End Sub)
|
|
Application.Msn.Register(Application.UPDATESTATUSUNITS, Sub(bMmUnits As Boolean)
|
|
StatusUnitsText = If(bMmUnits, "mm", "in")
|
|
EgtSetUiUnits(bMmUnits)
|
|
End Sub)
|
|
Application.Msn.Register(Application.STATUSSNAPPOINTTYPETEXT, Sub(sString As String)
|
|
SnapPointTypeText = sString
|
|
End Sub)
|
|
Application.Msn.Register(Application.STATUSSNAPPOINTTYPEBACKGROUND, Sub(Color As SolidColorBrush)
|
|
SnapPointTypeBackground = Color
|
|
End Sub)
|
|
SearchMachine()
|
|
Application.Msn.Register(Application.LOADCURRENTMACHINE, Sub()
|
|
Dim CurrMach As String = String.Empty
|
|
GetPrivateProfileString(S_MACH, K_CURRMACH, String.Empty, CurrMach)
|
|
If Not String.IsNullOrEmpty(CurrMach) Then
|
|
Dim Temp As Boolean = False
|
|
For Each Mach In MachinesList
|
|
If Mach.Name = CurrMach Then
|
|
Temp = True
|
|
SelectedMachine = Mach
|
|
Exit For
|
|
End If
|
|
Next
|
|
If Not Temp And MachinesList.Count > 0 Then
|
|
SelectedMachine = MachinesList(0)
|
|
End If
|
|
Else
|
|
If MachinesList.Count > 0 Then
|
|
SelectedMachine = MachinesList(0)
|
|
End If
|
|
End If
|
|
End Sub)
|
|
Application.Msn.Register(Application.SAVECURRENTMACHINE, Sub()
|
|
WritePrivateProfileString(S_MACH, K_CURRMACH, SelectedMachine.Name)
|
|
End Sub)
|
|
Application.Msn.Register(Application.RELOADCURRENTMACHINE, Sub()
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
EgtSetCurrMachine(SelectedMachine.Name)
|
|
End Sub)
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "StatusGridCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that set grid status.
|
|
''' </summary>
|
|
Public ReadOnly Property StatusGridCommand As ICommand
|
|
Get
|
|
If m_cmdStatusGrid Is Nothing Then
|
|
m_cmdStatusGrid = New RelayCommand(AddressOf StatusGrid, AddressOf CanStatusGrid)
|
|
End If
|
|
Return m_cmdStatusGrid
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Notify the function to set the status. This method is invoked by the StatusGridCommand.
|
|
''' </summary>
|
|
Public Sub StatusGrid(ByVal param As Object)
|
|
Application.Msn.NotifyColleagues(Application.STATUSGRIDCOMMAND)
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Returns always true.
|
|
''' </summary>
|
|
Private Function CanStatusGrid(ByVal param As Object) As Boolean
|
|
Return True
|
|
End Function
|
|
|
|
#End Region ' DoneCommand
|
|
|
|
#Region "CurrPosTypeCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that choose the current reference.
|
|
''' </summary>
|
|
Public ReadOnly Property CurrPosTypeCommand As ICommand
|
|
Get
|
|
If m_cmdCurrPosType Is Nothing Then
|
|
m_cmdCurrPosType = New RelayCommand(AddressOf CurrPosType, AddressOf CanCurrPosType)
|
|
End If
|
|
Return m_cmdCurrPosType
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the Point. This method is invoked by the CurrPosTypeCommand.
|
|
''' </summary>
|
|
Public Sub CurrPosType(ByVal param As Object)
|
|
Application.Msn.NotifyColleagues(Application.STATUSCURRPOSTYPECOMMAND)
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Returns always true.
|
|
''' </summary>
|
|
Private Function CanCurrPosType(ByVal param As Object) As Boolean
|
|
Return True
|
|
End Function
|
|
|
|
#End Region ' CurrPosTypeCommand
|
|
|
|
#Region "StatusUnitsCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that choose the current reference.
|
|
''' </summary>
|
|
Public ReadOnly Property StatusUnitsCommand As ICommand
|
|
Get
|
|
If m_cmdStatusUnits Is Nothing Then
|
|
m_cmdStatusUnits = New RelayCommand(AddressOf StatusUnits, AddressOf CanStatusUnits)
|
|
End If
|
|
Return m_cmdStatusUnits
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the Point. This method is invoked by the CurrPosTypeCommand.
|
|
''' </summary>
|
|
Public Sub StatusUnits(ByVal param As Object)
|
|
Application.Msn.NotifyColleagues(Application.STATUSUNITSCOMMAND)
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Returns always true.
|
|
''' </summary>
|
|
Private Function CanStatusUnits(ByVal param As Object) As Boolean
|
|
Return True
|
|
End Function
|
|
|
|
#End Region ' StatusUnitsCommand
|
|
|
|
#Region "StatusStopCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that choose the current reference.
|
|
''' </summary>
|
|
Public ReadOnly Property StatusStopCommand As ICommand
|
|
Get
|
|
If m_cmdStatusStop Is Nothing Then
|
|
m_cmdStatusStop = New RelayCommand(AddressOf StatusStop, AddressOf CanStatusStop)
|
|
End If
|
|
Return m_cmdStatusStop
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the Point. This method is invoked by the CurrPosTypeCommand.
|
|
''' </summary>
|
|
Public Sub StatusStop(ByVal param As Object)
|
|
m_bStopScript = True
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Returns always true.
|
|
''' </summary>
|
|
Private Function CanStatusStop(ByVal param As Object) As Boolean
|
|
Return True
|
|
End Function
|
|
|
|
#End Region ' StatusStopCommand
|
|
|
|
#End Region ' Commands
|
|
|
|
#Region "METHODS"
|
|
|
|
Private Sub UpdateStatusGrid(bShowGrid As Boolean, bShowGridFrame As Boolean)
|
|
'tsStatusGrid.ForeColor = If(m_bShowGrid, Color.Black, Color.Gray)
|
|
StatusGridText = If(bShowGrid, "GRID ON ", "GRID OFF")
|
|
EgtSetGridShow(bShowGrid, bShowGrid And bShowGridFrame)
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Method that search the machines in the correct folder and add to the MachinesList those valid.
|
|
''' </summary>
|
|
Private Sub SearchMachine()
|
|
Dim TempArray As String() = Directory.GetDirectories(IniFile.m_sMachinesRoot)
|
|
For i As Integer = 0 To TempArray.Count - 1
|
|
Dim MachinePathIni As String = TempArray(i) & "\" & Path.GetFileName(TempArray(i)) & ".ini"
|
|
If File.Exists(MachinePathIni) Then
|
|
m_MachinesList.Add(New Machine With {.Name = Path.GetFileName(TempArray(i)), .MachineDirPath = TempArray(i)})
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Class that create the association Name/IniPath for the machine's
|
|
''' </summary>
|
|
Class Machine
|
|
|
|
Private m_sName As String
|
|
Public Property Name As String
|
|
Get
|
|
Return m_sName
|
|
End Get
|
|
Set(value As String)
|
|
m_sName = value
|
|
End Set
|
|
End Property
|
|
|
|
Friend MachineDirPath As String
|
|
|
|
End Class
|
|
|
|
#End Region ' Methods
|
|
|
|
End Class
|
|
|
|
End Namespace |