4d610cea8b
- sulla status bar in modalità Disegna aggiunta indicazione numero di entità selezionate (Sel : NNN) - migliorie e correzioni a ExecuteWindow per caso di passaggio a Lavorazioni.
382 lines
12 KiB
VB.net
382 lines
12 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.Runtime.InteropServices
|
|
Imports System.IO
|
|
Imports EgtUILib
|
|
Imports System.Threading
|
|
Imports EgtWPFLib5
|
|
|
|
Public Class MyStatusBarVM
|
|
Inherits StatusBarVM
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
' Funzioni di callback per output in interfaccia da LUA
|
|
Private m_ProcEventsCallback As New ProcessEventsCallback(AddressOf ProcessEvents)
|
|
Private m_OutTextCallback As New OutTextCallback(AddressOf OutText)
|
|
|
|
Private m_GridDimensionText As String
|
|
Public Property GridDimensionText As String
|
|
Get
|
|
Return m_GridDimensionText
|
|
End Get
|
|
Set(value As String)
|
|
m_GridDimensionText = value
|
|
NotifyPropertyChanged("GridDimensionText")
|
|
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
|
|
NotifyPropertyChanged("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
|
|
NotifyPropertyChanged("CurrPosTypeText")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_nSelCount As Integer = 0
|
|
Public ReadOnly Property SelCount As String
|
|
Get
|
|
Return "Sel : " & m_nSelCount.ToString()
|
|
End Get
|
|
End Property
|
|
Public Sub UpdateSelectedCount()
|
|
Dim nSelCnt As Integer = EgtGetSelectedObjCount()
|
|
If nSelCnt <> m_nSelCount Then
|
|
m_nSelCount = nSelCnt
|
|
NotifyPropertyChanged("SelCount")
|
|
End If
|
|
End Sub
|
|
|
|
Public ReadOnly Property SelCountVisibility As Visibility
|
|
Get
|
|
If IniFile.m_ProjectMode = ProjectModeOpt.DRAW OrElse IniFile.m_ProjectMode = ProjectModeOpt.ONLYDRAW Then
|
|
Return Visibility.Visible
|
|
Else
|
|
Return Visibility.Hidden
|
|
End If
|
|
End Get
|
|
End Property
|
|
Friend Sub UpdateSelCountVisibility()
|
|
NotifyPropertyChanged("SelCountVisibility")
|
|
End Sub
|
|
|
|
' Commands definition
|
|
Private m_cmdGridDimension As ICommand
|
|
Private m_cmdGridDimensionLostFocus As ICommand
|
|
Private m_cmdStatusGrid As ICommand
|
|
Private m_cmdCurrPosType As ICommand
|
|
Private m_cmdStatusUnits As ICommand
|
|
Private m_cmdStatusStop As ICommand
|
|
Private m_cmdClearOutputMessage As ICommand
|
|
|
|
#End Region ' Fields & Properties
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
' Creo riferimento a questa classe in EgtCAM5Map
|
|
Map.SetRefStatusBarVM(Me)
|
|
' Installo funzione gestione eventi per lua
|
|
EgtSetProcessEvents(m_ProcEventsCallback)
|
|
' Installo funzione output testo su status per lua
|
|
EgtSetOutText(m_OutTextCallback)
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "GridDimensionCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that set grid status.
|
|
''' </summary>
|
|
Public ReadOnly Property GridDimensionCommand As ICommand
|
|
Get
|
|
If m_cmdGridDimension Is Nothing Then
|
|
m_cmdGridDimension = New RelayCommand(AddressOf GridDimension)
|
|
End If
|
|
Return m_cmdGridDimension
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Notify the function to set the status. This method is invoked by the StatusGridCommand.
|
|
''' </summary>
|
|
Public Sub GridDimension(ByVal param As Object)
|
|
If IniFile.m_bMmUnits Then
|
|
StringToLen(GridDimensionText, IniFile.dSnapStepMm)
|
|
EgtSetGridGeo(IniFile.dSnapStepMm, IniFile.nMinLineSStep, IniFile.nMajLineSStep, IniFile.nExtSStep)
|
|
Else
|
|
StringToLen(GridDimensionText, IniFile.dSnapStepInch)
|
|
EgtSetGridGeo(IniFile.dSnapStepInch, IniFile.nMinLineSStep, IniFile.nMajLineSStep, IniFile.nExtSStep)
|
|
End If
|
|
EgtSetGridColor(IniFile.MinLnColor, IniFile.MajLnColor)
|
|
Keyboard.ClearFocus()
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region ' GridDimensionCommand
|
|
|
|
#Region "GridDimensionLostFocusCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that set grid status.
|
|
''' </summary>
|
|
Public ReadOnly Property GridDimensionLostFocusCommand As ICommand
|
|
Get
|
|
If m_cmdGridDimensionLostFocus Is Nothing Then
|
|
m_cmdGridDimensionLostFocus = New RelayCommand(AddressOf GridDimensionLostFocus)
|
|
End If
|
|
Return m_cmdGridDimensionLostFocus
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Notify the function to set the status. This method is invoked by the StatusGridCommand.
|
|
''' </summary>
|
|
Public Sub GridDimensionLostFocus(ByVal param As Object)
|
|
If IniFile.m_bMmUnits Then
|
|
GridDimensionText = LenToString(IniFile.dSnapStepMm, 4)
|
|
Else
|
|
GridDimensionText = LenToString(IniFile.dSnapStepInch, 4)
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' GridDimensionLostFocusCommand
|
|
|
|
#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)
|
|
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)
|
|
Dim bGridState As Boolean
|
|
If IniFile.m_ProjectMode = ProjectModeOpt.DRAW OrElse IniFile.m_ProjectMode = ProjectModeOpt.ONLYDRAW Then
|
|
IniFile.m_bDrawShowGrid = Not IniFile.m_bDrawShowGrid
|
|
bGridState = m_bDrawShowGrid
|
|
ElseIf IniFile.m_ProjectMode = ProjectModeOpt.MACHINING Then
|
|
IniFile.m_bMachiningShowGrid = Not IniFile.m_bMachiningShowGrid
|
|
bGridState = m_bMachiningShowGrid
|
|
End If
|
|
Map.refStatusBarVM.UpdateStatusGrid(New UpdateStatusGridParam(bGridState, IniFile.m_bShowGridFrame))
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region ' StatusGridCommand
|
|
|
|
#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)
|
|
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)
|
|
Map.refProjectVM.StatusCurrPosTypeCommand()
|
|
End Sub
|
|
|
|
#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)
|
|
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)
|
|
Map.refProjectVM.StatusUnitsCommand()
|
|
If IniFile.m_bMmUnits Then
|
|
GridDimensionText = LenToString(IniFile.dSnapStepMm, 4)
|
|
Else
|
|
GridDimensionText = LenToString(IniFile.dSnapStepInch, 4)
|
|
End If
|
|
End Sub
|
|
|
|
#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)
|
|
End If
|
|
Return m_cmdStatusStop
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the Point. This method is invoked by the StatusStopCommand.
|
|
''' </summary>
|
|
Public Sub StatusStop(ByVal param As Object)
|
|
m_bStopScript = True
|
|
End Sub
|
|
|
|
#End Region ' StatusStopCommand
|
|
|
|
#Region "ClearOutputMessageCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that choose the current reference.
|
|
''' </summary>
|
|
Public Overrides ReadOnly Property ClearOutputMessage_Command As ICommand
|
|
Get
|
|
If m_cmdClearOutputMessage Is Nothing Then
|
|
m_cmdClearOutputMessage = New RelayCommand(AddressOf ClearOutputMessage)
|
|
End If
|
|
Return m_cmdClearOutputMessage
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the Point. This method is invoked by the ClearOutPutMessage_Command.
|
|
''' </summary>
|
|
Public Overloads Sub ClearOutputMessage(ByVal param As Object)
|
|
OutputMessage = String.Empty
|
|
SetLoadingProgress(0)
|
|
NotifyPropertyChanged("OutputMessage")
|
|
End Sub
|
|
|
|
#End Region ' ClearStatusOutputCommand
|
|
|
|
#End Region ' Commands
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Sub NotifyStatusOutput(sStatusOutput As String)
|
|
SetOutputMessage(sStatusOutput)
|
|
End Sub
|
|
|
|
Friend Sub NotifyCurrPos(sCursorPos As String)
|
|
SetCurrPos(sCursorPos)
|
|
End Sub
|
|
|
|
Friend Sub NotifyStatusProgress(sStatusProgress As Integer)
|
|
SetLoadingProgress(sStatusProgress)
|
|
End Sub
|
|
|
|
Friend Sub NotifyStatusStop(sStatusStop As Boolean)
|
|
SetStopProgress_IsEnabled(sStatusStop)
|
|
End Sub
|
|
|
|
Friend Sub UpdateStatusGrid(UpdateStatusGridParam As UpdateStatusGridParam)
|
|
UpdateStatusGrid(UpdateStatusGridParam.m_bShowGrid, UpdateStatusGridParam.m_bShowGridFrame)
|
|
End Sub
|
|
|
|
Friend Sub StatusCurrPosTypeText(sString As String)
|
|
CurrPosTypeText = sString
|
|
End Sub
|
|
|
|
Friend Sub UpdateStatusUnits(bMmUnits As Boolean)
|
|
SetMeasureUnit(If(bMmUnits, 1, 0)) 'StatusUnitsText = If(bMmUnits, "mm", "in")
|
|
EgtSetUiUnits(bMmUnits)
|
|
End Sub
|
|
|
|
Friend Sub StatusSnapPointTypeText(sString As String)
|
|
SetSnapPointType(sString)
|
|
End Sub
|
|
|
|
Friend Sub StatusSnapPointTypeBackground(Color As SolidColorBrush)
|
|
SetSnapPointType_Background(Color)
|
|
End Sub
|
|
|
|
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
|
|
|
|
Public Function OutText(ByRef psText As IntPtr) As Boolean
|
|
' Assegno stringa
|
|
OutputMessage = (Marshal.PtrToStringUni(psText))
|
|
' Costringo ad aggiornare
|
|
UpdateUI()
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ProcessEvents(ByVal nProg As Integer, ByVal nPause As Integer) As Integer
|
|
' Se previsto, imposto progress
|
|
If nProg > 0 Then SetLoadingProgress(Math.Min(nProg, 100))
|
|
' Se simulazione attiva, notifico aggiornamento dati
|
|
If Not IsNothing( Map.refSimulationExpanderVM) Then
|
|
' Uso i valori negativi del primo parametro come flag per la Simulazione
|
|
Dim nFlag As Integer = If( nProg < 0, -nProg, 0)
|
|
Map.refSimulationExpanderVM.SimulationExpander_Update_CncData( nFlag)
|
|
End If
|
|
' Costringo ad aggiornare
|
|
UpdateUI()
|
|
' Se richiesta pausa
|
|
If nPause >= 0 Then
|
|
Thread.Sleep(nPause)
|
|
' se altrimenti richiesto aggiornamento visualizzazione
|
|
ElseIf nPause = -1
|
|
EgtDraw()
|
|
End If
|
|
' Ritorno eventuale stop
|
|
If m_bStopScript Then
|
|
m_bStopScript = False
|
|
Return 1
|
|
Else
|
|
Return 0
|
|
End If
|
|
End Function
|
|
|
|
Public Sub SetSnapPointType_Background(SnapPntTypeBackground As SolidColorBrush)
|
|
SnapPointType_Background = SnapPntTypeBackground
|
|
NotifyPropertyChanged("SnapPointType_Background")
|
|
End Sub
|
|
|
|
#End Region ' Methods
|
|
|
|
End Class |