private void HandleMessage(DOMEvent e) { var data = e.As<MessageEvent>().data; var cmd = data.Member("cmd").As<string>(); switch (cmd) { case "load": Load(data.Member("data"), data.Member("indexes").As<int[]>()); break; case "invalidate": _renderer.Invalidate(); break; case "resize": _renderer.Resize(data.Member("width").As<int>()); break; case "tex": Tex(data.Member("data").As<string>()); break; case "renderMultiple": RenderMultiple(data.Member("data").As<int[]>()); break; case "updateSettings": UpdateSettings(data.Member("settings")); break; } }
private void HandleWorkerMessage(DOMEvent e) { var data = e.As<MessageEvent>().data; var cmd = data.Member("cmd").As<string>(); switch (cmd) { case "preRender": OnPreRender(); break; case "partialRenderFinished": OnPartialRenderFinished(data.Member("result").As<RenderFinishedEventArgs>()); break; case "renderFinished": OnRenderFinished(data.Member("result").As<RenderFinishedEventArgs>()); break; case "postRenderFinished": OnPostRenderFinished(); break; case "error": console.error(data.Member("exception")); break; case "loaded": var score = data.Member("score").As<Score>(); if (score.As<bool>()) { var jsonConverter = new JsonConverter(); score = jsonConverter.JsObjectToScore(score); } _workerApi.TriggerEvent("loaded", score); break; } }
public void HandleMessage(DOMEvent e) { var data = e.As<MessageEvent>().data; var cmd = data.Member("cmd").As<string>(); switch (cmd) { case "play": Play(); break; case "pause": Pause(); break; case "isReadyForPlay": PostMessage(new { cmd = "isReadyForPlay", value = IsReadyForPlay() }); break; case "getMasterVolume": PostMessage(new { cmd = "getMasterVolume", value = _player.MasterVolume }); break; case "setMasterVolume": _player.MasterVolume = data.Member("value").As<float>(); break; case "playPause": PlayPause(); break; case "stop": Stop(); break; case "setPositionTick": SetPositionTick(data.Member("tick").As<int>()); break; case "setPositionTime": SetPositionTime(data.Member("time").As<int>()); break; case "loadSoundFontUrl": LoadSoundFontUrl(data.Member("url").As<string>()); break; case "loadSoundFontBytes": LoadSoundFontBytes(data.Member("data").As<byte[]>()); break; case "loadMidiUrl": LoadMidiUrl(data.Member("url").As<string>()); break; case "loadMidiBytes": LoadMidiBytes(data.Member("data").As<byte[]>()); break; case "getState": PostMessage(new { cmd = "getState", value = GetState() }); break; case "isSoundFontLoaded": PostMessage(new { cmd = "isSoundFontLoaded", value = IsSoundFontLoaded() }); break; case "isMidiLoaded": PostMessage(new { cmd = "isMidiLoaded", value = IsMidiLoaded() }); break; case "setLogLevel": SetLogLevel(data.Member("level").As<LogLevel>()); break; } }
static void btnTest_click(DOMEvent e) { var doc = HtmlContext.document; new jQuery(doc.body).append("Hello world<br/>"); new jQuery(doc.body).append("Hello world2<br/>"); new jQuery(doc.body).append("Hello world3<br/>"); new jQuery(doc.body).append("Hello world4<br/>"); new jQuery(doc.body).append("Hello world5<br/>"); }
private void HandleMessage(DOMEvent e) { var data = e.As<MessageEvent>().data; var cmd = data.Member("cmd").As<string>(); switch (cmd) { case "playerSampleRequest": OnSampleRequest(); break; case "playerFinished": OnFinished(); break; case "playerPositionChanged": OnPositionChanged(data.Member("pos").As<int>()); break; } }
public bool dispatchEvent(DOMEvent evt) { throw new System.NotImplementedException(); }
private void HandleMessage(DOMEvent e) { var data = e.As<MessageEvent>().data; var cmd = data.Member("cmd").As<string>(); switch (cmd) { case "load": Load(data.Member("data"), data.Member("indexes").As<int[]>()); break; case "tex": Tex(data.Member("data").As<string>()); break; case "renderMultiple": RenderMultiple(data.Member("data").As<int[]>()); break; } }
/// <summary> /// get touch position for mobile apps /// </summary> /// <param name="evt"></param> /// <returns></returns> public object getTouchPosition(DOMEvent evt) { return null; }
static void btnTest_click(DOMEvent e) { new jQuery(HtmlContext.document.body).append("Hello world<br/>"); }
private void onTableClick(DOMEvent evt) { if (_turnClientId == ClientId) { var el = evt.target.As<HtmlElement>(); if (el is HtmlTableCellElement) { var cell = el.As<HtmlTableCellElement>(); var row = cell.parentNode.As<HtmlTableRowElement>(); //el.innerHTML = _figure; var request = new TurnRequest(); request.x = cell.cellIndex; request.y = JsContext.parseInt(row.getAttribute("rowIdx"), 10); request.ClientId = ClientId; request.figure = _figure; server.send(request); } } }
internal static void resizeHandler(DOMEvent e) { Validate(); }
public void _mouseMoveHandler(DOMEvent ev) { if ((getItem() != null && (_button == 1)) && (!getItem().isFixed() || isDesignMode())) { var xy = js.getEventXY(ev) as JsObject; var offset = js.getXY(HtmlContext.document.getElementById("res")) as JsObject; xy["x"] = (int) xy["x"] - (int) offset["x"]; xy["y"] = (int) xy["y"] - (int) offset["y"]; js.assert((int) xy["x"] >= 0); js.assert((int) xy["y"] >= 0); int x1 = JsContext.parseInt(xy["x"].ToString(), 10); int y1 = JsContext.parseInt(xy["y"].ToString(), 10); JsNumber x = x1/_item.getDiv().offsetWidth; JsNumber y = y1/_item.getDiv().offsetHeight; HtmlContext.console.log("x=" + x + " y=" + y); if (_item.getX() != x || _item.getY() != y) { if (map.inst()._isFree(x, y) && map.inst().canMove(_item, x, y)) { getItem().moveTo(x, y); } } //experement /* if (this._prevPoint) { var div = this.getItem().getDiv(); var diffX = parseInt((xy.x - this._prevPoint.x) / 1, 10); var diffY = parseInt((xy.y - this._prevPoint.y) / 1, 10); var x1 = this.getItem().getX(); var y1 = this.getItem().getY(); if (diffX > 0) { x1++; console.log("moveRight"); } else if (diffX < 0) { x1--; console.log("moveLeft"); } if (diffX != 0) { //if ($map._isFree(x1, y1) || ($map.getItemByXY(x1, y1) == this.getItem())) { div.style.left = (xy.x - this._diffXY.x) + "px"; } } else { var x2 = x; var y2 = y; if (diffY > 0) { y2++; console.log("moveDown"); } else if (diffY < 0) { y2--; console.log("moveUp"); } if (diffY != 0) { //if ($map._isFree(x2, y2) || ($map.getItemByXY(x2, y2) == this.getItem())) { div.style.top = (xy.y - this._diffXY.y) + "px"; } } } } this._prevPoint = xy; */ } }
public void _mouseDownHandler(DOMEvent ev) { var target = js.getSrcElement(ev) as HtmlElement; _button = 1; if (js.hasClass(target, "item")) { var xy = js.getEventXY(ev) as JsObject; var offset = js.getXY(target) as JsObject; xy["x"] = JsContext.parseInt(xy["x"].ToString(), 10) - JsContext.parseInt(offset["x"].ToString(), 10); xy["y"] = JsContext.parseInt(xy["y"].ToString(), 10) - JsContext.parseInt(offset["y"].ToString(), 10); _diffXY = xy; itemBase item = map.inst().getItemById(target.getAttribute("id")); setItem(item); } }
internal static int GetEventButton(DOMEvent evt) { return -1; }
internal static int getEventKeyCode(DOMEvent evt) { return -1; }
internal static object getSrcElement(DOMEvent ev) { throw new NotImplementedException(); }
public void _mouseUpHandler(DOMEvent ev) { _button = 0; if (_item != null) { //js.removeClass(this._item.getDiv(),"active"); //this._item = null; } }
public void _keyDownHandler(DOMEvent ev) { int keyCode = js.getEventKeyCode(ev); HtmlContext.console.log(keyCode); if (keyCode == 38 && map.inst().canMoveUp(_item)) { _item.moveUp(); } else if (keyCode == 40 && map.inst().canMoveDown(_item)) { _item.moveDown(); } else if (keyCode == 37 && map.inst().canMoveLeft(_item)) { _item.moveLeft(); } else if (keyCode == 39 && map.inst().canMoveRight(_item)) { _item.moveRight(); } }
public virtual void HandleWorkerMessage(DOMEvent e) { var data = e.As<MessageEvent>().data; var cmd = data.Member("cmd").As<string>(); switch (cmd) { // responses case "isReadyForPlay": case "getState": case "getMasterVolume": case "isSoundFontLoaded": case "isMidiLoaded": TriggerEvent(cmd, new[] { data.Member("value") }); break; // events case "ready": _isWorkerReady = true; CheckForReadyState(); break; case "positionChanged": TriggerEvent(cmd, new[] { data.Member("currentTime"), data.Member("endTime"), data.Member("currentTick"), data.Member("endTick") }); break; case "playerStateChanged": TriggerEvent(cmd, new[] { data.Member("state") }); break; case "finished": TriggerEvent(cmd); break; case "soundFontLoad": TriggerEvent(cmd, new[] { data.Member("loaded"), data.Member("total") }); break; case "soundFontLoaded": TriggerEvent(cmd); break; case "soundFontLoadFailed": TriggerEvent(cmd); break; case "midiLoad": TriggerEvent(cmd, new[] { data.Member("loaded"), data.Member("total") }); break; case "midiFileLoaded": TriggerEvent(cmd); break; case "midiFileLoadFailed": TriggerEvent(cmd); break; case "readyForPlay": TriggerEvent(cmd, new[] { data.Member("value") }); break; case "log": Log(data.Member("level").As<LogLevel>(), data.Member("message").As<string>()); break; // js player communication case "playerSequencerFinished": _player.SequencerFinished(); break; case "playerAddSamples": _player.AddSamples(data.Member("samples").As<SampleArray>()); break; case "playerPlay": _player.Play(); break; case "playerPause": _player.Pause(); break; case "playerStop": _player.Stop(); break; case "playerSeek": _player.Seek(data.Member("pos").As<int>()); break; } }
private void OnBeforeUnload(DOMEvent evt) { server.disconnect(); }
static void btnTest_click(DOMEvent e) { J(document.body).append("Hello world<br/>"); }
/// <summary> /// get mouse position for desktop apps /// </summary> /// <param name="evt"></param> /// <returns></returns> public object getMousePosition(DOMEvent evt) { return null; }
private void OnConnectClick(DOMEvent evt) { commet.connect(this.ClientId); }
/// <summary> /// get user position (mouse position or touch position) /// </summary> /// <param name="evt"></param> /// <returns></returns> public object getUserPosition(DOMEvent evt) { return null; }
private void onTableClick(DOMEvent evt) { if (_turnClientId == this.ClientId) { HtmlElement el = evt.target.As<HtmlElement>(); if (el is HtmlTableCellElement) { HtmlTableCellElement cell = el.As<HtmlTableCellElement>(); HtmlTableRowElement row = cell.parentNode.As<HtmlTableRowElement>(); //el.innerHTML = _figure; turnRequest request = new turnRequest(); request.x = cell.cellIndex; request.y = row.rowIndex; request.clientId = this.ClientId; request.figure = _figure; server.send(request); } } }
private void GenerateSound(DOMEvent e) { var ae = (AudioProcessingEvent)e; var left = ae.outputBuffer.getChannelData(0); var right = ae.outputBuffer.getChannelData(1); var samples = left.length + right.length; if (_circularBuffer.Count < samples) { if (_finished) { if (Finished != null) Finished(); Stop(); } else { // when buffering we count it as pause time _pauseTime += (int)((BufferSize * 1000) / (2 * _context.sampleRate)); } } else { var buffer = new SampleArray(samples); _circularBuffer.Read(buffer, 0, buffer.Length); var s = 0; for (int i = 0; i < left.length; i++) { left[i] = buffer[s++]; right[i] = buffer[s++]; } } if (PositionChanged != null) { PositionChanged((int)(CalcPosition())); } if (!_finished) { RequestBuffers(); } }
private void OnBeforeUnload(DOMEvent evt) { commet.disconnect(); }
public bool dispatchEvent(DOMEvent evt) { return(default(bool)); }
static void btnTest_click(DOMEvent e) { RunTests(); }
public bool dispatchEvent(DOMEvent @event) { return default(bool); }
private void GenerateSound(DOMEvent e) { var ae = (AudioProcessingEvent)e; var left = ae.outputBuffer.getChannelData(0); var right = ae.outputBuffer.getChannelData(1); var samples = left.length + right.length; if (_circularBuffer.Count < samples) { if (_finished) { if (Finished != null) Finished(); Stop(); } } else { var buffer = new SampleArray(samples); _circularBuffer.Read(buffer, 0, buffer.Length); var s = 0; for (int i = 0; i < left.length; i++) { left[i] = buffer[s++]; right[i] = buffer[s++]; } _currentTime += (left.length / (double)SampleRate) * 1000 * _playbackSpeed; } if (PositionChanged != null) { PositionChanged((int)_currentTime); } if (!_finished) { RequestBuffers(); } }