UIExtensionSites for UltraExplorerBar

Topics: CAB & Smart Client Software Factory
Oct 13, 2006 at 3:01 AM
originally posted by: subahnet

Hi frnds,

I have an UltraExplorerBar in my application, i want to add the groups to it from the module just like what we do for the toolstrips and menus. Is there no UIElementFactory for UltraExplorerBar..... please help me out ..... thanx in advance
Oct 13, 2006 at 9:14 AM
originally posted by: matiaswoloski

You should be able to do that. The ExplorerBarUIAdapterFactory shows that it supports adding an UltraExplorerBar

public bool Supports(object uiElement)
{
return uiElement is UltraExplorerBar ||
uiElement is UltraExplorerBarGroup ||
uiElement is UltraExplorerBarItemsCollection ||
uiElement is UltraExplorerBarItem;
}

Are you getting any exception? Can you show us your code?

Thanks
Matias
http://staff.southworks.net/blogs/matiaswoloski
Oct 13, 2006 at 11:15 AM
originally posted by: TrevStar22

Infragistics has released CAB extensions for their controls. If you don't have the latest controls, you can still install the trial software, and then re-compile the CAB extensions with whatever version you do own.

I had to modify the UltraExplorerBar and UltraExplorerItems so that they would work properly as UIExtensionSite items, though. The reason is that neither of these has a Click event that you can subscribe to.

I've posted the code below...

public partial class ClickableUltraExplorerBarItem : UltraExplorerBarItem
{
public event EventHandler Click;

public ClickableUltraExplorerBarItem()
{
}

public ClickableUltraExplorerBarItem(string key)
{
Key = key;
}

protected override void OnAddedToCollection(Infragistics.Shared.KeyedSubObjectsCollectionBase primaryCollection)
{
base.OnAddedToCollection(primaryCollection);
AssignClickEvent();
}

internal void AssignClickEvent()
{
if (ExplorerBar != null)
ExplorerBar.ItemClick += new ItemClickEventHandler(ExplorerBar_ItemClick);
}

void ExplorerBar_ItemClick(object sender, ItemEventArgs e)
{
if (e.Item == this)
{
if (Click != null)
{
Click(this, EventArgs.Empty);
}
}
}

}

public class ClickableUltraExplorerBarGroup : UltraExplorerBarGroup
{
public event EventHandler Click;

public ClickableUltraExplorerBarGroup()
{ }

public ClickableUltraExplorerBarGroup(string key)
: base(key)
{
}

protected override void OnAddedToCollection(Infragistics.Shared.KeyedSubObjectsCollectionBase primaryCollection)
{
base.OnAddedToCollection(primaryCollection);

if (ExplorerBar != null)
{
ExplorerBar.GroupClick += new GroupClickEventHandler(ExplorerBar_GroupClick);

foreach (UltraExplorerBarItem itm in this.Items)
{
if (itm is ClickableUltraExplorerBarItem)
{
((ClickableUltraExplorerBarItem)itm).AssignClickEvent();
}
}
}
}

void ExplorerBar_GroupClick(object sender, GroupEventArgs e)
{
if (e.Group == this)
{
if (Click != null)
{
Click(this, EventArgs.Empty);
}
}
}
}

Now you can use this for the groups extension:
ClickableUltraExplorerBarGroup grp1 = new ClickableUltraExplorerBarGroup("MyGroup");
grp1.Text = "My Group Name";
grp1.Expanded = true;
WorkItem.UIExtensionSitesUIExtensionSiteNames.ExplorerBarGroups.Add<UltraExplorerBarGroup>(grp1);

Then you can add items:
ClickableUltraExplorerBarItem itm;
itm = new ClickableUltraExplorerBarItem("myitem");
itm.Text = "My Item";
itm.Click += new EventHandler(itm_Click);


Hope this helps.
Oct 13, 2006 at 9:01 PM
originally posted by: subahnet

I get the following exception while handling with the UIExtensionSites.

No UIElementAdapterFactory register for type Infragistics.Win.UltraWinExplorerBar.UltraExplorerBar.
Oct 13, 2006 at 9:05 PM
originally posted by: subahnet

This is what the code i am writing in the ModuleController.. i Have registerd the explorer bar in shell also...

UltraExplorerBarGroup _group = new UltraExplorerBarGroup();
this.WorkItem.UIExtensionSitesUIExtensionSiteNames.MainExplorer.Add(_group);
Oct 13, 2006 at 10:00 PM
originally posted by: dagpauk

This is what we've added in the OnViewSet method of the ShellLayoutViewPresenter. It sets up a ultraexplorerbar, deckworkspace and ultradockworkspace


Microsoft.Practices.CompositeUI.UIElements.IUIElementAdapterFactoryCatalog catalog = catalog = WorkItem.Services.Get<Microsoft.Practices.CompositeUI.UIElements.IUIElementAdapterFactoryCatalog>();
catalog.RegisterFactory(new Infragistics.Practices.CompositeUI.WinForms.UIElements.ToolbarsManagerUIAdapterFactory());
catalog.RegisterFactory(new Infragistics.Practices.CompositeUI.WinForms.UIElements.StatusBarUIAdapterFactory());
WorkItem.UIExtensionSites.RegisterSite(UIExtensionSiteNames.MainMenuBar, View.MainToolbarsManager.ToolbarsUIExtensionSiteNames.MainMenuBar);
WorkItem.UIExtensionSites.RegisterSite(UIExtensionSiteNames.MainStatusBar, View.MainStatusBar);
WorkItem.UIExtensionSites.RegisterSite(UIExtensionSiteNames.MainToolBar, View.MainToolbarsManager.ToolbarsUIExtensionSiteNames.MainToolBar);

Infragistics.Practices.CompositeUI.WinForms.UltraDockWorkspace main = View.MainWorkspace;
WorkItem.Workspaces.Add(main, WorkspaceNames.MainWorkspace);

Infragistics.Practices.CompositeUI.WinForms.UltraExplorerBarWorkspace module = View.ModuleWorkspace;
WorkItem.Workspaces.Add(module, WorkspaceNames.ModuleWorkspace);

Microsoft.Practices.CompositeUI.WinForms.DeckWorkspace task = View.TaskWorkspace;
WorkItem.Workspaces.Add(task, WorkspaceNames.TaskWorkspace );
Oct 14, 2006 at 2:18 AM
originally posted by: subahnet

I am sorry but i am not clear on wat u r saying...
Oct 14, 2006 at 11:51 AM
originally posted by: TrevStar22

In this example, I register the extension site from the presenter's OnViewSet method. The explorer bar instance is exposed through the View's interface as CategorySelector.

WorkItem.UIExtensionSites.RegisterSite(UIExtensionSiteNames.ExplorerBarGroups, View.CategorySelector);