Files
EgtWPFLib5/StatusBar/StatusBarVM.vb
T
Dario Sassi 00a338c202 Revert "Merge commit 'f1aae48a2b80f96ae94b59a69addd6cc6e48ee14'"
This reverts commit 1f49d0936e, reversing
changes made to 236eeac038.
2025-03-21 19:21:02 +01:00

246 lines
7.1 KiB
VB.net

Imports EgtWPFLib5
Public Class StatusBarVM
Inherits VMBase
#Region "FIELDS & PROPERTIES"
Private WithEvents OutputMessageTimer As New System.Windows.Threading.DispatcherTimer
' GRAPHICAL ELEMENTS
Private m_LoadingProgress As Integer
Public Property LoadingProgress As Integer
Get
Return m_LoadingProgress
End Get
Set(value As Integer)
m_LoadingProgress = value
End Set
End Property
Private m_LoadingProgress_Visibility As Visibility = Visibility.Hidden
Public ReadOnly Property LoadingProgress_Visibility As Visibility
Get
Return m_LoadingProgress_Visibility
End Get
End Property
Private m_StopProgress_IsActive As Boolean = False
Private m_StopProgress_IsEnabled As Boolean = False
Public Property StopProgress_IsEnabled As Boolean
Get
Return m_StopProgress_IsEnabled
End Get
Set(value As Boolean)
m_StopProgress_IsEnabled = value
End Set
End Property
Private m_StopProgress_Visibility As Visibility = Visibility.Hidden
Public ReadOnly Property StopProgress_Visibility As Visibility
Get
Return m_StopProgress_Visibility
End Get
End Property
Private m_OutputMessage As String
Public Property OutputMessage As String
Get
Return m_OutputMessage
End Get
Set(value As String)
m_OutputMessage = value
NotifyPropertyChanged( "OutputMessage")
End Set
End Property
Private m_OutputMessage_Foreground As Brush = Brushes.Black
Public Property OutputMessage_Foreground As Brush
Get
Return m_OutputMessage_Foreground
End Get
Set(value As Brush)
m_OutputMessage_Foreground = value
NotifyPropertyChanged("OutputMessage_Foreground")
End Set
End Property
Private m_MeasureUnit As String
Public Property MeasureUnit As String
Get
Return m_MeasureUnit
End Get
Set(value As String)
m_MeasureUnit = value
End Set
End Property
Private m_CurrPos As String
Public Property CurrPos As String
Get
Return m_CurrPos
End Get
Set(value As String)
m_CurrPos = value
End Set
End Property
Private m_SnapPointType As String
Public Property SnapPointType As String
Get
Return m_SnapPointType
End Get
Set(value As String)
m_SnapPointType = value
End Set
End Property
Private m_SnapPointType_Background As SolidColorBrush
Public Property SnapPointType_Background As SolidColorBrush
Get
Return m_SnapPointType_Background
End Get
Set(value As SolidColorBrush)
m_SnapPointType_Background = value
End Set
End Property
' Commands definition
Private m_cmdClearOutputMessage As ICommand
#End Region ' FIELDS & PROPERTIES
#Region "CONSTRUCTOR"
Sub New()
' Creo riferimento a questa classe in OmagOFFICEMap
LibMap.SetRefStatusBarVM(Me)
End Sub
#End Region ' CONSTRUCTOR
#Region "METHODS"
Public Sub SetLoadingProgress(sProgress As Integer)
m_LoadingProgress = sProgress
NotifyPropertyChanged("LoadingProgress")
End Sub
Public Sub SetLoadingProgress_Visibility(IsVisible As Boolean)
If IsVisible Then
If m_StopProgress_IsActive Then
m_StopProgress_Visibility = Visibility.Visible
Else
m_StopProgress_Visibility = Visibility.Hidden
End If
m_LoadingProgress_Visibility = Visibility.Visible
Else
m_LoadingProgress_Visibility = Visibility.Hidden
m_StopProgress_Visibility = Visibility.Hidden
End If
NotifyPropertyChanged("LoadingProgress_Visibility")
NotifyPropertyChanged("StopProgress_Visibility")
End Sub
Public Sub SetStopProgress_IsEnabled(IsEnabled As Boolean)
m_StopProgress_IsEnabled = IsEnabled
NotifyPropertyChanged("StopProgress_IsEnabled")
End Sub
Public Sub SetStopProgress_IsActive(IsActive As Boolean)
m_StopProgress_IsActive = IsActive
End Sub
Public Overloads Sub SetOutputMessage(sMessage As String, Optional nMsgType As MSG_TYPE = MSG_TYPE.INFO)
SetMsgColor(nMsgType)
m_OutputMessage = sMessage
NotifyPropertyChanged("OutputMessage")
End Sub
Public Overloads Sub SetOutputMessage(sMessage As String, nTime As Integer, Optional nMsgType As MSG_TYPE = MSG_TYPE.INFO)
SetMsgColor(nMsgType)
m_OutputMessage = sMessage
NotifyPropertyChanged("OutputMessage")
OutputMessageTimer.Interval = TimeSpan.FromSeconds(nTime)
OutputMessageTimer.IsEnabled = True
OutputMessageTimer.Start()
End Sub
Public Overridable Sub ClearOutputMessage()
m_OutputMessage_Foreground = Brushes.Black
NotifyPropertyChanged("MsgColor")
m_OutputMessage = String.Empty
NotifyPropertyChanged("OutputMessage")
If OutputMessageTimer.IsEnabled Then
OutputMessageTimer.Stop()
OutputMessageTimer.IsEnabled = False
End If
End Sub
Public Sub SetMeasureUnit(nMeasureUnit As Integer)
m_MeasureUnit = If(nMeasureUnit = 0, "in", "mm")
NotifyPropertyChanged("MeasureUnit")
End Sub
Public Sub SetCurrPos(sCurrPos As String)
m_CurrPos = sCurrPos
NotifyPropertyChanged("CurrPos")
End Sub
Public Sub SetMsgColor(nMsgType As MSG_TYPE)
Select Case nMsgType
Case MSG_TYPE.INFO
m_OutputMessage_Foreground = Brushes.Black
Case MSG_TYPE.WARNING
m_OutputMessage_Foreground = Brushes.SaddleBrown
Case MSG_TYPE.ERROR_
m_OutputMessage_Foreground = Brushes.Red
End Select
NotifyPropertyChanged("OutputMessage_Foreground")
End Sub
Public Sub SetSnapPointType(sSnapPntType As String, Optional SnapPntTypeBackground As Brush = Nothing)
m_SnapPointType = sSnapPntType
NotifyPropertyChanged("SnapPointType")
If Not IsNothing(SnapPntTypeBackground) Then
m_SnapPointType_Background = SnapPntTypeBackground
NotifyPropertyChanged("SnapPointTypeBackground")
End If
End Sub
#End Region ' METHODS
#Region "COMMANDS"
#Region "ClearOutputMessage"
''' <summary>
''' Returns a command that choose the current reference.
''' </summary>
Public Overridable ReadOnly Property ClearOutputMessage_Command As ICommand
Get
If m_cmdClearOutputMessage Is Nothing Then
m_cmdClearOutputMessage = New Command(AddressOf ClearOutputMessage)
End If
Return m_cmdClearOutputMessage
End Get
End Property
#End Region ' ClearOutputMessage
#End Region ' COMMANDS
#Region "EVENTS"
Private Sub OutputMessageTimer_Tick(source As Object, e As EventArgs) Handles OutputMessageTimer.Tick
ClearOutputMessage()
OutputMessageTimer.Stop()
OutputMessageTimer.IsEnabled = False
End Sub
#End Region ' EVENTS
End Class