public MySound(int _id, string p, bool _loop = false) { path = p; id = _id; loop = _loop; JsInterop.InitializeSound(id, path, loop); }
protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { await JsInterop.InvokeVoidAsync("window.AntDesign.DocSearch.init", CurrentLanguage); } }
public static Board_Element get_Free_Point() { Board_Element result = new Board_Element(); bool b = false; for (var index = 0; index < points_Count * 10; index++) { result = Board.Matrix[MyFunctions.get_Random_Int(0, x_Length - 1), MyFunctions.get_Random_Int(0, y_Length - 1)]; if (result.MyValue == MyValueType.free) { if (check_if_one_of_neighbors_if_free(result.Point.x, result.Point.y)) { b = true; break; } } } if (!b) { JsInterop.Alert("Can't find free point!!!"); } return(result); }
public void RegisterJsEvents() { foreach (var item in listDragTarget) { JsInterop.HandleDrop(jsRuntimeCurrent, item.ElementID, item.ID, new DotNetObjectRef(this)); } }
protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { await JsInterop.SetElementStyleAsync(PaneElement, "flexBasis", SizeStyle); } }
public async void KeyboardCommand(string command, string action) { string html = null; try { html = await JsInterop.CallMethod <string>("getselection") as string; } catch (Exception ex) { string message = ex.Message; } action = action.ToLower(); if (action == "bold") { html = WrapValue(html, "**", "**", stripExtraSpaces: true); } else if (action == "italic") { var italic = "*"; html = WrapValue(html, italic, italic, stripExtraSpaces: true); } await JsInterop.CallMethod("setselection", html); }
//public class JsInterop //{ // protected string resultString; // protected IJSRuntime JSRuntime { get; set; } // protected DotNetObjectReference<JsInterop> dotNetObjectRef; // public JsInterop(IJSRuntime IJSRuntime) // { // JSRuntime = IJSRuntime; // dotNetObjectRef = DotNetObjectReference.Create(this); // JSRuntime.InvokeAsync<Task>("SetDotNetHelper", dotNetObjectRef); // } // [JSInvokable] // public void FromJS(string s) // { // Console.WriteLine("Received " + s); // resultString = s; // } // public async Task<string> CallFunction1() // { // await JSRuntime.InvokeAsync<Task>("FromNet", "Hello"); // //await JSRuntime.InvokeAsync<Task>("FromNet", dotNetObjectRef, "Hello"); // return resultString; // } // public async Task<string> CallFunction2() // { // await JSRuntime.InvokeAsync<Task>("FromNet2", dotNetObjectRef, "Hello again"); // return resultString; // } //} protected override async Task OnInitializedAsync() { jsInterop = new JsInterop(JSRuntime); //dotNetObjectRef = DotNetObjectReference.Create(dotNetObject); ruleParams = new List <RuleParams>(); ruleParams.Add(new RuleParams { parameter = RuleParamOptions.price, apply = true, sign1 = "below", sign2 = "between", sign3 = "above", borderVal1 = 400, borderVal2 = 600 }); ruleParams.Add(new RuleParams { parameter = RuleParamOptions.area, apply = false, sign1 = "", sign2 = "", sign3 = "", borderVal1 = 0, borderVal2 = 0 }); }
private async void OnLanguageChanged(object sender, CultureInfo culture) { await GetCurrentMenuItems(); await JsInterop.InvokeVoidAsync("window.AntDesign.DocSearch.localeChange", culture.Name); await InvokeAsync(StateHasChanged); }
private async void OnLanguageChanged(object sender, CultureInfo culture) { _menuItems = await DemoService.GetMenuAsync(); await JsInterop.InvokeVoidAsync("window.AntDesign.DocSearch.init", culture.Name); await InvokeAsync(StateHasChanged); }
protected override async Task OnFirstAfterRenderAsync() { Config.Ref = Ref; thisReference = DotNetObjectReference.Create(this); await JsInterop.InvokeAsync <object>("Orions.CodeMirror.init", new object[] { thisReference, Config }); }
/// <summary> /// 渲染后 /// </summary> /// <param name="firstRender"></param> /// <returns></returns> protected override async Task OnAfterRenderAsync(bool firstRender) { await base.OnAfterRenderAsync(firstRender); if (firstRender) { await JsInterop.BindClickWithoutSelf(Id); } }
protected override async Task OnFirstAfterRenderAsync() { if (ShakaPlayerConfig == null || string.IsNullOrWhiteSpace(ShakaPlayerConfig.Id)) { throw new ArgumentException(nameof(ShakaPlayerConfig)); } await JsInterop.InvokeAsync <object>("Orions.ShakaPlayer.init", new object[] { ShakaPlayerConfig }); }
public async Task SetSizeAsync(double size, bool shouldRender = true) { Size = size; // shouldrender is false when parent SplitArea initially sets size auto to splitpanes without an initial size if (shouldRender) { await JsInterop.SetElementStyleAsync(PaneElement, "flexBasis", SizeStyle); } }
public async Task Login() { await ApiClient.LoginUser(this.Email, this.Password); await JsInterop.SetSessionStorage("email", this.Email); await JsInterop.SetSessionStorage("password", this.Password); Navigate(); }
protected override async Task OnFirstAfterRenderAsync() { await Vm.Init(); var jsonData = Vm.GetJesonDesignData(); thisReference = DotNetObjectReference.Create(this); await JsInterop.InvokeAsync <object>("Orions.FlowDesigner.Init", new object[] { thisReference, jsonData }); }
private async Task SetIndeterminate() { bool indeterminate = Checked == null; if (isIndeterminate != indeterminate) { isIndeterminate = indeterminate; await JsInterop.SetElementProperty(elementReference, "indeterminate", indeterminate); } }
public static void Game_Over() { if (Is_Enabled_Audio) { SoundEffect.bg_sound.pause(); SoundEffect.game_over.play(); } timer.Dispose(); JsInterop.Alert("Game Over"); }
public async Task GetStats() { var email = await JsInterop.GetSessionStorage("email"); var password = await JsInterop.GetSessionStorage("password"); var userId = await ApiClient.GetUserIdWithGivenEmailAndPassword(email, password); this.Words = await ApiClient.GetAllWordsWithGivenUserIdDifficultyAndCategory(userId, this.WordDifficultyStat, this.CategoryStatId); this.State = true; }
/// <summary> /// Creates a new <see cref="JsExecutionContext"/> instance. /// </summary> public JsExecutionContext(JavaScriptRuntime runtime) { _runtime = runtime; _scope = new JsContextScope(_runtime.CreateContext()); _binder = new JsBinder(_scope); _interop = new JsInterop(this, _scope, _binder); _scope.Run(() => { _global = new JsBinding(_scope, _binder, _interop, JavaScriptValue.GlobalObject); }); }
public async Task UpdateZone(string oldZone, string newZone) { if (!string.IsNullOrWhiteSpace(oldZone)) { await JsInterop.InvokeAsync <object>("Orions.MapZone.AddClassById", new object[] { oldZone, _hideElementCSS }); } if (!string.IsNullOrWhiteSpace(newZone)) { await JsInterop.InvokeAsync <object>("Orions.MapZone.RemoveClassById", new object[] { newZone, _hideElementCSS }); } }
protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { if (Parent.Direction == Models.SplitDirection.Horizontal) { await JsInterop.SetElementStyleAsync(PaneElement, "flex-basis", SizeStyle); } else { await JsInterop.SetElementStyleAsync(PaneElement, "height", SizeStyle); } } }
/// <summary> /// Creates a new <see cref="JsModule"/> instance. /// </summary> public JsModule(JsContextScope scope, JsBinder binder, JsInterop interop, string moduleId) { _scope = scope; _binder = binder; _interop = interop; ModuleId = moduleId; // Create JS Representation Module = _scope.Run(() => { var jsValue = JavaScriptValue.CreateObject(); jsValue.AddRef(); return(new JsBinding(_scope, _binder, _interop, jsValue)); }); }
public async Task SetSizeAsync(double size, bool shouldRender = true) { Size = size; // shouldrender is false when parent SplitArea initially sets size auto to splitpanes without an initial size if (shouldRender) { if (Parent.Direction == Models.SplitDirection.Horizontal) { await JsInterop.SetElementStyleAsync(PaneElement, "flex-basis", SizeStyle); } else { await JsInterop.SetElementStyleAsync(PaneElement, "height", SizeStyle); } } }
protected override async Task OnFirstAfterRenderAsync() { thisReference = DotNetObjectReference.Create(this); await JsInterop.InvokeAsync <object>("Orions.MapZone.Init", new object[] { _zoneAreaId, _classNameOnMouseOver, thisReference }); if (!string.IsNullOrEmpty(Zone)) { var zones = Zone.Split(',', StringSplitOptions.RemoveEmptyEntries).Select(it => it.Trim()).ToArray(); foreach (var zone in zones) { await JsInterop.InvokeAsync <object>("Orions.MapZone.RemoveClassById", new object[] { zone, _hideElementCSS }); } } await base.OnInitializedAsync(); }
private async Task NewWord() { var difficulty = SessionClass.wordDifficulty; this.WordDifficulty = difficulty; var categoryId = SessionClass.categoryId; var category = await ApiClient.GetWordCategoryWithGivenId(categoryId); this.CategoryName = category; this.Word = await ApiClient.GetRandomWord(this.WordDifficulty.ToString(), categoryId); this.Email = await JsInterop.GetSessionStorage("email"); this.Password = await JsInterop.GetSessionStorage("password"); game.InitializingWord(this.Word); game.gameTracker.ResetScore(); }
async Task ExportFile() { if (exportAllData) { string jsonString = JsonSerializer.Serialize(DataService.CategoryList, new JsonSerializerOptions { IncludeFields = true, WriteIndented = true }); await JsInterop.SaveAsUTF8("TheLastTime.json", jsonString); } else { ISerializer serializer = new SerializerBuilder().Build(); var dict = DataService.CategoryList.ToDictionary(category => category.Description, category => category.HabitList.Select(habit => habit.Description)); string yamlString = serializer.Serialize(dict); await JsInterop.SaveAsUTF8("TheLastTime.yaml", yamlString); } }
public async Task ShowMainMenu() { await JsInterop.InvokeAsync <object>("Orions.FlowDesigner.ShowMainMenu"); }
public async Task HideCommonMenu() { await JsInterop.InvokeAsync <object>("Orions.FlowDesigner.HideCommonMenu"); }
public async Task RemoveElement() { thisReference = DotNetObjectReference.Create(this); await JsInterop.InvokeAsync <object>("Orions.FlowDesigner.Remove", new object[] { thisReference }); }
public async Task ZoomOut() { await JsInterop.InvokeAsync <object>("Orions.FlowDesigner.ZoomOut"); }