Community
Showing results for 
Search instead for 
Do you mean 
Reply

Inserting a navbar button

Accepted Solution Solved
New Member
Posts: 8
Country: USA
Accepted Solution

Inserting a navbar button

Hello

 

Does anyone have any sample code on creating a new navbar item at the bottom left of the program?

 


Accepted Solutions
Solution
Accepted by topic author theone
‎09-25-2015 03:20 AM
Bronze Super Contributor
Posts: 1,231
Country: USA

Re: Inserting a navbar button

[ Edited ]

In Impact we licensed a version of Infragistics UltraWinExplorerBar to support this code.
Impact adds a new bar group for every custom table in the current ACT database.

 

This is sudo code....

 

'--------------------------------------
' Create a new barGroup obeject

'--------------------------------------
Dim CustomBarGroup As New Infragistics.Win.UltraWinExplorerBar.UltraExplorerBarGroup

CustomBarGroup.Key = "myViewKey"
CustomBarGroup.Text = "myDisplayName"

 

'-----------------------------------------------
' Create a tag object so we can navigate to the

' custom table view on the GroupClick event
'-----------------------------------------------
Dim myTag As New Durkin.Common.Classes.Objects.ObjectNamed( "myViewKey", "myDisplayName")
CustomBarGroup.Tag = myTag

 

'--------------------------------------
' Create an image object

'--------------------------------------
Dim bmpImage As Drawing.Bitmap = Nothing

 

'-----------------------------------------------
' Get the JPG image from the hard drive

since we allow the users to change the custom table icon
'-----------------------------------------------
bmpImage = New Drawing.Bitmap("C:\Program Files (x86)\ACT\Act for Windows\Plugins\Durkin Computing\Invoice.jpg")

'-----------------------------------------------

' Add the image to the toolbar
'-----------------------------------------------

CustomBarGroup.Settings.AppearancesSmall.ActiveAppearance.Image = bmpImage
CustomBarGroup.Settings.AppearancesSmall.HeaderAppearance.Image = bmpImage
CustomBarGroup.Settings.AppearancesLarge.HeaderAppearance.Image = bmpImage

 

'-----------------------------------------------

' Make is visible by default

'-----------------------------------------------

CustomBarGroup.Visible = MakeVisible

 

'-----------------------------------------------

' Get the navBar from the UI

'-----------------------------------------------

Dim ACTUltraExplorerBar As Infragistics.Win.UltraWinExplorerBar.UltraExplorerBar

ACTUltraExplorerBar  = me.FindControl("ultraExplorerBar1", HostApplication)

 

'-----------------------------------------------

' Add the CustomGroup to the NavBar
'-----------------------------------------------
UltraExplorerBar.Groups.Add(CustomBarGroup)

 

'-----------------------------------------------

' Add a handler so we can pick up the UI group click event

'-----------------------------------------------

AddHandler UltraExplorerBar.GroupClick, AddressOf ImpactNavBar_GroupClick

 

 

Here is the click Infragistics group click event routing

Private Sub ImpactNavBar_GroupClick(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinExplorerBar.GroupEventArgs)
Try
'-----------------------------------------------------
' Which CustomView NavBar item was clicked?
'-----------------------------------------------------
If TypeOf e.Group.Tag Is Durkin.Common.Classes.Objects.ObjectNamed Then
'-----------------------------------------------------
' Show Impact's Custom View in the UI
'-----------------------------------------------------
Me.ShowViewCustom(e.Group.Key, e.Group.Tag.Name)

Else
' DO nothing since we need ACT 
' to handle this native click event
End If

Catch ex As Exception
LogError.Write(ex, "ImpactNavBar_GroupClick")
End Try

End Sub

 

 

Here is the function to get any control from the ACT UI. Just pass the control name and the ACT Application 

' Find a control in ACT
Public Shared Function FindControl(ByVal ControlName As String, ByVal CurrentControl As Control) As Control
Try
For Each ctr As Control In CurrentControl.Controls
If ctr.Name.ToUpper() = ControlName.ToUpper() Then
Return ctr
Else
ctr = FindControl(ControlName, ctr)
If Not ctr Is Nothing Then
Return ctr
End If
End If
Next ctr
Catch ex As Exception
Throw New ExceptionCustom.ACTCustomException("FindControl: " + ex.Message)
End Try

Return Nothing
End Function

 

Hope this helps

-- Jim Durkin

DurkinComputing.com

 

View solution in original post


All Replies
Employee
Posts: 1,163
Country: USA

Re: Inserting a navbar button

I don't have any sample code available that adds items to the left hand navigation panel. However some code was left on this forum for renaming items on this component. It may help get you going in the right direction.

 

http://community.act.com/t5/Sage-ACT-Developer-s-Forum/Rename-ACT-Navigation-Bar/m-p/72299#M2931

Matthew Wood
Act! SDK Support
Community Moderator
New Member
Posts: 8
Country: USA

Re: Inserting a navbar button

I haven't had much luck with those examples as they are in VB and I'm wirting in C#

 

I can compile in VB and run them so I know that it can be done in the program. 

 

Using the following code from the VB example, I don't know how to access  App.Controls.Item("navbar") in c#

 

    Dim WithEvents nb As NavBar

 

    Public Sub OnLoad(ByVal App As Act.UI.ActApplicationImplements Act.UI.IPlugin.OnLoad

        nb = App.Controls.Item("navbar")

 

 

If anyone has any examples, it would be much appreciated

Solution
Accepted by topic author theone
‎09-25-2015 03:20 AM
Bronze Super Contributor
Posts: 1,231
Country: USA

Re: Inserting a navbar button

[ Edited ]

In Impact we licensed a version of Infragistics UltraWinExplorerBar to support this code.
Impact adds a new bar group for every custom table in the current ACT database.

 

This is sudo code....

 

'--------------------------------------
' Create a new barGroup obeject

'--------------------------------------
Dim CustomBarGroup As New Infragistics.Win.UltraWinExplorerBar.UltraExplorerBarGroup

CustomBarGroup.Key = "myViewKey"
CustomBarGroup.Text = "myDisplayName"

 

'-----------------------------------------------
' Create a tag object so we can navigate to the

' custom table view on the GroupClick event
'-----------------------------------------------
Dim myTag As New Durkin.Common.Classes.Objects.ObjectNamed( "myViewKey", "myDisplayName")
CustomBarGroup.Tag = myTag

 

'--------------------------------------
' Create an image object

'--------------------------------------
Dim bmpImage As Drawing.Bitmap = Nothing

 

'-----------------------------------------------
' Get the JPG image from the hard drive

since we allow the users to change the custom table icon
'-----------------------------------------------
bmpImage = New Drawing.Bitmap("C:\Program Files (x86)\ACT\Act for Windows\Plugins\Durkin Computing\Invoice.jpg")

'-----------------------------------------------

' Add the image to the toolbar
'-----------------------------------------------

CustomBarGroup.Settings.AppearancesSmall.ActiveAppearance.Image = bmpImage
CustomBarGroup.Settings.AppearancesSmall.HeaderAppearance.Image = bmpImage
CustomBarGroup.Settings.AppearancesLarge.HeaderAppearance.Image = bmpImage

 

'-----------------------------------------------

' Make is visible by default

'-----------------------------------------------

CustomBarGroup.Visible = MakeVisible

 

'-----------------------------------------------

' Get the navBar from the UI

'-----------------------------------------------

Dim ACTUltraExplorerBar As Infragistics.Win.UltraWinExplorerBar.UltraExplorerBar

ACTUltraExplorerBar  = me.FindControl("ultraExplorerBar1", HostApplication)

 

'-----------------------------------------------

' Add the CustomGroup to the NavBar
'-----------------------------------------------
UltraExplorerBar.Groups.Add(CustomBarGroup)

 

'-----------------------------------------------

' Add a handler so we can pick up the UI group click event

'-----------------------------------------------

AddHandler UltraExplorerBar.GroupClick, AddressOf ImpactNavBar_GroupClick

 

 

Here is the click Infragistics group click event routing

Private Sub ImpactNavBar_GroupClick(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinExplorerBar.GroupEventArgs)
Try
'-----------------------------------------------------
' Which CustomView NavBar item was clicked?
'-----------------------------------------------------
If TypeOf e.Group.Tag Is Durkin.Common.Classes.Objects.ObjectNamed Then
'-----------------------------------------------------
' Show Impact's Custom View in the UI
'-----------------------------------------------------
Me.ShowViewCustom(e.Group.Key, e.Group.Tag.Name)

Else
' DO nothing since we need ACT 
' to handle this native click event
End If

Catch ex As Exception
LogError.Write(ex, "ImpactNavBar_GroupClick")
End Try

End Sub

 

 

Here is the function to get any control from the ACT UI. Just pass the control name and the ACT Application 

' Find a control in ACT
Public Shared Function FindControl(ByVal ControlName As String, ByVal CurrentControl As Control) As Control
Try
For Each ctr As Control In CurrentControl.Controls
If ctr.Name.ToUpper() = ControlName.ToUpper() Then
Return ctr
Else
ctr = FindControl(ControlName, ctr)
If Not ctr Is Nothing Then
Return ctr
End If
End If
Next ctr
Catch ex As Exception
Throw New ExceptionCustom.ACTCustomException("FindControl: " + ex.Message)
End Try

Return Nothing
End Function

 

Hope this helps

-- Jim Durkin

DurkinComputing.com

 

New Member
Posts: 8
Country: USA

Re: Inserting a navbar button

[ Edited ]

Thanks for the reply Jim.

I had a go applying your sudo code to my C# plugin but didn't have much luck, I might be going about it completely wrong however. Heres my code if you can point me in the right direction.

 

UltraExplorerBarGroup custombargroup = new UltraExplorerBarGroup();
custombargroup.Key = "My View Key";
custombargroup.Text = "myDisplayName";
custombargroup.Visible = true;
Control navbarcontrol;
navbarcontrol = FindControl("NAVBAR", oApp);
UltraExplorerBar actultraexplorerbar;
actultraexplorerbar = (UltraExplorerBar) navbarcontrol;
actultraexplorerbar.Groups.Add(custombargroup);
.....
public Control FindControl(string ControlName, Control CurrentControl)
{
foreach (Control ctr in CurrentControl.Controls)
{
if (ctr.Name.ToUpper() == ControlName.ToUpper())
{
return ctr;
}
.....

 

If anyone manages to show me some code that will do this, I will give you a medal (figuratively speaking )


At the end of the day though, I can provide access to my plugins via other means, but for this particular one, a new navbar would be ideal.

 

Edit: Is there not just some sort of equivalent to the below, but for adding navbar buttons?

 

oApp.RegisterCommand("act-ui://com.act/application/MyCommands/Button", new Act.UI.CommandHandler(handler), Act.UI.RegisterType.Shell);
CommandBarButton button = new CommandBarButton("plugin", "plugin", null, "act-ui://com.act/application/MyCommands/plugin", newImage, newImage, Act.UI.Core.CommandBarControl.ItemDisplayStyle.ImageAndText, true);
oApp.Explorer.CommandBarCollection["ACT! Toolbar"].ControlCollection.Add(button);

Bronze Super Contributor
Posts: 1,231
Country: USA

Re: Inserting a navbar button

It a glance the code look OK.

Does it throw an error?

 

 

-- Jim

New Member
Posts: 8
Country: USA

Re: Inserting a navbar button

Cheers Jim

 

Your solution actually worked for me in the end. I just had to add a few tweaks with regards to how how I was iterting through the controls to get the ultraexplorerbar and do some casting.

 

Much Appreciated!

Copper Super Contributor
Posts: 112
Country: Australia

Re: Inserting a navbar button

i could be wrong cause i am going from memory here, but to get the navbar control you should not have to loop through controls to find it??

In your plugin under OnLoad, you should be able to get it like
Control navbarcontrol;
navbarcontrol = oApp.Controls.Item("navbar");
or a full cast
UltraExplorerBar actultraexplorerbar;
actultraexplorerbar = (UltraExplorerBar) oApp.Controls.Item("navbar");

now my C# is prolly off, cant remember if you have to use [] or (), been doing a lot of Obj-C lately... but the point is that navbar is a top level item, so you shouldnt need to loop through controls to find it
I know i have a heap of code where i added my own controls from menus, toolbars, group buttons, custom form controls
New Member
Posts: 8
Country: USA

Re: Inserting a navbar button

That would be good if there was a method like this that I could use. Especially since I can't seem to add the navbar in the after logon event.

 

But there is no accessible 'Item' property in the controls class from what I can see

 

oApp.Controls.Item("navbar");

 


Employee
Posts: 1,163
Country: USA

Re: Inserting a navbar button

"Item" is only used in VB, in c# you just put the index/key in brackets following the collection. So in this case it'd look like:

 

Control navbar = ActApp.Controls["navbar"];

 

Also a general word of caution, any work done prior to AfterLogon, particularly in OnLoad can impact the load time of the appliation. It's advised where ever possible to have your plug-in do most of it's work AfterLogon.

Matthew Wood
Act! SDK Support
Community Moderator