/// <summary> /// Returns the HashCode for this Matrix3D /// </summary> /// <returns> /// int - the HashCode for this Matrix3D /// </returns> public override int GetHashCode() { if (IsDistinguishedIdentity) { return(c_identityHashCode); } else { // Perform field-by-field XOR of HashCodes return(M11.GetHashCode() ^ M12.GetHashCode() ^ M13.GetHashCode() ^ M14.GetHashCode() ^ M21.GetHashCode() ^ M22.GetHashCode() ^ M23.GetHashCode() ^ M24.GetHashCode() ^ M31.GetHashCode() ^ M32.GetHashCode() ^ M33.GetHashCode() ^ M34.GetHashCode() ^ OffsetX.GetHashCode() ^ OffsetY.GetHashCode() ^ OffsetZ.GetHashCode() ^ M44.GetHashCode()); } }
/// <summary> /// Returns the string representation of this object</summary> /// <param name="format">Optional standard numeric format string for a floating point number. /// If null, "R" is used for round-trip support in case the string is persisted. /// http://msdn.microsoft.com/en-us/library/vstudio/dwhawy9k(v=vs.100).aspx </param> /// <param name="formatProvider">Optional culture-specific formatting provider. This is usually /// a CultureInfo object or NumberFormatInfo object. If null, the current culture is used. /// Use CultureInfo.InvariantCulture for persistence.</param> /// <returns>String that represents matrix</returns> public string ToString(string format, IFormatProvider formatProvider) { string listSeparator = StringUtil.GetNumberListSeparator(formatProvider); // For historic reasons, use "R" for round-trip support, in case this string is persisted. if (format == null) { format = "R"; } return(String.Format( "{0}{16} {1}{16} {2}{16} {3}{16} {4}{16} {5}{16} {6}{16} {7}{16} {8}{16} {9}{16} " + "{10}{16} {11}{16} {12}{16} {13}{16} {14}{16} {15}", M11.ToString(format, formatProvider), M12.ToString(format, formatProvider), M13.ToString(format, formatProvider), M14.ToString(format, formatProvider), M21.ToString(format, formatProvider), M22.ToString(format, formatProvider), M23.ToString(format, formatProvider), M24.ToString(format, formatProvider), M31.ToString(format, formatProvider), M32.ToString(format, formatProvider), M33.ToString(format, formatProvider), M34.ToString(format, formatProvider), M41.ToString(format, formatProvider), M42.ToString(format, formatProvider), M43.ToString(format, formatProvider), M44.ToString(format, formatProvider), listSeparator)); }
public override int GetHashCode() { unchecked { var hashCode = M11.GetHashCode(); hashCode = (hashCode * 397) ^ M12.GetHashCode(); hashCode = (hashCode * 397) ^ M13.GetHashCode(); hashCode = (hashCode * 397) ^ M14.GetHashCode(); hashCode = (hashCode * 397) ^ M21.GetHashCode(); hashCode = (hashCode * 397) ^ M22.GetHashCode(); hashCode = (hashCode * 397) ^ M23.GetHashCode(); hashCode = (hashCode * 397) ^ M24.GetHashCode(); hashCode = (hashCode * 397) ^ M31.GetHashCode(); hashCode = (hashCode * 397) ^ M32.GetHashCode(); hashCode = (hashCode * 397) ^ M33.GetHashCode(); hashCode = (hashCode * 397) ^ M34.GetHashCode(); hashCode = (hashCode * 397) ^ M41.GetHashCode(); hashCode = (hashCode * 397) ^ M42.GetHashCode(); hashCode = (hashCode * 397) ^ M43.GetHashCode(); hashCode = (hashCode * 397) ^ M44.GetHashCode(); return(hashCode); } }
public override int GetHashCode() { return (M11.GetHashCode() ^ M12.GetHashCode() ^ M13.GetHashCode() ^ M14.GetHashCode() ^ M21.GetHashCode() ^ M22.GetHashCode() ^ M23.GetHashCode() ^ M24.GetHashCode() ^ M31.GetHashCode() ^ M32.GetHashCode() ^ M33.GetHashCode() ^ M34.GetHashCode() ^ M41.GetHashCode() ^ M42.GetHashCode() ^ M43.GetHashCode() ^ M44.GetHashCode()); }
public override int GetHashCode() { // Perform field-by-field XOR of HashCodes return(M11.GetHashCode() ^ M12.GetHashCode() ^ M13.GetHashCode() ^ M14.GetHashCode() ^ M21.GetHashCode() ^ M22.GetHashCode() ^ M23.GetHashCode() ^ M24.GetHashCode() ^ M31.GetHashCode() ^ M32.GetHashCode() ^ M33.GetHashCode() ^ M34.GetHashCode() ^ OffsetX.GetHashCode() ^ OffsetY.GetHashCode() ^ OffsetZ.GetHashCode() ^ M44.GetHashCode()); }
/// <summary> /// Serves as a hash function for this matrix. Is suitable for use in hashing algorithms /// and data structures like a hash table.</summary> /// <returns>A hash code for this matrix</returns> public override int GetHashCode() { long bits = 1; bits = 31 * bits + M11.GetHashCode(); bits = 31 * bits + M12.GetHashCode(); bits = 31 * bits + M13.GetHashCode(); bits = 31 * bits + M14.GetHashCode(); bits = 31 * bits + M21.GetHashCode(); bits = 31 * bits + M22.GetHashCode(); bits = 31 * bits + M23.GetHashCode(); bits = 31 * bits + M24.GetHashCode(); bits = 31 * bits + M31.GetHashCode(); bits = 31 * bits + M32.GetHashCode(); bits = 31 * bits + M33.GetHashCode(); bits = 31 * bits + M34.GetHashCode(); bits = 31 * bits + M41.GetHashCode(); bits = 31 * bits + M42.GetHashCode(); bits = 31 * bits + M43.GetHashCode(); bits = 31 * bits + M44.GetHashCode(); return((int)(bits ^ (bits >> 32))); }
/// <inheritdoc/> public override Int32 GetHashCode() { unchecked { var hash = 17; hash = hash * 23 + M11.GetHashCode(); hash = hash * 23 + M12.GetHashCode(); hash = hash * 23 + M13.GetHashCode(); hash = hash * 23 + M14.GetHashCode(); hash = hash * 23 + M21.GetHashCode(); hash = hash * 23 + M22.GetHashCode(); hash = hash * 23 + M23.GetHashCode(); hash = hash * 23 + M24.GetHashCode(); hash = hash * 23 + M31.GetHashCode(); hash = hash * 23 + M32.GetHashCode(); hash = hash * 23 + M33.GetHashCode(); hash = hash * 23 + M34.GetHashCode(); hash = hash * 23 + M41.GetHashCode(); hash = hash * 23 + M42.GetHashCode(); hash = hash * 23 + M43.GetHashCode(); hash = hash * 23 + M44.GetHashCode(); return(hash); } }
public override int GetHashCode() => M11.GetHashCode() ^ M12.GetHashCode() ^ M13.GetHashCode() ^ M14.GetHashCode() ^ M21.GetHashCode() ^ M22.GetHashCode() ^ M23.GetHashCode() ^ M24.GetHashCode() ^ M31.GetHashCode() ^ M32.GetHashCode() ^ M33.GetHashCode() ^ M34.GetHashCode() ^ M41.GetHashCode() ^ M42.GetHashCode() ^ M43.GetHashCode() ^ M44.GetHashCode();
public TransformNode(M44 rootTransMatrix) { }
internal void mul(M44 lidTrans1, M44 lidTrans2) { throw new NotImplementedException(); }
void InitializeContent(IDefaultPage page) { // http://www.addyosmani.com/resources/googlebox/test.js var TILT_BASE = 2.0f; var qtext = page.search_text; var tilt_cur = TILT_BASE; var tilt = TILT_BASE; var rot_cur = 1f; var rot = 1f; var lidAngle = 0f; var lidAngleV = 0f; var close_ok = false; var playing = false; var iframe = page.bottom_iframe; iframe.Hide(); var rootTransMatrix = new M44(); var rootTransNode = new TransformNode(rootTransMatrix); rootTransMatrix.rotX(tilt); M44 lidTrans1 = (new M44()).translate(0f, 100f, 0f); M44 lidTrans2 = new M44(); var box = new CSSCube(200, 200, 80, rootTransNode); var gbox = page.gift_box; var gbox_childnodes = gbox.childNodes.ExceptTextNodes(); for (var i = 0; i < 4; i++) { CSSFace f = box.getSide(i); f.element = gbox_childnodes[7 + i]; f.backElement = gbox_childnodes[1 + i]; } ((CSSFace)box.getTop()).element = gbox_childnodes[11]; var frontElement = (IHTMLElement)gbox_childnodes[7]; var frontElement_firstChild = (IHTMLElement)frontElement.childNodes.ExceptTextNodes()[0]; CSSFace bt = box.getBottom(); bt.element = gbox_childnodes[5]; bt.preTrans.rotX(Math.PI); box.getTop().backElement = gbox_childnodes[6]; var floorFace = new CSSFace(bt.tNode, 256, 256); floorFace.element = gbox_childnodes[0]; floorFace.N.z = 1f; #region updateTransform Action updateTransform = delegate { box.localTrans.rotY(rot_cur); box.localTrans._42 = (80f - box.height) / 2f; rootTransMatrix.rotX(tilt_cur); rootTransMatrix._42 = (80f - box.height) / 2f; floorFace.postTrans.translate(-28, -88 - box.localTrans._42, 0); box.applyTransform(); floorFace.applyTransform(); }; updateTransform(); #endregion #region resizing var resizing = default(Action); var resize_handle = page.resize_handle; resize_handle.style.cursor = IStyle.CursorEnum.move; var prevHandleY = 0f; var prevBoxH = 0f; resize_handle.onmousedown += e => { e.PreventDefault(); e.StopPropagation(); resizing = resize_handle.CaptureMouse(); //prevHandleY = e.screenY; prevHandleY = e.OffsetY; prevBoxH = box.height; }; resize_handle.onmousemove += e => { if (resizing != null) { e.PreventDefault(); e.StopPropagation(); var yy = rootTransMatrix._22; if (yy < -0.01 || yy > 0.01) { //var dy = e.screenY - prevHandleY; var dy = e.OffsetY - prevHandleY; var h = prevBoxH - dy / yy; if (h < 20) h = 20; if (h > 200) h = 200; box.changeHeight(h); frontElement_firstChild.style.height = frontElement.style.height; frontElement_firstChild.style.width = frontElement.style.width; updateTransform(); } else { resizing(); resizing = null; } } }; resize_handle.onmouseup += e => { if (resizing != null) { resizing(); resizing = null; } }; #endregion #region intpMotion Func<bool> intpMotion = delegate { var dR = rot_cur - rot; var dT = tilt_cur - tilt; if (dR < 0) dR = -dR; if (dT < 0) dT = -dT; var not_finished = false; if (dR < 0.002) rot_cur = rot; else { not_finished = true; rot_cur = rot_cur * 0.8f + rot * 0.2f; } if (dT < 0.002) tilt_cur = tilt; else { not_finished = true; tilt_cur = tilt_cur * 0.8f + tilt * 0.2f; } return not_finished; }; #endregion #region setLidRotate Action<float> setLidRotate = a => { lidTrans2.rotX(-a); lidTrans2._42 = -100; box.getTop().preTrans.mul(lidTrans1, lidTrans2); }; #endregion #region doAnimation Action doAnimation = null; doAnimation = delegate { playing = false; if (lidAngle > 0) { playing = true; if (close_ok || lidAngleV > 0) lidAngleV -= 0.01f; lidAngle += lidAngleV; if (lidAngle < 0) { lidAngle = 0; iframe.src = "about:blank"; iframe.Hide(); } else if (lidAngle >= 1.3f) { lidAngle = 1.3f; playing = false; } } else { lidAngle = 0f; lidAngleV = 0f; } setLidRotate(lidAngle); if ((resizing == null) && intpMotion()) playing = true; updateTransform(); if (playing) { var _this = this; Native.Window.requestAnimationFrame += delegate { doAnimation(); }; } }; #endregion #region onmousemove Native.Document.body.onmousemove += e => { if (Native.Document.pointerLockElement == Native.Document.body) { rot += e.movementX * 0.01f; tilt += e.movementY * 0.01f; } else { rot = e.CursorX * 0.006f - 0.9f; tilt = (TILT_BASE - e.CursorY * 0.004f); } if (tilt < 0.5f) tilt = 0.5f; //Console.WriteLine(new { rot, tilt }.ToString()); if (!playing) doAnimation(); }; #endregion #region close_button page.close_button.onclick += e => { e.StopPropagation(); close_ok = true; if (lidAngle > 1.2) { lidAngle -= 0.1f; lidAngleV = 0.01f; } if (!playing) doAnimation(); }; #endregion #region onSearchClick Action onSearchClick = delegate { lidAngle += 0.01f; lidAngleV = 0.17f; close_ok = false; iframe.Show(); // Refused to display document because display forbidden by X-Frame-Options. iframe.src = "http://example.com"; if (!playing) doAnimation(); }; page.search_text.onkeydown += e => { if (e.KeyCode == 13) { onSearchClick(); } }; page.search_button.onclick += e => { onSearchClick(); }; #endregion page.search_fullscreen.onmousedown += e => { e.PreventDefault(); if (e.MouseButton != IEvent.MouseButtonEnum.Left) Native.Document.body.requestPointerLock(); }; Native.Document.body.onmouseup += delegate { Native.Document.exitPointerLock(); }; page.search_fullscreen.onclick += delegate { page.box_label.requestFullscreen(); }; }
/// <summary> /// Compares whether current instance is equal to specified <see cref="Matrix" /> without any tolerance. /// </summary> /// <param name="other">The <see cref="Matrix" /> to compare.</param> /// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns> public bool Equals(Matrix other) { return(M11.Equals(other.M11) && M22.Equals(other.M22) && M33.Equals(other.M33) && M44.Equals(other.M44) && M12.Equals(other.M12) && M13.Equals(other.M13) && M14.Equals(other.M14) && M21.Equals(other.M21) && M23.Equals(other.M23) && M24.Equals(other.M24) && M31.Equals(other.M31) && M32.Equals(other.M32) && M34.Equals(other.M34) && M41.Equals(other.M41) && M42.Equals(other.M42) && M43.Equals(other.M43)); }
public void InitializeContent(IDefault page) { var control = new UserControl1(); this.frontcontrol = new FrontPanel(); this.frontcontrol.RelativeToAbsolute = href => { if (href.StartsWith("/")) return Native.Document.location.href.TakeUntilLastIfAny("/") + href; return Native.Document.location.href + href; }; Native.Document.body.ondragover += evt => { evt.stopPropagation(); evt.preventDefault(); evt.dataTransfer.dropEffect = "copy"; // Explicitly show this is a copy. }; Native.Document.body.ondrop += evt => { #region dataTransfer evt.dataTransfer.types.WithEach( x => { Console.WriteLine(x); //SystemSounds.Beep.Play(); //Console.Beep(); #region text/uri-list if (x == "text/uri-list") { var src = evt.dataTransfer.getData(x); if (src != "about:blank") { if (src.StartsWith("http://www.youtube.com/watch?v=")) src = "http://www.youtube.com/embed/" + src.SkipUntilIfAny("http://www.youtube.com/watch?v=").TakeUntilIfAny("&"); Console.WriteLine(new { src }); frontcontrol.CreateWindowAndNavigate(src); } } #endregion } ); #endregion }; Console.Write("frontcontrol set"); // http://www.addyosmani.com/resources/googlebox/test.js var TILT_BASE = 2.0f; var qtext = page.search_text; var tilt_cur = TILT_BASE; var tilt = TILT_BASE; var rot_cur = 1f; var rot = 1f; var lidAngle = 0f; var lidAngleV = 0f; var close_ok = false; var playing = false; var iframe = page.bottom_iframe; iframe.Hide(); var rootTransMatrix = new M44(); var rootTransNode = new TransformNode(rootTransMatrix); rootTransMatrix.rotX(tilt); M44 lidTrans1 = (new M44()).translate(0f, 100f, 0f); M44 lidTrans2 = new M44(); var box = new CSSCube(200, 200, 80, rootTransNode); var gbox = page.gift_box; var gbox_childnodes = gbox.childNodes.ExceptTextNodes(); for (var i = 0; i < 4; i++) { CSSFace f = box.getSide(i); f.element = gbox_childnodes[7 + i]; f.backElement = gbox_childnodes[1 + i]; } ((CSSFace)box.getTop()).element = gbox_childnodes[11]; var frontElement = (IHTMLElement)gbox_childnodes[7]; //var frontElement_firstChild = (IHTMLElement)frontElement.childNodes.ExceptTextNodes()[0]; CSSFace bt = box.getBottom(); bt.element = gbox_childnodes[5]; bt.preTrans.rotX(Math.PI); box.getTop().backElement = gbox_childnodes[6]; var floorFace = new CSSFace(bt.tNode, 256, 256); floorFace.element = gbox_childnodes[0]; floorFace.N.z = 1f; #region updateTransform Action updateTransform = delegate { box.localTrans.rotY(rot_cur); box.localTrans._42 = (80f - box.height) / 2f; rootTransMatrix.rotX(tilt_cur); rootTransMatrix._42 = (80f - box.height) / 2f; floorFace.postTrans.translate(-28, -88 - box.localTrans._42, 0); box.applyTransform(); floorFace.applyTransform(); }; updateTransform(); #endregion #region resizing var resizing = default(Action); var resize_handle = page.resize_handle; resize_handle.style.cursor = IStyle.CursorEnum.move; var prevHandleY = 0f; var prevBoxH = 0f; resize_handle.onmousedown += e => { e.PreventDefault(); e.StopPropagation(); resizing = resize_handle.CaptureMouse(); //prevHandleY = e.screenY; prevHandleY = e.OffsetY; prevBoxH = box.height; }; resize_handle.onmousemove += e => { if (resizing != null) { e.PreventDefault(); e.StopPropagation(); var yy = rootTransMatrix._22; if (yy < -0.01 || yy > 0.01) { //var dy = e.screenY - prevHandleY; var dy = e.OffsetY - prevHandleY; var h = prevBoxH - dy / yy; if (h < 20) h = 20; if (h > 200) h = 200; box.changeHeight(h); frontcontrol.Size = new System.Drawing.Size( frontElement.Bounds.Width, frontElement.Bounds.Height ); //frontElement_firstChild.style.height = frontElement.style.height; //frontElement_firstChild.style.width = frontElement.style.width; updateTransform(); } else { resizing(); resizing = null; } } }; resize_handle.onmouseup += e => { if (resizing != null) { resizing(); resizing = null; } }; #endregion #region intpMotion Func<bool> intpMotion = delegate { var dR = rot_cur - rot; var dT = tilt_cur - tilt; if (dR < 0) dR = -dR; if (dT < 0) dT = -dT; var not_finished = false; if (dR < 0.002) rot_cur = rot; else { not_finished = true; rot_cur = rot_cur * 0.8f + rot * 0.2f; } if (dT < 0.002) tilt_cur = tilt; else { not_finished = true; tilt_cur = tilt_cur * 0.8f + tilt * 0.2f; } return not_finished; }; #endregion #region setLidRotate Action<float> setLidRotate = a => { lidTrans2.rotX(-a); lidTrans2._42 = -100; box.getTop().preTrans.mul(lidTrans1, lidTrans2); }; #endregion #region doAnimation Action doAnimation = null; doAnimation = delegate { playing = false; if (lidAngle > 0) { playing = true; if (close_ok || lidAngleV > 0) lidAngleV -= 0.01f; lidAngle += lidAngleV; if (lidAngle < 0) { lidAngle = 0; iframe.src = "about:blank"; iframe.Hide(); } else if (lidAngle >= 1.3f) { lidAngle = 1.3f; playing = false; } } else { lidAngle = 0f; lidAngleV = 0f; } setLidRotate(lidAngle); if ((resizing == null) && intpMotion()) playing = true; updateTransform(); if (playing) { var _this = this; Native.window.requestAnimationFrame += delegate { doAnimation(); }; } }; #endregion #region onmousemove Native.Document.body.onmousemove += e => { if (control.checkBox1.Checked) return; if (Native.Document.pointerLockElement == Native.Document.body) { rot += e.movementX * 0.01f; tilt += e.movementY * 0.01f; } else { rot = e.CursorX * 0.006f - 0.9f; tilt = (TILT_BASE - e.CursorY * 0.004f); } if (tilt < 0.5f) tilt = 0.5f; //Console.WriteLine(new { rot, tilt }.ToString()); if (!playing) doAnimation(); }; #endregion #region close_button page.close_button.onclick += e => { e.StopPropagation(); close_ok = true; if (lidAngle > 1.2) { lidAngle -= 0.1f; lidAngleV = 0.01f; } if (!playing) doAnimation(); }; #endregion #region onSearchClick Action onSearchClick = delegate { lidAngle += 0.01f; lidAngleV = 0.17f; close_ok = false; iframe.Show(); iframe.allowFullScreen = true; // Refused to display document because display forbidden by X-Frame-Options. iframe.src = frontcontrol.comboBox1.Text; if (!playing) doAnimation(); }; page.search_text.onkeydown += e => { if (e.KeyCode == 13) { onSearchClick(); } }; page.search_button.onclick += e => { onSearchClick(); }; #endregion page.search_fullscreen.onmousedown += e => { e.preventDefault(); if (e.MouseButton != IEvent.MouseButtonEnum.Left) Native.Document.body.requestPointerLock(); }; Native.Document.body.onmouseup += delegate { Native.Document.exitPointerLock(); }; page.search_fullscreen.onclick += delegate { page.box_label.requestFullscreen(); }; { var ContainerShadow = new IHTMLDiv().AttachTo(page.box_label_container); ContainerShadow.style.position = IStyle.PositionEnum.absolute; ContainerShadow.style.left = "0px"; ContainerShadow.style.top = "0px"; ContainerShadow.style.right = "0px"; ContainerShadow.style.bottom = "0px"; var Container = new IHTMLDiv().AttachTo(page.box_label_container); Container.style.position = IStyle.PositionEnum.absolute; Container.style.left = "0px"; Container.style.top = "0px"; Container.style.right = "0px"; Container.style.bottom = "0px"; control.AttachControlTo(Container); //control.AutoSizeControlTo(ContainerShadow); } { var ContainerShadow = new IHTMLDiv().AttachTo(page.front_panel); ContainerShadow.style.position = IStyle.PositionEnum.absolute; ContainerShadow.style.left = "0px"; ContainerShadow.style.top = "0px"; ContainerShadow.style.right = "0px"; ContainerShadow.style.bottom = "0px"; var Container = new IHTMLDiv().AttachTo(page.front_panel); Container.style.position = IStyle.PositionEnum.absolute; Container.style.left = "0px"; Container.style.top = "0px"; Container.style.right = "0px"; Container.style.bottom = "0px"; frontcontrol.AttachControlTo(Container); //frontcontrol.AutoSizeControlTo(ContainerShadow); frontcontrol.Width = 200; frontcontrol.Height = 80; frontcontrol.button1.Click += delegate { onSearchClick(); }; resize_handle.Orphanize().AttachTo(page.front_panel); var once = false; frontcontrol.NewForm += f => { if (once) { #if DOESITWORK Abstractatech.JavaScript.FormAsPopup.FormAsPopupExtensions.PopupInsteadOfClosing(f); #endif return; } once = true; //f.DisableFormClosingHandler = true; global::CSSMinimizeFormToSidebar.ApplicationExtension.InitializeSidebarBehaviour( f ); }; } }
public TransformNode(M44 rootTransMatrix) { }
internal void mul(M44 lidTrans1, M44 lidTrans2) { throw new NotImplementedException(); }
void InitializeContent(IDefaultPage page) { // http://www.addyosmani.com/resources/googlebox/test.js var TILT_BASE = 2.0f; var qtext = page.search_text; var tilt_cur = TILT_BASE; var tilt = TILT_BASE; var rot_cur = 1f; var rot = 1f; var lidAngle = 0f; var lidAngleV = 0f; var close_ok = false; var playing = false; var iframe = page.bottom_iframe; iframe.Hide(); var rootTransMatrix = new M44(); var rootTransNode = new TransformNode(rootTransMatrix); rootTransMatrix.rotX(tilt); M44 lidTrans1 = (new M44()).translate(0f, 100f, 0f); M44 lidTrans2 = new M44(); var box = new CSSCube(200, 200, 80, rootTransNode); var gbox = page.gift_box; var gbox_childnodes = gbox.childNodes.ExceptTextNodes(); for (var i = 0; i < 4; i++) { CSSFace f = box.getSide(i); f.element = gbox_childnodes[7 + i]; f.backElement = gbox_childnodes[1 + i]; } ((CSSFace)box.getTop()).element = gbox_childnodes[11]; var frontElement = (IHTMLElement)gbox_childnodes[7]; var frontElement_firstChild = (IHTMLElement)frontElement.childNodes.ExceptTextNodes()[0]; CSSFace bt = box.getBottom(); bt.element = gbox_childnodes[5]; bt.preTrans.rotX(Math.PI); box.getTop().backElement = gbox_childnodes[6]; var floorFace = new CSSFace(bt.tNode, 256, 256); floorFace.element = gbox_childnodes[0]; floorFace.N.z = 1f; #region updateTransform Action updateTransform = delegate { box.localTrans.rotY(rot_cur); box.localTrans._42 = (80f - box.height) / 2f; rootTransMatrix.rotX(tilt_cur); rootTransMatrix._42 = (80f - box.height) / 2f; floorFace.postTrans.translate(-28, -88 - box.localTrans._42, 0); box.applyTransform(); floorFace.applyTransform(); }; updateTransform(); #endregion #region resizing var resizing = default(Action); var resize_handle = page.resize_handle; resize_handle.style.cursor = IStyle.CursorEnum.move; var prevHandleY = 0f; var prevBoxH = 0f; resize_handle.onmousedown += e => { e.PreventDefault(); e.StopPropagation(); resizing = resize_handle.CaptureMouse(); //prevHandleY = e.screenY; prevHandleY = e.OffsetY; prevBoxH = box.height; }; resize_handle.onmousemove += e => { if (resizing != null) { e.PreventDefault(); e.StopPropagation(); var yy = rootTransMatrix._22; if (yy < -0.01 || yy > 0.01) { //var dy = e.screenY - prevHandleY; var dy = e.OffsetY - prevHandleY; var h = prevBoxH - dy / yy; if (h < 20) { h = 20; } if (h > 200) { h = 200; } box.changeHeight(h); frontElement_firstChild.style.height = frontElement.style.height; frontElement_firstChild.style.width = frontElement.style.width; updateTransform(); } else { resizing(); resizing = null; } } }; resize_handle.onmouseup += e => { if (resizing != null) { resizing(); resizing = null; } }; #endregion #region intpMotion Func <bool> intpMotion = delegate { var dR = rot_cur - rot; var dT = tilt_cur - tilt; if (dR < 0) { dR = -dR; } if (dT < 0) { dT = -dT; } var not_finished = false; if (dR < 0.002) { rot_cur = rot; } else { not_finished = true; rot_cur = rot_cur * 0.8f + rot * 0.2f; } if (dT < 0.002) { tilt_cur = tilt; } else { not_finished = true; tilt_cur = tilt_cur * 0.8f + tilt * 0.2f; } return(not_finished); }; #endregion #region setLidRotate Action <float> setLidRotate = a => { lidTrans2.rotX(-a); lidTrans2._42 = -100; box.getTop().preTrans.mul(lidTrans1, lidTrans2); }; #endregion #region doAnimation Action doAnimation = null; doAnimation = delegate { playing = false; if (lidAngle > 0) { playing = true; if (close_ok || lidAngleV > 0) { lidAngleV -= 0.01f; } lidAngle += lidAngleV; if (lidAngle < 0) { lidAngle = 0; iframe.src = "about:blank"; iframe.Hide(); } else if (lidAngle >= 1.3f) { lidAngle = 1.3f; playing = false; } } else { lidAngle = 0f; lidAngleV = 0f; } setLidRotate(lidAngle); if ((resizing == null) && intpMotion()) { playing = true; } updateTransform(); if (playing) { var _this = this; Native.Window.requestAnimationFrame += delegate { doAnimation(); }; } }; #endregion #region onmousemove Native.Document.body.onmousemove += e => { if (Native.Document.pointerLockElement == Native.Document.body) { rot += e.movementX * 0.01f; tilt += e.movementY * 0.01f; } else { rot = e.CursorX * 0.006f - 0.9f; tilt = (TILT_BASE - e.CursorY * 0.004f); } if (tilt < 0.5f) { tilt = 0.5f; } //Console.WriteLine(new { rot, tilt }.ToString()); if (!playing) { doAnimation(); } }; #endregion #region close_button page.close_button.onclick += e => { e.StopPropagation(); close_ok = true; if (lidAngle > 1.2) { lidAngle -= 0.1f; lidAngleV = 0.01f; } if (!playing) { doAnimation(); } }; #endregion #region onSearchClick Action onSearchClick = delegate { lidAngle += 0.01f; lidAngleV = 0.17f; close_ok = false; iframe.Show(); // Refused to display document because display forbidden by X-Frame-Options. iframe.src = "http://example.com"; if (!playing) { doAnimation(); } }; page.search_text.onkeydown += e => { if (e.KeyCode == 13) { onSearchClick(); } }; page.search_button.onclick += e => { onSearchClick(); }; #endregion page.search_fullscreen.onmousedown += e => { e.PreventDefault(); if (e.MouseButton != IEvent.MouseButtonEnum.Left) { Native.Document.body.requestPointerLock(); } }; Native.Document.body.onmouseup += delegate { Native.Document.exitPointerLock(); }; page.search_fullscreen.onclick += delegate { page.box_label.requestFullscreen(); }; }