public AddEventListener ( CanvasElementEvents type, Action listener ) : void | ||
type | CanvasElementEvents | |
listener | Action | |
Résultat | void |
//------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------ public void Initialize(CanvasElement canvas, int screenX, int screenY) { this._screenX = screenX; this._screenY = screenY; /*no functions to minimize delegate creation*/ JsInputProvider that = this; canvas.AddEventListener("keydown", delegate(ElementEvent e) { that._keys[e.KeyCode] = true; }, true); canvas.AddEventListener("keyup", delegate(ElementEvent e) { that._keys[e.KeyCode] = false; }, true); canvas.AddEventListener("mousedown", delegate(ElementEvent e) { that._keys[Keys.MouseLeft] = true; }, true); canvas.AddEventListener("mouseup", delegate(ElementEvent e) { that._keys[Keys.MouseRight] = true; }, true); canvas.AddEventListener("mousemove", delegate(ElementEvent e) { /*convert to screen space*/ that._mouseX = (((float)(((MouseEvent)(Object)e).PageX - e.Target.OffsetLeft) / this._screenX) - 0.5f) * 2.0f; that._mouseY = (((float)(((MouseEvent)(Object)e).PageY - e.Target.OffsetTop) / this._screenY) - 0.5f) * 2.0f; }, true); }
public void Setup(CanvasElement canvas) { canvas.AddEventListener("dblclick", OnDoubleClick, false); //canvas.AddEventListener("mousemove", OnMouseMove, false); //canvas.AddEventListener("mouseup", OnMouseUp, false); //canvas.AddEventListener("pointerdown", OnPointerDown, false); canvas.AddEventListener("mousedown", OnMouseDown, false); canvas.AddEventListener("mousewheel", OnMouseWheel, false); canvas.AddEventListener("DOMMouseScroll", OnMouseWheel, false); // this is for firefox as it does not support mousewheel canvas.AddEventListener("touchstart", OnTouchStart, false); canvas.AddEventListener("touchmove", OnTouchMove, false); canvas.AddEventListener("touchend", OnTouchEnd, false); canvas.AddEventListener("gesturechange", OnGestureChange, false); canvas.AddEventListener("gesturestart", OnGestureStart, false); canvas.AddEventListener("gestureend", OnGestureEnd, false); Document.Body.AddEventListener("keydown", OnKeyDown, false); //canvas.AddEventListener("MSGestureChange", OnGestureChange, false); //canvas.AddEventListener("mouseout", OnMouseUp, false); // MS Touch code canvas.AddEventListener("pointerdown", OnPointerDown, false); canvas.AddEventListener("pointermove", OnPointerMove, false); canvas.AddEventListener("pointerup", OnPointerUp, false); // End MS touch code RenderContext.ViewCamera.Lat = StartLat; RenderContext.ViewCamera.Lng = StartLng; RenderContext.ViewCamera.Zoom = StartZoom; RenderContext.TargetCamera = RenderContext.ViewCamera.Copy(); if (RenderContext.gl == null) { foregroundCanvas = (CanvasElement)Document.CreateElement("canvas"); foregroundCanvas.Width = canvas.Width; foregroundCanvas.Height = canvas.Height; fgDevice = (CanvasContext2D)foregroundCanvas.GetContext(Rendering.Render2D); } webFolder = new Folder(); webFolder.LoadFromUrl("http://www.worldwidetelescope.org/wwtweb/catalog.aspx?X=ImageSets5", SetupComplete); WebFile webFile = new WebFile("http://www.worldwidetelescope.org/wwtweb/weblogin.aspx?user=12345678-03D2-4935-8D0F-DCE54C9113E5&Version=HTML5&webkey=AX2011Gqqu&platform=web"); webFile.Send(); }