using System;
using System.Collections.Generic;
using System.Text;
using Habanero.Faces.Base;
using <<BOPROJECTNAME>>;

namespace <<NAMESPACE>>
{
    public abstract class UIManager
    {
        public static IMainMenuHabanero SetupMainMenu(IFormHabanero programForm, IControlFactory controlFactory,
                                                      IMenuBuilder menuBuilder)
        {
            HabaneroMenu mainMenu = new HabaneroMenu("Main", programForm, GlobalUIRegistry.ControlFactory);

            HabaneroMenu currentMenu = mainMenu.AddSubMenu("&File");
            HabaneroMenu.Item currentMenuItem = currentMenu.AddMenuItem("E&xit");
            currentMenuItem.CustomHandler += delegate { programForm.Close(); };

            AddGeneratedFormsMenu(mainMenu, controlFactory);

            return menuBuilder.BuildMainMenu(mainMenu);
        }

        private static void AddGeneratedFormsMenu(HabaneroMenu menu, IControlFactory controlFactory)
        {
            HabaneroMenu dataMenu = menu.AddSubMenu("&Generated Forms");
            foreach (Type type in typeof (UIManager).Assembly.GetTypes())
            {
                if (!type.IsSubclassOf(typeof (MenuItemCreator))) continue;
                MenuItemCreator menuItemCreator = (MenuItemCreator) Activator.CreateInstance(type, new object[] {});
                menuItemCreator.AddToMenu(dataMenu, controlFactory);
            }
        }

        public abstract void SetupMainForm(IFormHabanero programForm);
    }
}
