コード例 #1
0
        protected override void AfterShellCreated()
        {
            base.AfterShellCreated();

            //create the main window
            BankShellWindow bankShellWindow = RootWorkItem.Items.AddNew <BankShellWindow>();

            Shell.MainWindow = bankShellWindow;
            MenuItem fileItem = bankShellWindow.FileMenuItem;

            RootWorkItem.UIExtensionSites.RegisterSite(UIExtensionConstants.MAINMENU, bankShellWindow.Menu);
            RootWorkItem.UIExtensionSites.RegisterSite(UIExtensionConstants.MAINSTATUS, bankShellWindow.StatusBar);
            RootWorkItem.UIExtensionSites.RegisterSite(UIExtensionConstants.FILE, bankShellWindow.Menu);
            RootWorkItem.UIExtensionSites.RegisterSite(UIExtensionConstants.FILEDROPDOWN, fileItem);

            // Load the menu structure from App.config
            UIElementBuilder.LoadFromConfig(RootWorkItem);

            //add commands that map to WPF commands (the LoadFromConfig method isn't smart enough to do this yet)
            MenuItem menuItem = new MenuItem();

            menuItem.Header  = "_Undo";
            menuItem.Command = ApplicationCommands.Undo;
            RootWorkItem.UIExtensionSites["Edit"].Add(menuItem);
            menuItem         = new MenuItem();
            menuItem.Header  = "_Redo";
            menuItem.Command = ApplicationCommands.Redo;
            RootWorkItem.UIExtensionSites["Edit"].Add(menuItem);

            RootWorkItem.UIExtensionSites["Edit"].Add(new Separator());

            menuItem         = new MenuItem();
            menuItem.Header  = "Cu_t";
            menuItem.Command = ApplicationCommands.Cut;
            RootWorkItem.UIExtensionSites["Edit"].Add(menuItem);
            menuItem         = new MenuItem();
            menuItem.Header  = "_Copy";
            menuItem.Command = ApplicationCommands.Copy;
            RootWorkItem.UIExtensionSites["Edit"].Add(menuItem);
            menuItem         = new MenuItem();
            menuItem.Header  = "_Paste";
            menuItem.Command = ApplicationCommands.Paste;
            RootWorkItem.UIExtensionSites["Edit"].Add(menuItem);

            RootWorkItem.UIExtensionSites["Edit"].Add(new Separator());

            menuItem         = new MenuItem();
            menuItem.Header  = "Select _All";
            menuItem.Command = ApplicationCommands.SelectAll;
            RootWorkItem.UIExtensionSites["Edit"].Add(menuItem);

            //show the main window
            bankShellWindow.Show();
        }
        // This method is called just after your shell has been created (the root work item
        // also exists). Here, you might want to:
        //   - Attach UIElementManagers
        //   - Register the form with a name.
        //   - Register additional workspaces (e.g. a named WindowWorkspace)
        protected override void AfterShellCreated()
        {
            base.AfterShellCreated();

            ToolStripMenuItem fileItem = (ToolStripMenuItem)Shell.MainMenuStrip.Items["File"];

            RootWorkItem.UIExtensionSites.RegisterSite(UIExtensionConstants.MAINMENU, Shell.MainMenuStrip);
            RootWorkItem.UIExtensionSites.RegisterSite(UIExtensionConstants.MAINSTATUS, Shell.mainStatusStrip);
            RootWorkItem.UIExtensionSites.RegisterSite(UIExtensionConstants.FILE, fileItem);
            RootWorkItem.UIExtensionSites.RegisterSite(UIExtensionConstants.FILEDROPDOWN, fileItem.DropDownItems);

            // Load the menu structure from App.config
            UIElementBuilder.LoadFromConfig(RootWorkItem);
        }
コード例 #3
0
        // This method is called just after your shell has been created (the root work item
        // also exists). Here, you might want to:
        //   - Attach UIElementManagers
        //   - Register the form with a name.
        //   - Register additional workspaces (e.g. a named WindowWorkspace)
        protected override void AfterShellCreated()
        {
            base.AfterShellCreated();

            XtraTabbedMdiWorkspace ContentWorkspace = new XtraTabbedMdiWorkspace(Shell);

            RootWorkItem.Items.Add(ContentWorkspace, WorkspaceNames.ShellContentWorkspace);

            //RootWorkItem.Items.Add(new MdiWorkspace(Shell), WorkspaceNames.ShellContentWorkspace);
            RootWorkItem.Items.Add(Shell.NavBarWorkspace, WorkspaceNames.ShellNavBarWorkspace);
            RootWorkItem.Items.Add(Shell.DockManagerWorkspace, WorkspaceNames.DockManagerWorkspace);
            RootWorkItem.Items.Add(Shell.DeckWorkspace, WorkspaceNames.DeckWorkspace);
            RootWorkItem.Workspaces[WorkspaceNames.ShellContentWorkspace].SmartPartActivated += BankShellApplication_SmartPartActivated;
            RootWorkItem.Workspaces[WorkspaceNames.ShellContentWorkspace].SmartPartClosing   += BankShellApplication_SmartPartClosing;
#if UseRibbonForm
            RootWorkItem.UIExtensionSites.RegisterSite(ExtensionSiteNames.Ribbon, Shell.Ribbon);
            RootWorkItem.UIExtensionSites.RegisterSite(ExtensionSiteNames.MainMenu, Shell.homePage);
            RootWorkItem.UIExtensionSites.RegisterSite(ExtensionSiteNames.MainStatus, Shell.mainStatusBar);
            RootWorkItem.UIExtensionSites.RegisterSite(ExtensionSiteNames.RibbonApplicationMenu, new
                                                       RibbonApplicationMenuUIAdapter(Shell.applicationMenu));

            RibbonPageGroup ribbonGroup = new RibbonPageGroup(ExtensionSiteNames.File);
            RootWorkItem.UIExtensionSites[ExtensionSiteNames.MainMenu].Add <RibbonPageGroup>(ribbonGroup);
            RootWorkItem.UIExtensionSites.RegisterSite(ExtensionSiteNames.File, ribbonGroup);
            RootWorkItem.UIExtensionSites.RegisterSite(ExtensionSiteNames.RibbonPageHeader, new
                                                       RibbonPageHeaderUIAdapter(Shell.Ribbon.PageHeaderItemLinks));
            RootWorkItem.UIExtensionSites.RegisterSite(ExtensionSiteNames.RibbonQuickAccessToolbar, new
                                                       RibbonQuickAccessToolbarUIAdapter(Shell.Ribbon.Toolbar));
            RootWorkItem.UIExtensionSites.RegisterSite(ExtensionSiteNames.RibbonAppMenuBottomPane, new
                                                       RibbonAppMenuBottomPaneSimpleButtonUIAdapter(RootWorkItem, Shell.applicationMenu));

            BankTellerRibbonSkins.Add(RootWorkItem);
            //BankTellerRibbonWindows.Add(RootWorkItem, Shell.xtraTabbedMdiManager, Shell);
            BankTellerRibbonWindows.Add(RootWorkItem, ContentWorkspace);
#else
            RootWorkItem.UIExtensionSites.RegisterSite(ExtensionSiteNames.MainMenu, Shell.mainMenuBar);
            RootWorkItem.UIExtensionSites.RegisterSite(ExtensionSiteNames.MainStatus, Shell.mainStatusBar);
            RootWorkItem.UIExtensionSites.RegisterSite(ExtensionSiteNames.FileDropDown, Shell.barSubItemFile);
            RootWorkItem.UIExtensionSites.RegisterSite(ExtensionSiteNames.File, new BarItemWrapper(Shell.mainMenuBar.ItemLinks, Shell.barSubItemFile));
            RootWorkItem.UIExtensionSites.RegisterSite(ExtensionSiteNames.SkinsToolBar, Shell.skinsBar);
            RootWorkItem.UIExtensionSites.RegisterSite(ExtensionSiteNames.ToolBar, Shell.mainBar);
            RootWorkItem.UIExtensionSites.RegisterSite(ExtensionSiteNames.WindowToolBar, Shell.windowToolBar);

            // There are two ways to add skins to the BankTeller demo.
            // 1) SkinMenu: Bypasses the CAB framework and directly adds and
            //    manipulates the menu items. The SkinMenu is standard .NET
            //    functionality and is more efficient and easier to understand.
            // 2) BankTellerDynamicSkins: Uses the event broker to handle both the
            //    menu Popup event and the handling of the menu item click. This
            //    allows both dynamic menu item creation as well as more adherence
            //    to the CAB decoupled philosophy. It does not provide any
            //    additional functionality.
            //
            // SkinMenu and BankTellerDynamicSkins are functionally equivalent.
            // The two methods give the developer a choice on how closely to
            // follow the CAB philosophy.
            //
            // To change between the two swap the comments on the following two
            // lines of code. The two lines can also both be uncommented and two
            // working skin menus will appear.
            RootWorkItem.UIExtensionSites[ExtensionSiteNames.MainMenu].Add(new SkinMenu(Shell.mainMenuBar));
            //BankTellerDynamicSkins.Skins.AddSkins(RootWorkItem);
            RootWorkItem.UIExtensionSites[ExtensionSiteNames.MainMenu].Add(new WindowMenu(Shell.mainMenuBar, ContentWorkspace, RootWorkItem));
#endif
            UIElementBuilder.LoadFromConfig(RootWorkItem);
        }