d5188fcd96
- aggiornata simulazione come EgtCAM5.
254 lines
8.8 KiB
VB.net
254 lines
8.8 KiB
VB.net
Imports System.Globalization
|
|
Imports System.Runtime.InteropServices
|
|
Imports System.Threading
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Public Class MyStatusBarVM
|
|
Inherits EgtWPFLib5.StatusBarVM
|
|
|
|
' Funzioni di callback per output in interfaccia da LUA
|
|
Private m_OutTextCallback As New OutTextCallback(AddressOf OutText)
|
|
|
|
Private m_bStopProgress As Boolean
|
|
Friend ReadOnly Property bStopProgress As Boolean
|
|
Get
|
|
Return m_bStopProgress
|
|
End Get
|
|
End Property
|
|
|
|
Private m_bGridVisibility As Boolean
|
|
Public Property bGridVisibility As Boolean
|
|
Get
|
|
Return m_bGridVisibility
|
|
End Get
|
|
Set(value As Boolean)
|
|
If Map.refRibPanelVM.bGrid_IsChecked Or Map.refStartMachPanelVM.bGrid_IsChecked Or Map.refShellNumberPanelVM.bGrid_IsChecked Then Return
|
|
m_bGridVisibility = value
|
|
OptionModule.m_bGridVisibility = m_bGridVisibility
|
|
EgtSetGridShow(value, value)
|
|
EgtDraw()
|
|
Map.refStartMachPanelVM.NotifyPropertyChanged(NameOf(Map.refStartMachPanelVM.bGrid_IsEnabled))
|
|
Map.refRibPanelVM.NotifyPropertyChanged(NameOf(Map.refRibPanelVM.bGrid_IsEnabled))
|
|
Map.refShellNumberPanelVM.NotifyPropertyChanged(NameOf(Map.refShellNumberPanelVM.bGrid_IsEnabled))
|
|
Map.refFilledSolidPanelVM.NotifyPropertyChanged(NameOf(Map.refFilledSolidPanelVM.bGrid_IsEnabled))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_SnapPointType As SP
|
|
Public ReadOnly Property SnapPointType_ToolTip As String
|
|
Get
|
|
Select Case m_SnapPointType
|
|
Case SP.PT_SKETCH
|
|
Return EgtMsg(1102) 'Sketch Point
|
|
Case SP.PT_GRID
|
|
Return EgtMsg(1104) 'Grid Point
|
|
Case SP.PT_END
|
|
Return EgtMsg(1106) 'End Point
|
|
Case SP.PT_MID
|
|
Return EgtMsg(1108) 'Mid Point
|
|
Case SP.CENTER
|
|
Return EgtMsg(1110) 'Center
|
|
Case SP.CENTROID
|
|
Return EgtMsg(1112) 'Centroid
|
|
Case SP.PT_NEAR
|
|
Return EgtMsg(1114) 'Near Point
|
|
Case SP.PT_INTERS
|
|
Return EgtMsg(1116) 'Inters Point
|
|
Case SP.PT_TANGENT
|
|
Return EgtMsg(1118) 'Tang Point
|
|
Case SP.PT_PERPENDICULAR
|
|
Return EgtMsg(1120) 'Perp Point
|
|
Case SP.PT_MINDIST
|
|
Return EgtMsg(1122) 'MinDist Point
|
|
Case Else
|
|
Return "---"
|
|
End Select
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property SnapPointType_Msg As String
|
|
Get
|
|
Select Case m_SnapPointType
|
|
Case SP.PT_SKETCH
|
|
Return "S" 'Sketch Point
|
|
Case SP.PT_GRID
|
|
Return "G" 'Grid Point
|
|
Case SP.PT_END
|
|
Return "E" 'End Point
|
|
Case SP.PT_MID
|
|
Return "M" 'Mid Point
|
|
Case SP.CENTER
|
|
Return "C" 'Center
|
|
Case SP.CENTROID
|
|
Return "C" 'Centroid
|
|
Case SP.PT_NEAR
|
|
Return "N" 'Near Point
|
|
Case SP.PT_INTERS
|
|
Return "I" 'Inters Point
|
|
Case SP.PT_TANGENT
|
|
Return "T" 'Tang Point
|
|
Case SP.PT_PERPENDICULAR
|
|
Return "P" 'Perp Point
|
|
Case SP.PT_MINDIST
|
|
Return "D" 'MinDist Point
|
|
Case Else
|
|
Return "-"
|
|
End Select
|
|
End Get
|
|
End Property
|
|
|
|
Private m_CurrPos As String
|
|
Public Shadows ReadOnly Property CurrPos As String
|
|
Get
|
|
Return m_CurrPos
|
|
End Get
|
|
End Property
|
|
|
|
' Definizione comandi
|
|
Private m_cmdStopProgress As ICommand
|
|
|
|
Public ReadOnly Property GridVisibilityMsg As String
|
|
Get
|
|
Return "GRID"
|
|
End Get
|
|
End Property
|
|
|
|
Sub New()
|
|
' Creo riferimento a questa classe in Map
|
|
Map.SetRefMyStatusBarVM(Me)
|
|
' Installo funzione output testo su status per lua
|
|
EgtSetOutText(m_OutTextCallback)
|
|
' imposto stato di visualizzazione della griglia
|
|
m_bGridVisibility = OptionModule.m_bGridVisibility
|
|
NotifyPropertyChanged(NameOf(bGridVisibility))
|
|
End Sub
|
|
|
|
Friend Overloads Sub SetSnapPointType(SnapPntType As SP)
|
|
m_SnapPointType = SnapPntType
|
|
NotifyPropertyChanged(NameOf(SnapPointType_Msg))
|
|
NotifyPropertyChanged(NameOf(SnapPointType_ToolTip))
|
|
End Sub
|
|
|
|
Friend Overloads Sub SetCurrPos(sCurrPos As String)
|
|
Dim sSplitCurrPos() As String = sCurrPos.Split(" "c)
|
|
Dim bX As Boolean = False
|
|
Dim bY As Boolean = False
|
|
Dim bZ As Boolean = False
|
|
Dim dX As Double = 0
|
|
Dim dY As Double = 0
|
|
Dim dZ As Double = 0
|
|
For Each Axis In sSplitCurrPos
|
|
If Axis.Contains("X"c) OrElse Axis.Contains("x"c) Then
|
|
bX = StringToDouble(Axis.Trim({"X"c, "x"c, "="c}), dX)
|
|
ElseIf Axis.Contains("Y"c) OrElse Axis.Contains("y"c) Then
|
|
bY = StringToDouble(Axis.Trim({"Y"c, "y"c, "="c}), dY)
|
|
ElseIf Axis.Contains("Z"c) OrElse Axis.Contains("z"c) Then
|
|
bZ = StringToDouble(Axis.Trim({"Z"c, "z"c, "="c}), dZ)
|
|
End If
|
|
Next
|
|
m_CurrPos = If(bX, "X=" & DoubleToString(dX, -2) & If(bY Or bZ, " ", ""), "") & If(bY, "Y=" & DoubleToString(dY, -2) & If(bZ, " ", ""), "") & If(bZ, "Z=" & DoubleToString(dZ, -2), "")
|
|
NotifyPropertyChanged("CurrPos")
|
|
End Sub
|
|
|
|
Friend Sub ResetStopProgress()
|
|
m_bStopProgress = False
|
|
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
|
|
|
|
Friend 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.refSimulationPanelVM) Then
|
|
' Uso i valori negativi del primo parametro come flag per la Simulazione
|
|
Dim nFlag As Integer = If( nProg < 0, -nProg, 0)
|
|
Map.refSimulationPanelVM.SimulationExpander_Update_CncData( nFlag)
|
|
End If
|
|
' Costringo ad aggiornare
|
|
UpdateUI()
|
|
' Eventuale attesa
|
|
If nPause >= 0 Then
|
|
Thread.Sleep(nPause)
|
|
' se altrimenti richiesto aggiornamento visualizzazione
|
|
ElseIf nPause = -1
|
|
EgtDraw()
|
|
End If
|
|
' Ritorno eventuale stop
|
|
If m_bStopProgress Then
|
|
m_bStopProgress = False
|
|
Return 1
|
|
Else
|
|
Return 0
|
|
End If
|
|
End Function
|
|
|
|
Friend Sub StartLoading(sMessage As String, bIsStop As Boolean)
|
|
Map.refMyStatusBarVM.SetLoadingProgress_Visibility(True)
|
|
Map.refMyStatusBarVM.SetStopProgress_IsActive(bIsStop)
|
|
Map.refMyStatusBarVM.SetStopProgress_IsEnabled(bIsStop)
|
|
Map.refMyStatusBarVM.SetOutputMessage(sMessage)
|
|
End Sub
|
|
|
|
Friend Sub EndLoading(sMessage As String, Optional nMessageTime As Integer = 3)
|
|
Map.refMyStatusBarVM.SetLoadingProgress_Visibility(False)
|
|
Map.refMyStatusBarVM.SetStopProgress_IsActive(False)
|
|
Map.refMyStatusBarVM.SetStopProgress_IsEnabled(False)
|
|
Map.refMyStatusBarVM.SetOutputMessage(sMessage, nMessageTime)
|
|
End Sub
|
|
|
|
Friend Sub RefreshMachName()
|
|
' NotifyPropertyChanged(NameOf(CurrMachine))
|
|
End Sub
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "StopProgress"
|
|
|
|
''' <summary>
|
|
''' Returns a command that do Exec.
|
|
''' </summary>
|
|
Public ReadOnly Property StopProgress_Command As ICommand
|
|
Get
|
|
If m_cmdStopProgress Is Nothing Then
|
|
m_cmdStopProgress = New Command(AddressOf StopProgress)
|
|
End If
|
|
Return m_cmdStopProgress
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the Exec. This method is invoked by the ExecCommand.
|
|
''' </summary>
|
|
Public Sub StopProgress()
|
|
m_bStopProgress = True
|
|
End Sub
|
|
|
|
#End Region ' StopProgress
|
|
|
|
#End Region ' COMMANDS
|
|
|
|
End Class
|
|
|
|
Public Class StringToVisibilityConverter
|
|
Implements IValueConverter
|
|
|
|
Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.Convert
|
|
If TypeOf value Is String Then
|
|
Dim sValue As String = CStr(value)
|
|
Return If(String.IsNullOrWhiteSpace(sValue), Visibility.Collapsed, Visibility.Visible)
|
|
End If
|
|
Return Visibility.Collapsed
|
|
End Function
|
|
|
|
Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.ConvertBack
|
|
Throw New NotImplementedException()
|
|
End Function
|
|
|
|
End Class |