コード例 #1
0
 public MySound(int _id, string p, bool _loop = false)
 {
     path = p;
     id   = _id;
     loop = _loop;
     JsInterop.InitializeSound(id, path, loop);
 }
コード例 #2
0
 protected override async Task OnAfterRenderAsync(bool firstRender)
 {
     if (firstRender)
     {
         await JsInterop.InvokeVoidAsync("window.AntDesign.DocSearch.init", CurrentLanguage);
     }
 }
コード例 #3
0
        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);
        }
コード例 #4
0
 public void RegisterJsEvents()
 {
     foreach (var item in listDragTarget)
     {
         JsInterop.HandleDrop(jsRuntimeCurrent, item.ElementID, item.ID, new DotNetObjectRef(this));
     }
 }
コード例 #5
0
 protected override async Task OnAfterRenderAsync(bool firstRender)
 {
     if (firstRender)
     {
         await JsInterop.SetElementStyleAsync(PaneElement, "flexBasis", SizeStyle);
     }
 }
コード例 #6
0
        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);
        }
コード例 #7
0
        //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
            });
        }
コード例 #8
0
        private async void OnLanguageChanged(object sender, CultureInfo culture)
        {
            await GetCurrentMenuItems();

            await JsInterop.InvokeVoidAsync("window.AntDesign.DocSearch.localeChange", culture.Name);

            await InvokeAsync(StateHasChanged);
        }
コード例 #9
0
        private async void OnLanguageChanged(object sender, CultureInfo culture)
        {
            _menuItems = await DemoService.GetMenuAsync();

            await JsInterop.InvokeVoidAsync("window.AntDesign.DocSearch.init", culture.Name);

            await InvokeAsync(StateHasChanged);
        }
コード例 #10
0
        protected override async Task OnFirstAfterRenderAsync()
        {
            Config.Ref = Ref;

            thisReference = DotNetObjectReference.Create(this);

            await JsInterop.InvokeAsync <object>("Orions.CodeMirror.init", new object[] { thisReference, Config });
        }
コード例 #11
0
ファイル: Dropdown.razor.cs プロジェクト: loogn/bulmarazor
        /// <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);
            }
        }
コード例 #12
0
        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 });
        }
コード例 #13
0
        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);
            }
        }
コード例 #14
0
        public async Task Login()
        {
            await ApiClient.LoginUser(this.Email, this.Password);

            await JsInterop.SetSessionStorage("email", this.Email);

            await JsInterop.SetSessionStorage("password", this.Password);

            Navigate();
        }
コード例 #15
0
        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 });
        }
コード例 #16
0
        private async Task SetIndeterminate()
        {
            bool indeterminate = Checked == null;

            if (isIndeterminate != indeterminate)
            {
                isIndeterminate = indeterminate;

                await JsInterop.SetElementProperty(elementReference, "indeterminate", indeterminate);
            }
        }
コード例 #17
0
        public static void Game_Over()
        {
            if (Is_Enabled_Audio)
            {
                SoundEffect.bg_sound.pause();
                SoundEffect.game_over.play();
            }

            timer.Dispose();
            JsInterop.Alert("Game Over");
        }
コード例 #18
0
        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;
        }
コード例 #19
0
ファイル: JsExecutionContext.cs プロジェクト: enklu/orchid
        /// <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);
            });
        }
コード例 #20
0
        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 });
            }
        }
コード例 #21
0
 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);
         }
     }
 }
コード例 #22
0
        /// <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));
            });
        }
コード例 #23
0
        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);
                }
            }
        }
コード例 #24
0
        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();
        }
コード例 #25
0
        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();
        }
コード例 #26
0
        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);
            }
        }
コード例 #27
0
 public async Task ShowMainMenu()
 {
     await JsInterop.InvokeAsync <object>("Orions.FlowDesigner.ShowMainMenu");
 }
コード例 #28
0
 public async Task HideCommonMenu()
 {
     await JsInterop.InvokeAsync <object>("Orions.FlowDesigner.HideCommonMenu");
 }
コード例 #29
0
 public async Task RemoveElement()
 {
     thisReference = DotNetObjectReference.Create(this);
     await JsInterop.InvokeAsync <object>("Orions.FlowDesigner.Remove", new object[] { thisReference });
 }
コード例 #30
0
 public async Task ZoomOut()
 {
     await JsInterop.InvokeAsync <object>("Orions.FlowDesigner.ZoomOut");
 }