Change the colour of the bottom panel(s)  Topic is solved

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

Change the colour of the bottom panel(s)

Postby DannyC » Tue Jun 03, 2014 4:41 pm

I used to have a handy breakout which would change the colour of one of the bottom panels if users logged into a different database (say a test/play /training database). It would give a quick visual indicator that the user is not in the normal database.
How can we change the colour of either the warehouse name panel or the panel adjacent where username & login dates are? Note I am not looking to change the warehouse colour on the bottom of each module - I am talking about the warehouse name at the bottom of the Jiwa screen.

The overall goal is to have an obvious visual indicator that the user is in a different database.

Cheers

Danny
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Change the colour of the bottom panel(s)  Topic is solved

Postby Mike.Sheen » Tue Jun 10, 2014 10:09 pm

DannyC wrote:I used to have a handy breakout which would change the colour of one of the bottom panels if users logged into a different database (say a test/play /training database). It would give a quick visual indicator that the user is not in the normal database.
How can we change the colour of either the warehouse name panel or the panel adjacent where username & login dates are? Note I am not looking to change the warehouse colour on the bottom of each module - I am talking about the warehouse name at the bottom of the Jiwa screen.

The overall goal is to have an obvious visual indicator that the user is in a different database.

Cheers

Danny


Hi Danny,

I'm yet to try this - but you can access that control using JiwaApplication.Manager.Instance.MDIParent.Statusbar and from there you will be able to access each panel and the controls on it and set the background colours.

I'll try this later and post back exactly how - but if you're feeling inquisitive in the meantime, feel free to have a crack at it yourself.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: Change the colour of the bottom panel(s)

Postby Microsharp » Thu Apr 30, 2015 1:21 am

Hi Mike

We tried this by creating a new plug in but could not access the StatusBar control (See below). Could you please help?


....
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.Load, AddressOf MainForm_Load
End Sub

Public Sub MainForm_Load(ByVal eventSender As Object, ByVal eventArgs As System.EventArgs)

AddHandler DirectCast(eventSender, System.Windows.Forms.Form).FormClosing, AddressOf MainForm_FormClosing
'JiwaApplication.Manager.Instance.MDIParentForm.MdiParent.Controls

End Sub

........
Microsharp
Occasional Contributor
Occasional Contributor
 
Posts: 19
Joined: Wed Apr 29, 2015 4:51 pm
Topics Solved: 1

Re: Change the colour of the bottom panel(s)

Postby Scott.Pearce » Thu Apr 30, 2015 11:20 am

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
Attachments
Plugin Set MainForm status by to red.xml
(32.69 KiB) Downloaded 585 times
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 765
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 230

Re: Change the colour of the bottom panel(s)

Postby DannyC » Thu Jan 21, 2016 3:34 pm

Scott,

Been a while, but I have finally got around to playing around with this.
In my case, the colour change would be based on the database name, as I am copying the live DB to a test DB at regular intervals and I needed a way to change the colour only if in the test database, so the plugin needs to be deployed into live database, but only show in test database.
So I just use
Code: Select all
   Public Sub MainForm_Shown(ByVal eventSender As Object, ByVal eventArgs As System.EventArgs)
      If RIGHT(JiwaApplication.Manager.Instance.Database.DatabaseName,4) = "Test" Then
         'Set the colour initially
         SetStatusbarColour
         'Force our colouring over the top of warehouse colouring
         AddHandler JiwaApplication.Manager.Instance.WarehouseStatusChanged, AddressOf JiwaApplicationManager_WarehouseStatusChanged   
         End If
   End Sub   


This works a treat! I know it was quite a while ago, but thanks anyway.
BTW, I've deployed this in 7.0.149.

Danny
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 3 guests