public HcduContent()
        {
            MainWindowPrototype     = new WindowPrototype();
            MainWindowPrototype.Url = "index.html";

            MenuPrototype toolsMenu = new MenuPrototype {
                Text = "Tools"
            };

            MainWindowPrototype.Menu.Add(toolsMenu);

            toolsMenu.Items.Add(new MenuPrototype {
                Text = "Home Page", OnAction = wh => { Container.NavigateTo(wh, MainWindowPrototype.Url); }
            });
            toolsMenu.Items.Add(new MenuPrototype {
                Text = "Angular Material Website", OnAction = wh => { Container.NavigateTo(wh, "https://material.angularjs.org"); }
            });
            toolsMenu.Items.Add(new MenuPrototype {
                Text = "Developer tools", OnAction = wh => { Container.ShowDevTools(wh); }
            });
            toolsMenu.Items.Add(new MenuPrototype {
                Text = "Reload", OnAction = wh => { Container.ReloadPage(wh); }
            });
            toolsMenu.Items.Add(new MenuPrototype {
                Text = "Resources List", OnAction = wh => { Container.NavigateTo(wh, DebugPages.ResourcesListUrl); }
            });

            Content.AddContent(typeof(HcduContent).Assembly, "HCDU.Content.Web");
            Content.AddMethod("rest/cars/boxter", () => new Car {
                Model = "Porsche Boxster", Year = 1996
            });
            Content.AddMethod <Car>("rest/exception", () => { throw new Exception("Test Exception"); });
            Content.AddMethod("rest/selectFolder", () => SelectFolder(false));
            Content.AddMethod("rest/selectNewFolder", () => SelectFolder(true));
            Content.AddMethod("rest/showCustomDialog", ShowCustomDialog);
            Content.AddMethod("rest/closeCustomDialog", CloseCustomDialog);
            Content.AddMethod("rest/backend-events/increment", BackendEventsIncrement);
            Content.AddMethod("rest/backend-events/increment5Sec", BackendEventsIncrement5Sec);

            Sockets.AddSocketProvider("ws/backend-events", stateSocket);
            stateSocket.State = backendEventsCounter;

            //todo: use more generic way of combining packages?
            DebugPages.AppendTo(Content);
        }
        private ToolStripMenuItem CreateMenuItem(WindowHandle handle, MenuPrototype menuItemProt)
        {
            ToolStripMenuItem menuItem = new ToolStripMenuItem(menuItemProt.Text);

            if (menuItemProt.OnAction != null)
            {
                menuItem.Click += (sender, args) => menuItemProt.OnAction(handle);
            }

            if (menuItemProt.Items != null && menuItemProt.Items.Any())
            {
                foreach (MenuPrototype menuSubItemProt in menuItemProt.Items)
                {
                    menuItem.DropDownItems.Add(CreateMenuItem(handle, menuSubItemProt));
                }
            }

            return(menuItem);
        }
Example #3
0
        private MenuItem CreateMenuItem(WindowHandle handle, MenuPrototype menuItemProt)
        {
            MenuItem menuItem = new MenuItem(menuItemProt.Text);

            if (menuItemProt.OnAction != null)
            {
                menuItem.Activated += (sender, e) => { menuItemProt.OnAction(handle); };
            }

            if (menuItemProt.Items != null && menuItemProt.Items.Any())
            {
                Menu subMenu = new Menu();
                menuItem.Submenu = subMenu;

                foreach (MenuPrototype menuSubItemProt in menuItemProt.Items)
                {
                    subMenu.Append(CreateMenuItem(handle, menuSubItemProt));
                }
            }

            return(menuItem);
        }