private static void CompositePatternExampleWithBuilder()
        {
            var builder = new MenuBuilder("main");

            builder.AddMenuDirectoryItem("directory 1");
            builder.AddMenuItem("item 1.1");
            builder.AddMenuItem("item 1.2");
            builder.SetCurrentMenuDirectory("main");
            builder.AddMenuDirectoryItem("directory 2");
            builder.AddMenuItem("item 2.1");
            builder.AddMenuItem("item 2.2");

            builder.Root.Draw(1);
        }
Example #2
0
        private void ShowShell(ContainerBuilder builder)
        {
            builder.RegisterType <MainWindow>()
            .SingleInstance()
            .OnActivated(e =>
            {
                var shell = e.Instance;

                var regionContainer  = e.Context.Resolve <IRegionContainer>();
                var tabRegion        = regionContainer.GetRegion <Regions.TabRegion>();
                var viewFactory      = e.Context.Resolve <ICreateView>();
                var tabRegionAdapter = Scope.From(new TabRegionAdapter(viewFactory, shell.TabRegion));
                tabRegion.Adapt(tabRegionAdapter);

                var menuBuilder = new MenuBuilder(shell.MenuRegion);
                menuBuilder.AddMenuItem("Add", () => AddNewView(tabRegion));
                menuBuilder.AddMenuItems("GroupOfItems", GetMenuCommands());

                var parentMenuItem = CreateParentMenuCommand();
                menuBuilder.AddMenuItem(parentMenuItem);
                menuBuilder.AddMenuItems(parentMenuItem, GetMenuCommands());

                menuBuilder.AddMenuItems(parentMenuItem, new MenuCommand()
                {
                    Title = "Added later"
                });

                menuBuilder.AddMenuItem("Other", () => tabRegion.RequestNavigate <OtherViewModel>(NavigationParameters.UserNavigation));
                menuBuilder.AddMenuItem("Close all", () => tabRegion.CloseAll());
            });

            _container = builder.Build();

            Application.Current.MainWindow = _container.Resolve <MainWindow>();
            Application.Current.MainWindow.Show();
        }