Exemplo n.º 1
0
        /// <summary>
        /// Initializing the menu items
        /// </summary>
        /// <returns></returns>
        private bool InitializeMenu()
        {
            try
            {
                string      maintoolbarResource = ApplicationMain.manifestNamespace + "DefaultToolbarItems.xml";
                string      menuResource        = ApplicationMain.manifestNamespace + "DefaultMenuItems.xml";
                FactoryType ft;
#if SyncfusionFramework2_0
                ft = FactoryType.WhidbeyMenuFactory;
#else
                ft = FactoryType.WinFormsMenuFactory;
#endif
                menuFactory = MenuLoader.CreateFactory(ft, ApplicationMain.menuNamespace, new string[] { maintoolbarResource },
                                                       new string[] { menuResource }, ApplicationMain.IconResources, this);

                if (menuFactory.ToolBars != null)
                {
                    this.Controls.AddRange(menuFactory.ToolBars as Control[]);
                }

                if (menuFactory.Menus != null)
                {
                    if (typeof(Menu).IsInstanceOfType(menuFactory.Menus[0]))
                    {
                        Menu = menuFactory.Menus[0] as MainMenu;
                    }
                    else
                    {
                        this.Controls.Add(menuFactory.Menus[0] as Control);
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine("Unable to create menu factory due to the following error:");
                Trace.WriteLine(ex.ToString());
                return(false);
            }
            return(true);
        }