Custom UIElements

Topics: CAB & Smart Client Software Factory
Oct 15, 2005 at 8:28 PM
originally posted by: cpiock

What i must do to create my on UIElemets. For example a would create a infragistics explorerbar on my shell. And the every module must create its own menus. How can i do this. or how can i find exemples for creating and handling my on menuitemtypes.
thx
Oct 18, 2005 at 4:33 AM
originally posted by: AgentOrange

I was wondering about this same question. I use Infragistics as well for toolbars/context menus and think that the ability to provide this functionality to other components (other than the built-in .net components) would be EXTREMELY helpful.
Oct 18, 2005 at 4:47 AM
originally posted by: Kidd_Kane

I was at the CAB training session in RedMond and some Infragistics guys were there. They mentioned possibly posting some examples of using their controls with the CAB, but as of yet I have seen none, probably because of the CTP status of the CAB.

The short of it is I also would like to see an implementation of the ExplorerBar, but better yet I'd love a generalized example of implementing a UIElement that really functions as a group control. ExplorerBars have groups and items, and there are a class of controls that fit this paradigm of being group and item controls... maybe a UIGroupElement example/interface/implementation is needed.
Oct 21, 2005 at 4:20 AM
originally posted by: cpiock

hmm so i have tried some example:
- i have created my own menu object
with a key a description and a parentmenu object

- than i must create my on UIElementManager
public class SIAGUIElementManager : UIElementManager <MyCommon.MenuItem>
{
private Infragistics.Win.UltraWinExplorerBar.UltraExplorerBar managedExplorerBar;
public SIAGUIElementManager(Infragistics.Win.UltraWinExplorerBar.UltraExplorerBar explorerBar)
{
Guard.ArgumentNotNull(explorerBar, "explorerBar");
managedExplorerBar = explorerBar;
}

protected override MenuItem Add(MenuItem uiElement)
{
if (uiElement.MenuParent == null)
managedExplorerBar.Groups.Add(uiElement.Key.ToString(), uiElement.Description);
else
{
Infragistics.Win.UltraWinExplorerBar.UltraExplorerBarItem menuItem = new Infragistics.Win.UltraWinExplorerBar.UltraExplorerBarItem();
menuItem.Key = uiElement.Key.ToString();
menuItem.Text = uiElement.Description;

if (managedExplorerBar.GroupsuiElement.MenuParent.Key.ToString() == null)
throw new Exception("Missing Groups!");

managedExplorerBar.GroupsmanagedExplorerBar.Groups[uiElement.MenuParent.Key.ToString()].Key.Items.Add(menuItem);
}
return uiElement;
}

protected override void Remove(MenuItem uiElement)
{
if (uiElement.MenuParent != null)
{
Infragistics.Win.UltraWinExplorerBar.UltraExplorerBarGroup group = managedExplorerBar.GroupsuiElement.MenuParent.Key.ToString();
managedExplorerBar.Groupsgroup.Key.Items.Remove(group.ItemsuiElement.Key.ToString());

if (managedExplorerBar.Groupsgroup.Key.Items.Count <= 0)
managedExplorerBar.Groups.Remove(group);
}

}
}

and now i can use it with the infragistics explorerbar:
-shellcode in the AfterShellCreated()
IUIElementManager mgr = new MyCommon.SIAGUIElementManager(this.Shell.ultraExplorerBar1);
IUIElementService svc = RootWorkItem.Services.Get<IUIElementService>();
svc.RegisterManager("MainMenu", mgr);

-workitem code
private void AddMenuItems()
{
MyCommon.MenuItem menuGroup = new MyCommon.MenuItem(Guid.NewGuid());
menuGroup.Description = "grouptest";

MyCommon.MenuItem menuItem = new MyCommon.MenuItem(Guid.NewGuid());
menuItem.MenuParent = menuGroup;
menuItem.Description = "test";

uielementService.Add<MyCommon.MenuItem>("MainMenu", menuGroup);
uielementService.Add<MyCommon.MenuItem>("MainMenu", menuItem);
}

yes i know that i don't must create my on menuobject and yes i know there sure some better solutions but it's only a little test, that i have made. and it works !yessss!!
suggestions welcome :-)