Messing with the status bar is a little more complicated now because of some of the new functionality that has been added to Jiwa (such as status bar colours per warehouse). We can still override this behavior via plugin, but a little more effort is required.
First of all, we need to add our handler at MainForm.Shown to ensure that our code is run *after* Jiwa's native warehouse colourisation code.
Second, we must add a reference to Jiwa.exe so that our plugin knows about the MainForm class.
Third, we need to change the colour of a number of controls in addition to the status bar - some panels sit upon the status bar now!
Finally, we need to ensure that our code is thread-safe, as the warehouse can be changed from business logic that may be running in a thread different to that of the main form.
The code is below. I've also attached the full plugin to this post so you can just import it and modify it to suit your specific needs.
- Code: Select all
Public Class ApplicationManagerPlugin
Inherits System.MarshalByRefObject
Implements JiwaApplication.IJiwaApplicationManagerPlugin
Public Overrides Function InitializeLifetimeService() As Object
' returning null here will prevent the lease manager
' from deleting the Object.
Return Nothing
End Function
Public Sub Setup(ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaApplicationManagerPlugin.Setup
AddHandler JiwaApplication.Manager.Instance.MDIParentForm.Shown, AddressOf MainForm_Shown
End Sub
Public Sub MainForm_Shown(ByVal eventSender As Object, ByVal eventArgs As System.EventArgs)
'Set the colour initially
SetStatusbarColour
'Force our colouring over the top of warehouse colouring
AddHandler JiwaApplication.Manager.Instance.WarehouseStatusChanged, AddressOf JiwaApplicationManager_WarehouseStatusChanged
End Sub
Delegate Sub JiwaApplicationManager_WarehouseStatusChangedCallback(ByVal NewStatus As String)
Private Sub JiwaApplicationManager_WarehouseStatusChanged(ByVal NewStatus As String)
' Can't update the label from another thread, so we use the delegate technique to add to message queue which will be pumped when .NET sees fit.
If JiwaApplication.Manager.Instance.MDIParentForm.InvokeRequired Then
Dim MyJiwaApplicationManager_WarehouseStatusChangedCallback As New JiwaApplicationManager_WarehouseStatusChangedCallback(AddressOf JiwaApplicationManager_WarehouseStatusChanged)
JiwaApplication.Manager.Instance.MDIParentForm.Invoke(MyJiwaApplicationManager_WarehouseStatusChangedCallback, New Object() {NewStatus})
Else
SetStatusbarColour
End If
End Sub
Public Sub SetStatusbarColour()
Dim UltraStatusBar1 As Infragistics.Win.UltraWinStatusBar.UltraStatusBar = DirectCast(JiwaApplication.Manager.Instance.MDIParentForm, Jiwa.MainForm).UltraStatusBar1
Dim NotificationAreaUltraPanel As Infragistics.Win.Misc.UltraPanel = DirectCast(JiwaApplication.Manager.Instance.MDIParentForm, Jiwa.MainForm).NotificationAreaUltraPanel
UltraStatusBar1.Appearance.BackColor = System.Drawing.Color.Red
UltraStatusBar1.Appearance.ForeColor = System.Drawing.Color.White
NotificationAreaUltraPanel.Appearance.BackColor = System.Drawing.Color.Red
NotificationAreaUltraPanel.Appearance.ForeColor = System.Drawing.Color.White
DirectCast(NotificationAreaUltraPanel.ClientArea.Controls("Login Time And Date"), Infragistics.Win.Misc.UltraLabel).Appearance.BackColor = UltraStatusBar1.Appearance.BackColor
DirectCast(NotificationAreaUltraPanel.ClientArea.Controls("Login Time And Date"), Infragistics.Win.Misc.UltraLabel).Appearance.ForeColor = UltraStatusBar1.Appearance.ForeColor
End Sub
End Class