/// <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(IApp page) { content.AttachControlToDocument(); var ss = new DataGridView { DataSource = Book1.GetDataSet(), DataMember = "Assets" }; content.Controls.Add(ss); var x = new IHTMLDiv(); x.style.backgroundColor = "rgba(255,255,255,1.0)"; x.style.position = IStyle.PositionEnum.absolute; x.style.height = "auto"; x.style.width = "100%"; x.style.top = "100%"; x.style.zIndex = 999; var temp = ss.Rows[1]; var sss = temp.Cells[0].AsHTMLElementContainer(); sss.style.backgroundColor = "red"; new TheOtherOption { }.With( o => { o.BackColor = Color.White; o.GetHTMLTarget().With( div => { div.AttachTo(x); div.style.position = IStyle.PositionEnum.absolute; } ); } ); x.AttachTo(sss.parentNode); x.Hide(); sss.onmouseover += delegate { x.Show(); }; sss.onmouseout += delegate { x.Hide(); }; //that.GotFocus += delegate //{ // x.Show(); //}; //that.Leave += delegate //{ // x.Hide(); //}; }
private static void AddSection11(Action<string, IHTMLDiv> AddSection) { var ToolbarHeight = "24px"; var Content = new IHTMLDiv().With( k => { k.style.border = "1px solid gray"; k.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.relative; k.style.width = "100%"; k.style.height = "20em"; } ); //global::ScriptCoreLib.Ultra.Components.HTML // reload the project to make visual studio happy! new TwentyTenWorkspace().ToBackground(Content.style, true); var ToolbarContainerBackground = new IHTMLDiv().With( k => { k.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute; k.style.left = "0px"; k.style.right = "0px"; k.style.top = "0px"; k.style.height = ToolbarHeight; k.style.backgroundColor = Color.White; k.style.Opacity = 0.5; } ).AttachTo(Content); var ToolbarContainer = new IHTMLDiv().With( k => { k.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute; k.style.left = "0px"; k.style.right = "0px"; k.style.top = "0px"; k.style.height = ToolbarHeight; } ).AttachTo(Content); var PreviewContainer = new IHTMLDiv().With( k => { k.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute; k.style.left = "0px"; k.style.right = "0px"; k.style.top = ToolbarHeight; k.style.bottom = "0px"; } ).AttachTo(Content); var PreviewFrame = new IHTMLIFrame { src = "about:blank" }; PreviewFrame.style.width = "100%"; PreviewFrame.style.height = "100%"; PreviewFrame.style.border = "0"; PreviewFrame.style.margin = "0"; PreviewFrame.style.padding = "0"; PreviewFrame.frameBorder = "0"; PreviewFrame.border = "0"; PreviewFrame.AttachTo(PreviewContainer); PreviewContainer.Hide(); var EditorContainer = new IHTMLDiv().With( k => { k.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute; k.style.left = "0px"; k.style.right = "0px"; k.style.top = ToolbarHeight; k.style.bottom = "0px"; } ).AttachTo(Content); var EditorFrame = VisualStudioView.CreateEditor().AttachTo(EditorContainer); PreviewFrame.allowTransparency = true; EditorFrame.allowTransparency = true; EditorFrame.WhenContentReady( body => { body.style.backgroundColor = Color.Transparent; new IHTMLDiv { "Hello world :)" }.With( div => { div.style.backgroundColor = Color.White; div.style.borderColor = Color.Gray; div.style.borderStyle = "solid"; div.style.borderWidth = "1px"; div.style.margin = "2em"; div.style.padding = "2em"; } ).AttachTo(body); } ); var ToolbarContent = new IHTMLDiv().AttachTo(ToolbarContainer); ToolbarContent.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.relative; Action<IHTMLElement> ApplyToolbarButtonStyle = k => { k.style.verticalAlign = "top"; k.style.padding = "0"; k.style.margin = "0"; k.style.overflow = ScriptCoreLib.JavaScript.DOM.IStyle.OverflowEnum.hidden; k.style.SetSize(24, 24); VisualStudioView.ApplyMouseHoverStyle(k, Color.Transparent); }; Func<IHTMLImage, IHTMLButton> AddButtonDummy = (img) => { return new IHTMLButton { img.WithinContainer() }.With(k => ApplyToolbarButtonStyle(k)).AttachTo(ToolbarContent); }; Func<IHTMLImage, Action, IHTMLButton> AddButtonAction = (img, command) => { return AddButtonDummy(img).With( k => { k.onclick += delegate { command(); }; } ); }; Func<IHTMLImage, string, IHTMLButton> AddButton = (img, command) => { return AddButtonAction(img, () => EditorFrame.contentWindow.document.execCommand( command, false, null ) ); }; //AddButtonDummy(new RTA_save()); var SaveContainer = new IHTMLDiv().With(k => ApplyToolbarButtonStyle(k)).AttachTo(ToolbarContent); SaveContainer.style.display = ScriptCoreLib.JavaScript.DOM.IStyle.DisplayEnum.inline_block; //var Save = new InternalSaveActionSprite(); //Save.ToTransparentSprite(); //Save.AttachSpriteTo(SaveContainer); var s = new { VisualStudioTemplates.VisualCSharpProject }; EditorFrame.WhenContentReady( body => { var t = (IHTMLTextArea)EditorFrame.contentWindow.document.createElement("textarea"); t.AttachTo(body); t.value = s.ToString(); } ); //Save.WhenReady( // i => // { // i.FileName = "Project1.zip"; // i.Add("Project1.txt", "x"); // i.Add("Project1.csproj", s.VisualCSharpProject); // } //); ToolbarContent.Add(new RTA_separator_horizontal()); var RTAButtons = new Dictionary<string, IHTMLImage> { // http://trac.symfony-project.org/browser/plugins/dmCkEditorPlugin/web/js/ckeditor/_source/plugins?rev=27455 {"Bold", new RTA_bold()}, {"Underline", new RTA_underline()}, {"Strikethrough", new RTA_strikethrough()}, {"Italic", new RTA_italic()}, {"JustifyLeft", new RTA_justifyleft()}, {"JustifyCenter", new RTA_justifycenter()}, {"JustifyRight", new RTA_justifyright()}, {"JustifyFull", new RTA_justifyfull()}, {"Indent", new RTA_indent()}, {"Outdent", new RTA_outdent()}, {"Superscript", new RTA_superscript()}, {"Subscript", new RTA_sub()}, {"Removeformat", new RTA_removeformat()}, {"InsertOrderedList", new RTA_numberedlist()}, {"InsertUnorderedList", new RTA_numberedlist()}, {"undo", new RTA_undo()}, {"redo", new RTA_redo()}, }.ToDictionary( k => k.Key, k => AddButton(k.Value, k.Key) ); var ButtonDesign = default(IHTMLButton); var ButtonHTML = default(IHTMLButton); ButtonDesign = AddButtonAction(new RTA_mode_design(), delegate { ButtonDesign.Hide(); ButtonHTML.Show(); EditorContainer.Show(); PreviewContainer.Hide(); } ); ButtonHTML = AddButtonAction(new RTA_mode_html(), delegate { ButtonHTML.Hide(); PreviewFrame.WithContent( body => { body.style.backgroundColor = Color.Transparent; body.innerHTML = EditorFrame.contentWindow.document.body.innerHTML; EditorContainer.Hide(); PreviewContainer.Show(); ButtonDesign.Show(); } ); } ); ButtonDesign.Hide(); AddSection( "Editor with toolbar with background and preview", Content ); }
public MatrixTransformBExample() { var x = 400; var y = 200; var w = 200; var h = 200; var ro_matrix = new IHTMLDiv(); ro_matrix.style.backgroundColor = "#8080ff"; ro_matrix.style.SetLocation(x, y); ro_matrix.AttachToDocument(); //ro_matrix.style.paddingLeft = w + "px"; //ro_matrix.style.paddingTop = h + "px"; var ro_matric_content = new IHTMLDiv(); ro_matric_content.style.backgroundColor = "#0000ff"; ro_matric_content.style.SetSize(w, h); ro_matric_content.AttachTo(ro_matrix); var r_matrix = new IHTMLDiv(); r_matrix.style.backgroundColor = "#80ff80"; r_matrix.style.SetLocation(x, y); r_matrix.AttachToDocument(); //r_matrix.style.paddingLeft = w + "px"; //r_matrix.style.paddingTop = h + "px"; var r_matric_content = new IHTMLDiv(); r_matric_content.style.backgroundColor = "#00ff00"; r_matric_content.style.SetSize(w, h); r_matric_content.AttachTo(r_matrix); #region blue rotation var jo = new IHTMLDiv(); jo.style.background = "blue"; jo.style.SetLocation(x - w / 2 - 4, y - h / 2 - 1, 8, 2); jo.AttachToDocument(); var joh = new IHTMLDiv(); joh.style.background = "blue"; joh.style.SetLocation(x - w / 2 - 1, y - h / 2 - 4, 2, 8); joh.AttachToDocument(); jo.BlinkAt(400); joh.BlinkAt(400); #endregion #region black origin var zo = new IHTMLDiv(); zo.style.background = "black"; zo.style.SetLocation(x - 4, y - 1, 8, 2); zo.AttachToDocument(); var zoh = new IHTMLDiv(); zoh.style.background = "black"; zoh.style.SetLocation(x - 1, y - 4, 2, 8); zoh.AttachToDocument(); #endregion var ro = new IHTMLDiv(); ro.style.background = "red"; ro.style.SetLocation(x, y, w, h); ro.style.Opacity = 0.3; ro.AttachToDocument(); var info = new IHTMLSpan { innerText = "MatrixTransform" }; info.style.SetLocation(x, y + h, w, h); info.AttachToDocument(); var at = new IHTMLDiv(); at.style.background = "yellow"; at.style.SetLocation(x - w / 2, y - h / 2, w * 2, h * 2); at.style.Opacity = 0.5; at.AttachToDocument(); var r = new IHTMLDiv(); r.style.background = "black"; r.style.SetLocation(x, y, w, h); r.style.Opacity = 0.3; r.AttachToDocument(); r.style.cursor = IStyle.CursorEnum.pointer; #region blue origin var o = new IHTMLDiv(); o.style.background = "blue"; o.style.SetLocation(x + w / 2 - 4, y + h / 2 - 1, 8, 2); o.AttachToDocument(); var oh = new IHTMLDiv(); oh.style.background = "blue"; oh.style.SetLocation(x + w / 2 - 1, y + h / 2 - 4, 2, 8); oh.AttachToDocument(); #endregion #region black rotation var jzo = new IHTMLDiv(); jzo.style.background = "black"; jzo.style.SetLocation(x - w / 2 - 4, y - h / 2 - 1, 8, 2); jzo.AttachToDocument(); var jzoh = new IHTMLDiv(); jzoh.style.background = "black"; jzoh.style.SetLocation(x - w / 2 - 1, y - h / 2 - 4, 2, 8); jzoh.AttachToDocument(); jzo.BlinkAt(400); jzoh.BlinkAt(400); #endregion var m = new MatrixModifiers(); var InteractiveSetOrigin_x = 0; var InteractiveSetOrigin_y = 0; var InteractiveSetRotation_x = 0; var InteractiveSetRotation_y = 0; Action<int, int> InteractiveSetRotation = null; Action<int, int> SetPadding = (ox, oy) => { // -0 ... -w ox += w / 2; oy += h / 2; info.innerText = "padding x: " + ox + " y:" + oy; if (ox > 0) { ro_matrix.style.paddingLeft = ox * 2 + "px"; ro_matrix.style.paddingRight = 0 + "px"; } else { ro_matrix.style.paddingLeft = 0 + "px"; ro_matrix.style.paddingRight = ox * -2 + "px"; } if (oy > 0) { ro_matrix.style.paddingTop = oy * 2 + "px"; ro_matrix.style.paddingBottom = 0 + "px"; } else { ro_matrix.style.paddingTop = 0 + "px"; ro_matrix.style.paddingBottom = oy * -2 + "px"; } if (ox > 0) { r_matrix.style.paddingLeft = ox * 2 + "px"; r_matrix.style.paddingRight = 0 + "px"; } else { r_matrix.style.paddingLeft = 0 + "px"; r_matrix.style.paddingRight = ox * -2 + "px"; } if (oy > 0) { r_matrix.style.paddingTop = oy * 2 + "px"; r_matrix.style.paddingBottom = 0 + "px"; } else { r_matrix.style.paddingTop = 0 + "px"; r_matrix.style.paddingBottom = oy * -2 + "px"; } }; m.Visual1.CheckedChanged += delegate { r_matrix.Show(m.Visual1.Checked); }; m.Visual2.CheckedChanged += delegate { ro_matrix.Show(m.Visual2.Checked); }; m.Debug1.CheckedChanged += delegate { if (m.Debug1.Checked) { ro_matrix.style.backgroundColor = "#8080ff"; r_matrix.style.backgroundColor = "#80ff80"; return; } ro_matrix.style.backgroundColor = ""; r_matrix.style.backgroundColor = ""; }; Action<int, int> InteractiveSetOrigin = (ox, oy) => { var dx = InteractiveSetOrigin_x - ox; var dy = InteractiveSetOrigin_y - oy; InteractiveSetOrigin_x = ox; InteractiveSetOrigin_y = oy; SetPadding(ox, oy); m.TranslateX.Text = "" + ox; m.TranslateY.Text = "" + oy; ro.style.SetLocation(x + ox, y + oy, w, h); ro_matrix.style.SetLocation(x + ox, y + oy /*, w, h*/); o.style.SetLocation(x - ox - 4, y - oy - 1, 8, 2); oh.style.SetLocation(x - ox - 1, y - oy - 4, 2, 8); InteractiveSetRotation(InteractiveSetRotation_x + dx, InteractiveSetRotation_y + dy); }; InteractiveSetRotation = (ox, oy) => { InteractiveSetRotation_x = ox; InteractiveSetRotation_y = oy; var ax = x - w / 2 + ox; var ay = y - h / 2 + oy; var bx = x - InteractiveSetOrigin_x; var by = y - InteractiveSetOrigin_y; var dx = ax - bx; var dy = ay - by; var rotation = Extensions.GetRotation(dx, dy); var rotation_degrees = rotation.RadiansToDegrees(); var costheta = Math.Cos(rotation); var sintheta = Math.Sin(rotation); var M11 = costheta; var M12 = -sintheta; var M21 = sintheta; var M22 = costheta; m.M11.Text = "" + M11; m.M12.Text = "" + M12; m.M21.Text = "" + M21; m.M22.Text = "" + M22; info.innerText = "rotation: " + rotation_degrees + "° x: " + InteractiveSetOrigin_x + " y:" + InteractiveSetOrigin_y; //Native.Document.title = new { ax, bx, dx, rotation_degrees }.ToString(); joh.style.SetLocation(ax - 1, y - h / 2 + oy - 4, 2, 8); jo.style.SetLocation(x - w / 2 + ox - 4, ay - 1, 8, 2); jzoh.style.SetLocation(x + InteractiveSetOrigin_x - w / 2 + ox - 1, y + InteractiveSetOrigin_y - h / 2 + oy - 4, 2, 8); jzo.style.SetLocation(x + InteractiveSetOrigin_x - w / 2 + ox - 4, y + InteractiveSetOrigin_y - h / 2 + oy - 1, 8, 2); var mm = new[] { M11, M21, M12, M22, 0, 0 //0.838670551776886,0.5446390509605408,-0.5446390509605408,0.838670551776886,0,0 }; var code = @" q.style.filter = ""progid:DXImageTransform.Microsoft.Matrix(M11='"" + m[0] + ""',M12='"" + m[2] + ""',M21='"" + m[1] + ""', M22='"" + m[3] + ""', sizingmethod='auto expand');""; q.style.MozTransform = ""matrix("" + m[0] + "","" + m[1] + "","" + m[2] + "","" + m[3] + "","" + m[4] + "","" + m[5] + "")""; q.style.WebkitTransform = ""matrix("" + m[0] + "","" + m[1] + "","" + m[2] + "","" + m[3] + "","" + m[4] + "","" + m[5] + "")""; "; new IFunction("q", "m", code).apply(null, r_matrix, mm); new IFunction("q", "m", code).apply(null, ro_matrix, mm); var r_matrix_adj_x = (r_matrix.clientWidth - r_matrix.offsetWidth) / 2; var r_matrix_adj_y = (r_matrix.clientHeight - r_matrix.offsetHeight) / 2; var ro_matrix_adj_x = (ro_matrix.clientWidth - ro_matrix.offsetWidth) / 2; var ro_matrix_adj_y = (ro_matrix.clientHeight - ro_matrix.offsetHeight) / 2; r_matrix.style.SetLocation(x + r_matrix_adj_x, y + r_matrix_adj_y/*, w, h*/); ro_matrix.style.SetLocation(x + InteractiveSetOrigin_x + ro_matrix_adj_x, y + InteractiveSetOrigin_y + ro_matrix_adj_y/*, w, h*/); }; #region bind InteractiveSetRotation at.onclick += e => { InteractiveSetRotation(e.OffsetX, e.OffsetY); }; at.onmousemove += e => { InteractiveSetRotation(e.OffsetX, e.OffsetY); }; at.onmouseover += delegate { info.innerText = "Click to set rotation"; }; InteractiveSetRotation(0, 0); #endregion #region bind InteractiveSetOrigin m.ButtonClear.Click += delegate { InteractiveSetOrigin(0, 0); }; r.onclick += e => { // 0 0 is top left InteractiveSetOrigin(-e.OffsetX, -e.OffsetY); }; r.onmouseover += delegate { if (m.Debug1.Checked) { info.innerText = "Click to set padding"; return; } info.innerText = "Click to set origin"; }; #endregion //InteractiveSetOrigin(0, 0); InteractiveSetOrigin(-w / 2, -h / 2); var f = new Form { Text = "MatrixModifier" }; m.BackColor = System.Drawing.Color.White; f.Controls.Add(m); f.ClientSize = m.Size; f.GetHTMLTarget().AttachToDocument(); }
public static IHTMLDiv AddDropDownOptions(this TextBox that, params object[] e) { var x = new IHTMLDiv(); x.style.backgroundColor = "rgba(255,255,255,1.0)"; x.style.position = IStyle.PositionEnum.absolute; x.style.height = "auto"; x.style.width = "100%"; x.style.top = "100%"; x.style.zIndex = 999; var c = that.GetHTMLTarget(); x.AttachTo(c); x.Hide(); that.GotFocus += delegate { x.Show(); }; that.Leave += delegate { x.Hide(); }; e.AsEnumerable().WithEach( k => { { //var o = k as UserControl; var o = k as Control; if (o != null) { o.BackColor = Color.Transparent; o.GetHTMLTarget().With( div => { div.AttachTo(x); div.style.width = "auto"; div.style.position = IStyle.PositionEnum.relative; } ); return; } } { var o = (INodeConvertible<IHTMLDiv>)k; { o.AttachTo(x); //o.div.css.hover.style.backgroundColor = "yellow"; } } } ); return x; }
/// <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(IApp page) { content.AttachControlToDocument(); var x = new IHTMLDiv(); x.style.backgroundColor = "rgba(255,255,255,1.0)"; x.style.position = IStyle.PositionEnum.absolute; x.style.height = "auto"; x.style.width = "100%"; x.style.top = "100%"; x.style.zIndex = 999; x.AttachTo(content.textBox1.GetHTMLTarget()); x.Hide(); Action close = delegate { x.Hide(); }; Action<string> add = name => new Option { name = name }.With( o => { o.AttachTo(x); o.div.css.hover.style.backgroundColor = "green"; o.div.onclick += delegate { Console.WriteLine(o.name.innerText); content.textBox1.Text = o.name.innerText; close(); //content.textBox1.Text = o.name; }; } ); //content.checkBox1.CheckedChanged += delegate { x.Show(content.checkBox1.Checked); }; content.textBox1.GotFocus += delegate { x.Show(); }; add("foo"); add("Marge Simpson"); new TheOtherOption { }.With( o => { o.BackColor = Color.Transparent; o.GetHTMLTarget().With( div => { div.AttachTo(x); div.style.position = IStyle.PositionEnum.relative; } ); } ); add("bar"); var ls = new Option { name = "Lisa Simpson EUR" }.With(o => { o.div.css.hover.style.backgroundColor = "rgba(118, 207, 140, 0.7)"; o.div.onclick += delegate { content.textBox1.Text = o.name.innerText; close(); }; }); content.textBox2.AddDropDownOptions( new Option { name = "hello" }, new TheOtherOption { }, new Option { name = "world" }, ls ); }
private static void AddTypeProperty( IHTMLDiv parent, CompilationProperty type, Action<string> UpdateLocation ) { var div = new IHTMLDiv().AttachTo(parent); div.style.marginTop = "0.1em"; div.style.fontFamily = ScriptCoreLib.JavaScript.DOM.IStyle.FontFamilyEnum.Verdana; div.style.whiteSpace = ScriptCoreLib.JavaScript.DOM.IStyle.WhiteSpaceEnum.nowrap; var i = new PublicProperty().AttachTo(div); i.style.verticalAlign = "middle"; i.style.marginRight = "0.5em"; var s = new IHTMLAnchor { innerText = type.Name }.AttachTo(div); s.href = "#"; s.style.textDecoration = "none"; s.style.color = JSColor.System.WindowText; Action onclick = delegate { }; s.onclick += e => { e.PreventDefault(); s.focus(); UpdateLocation(type.Name); onclick(); }; s.onfocus += delegate { s.style.backgroundColor = JSColor.System.Highlight; s.style.color = JSColor.System.HighlightText; }; s.onblur += delegate { s.style.backgroundColor = JSColor.None; s.style.color = JSColor.System.WindowText; }; onclick = delegate { var children = new IHTMLDiv().AttachTo(div); children.style.paddingLeft = "2em"; AddTypeMethod(children, type.GetGetMethod(), UpdateLocation); AddTypeMethod(children, type.GetSetMethod(), UpdateLocation); //a.GetTypes().ForEach( // (Current, Next) => // { // AddType(GetNamespaceContainer(children, Current), Current, UpdateLocation); // ScriptCoreLib.Shared.Avalon.Extensions.AvalonSharedExtensions.AtDelay( // 50, // Next // ); // } //); var NextClickHide = default(Action); var NextClickShow = default(Action); NextClickHide = delegate { children.Hide(); onclick = NextClickShow; }; NextClickShow = delegate { children.Show(); onclick = NextClickHide; }; onclick = NextClickHide; }; }
private static void AddTypeEvent( IHTMLDiv parent, CompilationEvent type, Action<string> UpdateLocation ) { var div = new IHTMLDiv().AttachTo(parent); div.style.marginTop = "0.1em"; div.style.fontFamily = ScriptCoreLib.JavaScript.DOM.IStyle.FontFamilyEnum.Verdana; div.style.whiteSpace = ScriptCoreLib.JavaScript.DOM.IStyle.WhiteSpaceEnum.nowrap; var i = new PublicEvent().AttachTo(div); i.style.verticalAlign = "middle"; i.style.marginRight = "0.5em"; var s = new IHTMLAnchor { innerText = type.Name }.AttachTo(div); s.href = "#"; s.style.textDecoration = "none"; s.style.color = JSColor.System.WindowText; Action onclick = delegate { }; s.onclick += e => { e.PreventDefault(); s.focus(); UpdateLocation(type.Name); onclick(); }; s.onfocus += delegate { s.style.backgroundColor = JSColor.System.Highlight; s.style.color = JSColor.System.HighlightText; }; s.onblur += delegate { s.style.backgroundColor = JSColor.None; s.style.color = JSColor.System.WindowText; }; onclick = delegate { var children = new IHTMLDiv().AttachTo(div); children.style.paddingLeft = "2em"; AddTypeMethod(children, type.GetAddMethod(), UpdateLocation); AddTypeMethod(children, type.GetRemoveMethod(), UpdateLocation); var NextClickHide = default(Action); var NextClickShow = default(Action); NextClickHide = delegate { children.Hide(); onclick = NextClickShow; }; NextClickShow = delegate { children.Show(); onclick = NextClickHide; }; onclick = NextClickHide; }; }
private void AddType(IHTMLDiv parent, CompilationType type, Action<string> UpdateLocation) { var div = new IHTMLDiv().AttachTo(parent); div.style.marginTop = "0.1em"; div.style.fontFamily = ScriptCoreLib.JavaScript.DOM.IStyle.FontFamilyEnum.Verdana; div.style.whiteSpace = ScriptCoreLib.JavaScript.DOM.IStyle.WhiteSpaceEnum.nowrap; var i = default(IHTMLImage); if (type.IsInterface) { i = new PublicInterface(); } else { i = new PublicClass(); } i.AttachTo(div); i.style.verticalAlign = "middle"; i.style.marginRight = "0.5em"; var s = new IHTMLAnchor { innerText = type.Name, title = "" + type.MetadataToken }.AttachTo(div); if (!string.IsNullOrEmpty(type.HTMLElement)) { var c = new IHTMLCode(); Action<string, JSColor> Write = (Text, Color) => { var cs = new IHTMLSpan { innerText = Text }; cs.style.color = Color; cs.AttachTo(c); }; Write("<", JSColor.Blue); Write(type.HTMLElement, JSColor.FromRGB(0xa0, 0, 0)); Write("/>", JSColor.Blue); //c.style.marginLeft = "1em"; c.style.Float = ScriptCoreLib.JavaScript.DOM.IStyle.FloatEnum.right; c.AttachTo(s); } s.href = "#"; s.style.textDecoration = "none"; s.style.color = JSColor.System.WindowText; Action onclick = delegate { }; s.onclick += e => { e.PreventDefault(); s.focus(); if (TouchTypeSelected != null) TouchTypeSelected(type); UpdateLocation(type.FullName + " - " + type.Summary + " - HTML:" + type.HTMLElement); onclick(); }; s.onfocus += delegate { s.style.backgroundColor = JSColor.System.Highlight; s.style.color = JSColor.System.HighlightText; }; s.onblur += delegate { s.style.backgroundColor = JSColor.None; s.style.color = JSColor.System.WindowText; }; onclick = delegate { var children = new IHTMLDiv().AttachTo(div); children.style.paddingLeft = "1em"; Func<IHTMLDiv> Group = () => new IHTMLDiv().AttachTo(children); var Groups = new { Nested = Group(), Constructors = Group(), Methods = Group(), Events = Group(), Fields = Group(), Properties = Group(), }; type.GetNestedTypes().ForEach( (Current, Next) => { AddType(Groups.Nested, Current, UpdateLocation); ScriptCoreLib.Shared.Avalon.Extensions.AvalonSharedExtensions.AtDelay( 50, Next ); } ); type.GetConstructors().ForEach( (Current, Next) => { AddTypeConstructor(Groups.Constructors, Current, UpdateLocation); ScriptCoreLib.Shared.Avalon.Extensions.AvalonSharedExtensions.AtDelay( 50, Next ); } ); var HiddenMethods = new List<int>(); Action<CompilationMethod> AddIfAny = SourceMethod => { if (SourceMethod == null) return; HiddenMethods.Add(SourceMethod.MetadataToken); }; Action AfterEvents = delegate { type.GetMethods().ForEach( (Current, Next) => { if (!HiddenMethods.Contains(Current.MetadataToken)) { AddTypeMethod(Groups.Methods, Current, UpdateLocation); } ScriptCoreLib.Shared.Avalon.Extensions.AvalonSharedExtensions.AtDelay( 50, Next ); } ); }; Action AfterProperties = delegate { type.GetEvents().ForEach( (Current, Next) => { AddIfAny(Current.GetAddMethod()); AddIfAny(Current.GetRemoveMethod()); AddTypeEvent(Groups.Events, Current, UpdateLocation); ScriptCoreLib.Shared.Avalon.Extensions.AvalonSharedExtensions.AtDelay( 50, Next ); } )(AfterEvents); }; type.GetProperties().ForEach( (Current, Next) => { AddIfAny(Current.GetSetMethod()); AddIfAny(Current.GetGetMethod()); AddTypeProperty(Groups.Properties, Current, UpdateLocation); ScriptCoreLib.Shared.Avalon.Extensions.AvalonSharedExtensions.AtDelay( 50, Next ); } )(AfterProperties); type.GetFields().ForEach( (Current, Next) => { AddTypeField(Groups.Fields, Current, UpdateLocation); ScriptCoreLib.Shared.Avalon.Extensions.AvalonSharedExtensions.AtDelay( 50, Next ); } ); var NextClickHide = default(Action); var NextClickShow = default(Action); NextClickHide = delegate { children.Hide(); onclick = NextClickShow; }; NextClickShow = delegate { children.Show(); onclick = NextClickHide; }; onclick = NextClickHide; }; }
private static IHTMLDiv AddNamespace(IHTMLDiv parent, IHTMLDiv NextNamespaceOrDefault, string Namespace, Action<string> UpdateLocation) { var div = new IHTMLDiv(); if (NextNamespaceOrDefault == null) div.AttachTo(parent); else NextNamespaceOrDefault.insertPreviousSibling(div); div.style.marginTop = "0.1em"; div.style.fontFamily = ScriptCoreLib.JavaScript.DOM.IStyle.FontFamilyEnum.Verdana; div.style.whiteSpace = ScriptCoreLib.JavaScript.DOM.IStyle.WhiteSpaceEnum.nowrap; var i = new Namespace().AttachTo(div); i.style.verticalAlign = "middle"; i.style.marginRight = "0.5em"; if (Namespace == "") Namespace = "<Module>"; var s = new IHTMLAnchor { innerText = Namespace }.AttachTo(div); s.href = "#"; s.style.textDecoration = "none"; s.style.color = JSColor.System.WindowText; Action onclick = delegate { }; s.onclick += e => { e.PreventDefault(); s.focus(); UpdateLocation(Namespace); onclick(); }; s.onfocus += delegate { s.style.backgroundColor = JSColor.System.Highlight; s.style.color = JSColor.System.HighlightText; }; s.onblur += delegate { s.style.backgroundColor = JSColor.None; s.style.color = JSColor.System.WindowText; }; var children = new IHTMLDiv().AttachTo(div); children.style.paddingLeft = "1em"; children.Hide(); var NextClickHide = default(Action); var NextClickShow = default(Action); NextClickHide = delegate { children.Hide(); onclick = NextClickShow; }; NextClickShow = delegate { children.Show(); onclick = NextClickHide; }; onclick = NextClickShow; return children; }
private void RenderAssemblies( CompilationArchiveBase archive, IHTMLElement parent, Func<string, IHTMLDiv> AllTypes, Action<string> UpdateLocation, Action<Action<Action>> YieldLoadAction) { var Assemblies = archive.GetAssemblies(); foreach (var Assembly in Assemblies) { Console.WriteLine(new { Assembly.Name }); } var q = from a in Assemblies where a.Name.StartsWith("ScriptCoreLib") orderby a.Name select a; // limit to only first one for speedup foreach (var item2 in q.Take(1)) { var item = item2; var div = new IHTMLDiv().AttachTo(parent); div.style.marginTop = "0.1em"; div.style.fontFamily = ScriptCoreLib.JavaScript.DOM.IStyle.FontFamilyEnum.Verdana; div.style.whiteSpace = ScriptCoreLib.JavaScript.DOM.IStyle.WhiteSpaceEnum.nowrap; var i = new Assembly().AttachTo(div); i.style.verticalAlign = "middle"; i.style.marginRight = "0.5em"; var s = new IHTMLAnchor { innerText = item2.Name }.AttachTo(div); //s.style.color = JSColor.Gray; s.href = "#"; s.style.textDecoration = "none"; s.style.color = JSColor.System.GrayText; Action onclick = delegate { }; s.onclick += e => { e.PreventDefault(); s.focus(); UpdateLocation(item.Name); onclick(); }; s.onfocus += delegate { s.style.backgroundColor = JSColor.System.Highlight; s.style.color = JSColor.System.HighlightText; }; s.onblur += delegate { s.style.backgroundColor = JSColor.None; s.style.color = JSColor.System.WindowText; }; var NamespaceLookup = new Dictionary<string, IHTMLDiv>(); Func<IHTMLDiv, CompilationType, IHTMLDiv> GetNamespaceContainer = (Container, SourceType) => { if (!NamespaceLookup.ContainsKey(SourceType.Namespace)) { NamespaceLookup[SourceType.Namespace] = null; var NextNamespaceOrDefault = default(IHTMLDiv); //var NextNamespaceOrDefault = NamespaceLookup.Keys.OrderBy(k => k).SkipWhile(k => k == SourceType.Namespace).Select(k => NamespaceLookup[k]).FirstOrDefault(); NamespaceLookup[SourceType.Namespace] = AddNamespace(Container, NextNamespaceOrDefault, SourceType.Namespace, UpdateLocation); } return NamespaceLookup[SourceType.Namespace]; }; var children = new IHTMLDiv().AttachTo(div); children.style.paddingLeft = "1em"; Action<Action> LoadAction = done => { Console.WriteLine("enter LoadAction"); s.style.color = JSColor.System.Highlight; Action done_ = delegate { done(); }; item.WhenReady( a => { Console.WriteLine("enter WhenReady"); s.style.color = JSColor.System.WindowText; Console.WriteLine("before GetTypes ToArray"); var TypesArray = a.GetTypes().ToArray(); //Console.WriteLine("before TypesByName"); //var TypesByName = TypesArray.OrderBy(k => k.Name); //Console.WriteLine("before TypesByName ToArray"); //// chokes on android? //var TypesByNameArray = TypesByName.ToArray(); //Console.WriteLine("before ForEach"); TypesArray.ForEach( (Current, Index, Next) => { Console.WriteLine("AddType"); if (!Current.IsNested) { AddType( GetNamespaceContainer(children, Current), Current, UpdateLocation ); AddType( AllTypes(Current.Namespace), Current, UpdateLocation ); } if (Index % 8 == 0) { ScriptCoreLib.Shared.Avalon.Extensions.AvalonSharedExtensions.AtDelay( 7, Next ); } else { Next(); } } )(done_); Console.WriteLine("exit WhenReady"); } ); }; Console.WriteLine("before YieldLoadAction"); YieldLoadAction(LoadAction); Console.WriteLine("after YieldLoadAction"); var NextClickHide = default(Action); var NextClickShow = default(Action); NextClickHide = delegate { children.Hide(); onclick = NextClickShow; }; NextClickShow = delegate { children.Show(); onclick = NextClickHide; }; NextClickHide(); } }