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); }
public virtual object Clone() { WindowPrototype prot = (WindowPrototype)MemberwiseClone(); prot.Menu = Menu.Select(mi => (MenuPrototype)mi.Clone()).ToList(); return(prot); }
public object CreateMainWindow() { //todo: move CreateMainWindow logic to Start method and use simple getter instead? if (mainWindow != null) { throw new HcduException("Main windows was created already."); } WindowPrototype prot = (WindowPrototype)ApplicationPackage.MainWindowPrototype.Clone(); //todo: this is an ugly approach prot.Url = MakeAbsoluteUrl(prot.Url); mainWindow = Platform.CreateWindow(prot); windows.Add(mainWindow); return(mainWindow.NativeWindow); }
public WindowHandle ShowDialog(WindowHandle parent, WindowPrototype prototype) { Form parentForm = (Form) parent.NativeWindow; if (parentForm.InvokeRequired) { return (WindowHandle) parentForm.Invoke(new Func<WindowHandle, WindowPrototype, WindowHandle>(ShowDialog), parent, prototype); } WindowHandle handle = ConstructDialog(prototype); Form window = (Form) handle.NativeWindow; window.Closed += (sender, args) => prototype.OnClose(handle); //todo: use ShowDialog when CefSharp 43 is released (now it freezes the application) window.Show(parentForm); //todo: this would conflict with window.ShowDialog return handle; }
public void ShowDialog(WindowPrototype prot) { //todo: this is an ugly approach prot = (WindowPrototype)prot.Clone(); prot.Url = MakeAbsoluteUrl(prot.Url); Action <WindowHandle> oldOnCloseHandler = prot.OnClose; prot.OnClose = wh => { OnWindowClose(wh); if (oldOnCloseHandler != null) { oldOnCloseHandler(wh); } }; //todo: should we always use mainWindow as a parent WindowHandle handle = Platform.ShowDialog(mainWindow, prot); windows.Add(handle); }
public void ShowDialog(WindowPrototype prot) { //todo: this is an ugly approach prot = (WindowPrototype) prot.Clone(); prot.Url = MakeAbsoluteUrl(prot.Url); Action<WindowHandle> oldOnCloseHandler = prot.OnClose; prot.OnClose = wh => { OnWindowClose(wh); if (oldOnCloseHandler != null) { oldOnCloseHandler(wh); } }; //todo: should we always use mainWindow as a parent WindowHandle handle = Platform.ShowDialog(mainWindow, prot); windows.Add(handle); }
private string ShowCustomDialog() { WindowPrototype win = new WindowPrototype(); win.Url = "dialogs/custom-dialog/custom-dialog.html"; Container.ShowDialog(win); //todo: return some value? return "todo"; }
private WindowHandle ConstructDialog(WindowPrototype prototype) { Form form = new Form(); form.Size = new Size(prototype.Width, prototype.Height); ChromiumWebBrowser webBrowser = new ChromiumWebBrowser("about:blank"); //todo: usage of WindowHandle is a little bit cumbersome WindowHandle handle = new WindowHandle(form, webBrowser); //todo: is SuspendLayout/ResumeLayout required? form.SuspendLayout(); int occupiedHeight = 0; if (prototype.Menu != null && prototype.Menu.Any()) { MenuStrip menu = CreateMenu(handle, prototype.Menu); const int menuHeight = 24; menu.Size = new Size(form.ClientSize.Width, menuHeight); menu.Location = new Point(0, 0); menu.TabIndex = 0; form.Controls.Add(menu); occupiedHeight += menuHeight; } form.Controls.Add(webBrowser); webBrowser.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; webBrowser.Location = new Point(0, occupiedHeight); webBrowser.Size = new Size(form.ClientSize.Width, form.ClientSize.Height - occupiedHeight); webBrowser.TabIndex = 1; form.Controls.Add(webBrowser); //todo: is SuspendLayout/ResumeLayout required? form.ResumeLayout(); webBrowser.TitleChanged += (sender, args) => { if (form.InvokeRequired) { form.Invoke(new Action<string>(title => { form.Text = title; }), webBrowser.Title); } }; webBrowser.Load(prototype.Url); return handle; }
public WindowHandle CreateWindow(WindowPrototype prototype) { return ConstructDialog(prototype); }