public SolutionFileDesignerHTMLElementTabs() { HTMLDesignerContent.style.position = IStyle.PositionEnum.absolute; HTMLDesignerContent.style.left = "0px"; HTMLDesignerContent.style.width = "100%"; HTMLDesignerContent.style.top = "0px"; HTMLDesignerContent.style.height = "100%"; HTMLDesignerContent.style.border = "0"; HTMLDesignerContent.style.margin = "0"; HTMLDesignerContent.style.padding = "0"; HTMLDesignerContent.frameBorder = "0"; HTMLDesignerContent.border = "0"; HTMLDesignerContent.WhenDocumentReady( document => { document.WithContent(StockPageDefault.Element); document.DesignMode = true; } ); HTMLDesignerContent.style.display = IStyle.DisplayEnum.none; HTMLSourceView.Container.style.position = IStyle.PositionEnum.absolute; HTMLSourceView.Container.style.left = "0px"; HTMLSourceView.Container.style.right = "0px"; HTMLSourceView.Container.style.top = "0px"; HTMLSourceView.Container.style.bottom = "0px"; HTMLSourceView.Container.style.display = IStyle.DisplayEnum.none; HTMLDesignerTab.Deactivated += delegate { HTMLDesignerContent.style.display = IStyle.DisplayEnum.none; }; HTMLDesignerTab.Activated += delegate { HTMLDesignerContent.style.display = IStyle.DisplayEnum.empty; }; HTMLSourceTab.Deactivated += delegate { HTMLSourceView.Container.style.display = IStyle.DisplayEnum.none; }; HTMLSourceTab.Activated += delegate { HTMLSourceFile.Clear(); HTMLDesignerContent.WhenContentReady( body => { HTMLSourceFile.WriteHTMLElement(body.AsXElement()); // update HTMLSourceView.File = HTMLSourceFile; HTMLSourceView.Container.style.display = IStyle.DisplayEnum.empty; } ); }; }
/// <summary> /// This is a javascript application. /// </summary> /// <param name="page">HTML document rendered by the web server which can now be enhanced.</param> public Application(IDefaultPage page) { new JSCSolutionsNETImage().ToBackground(page.Item1.style, false); new JSCSolutionsNETImage().ToBackground(page.Item2.style, false); // Update document title // http://do.jsc-solutions.net/Update-document-title @"Hello world".ToDocumentTitle(); // Send xml to server // http://do.jsc-solutions.net/Send-xml-to-server var v = new SolutionFileView(); var f = new SolutionFile(); f.WriteHTMLElement(StockPageDefault.Element); v.File = f; var Container = new IHTMLDiv(); Container.style.position = IStyle.PositionEnum.relative; Container.style.display = IStyle.DisplayEnum.inline_block; Container.style.width = "600px"; Container.style.height = "400px"; Container.style.border = "1px solid gray"; var ToolbarHeight = "1.3em"; var Content = new IHTMLDiv().AttachTo(Container); Content.style.position = IStyle.PositionEnum.absolute; Content.style.left = "0px"; Content.style.top = "0px"; Content.style.right = "0px"; Content.style.bottom = ToolbarHeight; var Toolbar = new IHTMLDiv().AttachTo(Container); Toolbar.style.backgroundColor = Color.FromGray(0xef); Toolbar.style.position = IStyle.PositionEnum.absolute; Toolbar.style.left = "0px"; Toolbar.style.height = ToolbarHeight; Toolbar.style.right = "0px"; Toolbar.style.bottom = "0px"; Action <IHTMLImage, string, Action> AddToolbarButton = (img, text, handler) => { var span = new IHTMLSpan { innerText = text }; span.style.paddingLeft = "1.5em"; span.style.paddingRight = "0.3em"; var a = new IHTMLAnchor { img, span }; img.style.verticalAlign = "middle"; img.border = 0; img.style.position = IStyle.PositionEnum.absolute; a.style.backgroundColor = Color.FromGray(0xef); a.style.color = Color.Black; a.style.textDecoration = "none"; a.style.fontFamily = IStyle.FontFamilyEnum.Tahoma; a.href = "javascript: void(0);"; a.onclick += delegate { handler(); }; a.style.display = IStyle.DisplayEnum.inline_block; a.style.height = "100%"; a.onmousemove += delegate { a.style.backgroundColor = Color.FromGray(0xff); }; a.onmouseout += delegate { a.style.backgroundColor = Color.FromGray(0xef); }; Toolbar.Add(a); }; v.Container.style.height = "100%"; v.Container.AttachTo(Content); Content.Add(v.Container); var i = CreateEditor(); i.AttachTo(Content); var ii = new IHTMLPre().AttachTo(Content); ii.style.position = IStyle.PositionEnum.absolute; ii.style.left = "0px"; ii.style.top = "0px"; ii.style.right = "0px"; ii.style.bottom = "0px"; ii.style.overflow = IStyle.OverflowEnum.auto; ii.style.padding = "0px"; ii.style.margin = "0px"; ii.style.whiteSpace = IStyle.WhiteSpaceEnum.normal; v.Container.style.display = IStyle.DisplayEnum.none; i.style.display = IStyle.DisplayEnum.empty; ii.style.display = IStyle.DisplayEnum.none; AddToolbarButton(new RTA_mode_design(), "Design", delegate { v.Container.style.display = IStyle.DisplayEnum.none; ii.style.display = IStyle.DisplayEnum.none; i.style.display = IStyle.DisplayEnum.empty; } ); AddToolbarButton(new RTA_mode_html(), "Source", delegate { v.Container.style.display = IStyle.DisplayEnum.empty; ii.style.display = IStyle.DisplayEnum.none; i.style.display = IStyle.DisplayEnum.none; f.Clear(); i.WhenContentReady( body => { f.WriteHTMLElement(body.AsXElement()); // update v.File = f; } ); } ); AddToolbarButton(new RTA_mode_html(), "Source raw", delegate { v.Container.style.display = IStyle.DisplayEnum.none; ii.style.display = IStyle.DisplayEnum.empty; i.style.display = IStyle.DisplayEnum.none; i.WhenContentReady( body => { ii.innerText = body.AsXElement().ToString(); } ); } ); page.PageContainer.Add(Container); new ApplicationWebService().WebMethod2( new XElement(@"Document", new object[] { new XElement(@"Data", new object[] { @"Hello world" } ), new XElement(@"Client", new object[] { @"Unchanged text" } ) } ), delegate(XElement doc) { // Show server message as document title // http://do.jsc-solutions.net/Show-server-message-as-document-title doc.Element(@"Data").Value.ToDocumentTitle(); } ); }