Imports System.Collections.ObjectModel Imports System.Collections.Specialized Imports System.Windows.Threading Imports EgtUILib Imports EgtWPFLib5 Public Class TFSEditorVM Inherits VMBase Private m_Selection_Timer As New DispatcherTimer Private m_bCollectionChanging As Boolean = False #Region "FIELDS & PROPERTIES" Public Enum MediaTypes As Integer HEIGHT = 1 'SECTIONCHANGE = 2 SELECTION = 2 FEED_INCREMENT = 3 SELECTION_WAIT = 4 End Enum Public Enum Filters As Integer NULL = 0 TIME_LOWER = 1 TIME_OK = 2 TIME_UPPER = 3 SPEED_MIN = 4 SPEED_MAX = 5 End Enum Private m_dSpeedMin As Double Public ReadOnly Property dSpeedMin As Double Get Return m_dSpeedMin End Get End Property Private m_dSpeedMax As Double Public ReadOnly Property dSpeedMax As Double Get Return m_dSpeedMax End Get End Property Private m_LayerList_View As CollectionView = Nothing Private m_LayerList As New ObservableCollection(Of TFSLayer) Public ReadOnly Property LayerList As ObservableCollection(Of TFSLayer) Get Return m_LayerList End Get End Property Private m_SelLayers As New ObservableCollection(Of TFSLayer) Public Property SelLayers As ObservableCollection(Of TFSLayer) Get Return m_SelLayers End Get Set(value As ObservableCollection(Of TFSLayer)) m_SelLayers = value End Set End Property Private m_MediaTypeList As New List(Of String)({"Feed by Slice Number", "Feed by Selection", "Wait by Selection", "Feed by Increment"}) Public ReadOnly Property MediaTypeList As List(Of String) Get If bWaitingTime Then Return New List(Of String)({"Feed by Slice Number", "Feed by Selection", "Feed by Increment", "Wait by Selection"}) Else Return New List(Of String)({"Feed by Slice Number", "Feed by Selection", "Feed by Increment"}) End If ' Return m_MediaTypeList End Get End Property Private m_nSelMediaType As MediaTypes Public Property ghSelMediaType As Integer Get Return m_nSelMediaType - 1 End Get Set(value As Integer) m_nSelMediaType = value + 1 Select Case m_nSelMediaType Case MediaTypes.HEIGHT SetSetVisibility(False) SetMediaVisibility(True) 'Case MediaTypes.SECTIONCHANGE ' SetSetVisibility(False) ' SetMediaVisibility(True) Case MediaTypes.SELECTION SetSetVisibility(True) SetMediaVisibility(False) Case MediaTypes.SELECTION_WAIT SetSetVisibility(True) SetMediaVisibility(False) Case MediaTypes.FEED_INCREMENT SetSetVisibility(True) SetMediaVisibility(False) End Select NotifyPropertyChanged(NameOf(Modify_Msg)) End Set End Property Private m_dModifyValue As Double Public Property sModifyValue As String Get Select Case m_nSelMediaType Case MediaTypes.HEIGHT Return DoubleToString(m_dModifyValue, 0) Case Else Return DoubleToString(m_dModifyValue, 1) End Select End Get Set(value As String) Dim dNewValue As Double = 0 Select Case m_nSelMediaType Case MediaTypes.HEIGHT If Integer.TryParse(value, dNewValue) Then m_dModifyValue = dNewValue Else NotifyPropertyChanged(NameOf(sModifyValue)) End If Case Else If StringToDouble(value, dNewValue) Then m_dModifyValue = dNewValue Else NotifyPropertyChanged(NameOf(sModifyValue)) End If End Select End Set End Property Private m_Media_Visibility As Visibility = Visibility.Visible Public ReadOnly Property Media_Visibility As Visibility Get Return m_Media_Visibility End Get End Property Private Sub SetMediaVisibility(bValue As Boolean) m_Media_Visibility = If(bValue, Visibility.Visible, Visibility.Collapsed) NotifyPropertyChanged(NameOf(Media_Visibility)) End Sub Private m_Set_Visibility As Visibility = Visibility.Collapsed Public ReadOnly Property Set_Visibility As Visibility Get Return m_Set_Visibility End Get End Property Private Sub SetSetVisibility(bValue As Boolean) m_Set_Visibility = If(bValue, Visibility.Visible, Visibility.Collapsed) NotifyPropertyChanged(NameOf(Set_Visibility)) End Sub Private m_FilterList As New List(Of String)({"", "Time Lower", "Time Ok", "Time Upper", "Speed Min", "Speed Max"}) Public ReadOnly Property FilterList As List(Of String) Get Return m_FilterList End Get End Property Private m_nSelFilter As Filters Public Property nSelFilter As Integer Get Return m_nSelFilter End Get Set(value As Integer) m_nSelFilter = value m_LayerList_View.Refresh() End Set End Property Private m_bColExtend As Boolean = False Public Property bColExtend As Boolean Get Return m_bColExtend End Get Set(value As Boolean) m_bColExtend = value NotifyPropertyChanged(NameOf(bColExtend)) NotifyPropertyChanged(NameOf(ColExtend_Visibility)) NotifyPropertyChanged(NameOf(ControlWidth)) End Set End Property Public ReadOnly Property ColExtend_Visibility As Visibility Get Return If(m_bColExtend, Visibility.Visible, Visibility.Collapsed) End Get End Property Public ReadOnly Property ControlWidth As Double Get Return If(m_bColExtend, 620, 310) End Get End Property Private m_bTFSEditor_IsEnabled As Boolean = True Public ReadOnly Property bTFSEditor_IsEnabled As Boolean Get Return m_bTFSEditor_IsEnabled End Get End Property Friend Sub SetTFSEditorIsEnabled(bValue As Boolean) m_bTFSEditor_IsEnabled = bValue NotifyPropertyChanged(NameOf(bTFSEditor_IsEnabled)) End Sub Private m_bWaitingTime As Boolean = False Public Property bWaitingTime As Boolean Get Return m_bWaitingTime End Get Set(value As Boolean) m_bWaitingTime = value Dim nLayTFSCalcId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, LAY_TFSCALC) If m_bWaitingTime Then EgtSetInfo(nLayTFSCalcId, KEY_EMITWAITINGTIME, True) Else EgtRemoveInfo(nLayTFSCalcId, KEY_EMITWAITINGTIME) End If ' aggiorno background di tutte le righe For Each Layer In m_LayerList Layer.NotifyPropertyChanged(NameOf(Layer.Background)) Next NotifyPropertyChanged(NameOf(MediaTypeList)) NotifyPropertyChanged(NameOf(ColWait_Visibility)) End Set End Property Public ReadOnly Property ColWait_Visibility As Visibility Get Return If(m_bWaitingTime, Visibility.Visible, Visibility.Collapsed) End Get End Property Public ReadOnly Property Modify_Msg As String Get Select Case m_nSelMediaType Case MediaTypes.HEIGHT Return "Slice Number:" 'Case MediaTypes.SECTIONCHANGE ' Return "Difference:" Case MediaTypes.SELECTION Return "Feed:" Case MediaTypes.SELECTION_WAIT Return "Wait:" Case MediaTypes.FEED_INCREMENT Return "Increment(%):" Case Else Return "" End Select End Get End Property #Region "Messages" Public ReadOnly Property Layer_Msg As String Get Return "Layer" End Get End Property Public ReadOnly Property Length_Msg As String Get Return "Length" End Get End Property Public ReadOnly Property TMin_Msg As String Get Return "TMin" End Get End Property Public ReadOnly Property TTrg_Msg As String Get Return "TTrg" End Get End Property Public ReadOnly Property TMax_Msg As String Get Return "TMax" End Get End Property Public ReadOnly Property TCurr_Msg As String Get Return "TCurr" End Get End Property Public ReadOnly Property TWait_Msg As String Get Return "TWait" End Get End Property Public ReadOnly Property FMin_Msg As String Get Return "FMin" End Get End Property Public ReadOnly Property FTrg_Msg As String Get Return "FTrg" End Get End Property Public ReadOnly Property FMax_Msg As String Get Return "FMax" End Get End Property Public ReadOnly Property FCurr_Msg As String Get Return "FCurr" End Get End Property Public ReadOnly Property Speed_Msg As String Get Return "Speed" End Get End Property Public ReadOnly Property Index_Msg As String Get Return "n°" End Get End Property Public ReadOnly Property Millimeters_Msg As String Get Return "mm" End Get End Property Public ReadOnly Property Seconds_Msg As String Get Return "min:s" End Get End Property Public ReadOnly Property MmPerMin_Msg As String Get Return "mm/min" End Get End Property Public ReadOnly Property Rpm_Msg As String Get Return "rpm" End Get End Property #End Region ' Messages ' Definizione comandi Private m_cmdSet As ICommand Private m_cmdMedia As ICommand Private m_cmdUpdate As ICommand Private m_cmdReset As ICommand Private m_cmdExtend As ICommand #End Region ' FIELDS & PROPERTIES #Region "CONSTRUCTORS" Sub New() ' Creo riferimento a questa classe in EgtCAM5Map Map.SetRefTFSEditorVM(Me) m_nSelMediaType = MediaTypes.HEIGHT NotifyPropertyChanged(NameOf(ghSelMediaType)) m_LayerList_View = CollectionViewSource.GetDefaultView(m_LayerList) m_LayerList_View.Filter = AddressOf LayerFilter AddHandler m_SelLayers.CollectionChanged, AddressOf SelLayers_CollectionChanged UpdateSpeedMinMax() ' inizializzo contatore per aggiornare grafica su selezione m_Selection_Timer.Interval = TimeSpan.FromMilliseconds(10) AddHandler m_Selection_Timer.Tick, AddressOf SelectionTimer_Tick NotifyPropertyChanged(NameOf(MediaTypeList)) End Sub #End Region ' CONSTRUCTORS #Region "METHODS" Private Sub SelLayers_CollectionChanged(sender As Object, e As NotifyCollectionChangedEventArgs) m_bCollectionChanging = True Select Case e.Action Case NotifyCollectionChangedAction.Add For Each AddedSelLayer In e.NewItems For Each nSliceId In AddedSelLayer.GeomSliceIdList EgtSelectObj(nSliceId) Next Next Case NotifyCollectionChangedAction.Remove For Each RemovedSelLayer In e.OldItems For Each nSliceId In RemovedSelLayer.GeomSliceIdList EgtDeselectObj(nSliceId) Next Next Case NotifyCollectionChangedAction.Replace Case NotifyCollectionChangedAction.Move Case NotifyCollectionChangedAction.Reset EgtDeselectAll() End Select m_Selection_Timer.Start() m_bCollectionChanging = False End Sub Private Sub SelectionTimer_Tick() If Not m_bCollectionChanging Then m_Selection_Timer.Stop() EgtDraw() End If End Sub Friend Sub Refresh() m_LayerList.Clear() Dim nLayTFSCalcId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, LAY_TFSCALC) Dim nTFSLayerId As Integer = EgtGetFirstInGroup(nLayTFSCalcId) While nTFSLayerId <> GDB_ID.NULL m_LayerList.Add(New TFSLayer(nTFSLayerId)) nTFSLayerId = EgtGetNext(nTFSLayerId) End While End Sub Private Function LayerFilter(Layer As Object) As Boolean Dim CurrLayer As TFSLayer = DirectCast(Layer, TFSLayer) Select Case m_nSelFilter Case Filters.NULL Return True Case Filters.TIME_LOWER Return CurrLayer.dTCurr < CurrLayer.dTMin Case Filters.TIME_OK Return CurrLayer.dTCurr >= CurrLayer.dTMin AndAlso CurrLayer.dTCurr <= CurrLayer.dTMax Case Filters.TIME_UPPER Return CurrLayer.dTCurr > CurrLayer.dTMax Case Filters.SPEED_MIN Return CurrLayer.dSpeed <= m_dSpeedMin Case Filters.SPEED_MAX Return CurrLayer.dSpeed >= m_dSpeedMax End Select Return True End Function Friend Sub UpdateSpeedMinMax() m_dSpeedMin = GetPrivateProfileDouble(S_MACH_PRINTING3D, K_SPEED_MIN, 0, CurrentMachine.sMachIniFile) m_dSpeedMax = GetPrivateProfileDouble(S_MACH_PRINTING3D, K_SPEED_MAX, 50000, CurrentMachine.sMachIniFile) End Sub #End Region ' METHODS #Region "COMMANDS" #Region "Set" ''' ''' Returns a command that do CPlaneTop. ''' Public ReadOnly Property Set_Command As ICommand Get If m_cmdSet Is Nothing Then m_cmdSet = New Command(AddressOf SetCmd) End If Return m_cmdSet End Get End Property ''' ''' Execute the CPlaneTop. This method is invoked by the CPlaneTopCommand. ''' Public Sub SetCmd() If m_LayerList.Count <= 0 Then Return Select Case m_nSelMediaType Case MediaTypes.SELECTION For Each Layer In m_SelLayers Layer.SetFCurr(m_dModifyValue) Next Case MediaTypes.SELECTION_WAIT For Each Layer In m_SelLayers Layer.SetTWait(m_dModifyValue) Next Case MediaTypes.FEED_INCREMENT For Each Layer In m_SelLayers Layer.SetFCurr(Layer.dFCurr * (m_dModifyValue / 100)) Next End Select End Sub #End Region ' Set #Region "Media" ''' ''' Returns a command that do CPlaneTop. ''' Public ReadOnly Property Media_Command As ICommand Get If m_cmdMedia Is Nothing Then m_cmdMedia = New Command(AddressOf Media) End If Return m_cmdMedia End Get End Property ''' ''' Execute the CPlaneTop. This method is invoked by the CPlaneTopCommand. ''' Public Sub Media() If m_LayerList.Count <= 0 Then Return Select Case m_nSelMediaType Case MediaTypes.HEIGHT ' verifico che sia un intero Dim nMediaHeight As Integer = Math.Floor(m_dModifyValue) If nMediaHeight <= 0 Then Return For Index = 0 To Math.Ceiling(m_LayerList.Count() / nMediaHeight) - 1 Dim dFSum As Double = 0 Dim dFIndex As Double = 0 For Index2 = (nMediaHeight * Index) To Math.Min(nMediaHeight * (Index + 1), m_LayerList.Count() - 1) dFSum += m_LayerList(Index2).sFCurr dFIndex += 1 Next Dim dNewFCurr As Double = dFSum / dFIndex For Index2 = (nMediaHeight * Index) To Math.Min(nMediaHeight * (Index + 1), m_LayerList.Count() - 1) m_LayerList(Index2).SetFCurr(dNewFCurr) Next Next 'Case MediaTypes.SECTIONCHANGE ' Dim ChangeIndexList As New List(Of Integer)({0}) ' Dim dPrevLength As Double = m_LayerList(0).dLength ' ' recupero punti di rottura ' For Index = 1 To m_LayerList.Count() - 1 ' Dim dCurrLength = m_LayerList(Index) ' If dPrevLength < m_LayerList(Index).dLength * (1 - (m_dModifyValue / 100)) OrElse dPrevLength > m_LayerList(Index).dLength * (1 + (m_dModifyValue / 100)) Then ' ChangeIndexList.Add(Index) ' End If ' dPrevLength = m_LayerList(Index).dLength ' Next ' If ChangeIndexList(ChangeIndexList.Count - 1) <> m_LayerList.Count() - 1 Then ' ChangeIndexList.Add(m_LayerList.Count() - 1) ' End If ' ' ricalcolo media sugli intervalli trovati ' For Index = 0 To ChangeIndexList.Count() - 2 ' Dim dFSum As Double = 0 ' Dim dFIndex As Double = 0 ' For Index2 = ChangeIndexList(Index) To ChangeIndexList(Index + 1) ' dFSum += m_LayerList(Index2).sFCurr ' dFIndex += 1 ' Next ' Dim dNewFCurr As Double = dFSum / dFIndex ' For Index2 = ChangeIndexList(Index) To ChangeIndexList(Index + 1) ' m_LayerList(Index2).SetFCurr(dNewFCurr) ' Next ' Next Case MediaTypes.SELECTION If m_SelLayers.Count <= 0 Then Return Dim dFSum As Double = 0 Dim dFIndex As Double = 0 For Each Layer In m_SelLayers dFSum += Layer.sFCurr dFIndex += 1 Next Dim dNewFCurr As Double = dFSum / dFIndex For Each Layer In m_SelLayers Layer.SetFCurr(dNewFCurr) Next End Select ' salvo selezione corrente Dim SelIndexList As New List(Of Integer) For Each SelLayer In m_SelLayers SelIndexList.Add(SelLayer.nIndex) Next '' ricalcolo valori 'Map.refSliceManagerVM.CalcSlice(False, True) '' ripristino layer selezionati 'For Each Index In SelIndexList ' Dim NewLayer As TFSLayer = m_LayerList.FirstOrDefault(Function(x) x.nIndex = Index) ' If Not IsNothing(NewLayer) Then ' m_SelLayers.Add(NewLayer) ' End If 'Next End Sub #End Region ' Media #Region "Update" ''' ''' Returns a command that do CPlaneTop. ''' Public ReadOnly Property Update_Command As ICommand Get If m_cmdUpdate Is Nothing Then m_cmdUpdate = New Command(AddressOf Update) End If Return m_cmdUpdate End Get End Property ''' ''' Execute the CPlaneTop. This method is invoked by the CPlaneTopCommand. ''' Public Sub Update() Map.refSliceManagerVM.Update() End Sub #End Region ' Update #Region "Reset" ''' ''' Returns a command that do CPlaneTop. ''' Public ReadOnly Property Reset_Command As ICommand Get If m_cmdReset Is Nothing Then m_cmdReset = New Command(AddressOf Reset) End If Return m_cmdReset End Get End Property ''' ''' Execute the CPlaneTop. This method is invoked by the CPlaneTopCommand. ''' Public Sub Reset() ' cancello gruppo della tabella Dim nLayTFSCalcId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, LAY_TFSCALC) EgtEmptyGroup(nLayTFSCalcId) For Each CurrPart In Map.refTopPanelVM.PartList EgtSetInfo(CurrPart.nPartId, MAC_TORECALC_TFS, True) Next Map.refSliceManagerVM.CalcSlice(False) End Sub #End Region ' Reset #Region "Extend" ''' ''' Returns a command that do CPlaneTop. ''' Public ReadOnly Property Extend_Command As ICommand Get If m_cmdExtend Is Nothing Then m_cmdExtend = New Command(AddressOf Extend) End If Return m_cmdExtend End Get End Property ''' ''' Execute the CPlaneTop. This method is invoked by the CPlaneTopCommand. ''' Public Sub Extend() m_bColExtend = Not m_bColExtend NotifyPropertyChanged(NameOf(bColExtend)) NotifyPropertyChanged(NameOf(ColExtend_Visibility)) NotifyPropertyChanged(NameOf(ControlWidth)) End Sub #End Region ' Extend #End Region ' COMMANDS End Class Public Class TFSLayer Inherits VMBase Private m_nId As Integer Public ReadOnly Property nId As Integer Get Return m_nId End Get End Property Private m_nIndex As Integer Public ReadOnly Property nIndex As Integer Get Return m_nIndex End Get End Property Private m_dLength As Double Public ReadOnly Property dLength As Double Get Return m_dLength End Get End Property Public ReadOnly Property sLength As String Get Return LenToString(m_dLength, 0) End Get End Property Private m_dTMin As Double Public ReadOnly Property dTMin As Double Get Return m_dTMin End Get End Property Public ReadOnly Property sTMin As String Get Return SecondsToStringConverter(m_dTMin) End Get End Property Private m_dTTrg As Double Public ReadOnly Property sTTrg As String Get Return SecondsToStringConverter(m_dTTrg) End Get End Property Private m_dTMax As Double Public ReadOnly Property dTMax As Double Get Return m_dTMax End Get End Property Public ReadOnly Property sTMax As String Get Return SecondsToStringConverter(m_dTMax) End Get End Property Private m_dTCurr As Double Public ReadOnly Property dTCurr As Double Get Return m_dTCurr End Get End Property Public ReadOnly Property sTCurr As String Get Return SecondsToStringConverter(m_dTCurr) End Get End Property Private m_dTWait As Double Public Property sTWait As String Get Return SecondsToStringConverter(m_dTWait) End Get Set(value As String) Dim dNewValue As Double If StringToLen(value, dNewValue) Then m_dTWait = dNewValue EgtSetInfo(nId, "WaitingTime", m_dTWait) m_bTWait_IsModified = True ' Imposto flag di ricalcolo generate EgtSetInfo(Map.refTopPanelVM.SelPart.nPartId, MAC_TORECALC_TFS, True) NotifyPropertyChanged(NameOf(Background)) NotifyPropertyChanged(NameOf(Foreground)) Else NotifyPropertyChanged(NameOf(sTWait)) End If End Set End Property Friend Sub SetTWait(value As Double) m_dTWait = value EgtSetInfo(nId, "WaitingTime", m_dTWait) m_bTWait_IsModified = True ' Imposto flag di ricalcolo generate EgtSetInfo(Map.refTopPanelVM.SelPart.nPartId, MAC_TORECALC_TFS, True) NotifyPropertyChanged(NameOf(Background)) NotifyPropertyChanged(NameOf(Foreground)) NotifyPropertyChanged(NameOf(sTWait)) End Sub Private m_bTWait_IsModified As Boolean Public ReadOnly Property bTWait_IsModified As Boolean Get Return m_bTWait_IsModified End Get End Property Private m_dFMin As Double Public ReadOnly Property sFMin As String Get Return LenToString(m_dFMin, 0) End Get End Property Private m_dFTrg As Double Public ReadOnly Property sFTrg As String Get Return LenToString(m_dFTrg, 0) End Get End Property Private m_dFMax As Double Public ReadOnly Property sFMax As String Get Return LenToString(m_dFMax, 0) End Get End Property Private m_dFCurr As Double Public Property sFCurr As String Get Return LenToString(m_dFCurr, 0) End Get Set(value As String) Dim dNewValue As Double If StringToLen(value, dNewValue) Then m_dFCurr = dNewValue EgtSetInfo(nId, "FCur", m_dFCurr) m_bFCurr_IsModified = True ' Imposto flag di ricalcolo generate EgtSetInfo(Map.refTopPanelVM.SelPart.nPartId, MAC_TORECALC_TFS, True) NotifyPropertyChanged(NameOf(Background)) NotifyPropertyChanged(NameOf(Foreground)) Else NotifyPropertyChanged(NameOf(sFCurr)) End If End Set End Property Friend Sub SetFCurr(value As Double) m_dFCurr = value EgtSetInfo(nId, "FCur", m_dFCurr) m_bFCurr_IsModified = True ' Imposto flag di ricalcolo generate EgtSetInfo(Map.refTopPanelVM.SelPart.nPartId, MAC_TORECALC_TFS, True) NotifyPropertyChanged(NameOf(Background)) NotifyPropertyChanged(NameOf(Foreground)) NotifyPropertyChanged(NameOf(sFCurr)) End Sub Public ReadOnly Property dFCurr As Double Get Return m_dFCurr End Get End Property Private m_bFCurr_IsModified As Boolean Public ReadOnly Property bFCurr_IsModified As Boolean Get Return m_bFCurr_IsModified End Get End Property Private m_dSpeed As Double Public ReadOnly Property dSpeed As Double Get Return m_dSpeed End Get End Property Public ReadOnly Property sSpeed As String Get Return DoubleToString(m_dSpeed, 0) End Get End Property Private m_GeomSliceIdList As New List(Of Integer) Public ReadOnly Property GeomSliceIdList As List(Of Integer) Get Return m_GeomSliceIdList End Get End Property Public ReadOnly Property Background As SolidColorBrush Get If m_bFCurr_IsModified OrElse m_bTWait_IsModified Then Return Brushes.White ElseIf (Not Map.refTFSEditorVM.bWaitingTime AndAlso m_dTCurr + 1 < m_dTMin) OrElse (Map.refTFSEditorVM.bWaitingTime AndAlso m_dTCurr + m_dTWait + 1 < m_dTMin) Then Return Dictionary.Icarus_Orange ElseIf m_dTCurr - 1 > m_dTMax Then Return Dictionary.Icarus_Purple Else Return Dictionary.Icarus_Green End If End Get End Property Public ReadOnly Property Foreground As SolidColorBrush Get If m_bFCurr_IsModified OrElse m_bTWait_IsModified Then Return Brushes.Black ElseIf m_dSpeed <= Map.refTFSEditorVM.dSpeedMin OrElse m_dSpeed >= Map.refTFSEditorVM.dSpeedMax Then If (Not Map.refTFSEditorVM.bWaitingTime AndAlso m_dTCurr + 1 < m_dTMin) OrElse (Map.refTFSEditorVM.bWaitingTime AndAlso m_dTCurr + m_dTWait + 1 < m_dTMin) OrElse m_dTCurr - 1 > m_dTMax Then Return New BrushConverter().ConvertFrom("#63181b") Else Return New BrushConverter().ConvertFrom("#961824") End If Else Return Brushes.White End If End Get End Property Public ReadOnly Property FontWeight As FontWeight Get If m_bFCurr_IsModified OrElse m_bTWait_IsModified Then Return FontWeights.Normal ElseIf m_dSpeed <= Map.refTFSEditorVM.dSpeedMin OrElse m_dSpeed >= Map.refTFSEditorVM.dSpeedMax Then Return FontWeights.Bold Else Return FontWeights.Normal End If End Get End Property Sub New(nId As Integer) m_nId = nId Dim sIndex As String = "" EgtGetName(nId, sIndex) Integer.TryParse(sIndex, m_nIndex) EgtGetInfo(nId, KEY_LENGTH, m_dLength) EgtGetInfo(nId, KEY_TMIN, m_dTMin) EgtGetInfo(nId, KEY_TTRG, m_dTTrg) EgtGetInfo(nId, KEY_TMAX, m_dTMax) EgtGetInfo(nId, KEY_TCUR, m_dTCurr) EgtGetInfo(nId, KEY_TWAIT, m_dTWait) EgtGetInfo(nId, KEY_FMIN, m_dFMin) EgtGetInfo(nId, KEY_FTRG, m_dFTrg) EgtGetInfo(nId, KEY_FMAX, m_dFMax) EgtGetInfo(nId, KEY_FCUR, m_dFCurr) EgtGetInfo(nId, KEY_SPEED, m_dSpeed) If EgtGetInfo(nId, KEY_SLICEID, sIndex) Then Dim sSliceIdList() As String = sIndex.Split(";"c) If sSliceIdList.Count > 0 Then For Each sSliceId In sSliceIdList Dim nSliceId As Integer = GDB_ID.NULL If Integer.TryParse(sSliceId, nSliceId) Then m_GeomSliceIdList.Add(nSliceId) End If Next End If End If NotifyPropertyChanged(NameOf(Background)) NotifyPropertyChanged(NameOf(Foreground)) End Sub Sub New(nId As Integer, nIndex As Integer, dLength As Double, dTMin As Double, dTTrg As Double, dTMax As Double, dTCurr As Double, dTWait As Double, dFMin As Double, dFTrg As Double, dFMax As Double, dFCurr As Double, dSpeed As Double) m_nId = nId m_nIndex = nIndex m_dLength = dLength m_dTMin = dTMin m_dTTrg = dTTrg m_dTMax = dTMax m_dTCurr = dTCurr m_dTWait = dTWait m_dFMin = dFMin m_dFTrg = dFTrg m_dFMax = dFMax m_dFCurr = dFCurr m_dSpeed = dSpeed End Sub Private Function SecondsToStringConverter(value As Double) As String Dim dtTime As TimeSpan = TimeSpan.FromSeconds(value) Dim dHours As Double = Math.Floor(dtTime.TotalHours) Dim dMinutes As Double = Math.Floor(dtTime.Minutes) Dim dSeconds As Double = Math.Ceiling(dtTime.Seconds) Return If(dHours > 0, dHours.ToString("00") & ":", "") & If(dHours > 0, dMinutes.ToString("00"), dMinutes.ToString()) & ":" & dSeconds.ToString("00") End Function End Class