public Application(IApp page) { // X:\jsc.svn\examples\javascript\Test\TestNativeStaticDelegateCall\TestNativeStaticDelegateCall\Application.cs // 02000053 ScriptCoreLib.Query.Experimental.QueryExpressionBuilder + SQLWriter`1 +<> c__DisplayClass77 //script: error JSC1000: unsupported flow detected, try to simplify. // Assembly V:\GGearAlpha.Application.exe // DeclaringType ScriptCoreLib.Query.Experimental.QueryExpressionBuilder + SQLWriter`1 +<> c__DisplayClass77, GGearAlpha.Application, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = null // OwnerMethod <.ctor > b__57 //Offset 0664 //.Try ommiting the return, break or continue instruction. #if FCHROME #region AtFormCreated FormStyler.AtFormCreated = s => { s.Context.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; // this is working? var x = new ChromeTCPServerWithFrameNone.HTML.Pages.AppWindowDrag().AttachTo(s.Context.GetHTMLTarget()); }; #endregion #region ChromeTCPServer dynamic self = Native.self; dynamic self_chrome = self.chrome; object self_chrome_socket = self_chrome.socket; if (self_chrome_socket != null) { chrome.Notification.DefaultTitle = "GGearAlpha"; chrome.Notification.DefaultIconUrl = new HTML.Images.FromAssets.Preview128().src; ChromeTCPServer.TheServerWithStyledForm.Invoke( AppSource.Text, AtFormCreated: FormStyler.AtFormCreated ); return; } #endregion #endif // 7 years later, 28.06.2007 to 20140629 // google gears ws discontinued // yet today jsc allows to use websql in a worker thread in a browser. // can we just do a svn move from7 years ago // and then just call // "X:\jsc.svn\javascript\Examples\GoogleGears\GGearAlpha\bin\Debug\web\GoogleGearsAdvanced.htm" // we do have to update the way we refernce images.in 2014 we haev AssetsLibrary. :) what about 2021? timetravel? // http://gearsblog.blogspot.com/2011/03/stopping-gears.html // once images are restored, lets switch to SQLite api. new js.GoogleGearsAdvanced(); }
/// <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) { #region AtFormCreated FormStyler.AtFormCreated = s => { s.Context.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; var x = new ChromeTCPServerWithFrameNone.HTML.Pages.AppWindowDrag().AttachTo(s.Context.GetHTMLTarget()); }; #endregion #region ChromeTCPServer dynamic self = Native.self; dynamic self_chrome = self.chrome; object self_chrome_socket = self_chrome.socket; if (self_chrome_socket != null) { chrome.Notification.DefaultTitle = "AvalonCloseWindowExperiment"; //chrome.Notification.DefaultIconUrl = new HTML.Images.FromAssets.Preview().src; ChromeTCPServer.TheServerWithStyledForm.Invoke( AppSource.Text, AtFormCreated: FormStyler.AtFormCreated ); return; } #endregion ApplicationSprite sprite = new ApplicationSprite(); sprite.AutoSizeSpriteTo(page.ContentSize); sprite.AttachSpriteTo(page.Content); sprite.DoClose += delegate { // if we are running as a chrome AppWindow // then the webview might want to // listen to the close event? // for now we get a blank screen instead. // waiting for the fix. // X:\jsc.svn\examples\javascript\chrome\apps\ChromeTCPServerWithFrameNone\ChromeTCPServerWithFrameNone\Application.cs // http://developer.chrome.com/apps/tags/webview.html Native.window.close(); }; }
/// <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) { #region AtFormCreated FormStyler.AtFormCreated = s => { s.Context.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; var x = new ChromeTCPServerWithFrameNone.HTML.Pages.AppWindowDrag().AttachTo(s.Context.GetHTMLTarget()); }; #endregion #region ChromeTCPServer dynamic self = Native.self; dynamic self_chrome = self.chrome; object self_chrome_socket = self_chrome.socket; if (self_chrome_socket != null) { chrome.Notification.DefaultTitle = "AvalonCloseWindowExperiment"; //chrome.Notification.DefaultIconUrl = new HTML.Images.FromAssets.Preview().src; ChromeTCPServer.TheServerWithStyledForm.Invoke( AppSource.Text, AtFormCreated: FormStyler.AtFormCreated ); return; } #endregion ApplicationSprite sprite = new ApplicationSprite(); sprite.AutoSizeSpriteTo(page.ContentSize); sprite.AttachSpriteTo(page.Content); sprite.DoClose += delegate { // if we are running as a chrome AppWindow // then the webview might want to // listen to the close event? // for now we get a blank screen instead. // waiting for the fix. // X:\jsc.svn\examples\javascript\chrome\apps\ChromeTCPServerWithFrameNone\ChromeTCPServerWithFrameNone\Application.cs // http://developer.chrome.com/apps/tags/webview.html Native.window.close(); }; }
/// <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(IDefault page) { // has it ever been a chrome app? // we do have a version for android // X:\jsc.svn\examples\javascript\android\com.abstractatech.consoleworm\com.abstractatech.consoleworm\Application.cs // code duplicates! // "X:\jsc.svn\examples\javascript\android\com.abstractatech.gamification.craft\com.abstractatech.gamification.craft.sln" #if FCHROME #region AtFormCreated FormStyler.AtFormCreated = s => { s.Context.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; var x = new ChromeTCPServerWithFrameNone.HTML.Pages.AppWindowDrag().AttachTo(s.Context.GetHTMLTarget()); }; #endregion #region ChromeTCPServer dynamic self = Native.self; dynamic self_chrome = self.chrome; object self_chrome_socket = self_chrome.socket; if (self_chrome_socket != null) { chrome.Notification.DefaultTitle = "ConsoleWorm"; chrome.Notification.DefaultIconUrl = new HTML.Images.FromAssets.Preview().src; ChromeTCPServer.TheServerWithStyledForm.Invoke( DefaultSource.Text, AtFormCreated: FormStyler.AtFormCreated ); return; } #endregion #endif new ConsoleWorm.js.Game(); //@"Console Worm".ToDocumentTitle(); //// Send data from JavaScript to the server tier //service.WebMethod2( // @"Console Multi Worm", // value => value.ToDocumentTitle() //); }
/// <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(IDefault page) { // has it ever been a chrome app? // we do have a version for android // X:\jsc.svn\examples\javascript\android\com.abstractatech.consoleworm\com.abstractatech.consoleworm\Application.cs // code duplicates! // "X:\jsc.svn\examples\javascript\android\com.abstractatech.gamification.craft\com.abstractatech.gamification.craft.sln" #if FCHROME #region AtFormCreated FormStyler.AtFormCreated = s => { s.Context.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; var x = new ChromeTCPServerWithFrameNone.HTML.Pages.AppWindowDrag().AttachTo(s.Context.GetHTMLTarget()); }; #endregion #region ChromeTCPServer dynamic self = Native.self; dynamic self_chrome = self.chrome; object self_chrome_socket = self_chrome.socket; if (self_chrome_socket != null) { chrome.Notification.DefaultTitle = "ConsoleWorm"; chrome.Notification.DefaultIconUrl = new HTML.Images.FromAssets.Preview().src; ChromeTCPServer.TheServerWithStyledForm.Invoke( DefaultSource.Text, AtFormCreated: FormStyler.AtFormCreated ); return; } #endregion #endif new ConsoleWorm.js.Game(); //@"Console Worm".ToDocumentTitle(); //// Send data from JavaScript to the server tier //service.WebMethod2( // @"Console Multi Worm", // value => value.ToDocumentTitle() //); }
/// <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) { #region AtFormCreated FormStyler.AtFormCreated = s => { s.Context.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; var x = new ChromeTCPServerWithFrameNone.HTML.Pages.AppWindowDrag().AttachTo(s.Context.GetHTMLTarget()); }; #endregion #region ChromeTCPServer dynamic self = Native.self; dynamic self_chrome = self.chrome; object self_chrome_socket = self_chrome.socket; if (self_chrome_socket != null) { chrome.Notification.DefaultTitle = "Flare3DMeetsStarlingExperiment"; chrome.Notification.DefaultIconUrl = new HTML.Images.FromAssets.Preview().src; ChromeTCPServer.TheServerWithStyledForm.Invoke( AppSource.Text, AtFormCreated: FormStyler.AtFormCreated ); return; } #endregion // can we make it as a chrome app? :) var sprite = new ApplicationSprite(); sprite.AttachSpriteToDocument().With( embed => { embed.style.SetLocation(0, 0); embed.style.SetSize(Native.window.Width, Native.window.Height); Native.window.onresize += delegate { embed.style.SetSize(Native.window.Width, Native.window.Height); }; } ); }
/// <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) { #region AtFormCreated FormStyler.AtFormCreated = s => { s.Context.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; var x = new ChromeTCPServerWithFrameNone.HTML.Pages.AppWindowDrag().AttachTo(s.Context.GetHTMLTarget()); }; #endregion #region ChromeTCPServer dynamic self = Native.self; dynamic self_chrome = self.chrome; object self_chrome_socket = self_chrome.socket; if (self_chrome_socket != null) { chrome.Notification.DefaultTitle = "Flare3DMeetsStarlingExperiment"; chrome.Notification.DefaultIconUrl = new HTML.Images.FromAssets.Preview().src; ChromeTCPServer.TheServerWithStyledForm.Invoke( AppSource.Text, AtFormCreated: FormStyler.AtFormCreated ); return; } #endregion // can we make it as a chrome app? :) var sprite = new ApplicationSprite(); sprite.AttachSpriteToDocument().With( embed => { embed.style.SetLocation(0, 0); embed.style.SetSize(Native.window.Width, Native.window.Height); Native.window.onresize += delegate { embed.style.SetSize(Native.window.Width, Native.window.Height); }; } ); }
/// <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) { // 1e40:01:01 RewriteToAssembly error: System.MissingMethodException: Method not found: 'Void ScriptCoreLib.JavaScript.DOM.IWindow.add_onframe(System.Action`1<Int32>)'. #if chrome_works_again #region AtFormCreated FormStyler.AtFormCreated = s => { s.Context.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; var x = new ChromeTCPServerWithFrameNone.HTML.Pages.AppWindowDrag().AttachTo(s.Context.GetHTMLTarget()); }; #endregion // chrome 31 wont load view-source // chrome 33 shows black window. nice. #region ChromeTCPServer dynamic self = Native.self; dynamic self_chrome = self.chrome; object self_chrome_socket = self_chrome.socket; if (self_chrome_socket != null) { chrome.Notification.DefaultTitle = "Droplet"; //chrome.Notification.DefaultIconUrl = new HTML.Images.FromAssets.Preview().src; ChromeTCPServer.TheServerWithStyledForm.Invoke( AppSource.Text, AtFormCreated: FormStyler.AtFormCreated ); return; } #endregion #endif #region clouds new WebGLClouds.HTML.Pages.Default().With( layout => { layout.body.AttachTo(page.clouds); new WebGLClouds.Application(layout); } ); #endregion page.header.style.backgroundColor = ""; page.header.css.style.transition = "background-color 200ms linear"; page.header.css.style.backgroundColor = "rgba(255, 255, 0, 0)"; //page.header.css.style.backgroundColor = "rgba(255, 255, 0, 0.2)"; page.header.css.hover.style.backgroundColor = "rgba(255, 255, 0, 1.0)"; Native.window.onframe += delegate { if (Native.document.body.scrollTop == 0) page.header.css.style.backgroundColor = "rgba(255, 255, 0, 0)"; else page.header.css.style.backgroundColor = "rgba(0, 0, 0, 0.3)"; }; var oo = new List<THREE.Object3D>(); var window = Native.window; var camera = new THREE.PerspectiveCamera( 45, page.header.clientWidth / (double)page.header.clientHeight, 1, 2000 ); camera.position.z = 400; // scene var scene = new THREE.Scene(); var ambient = new THREE.AmbientLight(0x101030); scene.add(ambient); var directionalLight = new THREE.DirectionalLight(0xffeedd); directionalLight.position.set(0, 0, 1); scene.add(directionalLight); var renderer = new THREE.WebGLRenderer(); //renderer.domElement.AttachToDocument(); renderer.domElement.AttachTo(page.header); renderer.setSize(page.header.clientWidth, page.header.clientHeight); //renderer.setSize(window.Width, window.Height); //renderer.domElement.style.SetLocation(0, 0); var mouseX = 0; var mouseY = 0; var st = new Stopwatch(); st.Start(); Native.window.onframe += delegate { oo.WithEach( x => x.rotation.y = st.ElapsedMilliseconds * 0.001 ); camera.position.x += (mouseX - camera.position.x) * .05; camera.position.y += (-mouseY - camera.position.y) * .05; camera.lookAt(scene.position); renderer.render(scene, camera); }; Native.window.onresize += delegate { camera.aspect = page.header.clientWidth / (double)page.header.clientHeight; camera.updateProjectionMatrix(); //renderer.setSize(window.Width, window.Height); renderer.setSize(page.header.clientWidth, page.header.clientHeight); }; var data = Book1.GetDataSet(); #region bind Func<string, IHTMLElement, DataGridView> bind = (DataMember, c) => { var g = new DataGridView { BackgroundColor = Color.Transparent, // does this work? DefaultCellStyle = new DataGridViewCellStyle { SelectionBackColor = Color.Black, SelectionForeColor = Color.Yellow, //BackColor = Color.Transparent //BackColor = Color.FromArgb(0x05, 0, 0, 0) BackColor = Color.FromArgb(0x3f, 255, 255, 255) }, ColumnHeadersDefaultCellStyle = new DataGridViewCellStyle { BackColor = Color.FromArgb(0x8f, 255, 255, 255) }, SelectionMode = DataGridViewSelectionMode.FullRowSelect, AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill, // do we have a test for this? AllowUserToAddRows = false, //AllowUserToDeleteRows = false, RowHeadersVisible = false, // cannot hide column headers yet // script: error JSC1000: No implementation found for this native method, please implement [System.Windows.Forms.DataGridView.set_ColumnHeadersVisible(System.Boolean)] //ColumnHeadersVisible = false, DataSource = data, DataMember = DataMember, }; // this should be the one that maximizes itself onto the parent which is supposed to be absolute in size //g.GetHTMLTarget().With( // div => // { // //div.style.reset(); // // no scrollbars, thanks // div.style.overflow = IStyle.OverflowEnum.hidden; // (div.style as dynamic).zIndex = ""; // div.style.position = IStyle.PositionEnum.relative; // div.style.left = ""; // div.style.top = ""; // div.style.right = ""; // } //); c.style.position = IStyle.PositionEnum.relative; c.style.height = "20em"; c.Clear(); g.AttachControlTo(c); return g; }; #endregion bind("Assets", page.assets); bind("Transactions", page.transactions).ReadOnly = true; // script: error JSC1000: No implementation found for this native method, please implement [System.Data.DataTableCollection.get_Item(System.String)] var data_Assets = data.Tables["Assets"]; var data_Transactions = data.Tables["Transactions"]; #region data_Assets_NewRow Action<DataRow> data_Assets_NewRow = SourceRow => { var r = new Random(); new sack_of_gold2().Source.Task.ContinueWithResult( o => { o.position.y = -80; scene.add(o); oo.Add(o); o.position.x = r.Next(-250, 250); o.position.z = r.Next(-400, 200); (o as dynamic).scale = new THREE.Vector3(0.5, 0.5, 0.5); data_Assets.RowDeleting += (sender, e) => { if (SourceRow != e.Row) return; scene.remove(o); oo.Remove(o); data_Transactions.Rows.Add( "now", "item removed -" + SourceRow["Net worth"] ); }; } ); }; #endregion data_Assets.Rows.AsEnumerable().WithEach(data_Assets_NewRow); // "X:\jsc.svn\examples\javascript\DropFileIntoSQLite\DropFileIntoSQLite.sln" // X:\jsc.svn\examples\javascript\DragDataTableIntoCSVFile\DragDataTableIntoCSVFile\Application.cs #region ondragstart page.header.ondragstart += e => { data_Assets.Rows.AsEnumerable().FirstOrDefault().With( SourceRow => { // x:\jsc.svn\examples\javascript\dropfileintosqlite\dropfileintosqlite\application.cs data_Assets.Rows.Remove(SourceRow); //data_Assets.Rows.RemoveAt(0); var clipboard = new DataTable(); clipboard.Columns.AddRange( Enumerable.ToArray( from x in data_Assets.Columns.AsEnumerable() select new DataColumn { ColumnName = x.ColumnName } ) ); clipboard.Rows.Add( Enumerable.ToArray( from x in data_Assets.Columns.AsEnumerable() select SourceRow[x] ) ); e.dataTransfer.effectAllowed = "copy"; var clipboard_string = StringConversionsForDataTable.ConvertToString(clipboard); e.dataTransfer.setData(typeof(DataTable).Name, clipboard_string); } ); }; #endregion // X:\jsc.svn\market\javascript\Abstractatech.JavaScript.FileStorage\Abstractatech.JavaScript.FileStorage\Application.cs var dz = new DropZone(); var TimerHide = new ScriptCoreLib.JavaScript.Runtime.Timer( delegate { dz.body.Orphanize(); } ); #region ondragover Action<DragEvent> ondragover = evt => { evt.stopPropagation(); evt.preventDefault(); if (evt.dataTransfer.types.Contains(typeof(DataTable).Name.ToLower())) { evt.dataTransfer.dropEffect = "copy"; // Explicitly show this is a copy. dz.body.AttachTo(Native.document.documentElement); dz.bglayer.style.transition = "background-color 500ms linear"; dz.bglayer.style.backgroundColor = "rgba(0,0,0, 0.7)"; TimerHide.Stop(); } }; Native.Document.body.ondragover += ondragover; dz.Container.ondragover += ondragover; #endregion dz.Container.ondragleave += evt => { //Console.WriteLine("ondragleave"); //Console.WriteLine(" dz.Container.ondragleave"); TimerHide.StartTimeout(90); evt.stopPropagation(); evt.preventDefault(); }; Native.window.onblur += delegate { data_Transactions.Rows.Add( //"now", "item added +" + SourceRow["Net worth"] "now", "blur" ); }; Native.window.onfocus += delegate { data_Transactions.Rows.Add( //"now", "item added +" + SourceRow["Net worth"] "now", "focus" ); }; data_Assets_NewRow += SourceRow => { data_Transactions.Rows.Add( //"now", "item added +" + SourceRow["Net worth"] "now", "item added" ); }; data_Assets.TableNewRow += (sender, e) => { data_Assets_NewRow(e.Row); }; #region ondrop dz.Container.ondrop += evt => { //Console.WriteLine("ondrop"); TimerHide.StartTimeout(90); evt.stopPropagation(); evt.preventDefault(); if (evt.dataTransfer.items != null) { // X:\jsc.svn\examples\javascript\DragDataTableIntoCSVFile\DragDataTableIntoCSVFile\Application.cs evt.dataTransfer.items.AsEnumerable().Where( x => x.type.ToLower() == // let jsc type system sort it out? // how much reflection does jsc give us nowadays? typeof(DataTable).Name.ToLower() ).WithEach( async xx => { // http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#dfnReturnLink-0 var DataTable_xml = await xx.getAsString(); var DataTable = StringConversionsForDataTable.ConvertFromString(DataTable_xml); DataTable.Rows.AsEnumerable().WithEach( SourceRow => { data_Assets.Rows.Add( Enumerable.ToArray( from x in data_Assets.Columns.AsEnumerable() select SourceRow[x] ) ); } ); } ); } }; #endregion }
/// <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) { // https://chrome.google.com/webstore/detail/dglmddjmdpdbijfkoaiadbpmjampfdjh/publish-delayed #region ChromeTCPServer dynamic self = Native.self; dynamic self_chrome = self.chrome; object self_chrome_socket = self_chrome.socket; if (self_chrome_socket != null) { #region AtFormCreated FormStyler.AtFormCreated = ss => { ss.Context.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; // this is working? var x = new ChromeTCPServerWithFrameNone.HTML.Pages.AppWindowDrag().AttachTo(ss.Context.GetHTMLTarget()); }; #endregion chrome.Notification.DefaultTitle = "Heat Zeeker"; chrome.Notification.DefaultIconUrl = new HTML.Images.FromAssets.Promotion3D_iso1_tiltshift_128().src; ChromeTCPServer.TheServerWithStyledForm.Invoke( AppSource.Text, AtFormCreated: FormStyler.AtFormCreated ); return; } #endregion Native.body.style.margin = "0px"; Native.body.style.overflow = IStyle.OverflowEnum.hidden; // jsc, add THREE // ... ok. // X:\jsc.svn\examples\javascript\WebGL\WebGLOrthographicCamera\WebGLOrthographicCamera\Application.cs // this is not isometric. // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20151112 var camera = new THREE.OrthographicCamera( Native.window.Width / -2, Native.window.Width / 2, Native.window.Height / 2, Native.window.Height / -2 , // if we change these values what will change? -1000, 1000 ); camera.position.x = 200; camera.position.y = 100; camera.position.z = 200; var scene = new THREE.Scene(); // Grid var size = 600; var step = 50; Func <double> random = new Random().NextDouble; // how do I add a new ground box? { var geometry = new THREE.BoxGeometry(size * 2, 2, size * 2); var material = new THREE.MeshLambertMaterial(new { color = 0xB27D51 // , shading = THREE.FlatShading, overdraw = 0.5 }); { var cube = new THREE.Mesh(geometry, material); // why cant we get the shadows?? cube.receiveShadow = true; cube.scale.y = Math.Floor(random() * 2 + 1); cube.position.x = 0; //cube.position.y = (cube.scale.y * 50) / 2; cube.position.y = -2; cube.position.z = 0; scene.add(cube); } } { var geometry = new THREE.Geometry(); for (var i = -size; i <= size; i += step) { ((IArray <THREE.Vector3>)(object) geometry.vertices).push(new THREE.Vector3(-size, 0, i)); ((IArray <THREE.Vector3>)(object) geometry.vertices).push(new THREE.Vector3(size, 0, i)); ((IArray <THREE.Vector3>)(object) geometry.vertices).push(new THREE.Vector3(i, 0, -size)); ((IArray <THREE.Vector3>)(object) geometry.vertices).push(new THREE.Vector3(i, 0, size)); } var material = new THREE.LineBasicMaterial(new { color = 0, opacity = 0.2 }); var line = new THREE.Line(geometry, material, mode: THREE.LinePieces); scene.add(line); } var interactiveObjects = new List <THREE.Object3D>(); #region Cubes { for (var i = 0; i < 8; i++) { new HZBunker().Source.Task.ContinueWithResult( cube => { // https://github.com/mrdoob/three.js/issues/1285 //cube.children.WithEach(c => c.castShadow = true); //cube.traverse( // new Action<THREE.Object3D>( // child => // { // // does it work? do we need it? // //if (child is THREE.Mesh) // child.castShadow = true; // child.receiveShadow = true; // } // ) //); // um can edit and continue insert code going back in time? cube.scale.x = 2.0; cube.scale.y = 2.0; cube.scale.z = 2.0; //cube.castShadow = true; //dae.receiveShadow = true; cube.position.x = Math.Floor((random() * 1000 - 500) / 50) * 50 + 25; //cube.position.y = (cube.scale.y * 50) / 2; cube.position.z = Math.Floor((random() * 1000 - 500) / 50) * 50 + 25; scene.add(cube); interactiveObjects.Add(cube); } ); new HZWaterTower().Source.Task.ContinueWithResult( cube => { // https://github.com/mrdoob/three.js/issues/1285 // https://github.com/mrdoob/three.js/issues/1285 //cube.children.WithEach(c => c.castShadow = true); // http://stackoverflow.com/questions/15906248/three-js-objloader-obj-model-not-casting-shadows // http://stackoverflow.com/questions/22895120/imported-3d-objects-are-not-casting-shadows-with-three-js //cube.traverse( // new Action<THREE.Object3D>( // child => // { // // does it work? do we need it? // //if (child is THREE.Mesh) // child.castShadow = true; // child.receiveShadow = true; // } // ) //); // um can edit and continue insert code going back in time? cube.scale.x = 2.0; cube.scale.y = 2.0; cube.scale.z = 2.0; //cube.castShadow = true; //dae.receiveShadow = true; cube.position.x = Math.Floor((random() * 1000 - 500) / 50) * 50 + 25; //cube.position.y = (cube.scale.y * 50) / 2; cube.position.z = Math.Floor((random() * 1000 - 500) / 50) * 50 + 25; scene.add(cube); interactiveObjects.Add(cube); } ); new HZCannon().Source.Task.ContinueWithResult( cube => { // https://github.com/mrdoob/three.js/issues/1285 //cube.children.WithEach(c => c.castShadow = true); //cube.traverse( // new Action<THREE.Object3D>( // child => // { // // does it work? do we need it? // //if (child is THREE.Mesh) // child.castShadow = true; // child.receiveShadow = true; // } // ) //); // um can edit and continue insert code going back in time? cube.scale.x = 2.0; cube.scale.y = 2.0; cube.scale.z = 2.0; //cube.castShadow = true; //dae.receiveShadow = true; cube.position.x = Math.Floor((random() * 1000 - 500) / 50) * 50 + 25; //cube.position.y = (cube.scale.y * 50) / 2; cube.position.z = Math.Floor((random() * 1000 - 500) / 50) * 50 + 25; // if i want to rotate, how do I do it? //cube.rotation.z = random() + Math.PI; //cube.rotation.x = random() + Math.PI; cube.rotation.y = random() * Math.PI * 2; scene.add(cube); interactiveObjects.Add(cube); } ); } } #endregion // we need expression evaluator with intellisense for live debugging sessions #region Lights var ambientLight = new THREE.AmbientLight((int)(random() * 0x10)); scene.add(ambientLight); // can we get our shadows? { var directionalLight = new THREE.DirectionalLight((int)(random() * 0xffffff), 0.5); directionalLight.position.x = random() - 0.5; directionalLight.position.y = 400; directionalLight.position.z = random() - 0.5; directionalLight.position.normalize(); scene.add(directionalLight); } { var directionalLight = new THREE.DirectionalLight((int)(random() * 0xffffff), 0.5); directionalLight.position.x = random() - 0.5; directionalLight.position.y = 400; directionalLight.position.z = random() - 0.5; directionalLight.position.normalize(); scene.add(directionalLight); } #endregion //var renderer = new THREE.CanvasRenderer(); var renderer = new THREE.WebGLRenderer(); renderer.shadowMapEnabled = true; // background-color: #B27D51; renderer.setClearColor(0xB27D51); //renderer.setSize( // Native.window.Width , // Native.window.Height * 10 // ); renderer.setSize(); renderer.domElement.AttachToDocument(); Native.window.onresize += delegate { camera.left = Native.window.Width / -2; camera.right = Native.window.Width / 2; camera.top = Native.window.Height / 2; camera.bottom = Native.window.Height / -2; camera.updateProjectionMatrix(); renderer.setSize(); }; //window.addEventListener( 'resize', onWindowResize, false ); //#region Comanche //new Comanche().Source.Task.ContinueWithResult( // Comanche => // { // Comanche.position.y = 200; // //dae.position.z = 280; // Comanche.AttachTo(scene); // //scene.add(dae); // //oo.Add(Comanche); // // wont do it // //dae.castShadow = true; // // http://stackoverflow.com/questions/15492857/any-way-to-get-a-bounding-box-from-a-three-js-object3d // //var helper = new THREE.BoundingBoxHelper(dae, 0xff0000); // //helper.update(); // //// If you want a visible bounding box // //scene.add(helper); // Comanche.children[0].children[0].children.WithEach(x => x.castShadow = true); // // the rotors? // Comanche.children[0].children[0].children.Last().children.WithEach(x => x.castShadow = true); // Comanche.scale.set(0.5, 0.5, 0.5); // //helper.scale.set(0.5, 0.5, 0.5); // var sw = Stopwatch.StartNew(); // Native.window.onframe += delegate // { // //dae.children[0].children[0].children.Last().al // //dae.children[0].children[0].children.Last().rotation.z = sw.ElapsedMilliseconds * 0.01; // //dae.children[0].children[0].children.Last().rotation.x = sw.ElapsedMilliseconds * 0.01; // //rotation.y = sw.ElapsedMilliseconds * 0.01; // Comanche.children[0].children[0].children.Last().rotation.y = sw.ElapsedMilliseconds * 0.001; // //dae.children[0].children[0].children.Last().app // }; // } //); //#endregion //#region ee //// X:\jsc.svn\examples\javascript\forms\NumericTextBox\NumericTextBox\ApplicationControl.cs //// can we restile the window as the pin window in IDE? //var ee = new Form { Left = 0, StartPosition = FormStartPosition.Manual }; //var ee_camera_y = new TextBox { Dock = DockStyle.Fill, Text = camera.position.y + "" }.AttachTo(ee); ////ee.AutoSize = AutoSizeMode. ////ee.ClientSize = new System.Drawing.Size(ee_camera_y.Width, ee_camera_y.Height); //ee.ClientSize = new System.Drawing.Size(200, 24); //ee.Show(); ////ee_camera_y. //ee_camera_y.TextChanged += delegate //{ // camera.position.y = double.Parse(ee_camera_y.Text); //}; //#endregion var s = Stopwatch.StartNew(); var controls = new THREE.OrbitControls(camera, renderer.domElement); // http://stackoverflow.com/questions/26497903/nested-webglrendertargets-in-three-js // var effect = new THREE.OculusRiftEffect( //renderer, new //{ // worldScale = 100, // //HMD // } //); // effect.setSize(1920, 1080); Native.window.onframe += e => { // jsc, when can we have the edit and continue already? //var timer = s.ElapsedMilliseconds * 0.1; //var timer = s.ElapsedMilliseconds * 0.0001; //camera.position.x = Math.Cos(timer) * 200; //camera.position.z = Math.Sin(timer) * 200; // camera.position.z = 200; //camera.position.y = 100; //camera.position.y = Math.Sin(timer * 0.1) * 200; controls.update(); camera.position = controls.center.clone(); renderer.render(scene, camera); //effect.render(scene, camera); }; //var ze = new ZeProperties(); //ze.Show(); //ze.treeView1.Nodes.Clear(); //ze.Add(() => renderer); ////ze.Add(() => controls); //ze.Add(() => scene); //ze.Left = 0; // view-source:http://mrdoob.github.io/three.js/examples/webgl_interactive_voxelpainter.html //var mouse2D = new THREE.Vector3(0, 10000, 0.5); //renderer.domElement.onclick += // e => // { // e.preventDefault(); // mouse2D.x = (e.CursorX / (double)Native.window.Width) * 2 - 1; // mouse2D.y = -(e.CursorY / (double)Native.window.Height) * 2 + 1; // var vector = new THREE.Vector3( // (e.CursorX / (double)Native.window.Width) * 2 - 1, // -(e.CursorY / (double)Native.window.Height) * 2 + 1, // 0.5); // // X:\jsc.svn\examples\javascript\WebGL\WebGLInteractiveCubes\WebGLInteractiveCubes\Application.cs // var projector = new THREE.Projector(); // projector.unprojectVector(vector, camera); // // http://stackoverflow.com/questions/18553209/orthographic-camera-and-selecting-objects-with-raycast // // http://stackoverflow.com/questions/20361776/orthographic-camera-and-pickingray // // view-source:http://stemkoski.github.io/Three.js/Mouse-Click.html // // http://stackoverflow.com/questions/11921033/projector-and-ray-with-orthographiccamera // // use picking ray since it's an orthographic camera // // doesnt fkin work ??? // //var raycaster = projector.pickingRay(vector, camera); // var raycaster = projector.pickingRay(mouse2D.clone(), camera); // //var raycaster = new THREE.Raycaster(camera.position, vector.sub(camera.position).normalize()); // var intersects = raycaster.intersectObjects(interactiveObjects.ToArray()); // // https://github.com/mrdoob/three.js/issues/599 // Native.document.title = new { intersects.Length }.ToString(); // }; }
/// <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) { // 1e40:01:01 RewriteToAssembly error: System.MissingMethodException: Method not found: 'Void ScriptCoreLib.JavaScript.DOM.IWindow.add_onframe(System.Action`1<Int32>)'. #if chrome_works_again #region AtFormCreated FormStyler.AtFormCreated = s => { s.Context.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; var x = new ChromeTCPServerWithFrameNone.HTML.Pages.AppWindowDrag().AttachTo(s.Context.GetHTMLTarget()); }; #endregion // chrome 31 wont load view-source // chrome 33 shows black window. nice. #region ChromeTCPServer dynamic self = Native.self; dynamic self_chrome = self.chrome; object self_chrome_socket = self_chrome.socket; if (self_chrome_socket != null) { chrome.Notification.DefaultTitle = "Droplet"; //chrome.Notification.DefaultIconUrl = new HTML.Images.FromAssets.Preview().src; ChromeTCPServer.TheServerWithStyledForm.Invoke( AppSource.Text, AtFormCreated: FormStyler.AtFormCreated ); return; } #endregion #endif #region clouds new WebGLClouds.HTML.Pages.Default().With( layout => { layout.body.AttachTo(page.clouds); new WebGLClouds.Application(layout); } ); #endregion page.header.style.backgroundColor = ""; page.header.css.style.transition = "background-color 200ms linear"; page.header.css.style.backgroundColor = "rgba(255, 255, 0, 0)"; //page.header.css.style.backgroundColor = "rgba(255, 255, 0, 0.2)"; page.header.css.hover.style.backgroundColor = "rgba(255, 255, 0, 1.0)"; Native.window.onframe += delegate { if (Native.document.body.scrollTop == 0) { page.header.css.style.backgroundColor = "rgba(255, 255, 0, 0)"; } else { page.header.css.style.backgroundColor = "rgba(0, 0, 0, 0.3)"; } }; var oo = new List <THREE.Object3D>(); var window = Native.window; var camera = new THREE.PerspectiveCamera( 45, page.header.clientWidth / (double)page.header.clientHeight, 1, 2000 ); camera.position.z = 400; // scene var scene = new THREE.Scene(); var ambient = new THREE.AmbientLight(0x101030); scene.add(ambient); var directionalLight = new THREE.DirectionalLight(0xffeedd); directionalLight.position.set(0, 0, 1); scene.add(directionalLight); var renderer = new THREE.WebGLRenderer(); //renderer.domElement.AttachToDocument(); renderer.domElement.AttachTo(page.header); renderer.setSize(page.header.clientWidth, page.header.clientHeight); //renderer.setSize(window.Width, window.Height); //renderer.domElement.style.SetLocation(0, 0); var mouseX = 0; var mouseY = 0; var st = new Stopwatch(); st.Start(); Native.window.onframe += delegate { oo.WithEach( x => x.rotation.y = st.ElapsedMilliseconds * 0.001 ); camera.position.x += (mouseX - camera.position.x) * .05; camera.position.y += (-mouseY - camera.position.y) * .05; camera.lookAt(scene.position); renderer.render(scene, camera); }; Native.window.onresize += delegate { camera.aspect = page.header.clientWidth / (double)page.header.clientHeight; camera.updateProjectionMatrix(); //renderer.setSize(window.Width, window.Height); renderer.setSize(page.header.clientWidth, page.header.clientHeight); }; var data = Book1.GetDataSet(); #region bind Func <string, IHTMLElement, DataGridView> bind = (DataMember, c) => { var g = new DataGridView { BackgroundColor = Color.Transparent, // does this work? DefaultCellStyle = new DataGridViewCellStyle { SelectionBackColor = Color.Black, SelectionForeColor = Color.Yellow, //BackColor = Color.Transparent //BackColor = Color.FromArgb(0x05, 0, 0, 0) BackColor = Color.FromArgb(0x3f, 255, 255, 255) }, ColumnHeadersDefaultCellStyle = new DataGridViewCellStyle { BackColor = Color.FromArgb(0x8f, 255, 255, 255) }, SelectionMode = DataGridViewSelectionMode.FullRowSelect, AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill, // do we have a test for this? AllowUserToAddRows = false, //AllowUserToDeleteRows = false, RowHeadersVisible = false, // cannot hide column headers yet // script: error JSC1000: No implementation found for this native method, please implement [System.Windows.Forms.DataGridView.set_ColumnHeadersVisible(System.Boolean)] //ColumnHeadersVisible = false, DataSource = data, DataMember = DataMember, }; // this should be the one that maximizes itself onto the parent which is supposed to be absolute in size //g.GetHTMLTarget().With( // div => // { // //div.style.reset(); // // no scrollbars, thanks // div.style.overflow = IStyle.OverflowEnum.hidden; // (div.style as dynamic).zIndex = ""; // div.style.position = IStyle.PositionEnum.relative; // div.style.left = ""; // div.style.top = ""; // div.style.right = ""; // } //); c.style.position = IStyle.PositionEnum.relative; c.style.height = "20em"; c.Clear(); g.AttachControlTo(c); return(g); }; #endregion bind("Assets", page.assets); bind("Transactions", page.transactions).ReadOnly = true; // script: error JSC1000: No implementation found for this native method, please implement [System.Data.DataTableCollection.get_Item(System.String)] var data_Assets = data.Tables["Assets"]; var data_Transactions = data.Tables["Transactions"]; #region data_Assets_NewRow Action <DataRow> data_Assets_NewRow = SourceRow => { var r = new Random(); new sack_of_gold2().Source.Task.ContinueWithResult( o => { o.position.y = -80; scene.add(o); oo.Add(o); o.position.x = r.Next(-250, 250); o.position.z = r.Next(-400, 200); (o as dynamic).scale = new THREE.Vector3(0.5, 0.5, 0.5); data_Assets.RowDeleting += (sender, e) => { if (SourceRow != e.Row) { return; } scene.remove(o); oo.Remove(o); data_Transactions.Rows.Add( "now", "item removed -" + SourceRow["Net worth"] ); }; } ); }; #endregion data_Assets.Rows.AsEnumerable().WithEach(data_Assets_NewRow); // "X:\jsc.svn\examples\javascript\DropFileIntoSQLite\DropFileIntoSQLite.sln" // X:\jsc.svn\examples\javascript\DragDataTableIntoCSVFile\DragDataTableIntoCSVFile\Application.cs #region ondragstart page.header.ondragstart += e => { data_Assets.Rows.AsEnumerable().FirstOrDefault().With( SourceRow => { // x:\jsc.svn\examples\javascript\dropfileintosqlite\dropfileintosqlite\application.cs data_Assets.Rows.Remove(SourceRow); //data_Assets.Rows.RemoveAt(0); var clipboard = new DataTable(); clipboard.Columns.AddRange( Enumerable.ToArray( from x in data_Assets.Columns.AsEnumerable() select new DataColumn { ColumnName = x.ColumnName } ) ); clipboard.Rows.Add( Enumerable.ToArray( from x in data_Assets.Columns.AsEnumerable() select SourceRow[x] ) ); e.dataTransfer.effectAllowed = "copy"; var clipboard_string = StringConversionsForDataTable.ConvertToString(clipboard); e.dataTransfer.setData(typeof(DataTable).Name, clipboard_string); } ); }; #endregion // X:\jsc.svn\market\javascript\Abstractatech.JavaScript.FileStorage\Abstractatech.JavaScript.FileStorage\Application.cs var dz = new DropZone(); var TimerHide = new ScriptCoreLib.JavaScript.Runtime.Timer( delegate { dz.body.Orphanize(); } ); #region ondragover Action <DragEvent> ondragover = evt => { evt.stopPropagation(); evt.preventDefault(); if (evt.dataTransfer.types.Contains(typeof(DataTable).Name.ToLower())) { evt.dataTransfer.dropEffect = "copy"; // Explicitly show this is a copy. dz.body.AttachTo(Native.document.documentElement); dz.bglayer.style.transition = "background-color 500ms linear"; dz.bglayer.style.backgroundColor = "rgba(0,0,0, 0.7)"; TimerHide.Stop(); } }; Native.Document.body.ondragover += ondragover; dz.Container.ondragover += ondragover; #endregion dz.Container.ondragleave += evt => { //Console.WriteLine("ondragleave"); //Console.WriteLine(" dz.Container.ondragleave"); TimerHide.StartTimeout(90); evt.stopPropagation(); evt.preventDefault(); }; Native.window.onblur += delegate { data_Transactions.Rows.Add( //"now", "item added +" + SourceRow["Net worth"] "now", "blur" ); }; Native.window.onfocus += delegate { data_Transactions.Rows.Add( //"now", "item added +" + SourceRow["Net worth"] "now", "focus" ); }; data_Assets_NewRow += SourceRow => { data_Transactions.Rows.Add( //"now", "item added +" + SourceRow["Net worth"] "now", "item added" ); }; data_Assets.TableNewRow += (sender, e) => { data_Assets_NewRow(e.Row); }; #region ondrop dz.Container.ondrop += evt => { //Console.WriteLine("ondrop"); TimerHide.StartTimeout(90); evt.stopPropagation(); evt.preventDefault(); if (evt.dataTransfer.items != null) { // X:\jsc.svn\examples\javascript\DragDataTableIntoCSVFile\DragDataTableIntoCSVFile\Application.cs evt.dataTransfer.items.AsEnumerable().Where( x => x.type.ToLower() == // let jsc type system sort it out? // how much reflection does jsc give us nowadays? typeof(DataTable).Name.ToLower() ).WithEach( async xx => { // http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#dfnReturnLink-0 var DataTable_xml = await xx.getAsString(); var DataTable = StringConversionsForDataTable.ConvertFromString(DataTable_xml); DataTable.Rows.AsEnumerable().WithEach( SourceRow => { data_Assets.Rows.Add( Enumerable.ToArray( from x in data_Assets.Columns.AsEnumerable() select SourceRow[x] ) ); } ); } ); } }; #endregion }
/// <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) { // will skip DefineVersionInfoResource //2b5c:02:01:1e RewriteToAssembly error: System.NotSupportedException: Type 'xchrome.BCLImplementation.System.Net.Sockets.__TcpListener' was not completed. // Uncaught ReferenceError: kvYlVNrcg0qBT40xR_bUt6Q is not defined // it does work, yet chrome server is a slow asset server for now.. #if false #region AtFormCreated FormStyler.AtFormCreated = s => { s.Context.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; var x = new ChromeTCPServerWithFrameNone.HTML.Pages.AppWindowDrag().AttachTo(s.Context.GetHTMLTarget()); }; #endregion #region ChromeTCPServer dynamic self = Native.self; dynamic self_chrome = self.chrome; object self_chrome_socket = self_chrome.socket; if (self_chrome_socket != null) { chrome.Notification.DefaultTitle = "Craft"; chrome.Notification.DefaultIconUrl = new HTML.Images.FromAssets.Preview().src; ChromeTCPServer.TheServerWithStyledForm.Invoke( AppSource.Text, AtFormCreated: FormStyler.AtFormCreated ); return; } #endregion #endif // Process com.abstractatech.gamification.craft (pid 1456) has died. // http://stackoverflow.com/questions/7316680/process-has-died // http://zproxy.wordpress.com/2012/11/13/dos-warcraft/ // load the shadow land // why does this not work?? page.body.style.cursorImage = new severed(); page.Preview.style.cursorImage = new guantlet(); page.Avatar.style.cursorImage = new guantlet(); // http://www.effectgames.com/effect/article.psp.html/joe/Old_School_Color_Cycling_with_HTML5 // http://www.effectgames.com/demos/canvascycle/ // http://productforums.google.com/forum/#!topic/chrome/hgxRgmT0INY // http://www.boutell.com/newfaq/creating/midi.html //new com.abstractatech.gamification.craft.HTML.Audio.FromAssets.intro().AttachToHead().play(); // http://www.javascripter.net/faq/sound/play.htm new HTML.Audio.FromAssets.IntroWarII { loop = true, volume = 0.5 }.play(); //new IHTMLObject //{ // data = // new com.abstractatech.gamification.craft.HTML.Audio.FromAssets.intro().src //}.AttachToHead(); // <object data="mysong.mid"> //<param name="loop" value="10"/> //If you're seeing this, you don't have a MIDI player //on your computer. //</object> // IStyleSheet.Default.AddRule("body", "cursor: url('" + new cursor().src + "'), auto;", 0); // // do we have to use MIDI.js? //new HTML.Audio.FromAssets.Warcraft1_TitleTheme().play(); #region OrcSounds var orc = new Func<Action>( delegate { // I/ChromiumHTTPDataSourceSupport( 124): Request failed with status 4 and os_error -102 //I/chromium(27962): [INFO:CONSOLE(40699)] "Uncaught InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable.", source: http://192.168.43.7:18906/view-source (40699) var nodes = new OrcSounds().AudioElements() // will we run out of memory? //.Take(2) .ToArray(); nodes.WithEach(a => a.load()); return delegate { var r = new Random().Next(); var i = r % nodes.Length; Console.WriteLine(new { i }); nodes[i].play(); var src = nodes[i].src; nodes[i] = (IHTMLAudio)nodes[i].cloneNode(false); //nodes[i].src = src; //nodes[i].load(); }; } )(); #endregion page.Preview.onclick += delegate { orc(); }; // vb xlinq ..<img> #region arena // could run out of memory fast! var map = new Point(2048 * 3, 2048 * 2); var arena = new ArenaControl(); arena.Layers.Canvas.style.backgroundColor = Color.FromGray(0); arena.SetLocation(Rectangle.Of(0, 0, Native.window.Width, Native.window.Height)); arena.SetCanvasSize(map); arena.Control.AttachToDocument(); page.header.AttachTo( arena.Layers.User ); //arena.DrawTextToInfo("Craft", new Point(8, 8), Color.White); Native.window.onresize += delegate { arena.SetLocation( Rectangle.Of(0, 0, Native.window.Width, Native.window.Height)); arena.SetCanvasPosition( arena.CurrentCanvasPosition ); }; #endregion //arena.CurrentCanvasPosition = arena.SetCanvasViewCenter( new Point( 1048 + 2048, 1024 + 2048 ) ); //{ X = -2645 } //{ X = -2290 } //Console.WriteLine(new { arena.CurrentCanvasPosition.X }); Console.WriteLine(new { arena.GetCanvasViewCenter().X }); new ScriptCoreLib.JavaScript.Runtime.Timer( delegate { // two fingers? if (arena.DragEngaged) return; if (arena.InSelectionMode) return; var pp = arena.GetCanvasViewCenter(); //Console.WriteLine(new { pp.X }); pp.X += 1; //Console.WriteLine(new { pp.X }); arena.SetCanvasViewCenter(pp); } ).StartInterval(1000 / 5); var scalarx = 0; new WarcraftImages().ImageElements().Randomize() .Take(6) .WithEachIndex( (img, index) => { // we need 4x images. think retina displays. Console.WriteLine(new { index }); img.InvokeOnComplete( delegate { var context = new CanvasRenderingContext2D(img.width * 2, img.height * 2) { // http://phoboslab.org/log/html5 // not supported for IE ImageSmoothingEnabled = false }; context.drawImage(img, 0, 0, context.canvas.width, context.canvas.height); var x = scalarx % map.X; var y = (int)Math.Floor((float)scalarx / map.X) * context.canvas.height; //Console.WriteLine(new { index, x, y }); context.canvas.AttachTo(arena.Layers.Canvas).style.SetLocation( x, y ); scalarx += context.canvas.width; } ); //img.AttachToDocument(); } ); }
public Application(IApp page) { // X:\jsc.svn\examples\javascript\Test\TestNativeStaticDelegateCall\TestNativeStaticDelegateCall\Application.cs // 02000053 ScriptCoreLib.Query.Experimental.QueryExpressionBuilder + SQLWriter`1 +<> c__DisplayClass77 //script: error JSC1000: unsupported flow detected, try to simplify. // Assembly V:\GGearAlpha.Application.exe // DeclaringType ScriptCoreLib.Query.Experimental.QueryExpressionBuilder + SQLWriter`1 +<> c__DisplayClass77, GGearAlpha.Application, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = null // OwnerMethod <.ctor > b__57 //Offset 0664 //.Try ommiting the return, break or continue instruction. #if FCHROME #region AtFormCreated FormStyler.AtFormCreated = s => { s.Context.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; // this is working? var x = new ChromeTCPServerWithFrameNone.HTML.Pages.AppWindowDrag().AttachTo(s.Context.GetHTMLTarget()); }; #endregion #region ChromeTCPServer dynamic self = Native.self; dynamic self_chrome = self.chrome; object self_chrome_socket = self_chrome.socket; if (self_chrome_socket != null) { chrome.Notification.DefaultTitle = "GGearAlpha"; chrome.Notification.DefaultIconUrl = new HTML.Images.FromAssets.Preview128().src; ChromeTCPServer.TheServerWithStyledForm.Invoke( AppSource.Text, AtFormCreated: FormStyler.AtFormCreated ); return; } #endregion #endif // 7 years later, 28.06.2007 to 20140629 // google gears ws discontinued // yet today jsc allows to use websql in a worker thread in a browser. // can we just do a svn move from7 years ago // and then just call // "X:\jsc.svn\javascript\Examples\GoogleGears\GGearAlpha\bin\Debug\web\GoogleGearsAdvanced.htm" // we do have to update the way we refernce images.in 2014 we haev AssetsLibrary. :) what about 2021? timetravel? // http://gearsblog.blogspot.com/2011/03/stopping-gears.html // once images are restored, lets switch to SQLite api. new js.GoogleGearsAdvanced(); }
/// <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) { // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/20140705/20140706 // chrome://extensions/ #region ChromeTCPServer dynamic self = Native.self; dynamic self_chrome = self.chrome; object self_chrome_socket = self_chrome.socket; if (self_chrome_socket != null) { chrome.Notification.DefaultTitle = "Heat Zeeker"; chrome.Notification.DefaultIconUrl = new HTML.Images.FromAssets.Promotion3D_iso1_tiltshift_128().src; #region AtFormCreated FormStyler.AtFormCreated = s => { s.Context.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; // this is working? var x = new ChromeTCPServerWithFrameNone.HTML.Pages.AppWindowDrag().AttachTo(s.Context.GetHTMLTarget()); }; #endregion Console.WriteLine("will enter TheServerWithStyledForm.Invoke"); ChromeTCPServer.TheServerWithStyledForm.Invoke( AppSource.Text, AtFormCreated: FormStyler.AtFormCreated ); return; } #endregion // position: fixed; top: 0; left: 0; right: 0; //background: linear - gradient(to bottom, rgba(0, 0, 0, 0.9) 0 %, rgba(0, 0, 0, 0) 100 %); /* W3C */ // X:\jsc.svn\examples\javascript\svg\SVGCSSContent\SVGCSSContent\Application.cs // jsc where id the svg cursor example? // X:\jsc.svn\examples\javascript\android\MultiMouse\MultiMouse.SVGCursor // webgl is to provide 3d point clouds with tilt shift // for physics and palm trees, with md2 actors // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201405/20140527/hz // can we create our svg object now and interact with it? // path2985 //css.style.cursorImage = new MyCursor(); //new MyCursor().AttachToHead(); //document.head // jsc when can we talk to assets? //new MyCursor().path2985.fill = "blue"; #region svg cursor new IXMLHttpRequest(ScriptCoreLib.Shared.HTTPMethodEnum.GET, new MyCursor().src, r => { // public static XElement AsXElement(this IElement e); var svg = (ISVGSVGElement)(IElement)(r.responseXML.documentElement); var cursor1 = svg.AsXElement(); cursor1 .Elements("g") .Elements("path") .Where(x => x.Attribute("id").Value == "path2985") .WithEach( path => path.Attribute("style").Value = path.Attribute("style").Value.Replace("fill:#ffff00;", "fill:#00ff00;") ); cursor1 .Elements("g") .Elements("path") .Where(x => x.Attribute("id").Value == "path2985-1") .WithEach( path => path.Attribute("style").Value = path.Attribute("style").Value.Replace("fill:#d9d900;", "fill:#00df00;") ); //.AttachToDocument(); Native.css.style.cursorImage = svg; // this wont work no more? new IStyle(Native.css[IHTMLElement.HTMLElementEnum.div].hover) { // last change was abut adding pointer // jsc jit could atleast let us know how it looks like //cursor = IStyle.CursorEnum.pointer //cursorImage = new MyCursor() }; //Native.document.documentElement.style.cursorImage = svg; //Native.document.documentElement.style.cursorImage = cursor1; //Native.document.documentElement.style.cursorElement = cursor1; //Native.document.documentElement.style.cursorElement = cursor1.AsHTMLElement(); //public static IHTMLElement AttachToDocument(this XElement e); //.AttachToHead(); } ); #endregion // can we show another color // if howering? Native.document.title = "Heat Zeeker"; new IStyle(Native.css[IHTMLElement.HTMLElementEnum.div]) { transition = "border 100ms linear" }; // can we add a health bar, by the background compiler? // is .before already used at all? // can jsc do timetravel and sneak this new code into live app while we hit ctrl s? //new IStyle(Native.css[IHTMLElement.HTMLElementEnum.div].before) //{ // content = "''", // //marginTop = "-0.5em", // position = IStyle.PositionEnum.absolute, // left = "0px", // bottom = "105%", // height = "1em", // right = "0px", // backgroundColor = "rgba(0,255,0,1.0)" //}; new IStyle(!Native.css[IHTMLElement.HTMLElementEnum.div].hover) //new IStyle(css.hover & !css[IHTMLElement.HTMLElementEnum.div].hover) { border = "1px solid rgba(255,0,0,0.7)" }; new IStyle(Native.css[IHTMLElement.HTMLElementEnum.div].hover.before) { content = "''", //marginTop = "-0.5em", position = IStyle.PositionEnum.absolute, left = "0px", bottom = "105%", height = "1em", right = "0px", backgroundColor = "rgba(0,255,0,1.0)" }; new IStyle(Native.css[IHTMLElement.HTMLElementEnum.div].active) { // while mouse down be cyan border = "1px solid rgba(255,255,0,0.7)" }; new IStyle(Native.css[IHTMLElement.HTMLElementEnum.head] | Native.css[IHTMLElement.HTMLElementEnum.title]) { display = IStyle.DisplayEnum.block, //position = IStyle.PositionEnum.absolute, position = IStyle.PositionEnum.@fixed, color = "yellow", //fontSize = "" whiteSpace = IStyle.WhiteSpaceEnum.nowrap, zIndex = 100 }; // X:\jsc.svn\examples\javascript\android\com.abstractatech.gamification.craft\com.abstractatech.gamification.craft\Design\App.htm new IStyle(IHTMLElement.HTMLElementEnum.head) { top = "0px", left = "0px", right = "0px", height = "3em", background = "linear-gradient(to bottom, rgba(0,0,0,0.9) 0%,rgba(0,0,0,0) 100%)" /* W3C */ }; // https://bugs.webkit.org/show_bug.cgi?id=56543 //(css[IHTMLElement.HTMLElementEnum.title].style as dynamic).webkitTextSizeAdjust = "none"; // http://stackoverflow.com/questions/7907760/why-the-font-size-wont-change-with-browser-zoom-in // {{ OffsetX = 3721, CursorX = 3721, scrollLeft = 2831.818120440177, // scrollWidth = 3999.9999133023366, clientWidth = 1142.1875 }} // wwould jsc be able to tell me whats the difference by adding this line? //body.style.overflowY = IStyle.OverflowEnum.hidden; Native.body.style.overflow = IStyle.OverflowEnum.hidden; // music! // http://stackoverflow.com/questions/7747526/why-wont-my-html5-audio-loop #region playmusic Action playmusic = null; playmusic = delegate { new crickets { //loop = true, //controls = true }.AttachToHead().With( //async music => music => { music.play(); //while (music.async.onen) music.onended += delegate { // why wont it play? //title = " music.onended "; //music.currentTime = 0; //music.play(); music.Orphanize(); playmusic(); }; } ); }; playmusic(); #endregion //body[typeof(IHTMLDiv)].onclick += { }; Native.document.onmousedown += e => { e.preventDefault(); }; Native.document[IHTMLElement.HTMLElementEnum.div].onmouseover += e => { new flag { volume = 0.3 }.play(); page.hud_look.Hide(); }; Native.document[IHTMLElement.HTMLElementEnum.div].onmouseout += e => { // should jsc prebuffer all audio linked into app? // and fonts? new tick { volume = 0.3 }.play(); page.hud_look.Show(); }; Native.document.oncontextmenu += e => { e.preventDefault(); e.stopPropagation(); }; Native.document[IHTMLElement.HTMLElementEnum.div].oncontextmenu += e => { new buzzer { volume = 0.2 }.play(); ((IHTMLElement)e.Element).Orphanize(); }; //document[e => e.Element is IHTMLDiv] // query selector. //document[IHTMLElement.HTMLElementEnum.div]. // X:\jsc.svn\examples\javascript\VirtualElementEvents\VirtualElementEvents\Application.cs Native.document[IHTMLElement.HTMLElementEnum.div].onclick += delegate { new snd_dooropen().play(); }; Native.document[IHTMLElement.HTMLElementEnum.img].onclick += e => { new snd_dooropen().play(); Console.WriteLine( new { IHTMLElement.HTMLElementEnum.div, e.Element.nodeName, e.OffsetX, e.OffsetY } ); //var fixleft = e.CursorX - body.scrollLeft; new IHTMLDiv().AttachToDocument().style.SetLocation( e.OffsetX, e.OffsetY ); }; Native.document.documentElement.onmousemove += e => { // edit and continue yet? // either msbuild or roslyn? var fixleft = e.CursorX - Native.body.scrollLeft; //var fixtop = e.CursorY - body.scrollTop; // fixleft spans from 0 ... clientwidth // scrollleft shal follow it from 0 to scrollWidth - ?view width * zoom? // scroll width oes not know about zoom // we did this already for pipe mania // and webgl earth Native.body.scrollLeft = fixleft * (Native.body.scrollWidth) / Native.body.clientWidth; //body.scrollTop = fixtop * (body.scrollHeight) / document.documentElement.clientHeight; Native.body.scrollTop = e.CursorY * (Native.body.scrollHeight) / Native.document.documentElement.clientHeight; //title = new //{ // //body.scrollTop, // ////fixtop, // //body.scrollHeight, // ////body.clientHeight, // //document.documentElement.clientHeight, // x = fixleft, // y = e.CursorY, // ////e.OffsetX, // ////e.CursorX, // //body.scrollLeft, // //body.scrollWidth, // //body.clientWidth //}; }; }
/// <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) { // https://chrome.google.com/webstore/detail/dglmddjmdpdbijfkoaiadbpmjampfdjh/publish-delayed #region ChromeTCPServer dynamic self = Native.self; dynamic self_chrome = self.chrome; object self_chrome_socket = self_chrome.socket; if (self_chrome_socket != null) { #region AtFormCreated FormStyler.AtFormCreated = ss => { ss.Context.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; // this is working? var x = new ChromeTCPServerWithFrameNone.HTML.Pages.AppWindowDrag().AttachTo(ss.Context.GetHTMLTarget()); }; #endregion chrome.Notification.DefaultTitle = "Heat Zeeker"; chrome.Notification.DefaultIconUrl = new HTML.Images.FromAssets.Promotion3D_iso1_tiltshift_128().src; ChromeTCPServer.TheServerWithStyledForm.Invoke( AppSource.Text, AtFormCreated: FormStyler.AtFormCreated ); return; } #endregion Native.body.style.margin = "0px"; Native.body.style.overflow = IStyle.OverflowEnum.hidden; // jsc, add THREE // ... ok. // X:\jsc.svn\examples\javascript\WebGL\WebGLOrthographicCamera\WebGLOrthographicCamera\Application.cs // this is not isometric. // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20151112 var camera = new THREE.OrthographicCamera( Native.window.Width / -2, Native.window.Width / 2, Native.window.Height / 2, Native.window.Height / -2 , // if we change these values what will change? -1000, 1000 ); camera.position.x = 200; camera.position.y = 100; camera.position.z = 200; var scene = new THREE.Scene(); // Grid var size = 600; var step = 50; Func<double> random = new Random().NextDouble; // how do I add a new ground box? { var geometry = new THREE.BoxGeometry(size * 2, 2, size * 2); var material = new THREE.MeshLambertMaterial(new { color = 0xB27D51 // , shading = THREE.FlatShading, overdraw = 0.5 }); { var cube = new THREE.Mesh(geometry, material); // why cant we get the shadows?? cube.receiveShadow = true; cube.scale.y = Math.Floor(random() * 2 + 1); cube.position.x = 0; //cube.position.y = (cube.scale.y * 50) / 2; cube.position.y = -2; cube.position.z = 0; scene.add(cube); } } { var geometry = new THREE.Geometry(); for (var i = -size; i <= size; i += step) { ((IArray<THREE.Vector3>)(object)geometry.vertices).push(new THREE.Vector3(-size, 0, i)); ((IArray<THREE.Vector3>)(object)geometry.vertices).push(new THREE.Vector3(size, 0, i)); ((IArray<THREE.Vector3>)(object)geometry.vertices).push(new THREE.Vector3(i, 0, -size)); ((IArray<THREE.Vector3>)(object)geometry.vertices).push(new THREE.Vector3(i, 0, size)); } var material = new THREE.LineBasicMaterial(new { color = 0, opacity = 0.2 }); var line = new THREE.Line(geometry, material, mode: THREE.LinePieces); scene.add(line); } var interactiveObjects = new List<THREE.Object3D>(); #region Cubes { for (var i = 0; i < 8; i++) { new HZBunker().Source.Task.ContinueWithResult( cube => { // https://github.com/mrdoob/three.js/issues/1285 //cube.children.WithEach(c => c.castShadow = true); //cube.traverse( // new Action<THREE.Object3D>( // child => // { // // does it work? do we need it? // //if (child is THREE.Mesh) // child.castShadow = true; // child.receiveShadow = true; // } // ) //); // um can edit and continue insert code going back in time? cube.scale.x = 2.0; cube.scale.y = 2.0; cube.scale.z = 2.0; //cube.castShadow = true; //dae.receiveShadow = true; cube.position.x = Math.Floor((random() * 1000 - 500) / 50) * 50 + 25; //cube.position.y = (cube.scale.y * 50) / 2; cube.position.z = Math.Floor((random() * 1000 - 500) / 50) * 50 + 25; scene.add(cube); interactiveObjects.Add(cube); } ); new HZWaterTower().Source.Task.ContinueWithResult( cube => { // https://github.com/mrdoob/three.js/issues/1285 // https://github.com/mrdoob/three.js/issues/1285 //cube.children.WithEach(c => c.castShadow = true); // http://stackoverflow.com/questions/15906248/three-js-objloader-obj-model-not-casting-shadows // http://stackoverflow.com/questions/22895120/imported-3d-objects-are-not-casting-shadows-with-three-js //cube.traverse( // new Action<THREE.Object3D>( // child => // { // // does it work? do we need it? // //if (child is THREE.Mesh) // child.castShadow = true; // child.receiveShadow = true; // } // ) //); // um can edit and continue insert code going back in time? cube.scale.x = 2.0; cube.scale.y = 2.0; cube.scale.z = 2.0; //cube.castShadow = true; //dae.receiveShadow = true; cube.position.x = Math.Floor((random() * 1000 - 500) / 50) * 50 + 25; //cube.position.y = (cube.scale.y * 50) / 2; cube.position.z = Math.Floor((random() * 1000 - 500) / 50) * 50 + 25; scene.add(cube); interactiveObjects.Add(cube); } ); new HZCannon().Source.Task.ContinueWithResult( cube => { // https://github.com/mrdoob/three.js/issues/1285 //cube.children.WithEach(c => c.castShadow = true); //cube.traverse( // new Action<THREE.Object3D>( // child => // { // // does it work? do we need it? // //if (child is THREE.Mesh) // child.castShadow = true; // child.receiveShadow = true; // } // ) //); // um can edit and continue insert code going back in time? cube.scale.x = 2.0; cube.scale.y = 2.0; cube.scale.z = 2.0; //cube.castShadow = true; //dae.receiveShadow = true; cube.position.x = Math.Floor((random() * 1000 - 500) / 50) * 50 + 25; //cube.position.y = (cube.scale.y * 50) / 2; cube.position.z = Math.Floor((random() * 1000 - 500) / 50) * 50 + 25; // if i want to rotate, how do I do it? //cube.rotation.z = random() + Math.PI; //cube.rotation.x = random() + Math.PI; cube.rotation.y = random() * Math.PI * 2; scene.add(cube); interactiveObjects.Add(cube); } ); } } #endregion // we need expression evaluator with intellisense for live debugging sessions #region Lights var ambientLight = new THREE.AmbientLight((int)(random() * 0x10)); scene.add(ambientLight); // can we get our shadows? { var directionalLight = new THREE.DirectionalLight((int)(random() * 0xffffff), 0.5); directionalLight.position.x = random() - 0.5; directionalLight.position.y = 400; directionalLight.position.z = random() - 0.5; directionalLight.position.normalize(); scene.add(directionalLight); } { var directionalLight = new THREE.DirectionalLight((int)(random() * 0xffffff), 0.5); directionalLight.position.x = random() - 0.5; directionalLight.position.y = 400; directionalLight.position.z = random() - 0.5; directionalLight.position.normalize(); scene.add(directionalLight); } #endregion //var renderer = new THREE.CanvasRenderer(); var renderer = new THREE.WebGLRenderer(); renderer.shadowMapEnabled = true; // background-color: #B27D51; renderer.setClearColor(0xB27D51); //renderer.setSize( // Native.window.Width , // Native.window.Height * 10 // ); renderer.setSize(); renderer.domElement.AttachToDocument(); Native.window.onresize += delegate { camera.left = Native.window.Width / -2; camera.right = Native.window.Width / 2; camera.top = Native.window.Height / 2; camera.bottom = Native.window.Height / -2; camera.updateProjectionMatrix(); renderer.setSize(); }; //window.addEventListener( 'resize', onWindowResize, false ); //#region Comanche //new Comanche().Source.Task.ContinueWithResult( // Comanche => // { // Comanche.position.y = 200; // //dae.position.z = 280; // Comanche.AttachTo(scene); // //scene.add(dae); // //oo.Add(Comanche); // // wont do it // //dae.castShadow = true; // // http://stackoverflow.com/questions/15492857/any-way-to-get-a-bounding-box-from-a-three-js-object3d // //var helper = new THREE.BoundingBoxHelper(dae, 0xff0000); // //helper.update(); // //// If you want a visible bounding box // //scene.add(helper); // Comanche.children[0].children[0].children.WithEach(x => x.castShadow = true); // // the rotors? // Comanche.children[0].children[0].children.Last().children.WithEach(x => x.castShadow = true); // Comanche.scale.set(0.5, 0.5, 0.5); // //helper.scale.set(0.5, 0.5, 0.5); // var sw = Stopwatch.StartNew(); // Native.window.onframe += delegate // { // //dae.children[0].children[0].children.Last().al // //dae.children[0].children[0].children.Last().rotation.z = sw.ElapsedMilliseconds * 0.01; // //dae.children[0].children[0].children.Last().rotation.x = sw.ElapsedMilliseconds * 0.01; // //rotation.y = sw.ElapsedMilliseconds * 0.01; // Comanche.children[0].children[0].children.Last().rotation.y = sw.ElapsedMilliseconds * 0.001; // //dae.children[0].children[0].children.Last().app // }; // } //); //#endregion //#region ee //// X:\jsc.svn\examples\javascript\forms\NumericTextBox\NumericTextBox\ApplicationControl.cs //// can we restile the window as the pin window in IDE? //var ee = new Form { Left = 0, StartPosition = FormStartPosition.Manual }; //var ee_camera_y = new TextBox { Dock = DockStyle.Fill, Text = camera.position.y + "" }.AttachTo(ee); ////ee.AutoSize = AutoSizeMode. ////ee.ClientSize = new System.Drawing.Size(ee_camera_y.Width, ee_camera_y.Height); //ee.ClientSize = new System.Drawing.Size(200, 24); //ee.Show(); ////ee_camera_y. //ee_camera_y.TextChanged += delegate //{ // camera.position.y = double.Parse(ee_camera_y.Text); //}; //#endregion var s = Stopwatch.StartNew(); var controls = new THREE.OrbitControls(camera, renderer.domElement); // http://stackoverflow.com/questions/26497903/nested-webglrendertargets-in-three-js // var effect = new THREE.OculusRiftEffect( //renderer, new //{ // worldScale = 100, // //HMD // } //); // effect.setSize(1920, 1080); Native.window.onframe += e => { // jsc, when can we have the edit and continue already? //var timer = s.ElapsedMilliseconds * 0.1; //var timer = s.ElapsedMilliseconds * 0.0001; //camera.position.x = Math.Cos(timer) * 200; //camera.position.z = Math.Sin(timer) * 200; // camera.position.z = 200; //camera.position.y = 100; //camera.position.y = Math.Sin(timer * 0.1) * 200; controls.update(); camera.position = controls.center.clone(); renderer.render(scene, camera); //effect.render(scene, camera); }; //var ze = new ZeProperties(); //ze.Show(); //ze.treeView1.Nodes.Clear(); //ze.Add(() => renderer); ////ze.Add(() => controls); //ze.Add(() => scene); //ze.Left = 0; // view-source:http://mrdoob.github.io/three.js/examples/webgl_interactive_voxelpainter.html //var mouse2D = new THREE.Vector3(0, 10000, 0.5); //renderer.domElement.onclick += // e => // { // e.preventDefault(); // mouse2D.x = (e.CursorX / (double)Native.window.Width) * 2 - 1; // mouse2D.y = -(e.CursorY / (double)Native.window.Height) * 2 + 1; // var vector = new THREE.Vector3( // (e.CursorX / (double)Native.window.Width) * 2 - 1, // -(e.CursorY / (double)Native.window.Height) * 2 + 1, // 0.5); // // X:\jsc.svn\examples\javascript\WebGL\WebGLInteractiveCubes\WebGLInteractiveCubes\Application.cs // var projector = new THREE.Projector(); // projector.unprojectVector(vector, camera); // // http://stackoverflow.com/questions/18553209/orthographic-camera-and-selecting-objects-with-raycast // // http://stackoverflow.com/questions/20361776/orthographic-camera-and-pickingray // // view-source:http://stemkoski.github.io/Three.js/Mouse-Click.html // // http://stackoverflow.com/questions/11921033/projector-and-ray-with-orthographiccamera // // use picking ray since it's an orthographic camera // // doesnt fkin work ??? // //var raycaster = projector.pickingRay(vector, camera); // var raycaster = projector.pickingRay(mouse2D.clone(), camera); // //var raycaster = new THREE.Raycaster(camera.position, vector.sub(camera.position).normalize()); // var intersects = raycaster.intersectObjects(interactiveObjects.ToArray()); // // https://github.com/mrdoob/three.js/issues/599 // Native.document.title = new { intersects.Length }.ToString(); // }; }
/// <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 = null) { { THREE.SkinnedMesh ref0; } { THREE.SpeedBlendCharacter ref0; } // will skip DefineVersionInfoResource //102c: 02:01:1e RewriteToAssembly error: System.NotSupportedException: Type 'xchrome.BCLImplementation.System.Net.Sockets.__TcpListener' was not completed. #region AtFormCreated FormStyler.AtFormCreated = s => { s.Context.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; // this is working? var x = new ChromeTCPServerWithFrameNone.HTML.Pages.AppWindowDrag().AttachTo(s.Context.GetHTMLTarget()); }; #endregion #if false #region ChromeTCPServer dynamic self = Native.self; dynamic self_chrome = self.chrome; object self_chrome_socket = self_chrome.socket; if (self_chrome_socket != null) { chrome.Notification.DefaultIconUrl = new HTML.Images.FromAssets.Preview().src; chrome.Notification.DefaultTitle = "WebGLYomotsuTPS"; ChromeTCPServer.TheServerWithStyledForm.Invoke( AppSource.Text, AtFormCreated: FormStyler.AtFormCreated ); return; } #endregion #endif var fov = 40; #region container Native.document.body.style.overflow = IStyle.OverflowEnum.hidden; var container = new IHTMLDiv(); container.AttachToDocument(); container.style.backgroundColor = "#000000"; container.style.SetLocation(0, 0, Native.window.Width, Native.window.Height); #endregion var player_model_objects = new THREE.Object3D(); var player_position_x = 0.0f; var player_position_y = 0.0f; var player_position_z = 0.0f; var player_position_direction = 0; var player_camera_speed = 300; var player_camera_distance = 5; var player_camera_x = 0.0f; var player_camera_y = 0.0f; var player_camera_z = 0.0f; var player_motion = default(motion); //var width = Native.window.Width; //var height = Native.window.Height; var clock = new Stopwatch(); clock.Start(); //var clock = new THREE.Clock(); var scene = new THREE.Scene(); scene.fog = new THREE.FogExp2(0x000000, 0.05f); scene.add(player_model_objects); var camera = new THREE.PerspectiveCamera(fov, Native.window.aspect, //width / height, 1, 1000); scene.add(camera); #region light var light = new THREE.DirectionalLight(0xffffff, 1.5); light.position.set(1, 1, 1).normalize(); light.castShadow = true; scene.add(light); #endregion var md2frames = new md2frames(); var moveState_moving = false; var moveState_front = false; var moveState_Backwards = false; var moveState_left = false; var moveState_right = false; var moveState_speed = .1; var moveState_angle = 0; #region move Action move = delegate { // if(player.model.motion !== 'run' && player.model.state === 'stand'){ // changeMotion('run'); //} //if(player.model.motion !== 'crwalk' && player.model.state === 'crstand'){ // changeMotion('crwalk'); //} var speed = moveState_speed; //if(player.model.state === 'crstand'){speed *= .5;} //if(player.model.state === 'freeze') {speed *= 0;} var direction = moveState_angle; if (moveState_front && !moveState_left && !moveState_Backwards && !moveState_right) { direction += 0; } if (moveState_front && moveState_left && !moveState_Backwards && !moveState_right) { direction += 45; } if (!moveState_front && moveState_left && !moveState_Backwards && !moveState_right) { direction += 90; } if (!moveState_front && moveState_left && moveState_Backwards && !moveState_right) { direction += 135; } if (!moveState_front && !moveState_left && moveState_Backwards && !moveState_right) { direction += 180; } if (!moveState_front && !moveState_left && moveState_Backwards && moveState_right) { direction += 225; } if (!moveState_front && !moveState_left && !moveState_Backwards && moveState_right) { direction += 270; } if (moveState_front && !moveState_left && !moveState_Backwards && moveState_right) { direction += 315; } player_model_objects.rotation.y = (float)(direction * Math.PI / 180); player_position_x -= (float)(Math.Sin(direction * Math.PI / 180) * speed); player_position_z -= (float)(Math.Cos(direction * Math.PI / 180) * speed); }; #endregion #region camera rotation Action rotate = delegate { }; var pointer_x = 0f; var pointer_y = 0f; var oldPointerX = 0f; var oldPointerY = 0f; container.onmousemove += e => { if (Native.document.pointerLockElement == container) { oldPointerX = 0; oldPointerY = 0; pointer_x = e.movementX * 0.01f; pointer_y = -e.movementY * 0.01f; rotate(); return; } pointer_x = (e.CursorX / Native.window.Width) * 2 - 1; pointer_y = -(e.CursorY / Native.window.Height) * 2 + 1; rotate(); }; container.onmouseup += e => { rotate = delegate { }; Native.document.exitPointerLock(); }; container.onmousedown += e => { oldPointerX = pointer_x; oldPointerY = pointer_y; rotate = delegate { player_camera_x += (oldPointerX - pointer_x) * player_camera_speed; player_camera_y += (oldPointerY - pointer_y) * player_camera_speed; if (player_camera_y > 150) { player_camera_y = 150; } if (player_camera_y < -150) { player_camera_y = -150; } moveState_angle = Convert.ToInt32(player_camera_x / 2) % 360; oldPointerX = pointer_x; oldPointerY = pointer_y; }; Console.WriteLine("requestPointerLock"); container.requestPointerLock(); }; #endregion var renderer = new THREE.WebGLRenderer(); //renderer.setSize(width, height); renderer.setSize(); renderer.shadowMapEnabled = true; renderer.shadowMapSoft = true; renderer.domElement.AttachTo(container); #region create field var planeGeometry = new THREE.PlaneGeometry(1000, 1000); var planeMaterial = new THREE.MeshLambertMaterial( new { map = THREE.ImageUtils.loadTexture(new HTML.Images.FromAssets.bg().src), color = 0xffffff } ); planeMaterial.map.repeat.x = 300; planeMaterial.map.repeat.y = 300; planeMaterial.map.wrapS = THREE.RepeatWrapping; planeMaterial.map.wrapT = THREE.RepeatWrapping; var plane = new THREE.Mesh(planeGeometry, planeMaterial); plane.castShadow = false; plane.receiveShadow = true; { var parent = new THREE.Object3D(); parent.add(plane); parent.rotation.x = -Math.PI / 2; scene.add(parent); } var random = new Random(); var meshArray = new List<THREE.Mesh>(); var geometry = new THREE.CubeGeometry(1, 1, 1); for (var i = 0; i < 100; i++) { var ii = new THREE.Mesh(geometry, new THREE.MeshLambertMaterial( new { color = (Convert.ToInt32(0xffffff * random.NextDouble())) })); ii.position.x = i % 2 * 5 - 2.5f; ii.position.y = .5f; ii.position.z = -1 * i * 4; ii.castShadow = true; ii.receiveShadow = true; meshArray.Add(ii); scene.add(ii); } #endregion //load converted md2 data var material = new THREE.MeshPhongMaterial( new { map = THREE.ImageUtils.loadTexture( new HTML.Images.FromAssets._1().src ), ambient = 0x999999, color = 0xffffff, specular = 0xffffff, shininess = 25, morphTargets = true } ); var loader = new THREE.JSONLoader(); loader.load( new global::WebGLYomotsuTPS.Design.droid().Content.src, xgeometry => { var md2meshBody = new THREE.MorphAnimMesh(xgeometry, material); md2meshBody.rotation.y = (float)(-Math.PI / 2); md2meshBody.scale.set(.02, .02, .02); md2meshBody.position.y = .5f; md2meshBody.castShadow = true; md2meshBody.receiveShadow = false; #region player_motion Action<motion> player_changeMotion = motion => { Console.WriteLine( new { motion, md2frames.run, md2frames.stand }); player_motion = motion; // player.state = md2frames[motion][3].state; var animMin = motion.min; var animMax = motion.max; var animFps = motion.fps; md2meshBody.time = 0; md2meshBody.duration = (int)( 1000 * ((animMax - animMin) / (double)animFps) ); Native.document.title = new { animMin, animMax }.ToString(); md2meshBody.setFrameRange(animMin, animMax); }; player_changeMotion(md2frames.stand); #endregion player_model_objects.add(md2meshBody); #region onkeydown Native.document.onkeydown += e => { if (e.KeyCode == 67) { if (player_motion == md2frames.stand) player_changeMotion(md2frames.crstand); else if (player_motion == md2frames.crstand) player_changeMotion(md2frames.stand); } else if (e.KeyCode == 87) { moveState_front = true; moveState_Backwards = false; } else if (e.KeyCode == 83) { moveState_front = false; moveState_Backwards = true; } else if (e.KeyCode == 65) { moveState_left = true; moveState_right = false; } else if (e.KeyCode == 68) { moveState_left = false; moveState_right = true; } var isStand = player_motion == md2frames.stand; Console.WriteLine( new { e.KeyCode, moveState_front, moveState_Backwards, isStand } ); if (moveState_front || moveState_Backwards || moveState_left || moveState_right) if (player_motion == md2frames.stand) player_changeMotion(md2frames.run); else if (player_motion == md2frames.crstand) player_changeMotion(md2frames.crwalk); }; #endregion #region onkeyup Native.document.onkeyup += e => { if (e.KeyCode == 87) { moveState_front = false; } else if (e.KeyCode == 83) { moveState_Backwards = false; } else if (e.KeyCode == 65) { moveState_left = false; } else if (e.KeyCode == 68) { moveState_right = false; } }; #endregion #region loop Native.window.onframe += delegate { if (moveState_front || moveState_Backwards || moveState_left || moveState_right) move(); else if (player_motion == md2frames.run) player_changeMotion(md2frames.stand); else if (player_motion == md2frames.crwalk) player_changeMotion(md2frames.crstand); player_model_objects.position.x = player_position_x; player_model_objects.position.y = player_position_y; player_model_objects.position.z = player_position_z; // camera rotate x camera.position.x = (float)(player_position_x + player_camera_distance * Math.Sin((player_camera_x) * Math.PI / 360.0)); camera.position.z = (float)(player_position_z + player_camera_distance * Math.Cos((player_camera_x) * Math.PI / 360.0)); //camera rotate y //camera.position.x = player.position.x + player.camera.distance * Math.cos( (player.camera.y) * Math.PI / 360 ); camera.position.y = (float)(player_position_y + player_camera_distance * Math.Sin((player_camera_y) * Math.PI / 360.0)); //camera.position.z = player.position.z + player.camera.distance * Math.cos( (player.camera.y) * Math.PI / 360 ); camera.position.y += 1; //console.log(camera.position.z) var vec3 = new THREE.Vector3(player_position_x, player_position_y, player_position_z); camera.lookAt(vec3); #region model animation var delta = clock.ElapsedMilliseconds * 0.001; clock.Restart(); var isEndFleame = (player_motion.max == md2meshBody.currentKeyframe); var isAction = player_motion.action; var x = (isAction && !isEndFleame); if (!isAction || x) { md2meshBody.updateAnimation(1000 * delta); } else if (player_motion.state == "freeze") { //dead... } else { player_changeMotion(player_motion); } #endregion renderer.render(scene, camera); }; #endregion #region AtResize Action AtResize = delegate { container.style.SetLocation(0, 0, Native.window.Width, Native.window.Height); renderer.setSize(Native.window.Width, Native.window.Height); camera.projectionMatrix.makePerspective(fov, Native.window.aspect, 1, 1100); //camera.aspect = Native.Window.Width / Native.Window.Height; //camera.updateProjectionMatrix(); }; Native.window.onresize += delegate { AtResize(); }; AtResize(); #endregion #region requestFullscreen Native.document.body.ondblclick += delegate { if (IsDisposed) return; // http://tutorialzine.com/2012/02/enhance-your-website-fullscreen-api/ Native.document.body.requestFullscreen(); //AtResize(); }; #endregion } ); }
/// <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) { // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/20140705/20140706 // chrome://extensions/ #region ChromeTCPServer dynamic self = Native.self; dynamic self_chrome = self.chrome; object self_chrome_socket = self_chrome.socket; if (self_chrome_socket != null) { chrome.Notification.DefaultTitle = "Heat Zeeker"; chrome.Notification.DefaultIconUrl = new HTML.Images.FromAssets.Promotion3D_iso1_tiltshift_128().src; #region AtFormCreated FormStyler.AtFormCreated = s => { s.Context.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; // this is working? var x = new ChromeTCPServerWithFrameNone.HTML.Pages.AppWindowDrag().AttachTo(s.Context.GetHTMLTarget()); }; #endregion Console.WriteLine("will enter TheServerWithStyledForm.Invoke"); ChromeTCPServer.TheServerWithStyledForm.Invoke( AppSource.Text, AtFormCreated: FormStyler.AtFormCreated ); return; } #endregion // position: fixed; top: 0; left: 0; right: 0; //background: linear - gradient(to bottom, rgba(0, 0, 0, 0.9) 0 %, rgba(0, 0, 0, 0) 100 %); /* W3C */ // X:\jsc.svn\examples\javascript\svg\SVGCSSContent\SVGCSSContent\Application.cs // jsc where id the svg cursor example? // X:\jsc.svn\examples\javascript\android\MultiMouse\MultiMouse.SVGCursor // webgl is to provide 3d point clouds with tilt shift // for physics and palm trees, with md2 actors // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201405/20140527/hz // can we create our svg object now and interact with it? // path2985 //css.style.cursorImage = new MyCursor(); //new MyCursor().AttachToHead(); //document.head // jsc when can we talk to assets? //new MyCursor().path2985.fill = "blue"; #region svg cursor new IXMLHttpRequest(ScriptCoreLib.Shared.HTTPMethodEnum.GET, new MyCursor().src, r => { // public static XElement AsXElement(this IElement e); var svg = (ISVGSVGElement)(IElement)(r.responseXML.documentElement); var cursor1 = svg.AsXElement(); cursor1 .Elements("g") .Elements("path") .Where(x => x.Attribute("id").Value == "path2985") .WithEach( path => path.Attribute("style").Value = path.Attribute("style").Value.Replace("fill:#ffff00;", "fill:#00ff00;") ); cursor1 .Elements("g") .Elements("path") .Where(x => x.Attribute("id").Value == "path2985-1") .WithEach( path => path.Attribute("style").Value = path.Attribute("style").Value.Replace("fill:#d9d900;", "fill:#00df00;") ); //.AttachToDocument(); Native.css.style.cursorImage = svg; // this wont work no more? new IStyle(Native.css[IHTMLElement.HTMLElementEnum.div].hover) { // last change was abut adding pointer // jsc jit could atleast let us know how it looks like //cursor = IStyle.CursorEnum.pointer //cursorImage = new MyCursor() }; //Native.document.documentElement.style.cursorImage = svg; //Native.document.documentElement.style.cursorImage = cursor1; //Native.document.documentElement.style.cursorElement = cursor1; //Native.document.documentElement.style.cursorElement = cursor1.AsHTMLElement(); //public static IHTMLElement AttachToDocument(this XElement e); //.AttachToHead(); } ); #endregion // can we show another color // if howering? Native.document.title = "Heat Zeeker"; new IStyle(Native.css[IHTMLElement.HTMLElementEnum.div]) { transition = "border 100ms linear" }; // can we add a health bar, by the background compiler? // is .before already used at all? // can jsc do timetravel and sneak this new code into live app while we hit ctrl s? //new IStyle(Native.css[IHTMLElement.HTMLElementEnum.div].before) //{ // content = "''", // //marginTop = "-0.5em", // position = IStyle.PositionEnum.absolute, // left = "0px", // bottom = "105%", // height = "1em", // right = "0px", // backgroundColor = "rgba(0,255,0,1.0)" //}; new IStyle(!Native.css[IHTMLElement.HTMLElementEnum.div].hover) //new IStyle(css.hover & !css[IHTMLElement.HTMLElementEnum.div].hover) { border = "1px solid rgba(255,0,0,0.7)" }; new IStyle(Native.css[IHTMLElement.HTMLElementEnum.div].hover.before) { content = "''", //marginTop = "-0.5em", position = IStyle.PositionEnum.absolute, left = "0px", bottom = "105%", height = "1em", right = "0px", backgroundColor = "rgba(0,255,0,1.0)" }; new IStyle(Native.css[IHTMLElement.HTMLElementEnum.div].active) { // while mouse down be cyan border = "1px solid rgba(255,255,0,0.7)" }; new IStyle(Native.css[IHTMLElement.HTMLElementEnum.head] | Native.css[IHTMLElement.HTMLElementEnum.title]) { display = IStyle.DisplayEnum.block, //position = IStyle.PositionEnum.absolute, position = IStyle.PositionEnum.@fixed, color = "yellow", //fontSize = "" whiteSpace = IStyle.WhiteSpaceEnum.nowrap, zIndex = 100 }; // X:\jsc.svn\examples\javascript\android\com.abstractatech.gamification.craft\com.abstractatech.gamification.craft\Design\App.htm new IStyle(IHTMLElement.HTMLElementEnum.head) { top = "0px", left = "0px", right = "0px", height = "3em", background = "linear-gradient(to bottom, rgba(0,0,0,0.9) 0%,rgba(0,0,0,0) 100%)" /* W3C */ }; // https://bugs.webkit.org/show_bug.cgi?id=56543 //(css[IHTMLElement.HTMLElementEnum.title].style as dynamic).webkitTextSizeAdjust = "none"; // http://stackoverflow.com/questions/7907760/why-the-font-size-wont-change-with-browser-zoom-in // {{ OffsetX = 3721, CursorX = 3721, scrollLeft = 2831.818120440177, // scrollWidth = 3999.9999133023366, clientWidth = 1142.1875 }} // wwould jsc be able to tell me whats the difference by adding this line? //body.style.overflowY = IStyle.OverflowEnum.hidden; Native.body.style.overflow = IStyle.OverflowEnum.hidden; // music! // http://stackoverflow.com/questions/7747526/why-wont-my-html5-audio-loop #region playmusic Action playmusic = null; playmusic = delegate { new crickets { //loop = true, //controls = true }.AttachToHead().With( //async music => music => { music.play(); //while (music.async.onen) music.onended += delegate { // why wont it play? //title = " music.onended "; //music.currentTime = 0; //music.play(); music.Orphanize(); playmusic(); }; } ); }; playmusic(); #endregion //body[typeof(IHTMLDiv)].onclick += { }; Native.document.onmousedown += e => { e.preventDefault(); }; Native.document[IHTMLElement.HTMLElementEnum.div].onmouseover += e => { new flag { volume = 0.3 }.play(); page.hud_look.Hide(); }; Native.document[IHTMLElement.HTMLElementEnum.div].onmouseout += e => { // should jsc prebuffer all audio linked into app? // and fonts? new tick { volume = 0.3 }.play(); page.hud_look.Show(); }; Native.document.oncontextmenu += e => { e.preventDefault(); e.stopPropagation(); }; Native.document[IHTMLElement.HTMLElementEnum.div].oncontextmenu += e => { new buzzer { volume = 0.2 }.play(); ((IHTMLElement)e.Element).Orphanize(); }; //document[e => e.Element is IHTMLDiv] // query selector. //document[IHTMLElement.HTMLElementEnum.div]. // X:\jsc.svn\examples\javascript\VirtualElementEvents\VirtualElementEvents\Application.cs Native.document[IHTMLElement.HTMLElementEnum.div].onclick += delegate { new snd_dooropen().play(); }; Native.document[IHTMLElement.HTMLElementEnum.img].onclick += e => { new snd_dooropen().play(); Console.WriteLine( new { IHTMLElement.HTMLElementEnum.div, e.Element.nodeName, e.OffsetX, e.OffsetY } ); //var fixleft = e.CursorX - body.scrollLeft; new IHTMLDiv().AttachToDocument().style.SetLocation( e.OffsetX, e.OffsetY ); }; Native.document.documentElement.onmousemove += e => { // edit and continue yet? // either msbuild or roslyn? var fixleft = e.CursorX - Native.body.scrollLeft; //var fixtop = e.CursorY - body.scrollTop; // fixleft spans from 0 ... clientwidth // scrollleft shal follow it from 0 to scrollWidth - ?view width * zoom? // scroll width oes not know about zoom // we did this already for pipe mania // and webgl earth Native.body.scrollLeft = fixleft * (Native.body.scrollWidth) / Native.body.clientWidth; //body.scrollTop = fixtop * (body.scrollHeight) / document.documentElement.clientHeight; Native.body.scrollTop = e.CursorY * (Native.body.scrollHeight) / Native.document.documentElement.clientHeight; //title = new //{ // //body.scrollTop, // ////fixtop, // //body.scrollHeight, // ////body.clientHeight, // //document.documentElement.clientHeight, // x = fixleft, // y = e.CursorY, // ////e.OffsetX, // ////e.CursorX, // //body.scrollLeft, // //body.scrollWidth, // //body.clientWidth //}; }; }
/// <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) { // what is roslyn doing that is breaking async for us? // 02000002 LBAPrequelPromotion.Application // script: error JSC1000: unsupported flow detected, try to simplify. //Assembly V:\LBAPrequelPromotion.Application.exe //DeclaringType LBAPrequelPromotion.Application, LBAPrequelPromotion.Application, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = null // OwnerMethod.ctor // Offset 0065 // .Try ommiting the return, break or continue instruction. // not ready for roslyn! #region AtFormCreated FormStyler.AtFormCreated = s => { s.Context.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; var x = new ChromeTCPServerWithFrameNone.HTML.Pages.AppWindowDrag().AttachTo(s.Context.GetHTMLTarget()); }; #endregion #region ChromeTCPServer dynamic self = Native.self; dynamic self_chrome = self.chrome; object self_chrome_socket = self_chrome.socket; if (self_chrome_socket != null) { chrome.Notification.DefaultTitle = "LBA Redux"; chrome.Notification.DefaultIconUrl = new HTML.Images.FromAssets.Preview().src; ChromeTCPServer.TheServerWithStyledForm.Invoke( AppSource.Text, AtFormCreated: FormStyler.AtFormCreated ); return; } #endregion // https://docs.google.com/a/jsc-solutions.net/spreadsheet/ccc?key=0AjBm0oHdZ3DwdFhMb2UxVnBYUnNnUE16LUNiUzJJSVE#gid=0 //<iframe src="https://docs.google.com/a/jsc-solutions.net/spreadsheet/embeddedform?formkey=dFhMb2UxVnBYUnNnUE16LUNiUzJJSVE6MQ" width="760" height="692" frameborder="0" marginheight="0" marginwidth="0">Loading...</iframe> var onpause = new SAMPLES036 { volume = 0.3, autobuffer = true }; var onunpause = new SAMPLES219 { autobuffer = true }; onunpause.load(); page.p96.InvokeOnComplete( delegate { page.p512.InvokeOnComplete( delegate { var diagnostics = new IHTMLIFrame { src = "https://docs.google.com/a/jsc-solutions.net/spreadsheet/embeddedform?formkey=dFhMb2UxVnBYUnNnUE16LUNiUzJJSVE6MQ", frameBorder = "0" }; diagnostics.style.backgroundColor = "rgba(255, 255, 255, 0)"; diagnostics.style.position = IStyle.PositionEnum.absolute; diagnostics.style.left = "0px"; diagnostics.style.top = "-100%"; diagnostics.style.width = "100%"; diagnostics.style.height = "100%"; diagnostics.style.zIndex = 9000; diagnostics.AttachToDocument(); // http://www.w3schools.com/css3/css3_transitions.asp diagnostics.style.transition = "all 0.2s ease-in-out"; diagnostics.style.transition = "all 0.3s ease-in-out"; Action Hide = delegate { diagnostics.style.top = "-100%"; diagnostics.style.backgroundColor = "rgba(255, 255, 255, 0)"; onpause.play(); onpause = new SAMPLES036 { volume = 0.3, autobuffer = true }; }; Action Show = delegate { diagnostics.style.top = "0%"; diagnostics.style.backgroundColor = "rgba(255, 255, 255, 0.9)"; onpause.play(); onpause = new SAMPLES036 { volume = 0.3, autobuffer = true }; }; Action Toggle = delegate { if (diagnostics.style.top == "0%") { Hide(); } else { Show(); } }; Action<int> AtKeyCode = KeyCode => { //new { KeyCode }.ToString().ToDocumentTitle(); if (KeyCode == 27) { Hide(); } // EE if (KeyCode == 222) { Toggle(); } // US if (KeyCode == 192) { Toggle(); } }; Native.Document.onkeyup += e => { AtKeyCode(e.KeyCode); }; //Native.window.onorientationchange += // delegate // { // Toggle(); // }; page.fund.href = diagnostics.src; page.fund.onclick += e => { e.preventDefault(); e.stopPropagation(); Toggle(); }; #region fundraiser Action fundraiser = null; fundraiser = delegate { var snd = new SAMPLES037 { volume = 0.01 + 0.1.Random() }; new Timer( delegate { page.fundspan.style.Opacity = 0.3; new Timer( delegate { page.fundspan.style.Opacity = 1; snd.play(); new Timer( delegate { page.fundspan.style.Opacity = 0.7; new Timer( delegate { page.fundspan.style.Opacity = 1; new Timer( delegate { page.fundspan.style.Opacity = 0.7; new Timer( delegate { page.fundspan.style.Opacity = 1; new Timer( delegate { page.fundspan.style.Opacity = 0.7; new Timer( delegate { page.fundspan.style.Opacity = 1; new Timer( delegate { fundraiser(); } ).StartTimeout(3000); } ).StartTimeout(300); } ).StartTimeout(300); } ).StartTimeout(300); } ).StartTimeout(300); } ).StartTimeout(300); } ).StartTimeout(300); } ).StartTimeout(10000 + 60000.Random()); } ).StartTimeout(300); }; fundraiser(); #endregion Native.Document.title = "LBA Redux"; #region newicon Action newicon = delegate { Native.Document.getElementsByTagName("link").AsEnumerable().ToList().WithEach( e => { var link = (IHTMLLink)e; if (link.rel == "icon") { if (link.type == "image/png") { link.href = new fullbox().src; } else { link.Orphanize(); } } } ); }; newicon(); #endregion #region music var musicnext = new _01_Track_1 { volume = 0.1, autobuffer = true }; var music = default(_01_Track_1); Action loop = null; loop = delegate { music = musicnext.AttachToDocument(); musicnext = new _01_Track_1 { volume = 0.1, autobuffer = true }; music.onended += delegate { Console.WriteLine(" music.onended "); music.Orphanize(); loop(); }; music.play(); }; loop(); #endregion Native.window.onscroll += e => { if (e.Element != Native.Document) return; e.preventDefault(); e.stopPropagation(); Native.window.scrollTo(0, 0); }; //new gong().AttachToDocument().play(); new ThreeDStuff.js.Tycoon4( t => { page.Preview.onclick += delegate { t.toolbar_btn_pause.RaiseClicked(); }; t.toolbar_btn_pause.Clicked += delegate { if (t.toolbar_btn_pause.IsActivated) { onpause.play(); onpause = new SAMPLES036 { volume = 0.3, autobuffer = true }; t.PauseFogTween.Value = 0.7; music.volume = 0.01; page.Preview.Show(); } else { //PauseFogTween.Value = 0; t.PauseFogTween.Value = 0; //gong.play(); onunpause.play(); onunpause = new SAMPLES219 { autobuffer = true }; page.Preview.FadeOut(); music.volume = 0.1; } }; t.toolbar_btn_pause.RaiseClicked(); new Timer( delegate { t.toolbar_btn_pause.RaiseClicked(); } ).StartTimeout(4000); } ); } ); } ); }