示例#1
0
        protected async Task OnResponseSetKeyChange(UIChangeEventArgs args)
        {
            LocalStorage["ResponseSetKey"] = args.Value.ToString();
            this.ResponseSetKey            = args.Value.ToString();

            await LoadViewModel();
        }
示例#2
0
        public void SelectFaction(UIChangeEventArgs e)
        {
            var factionType = (FactionType)Enum.Parse(typeof(FactionType), e.Value.ToString());

            SelectedFaction = KillTeam.FactionByType(factionType);
            HasSubFactions  = SelectedFaction.HasSubFactions;
        }
示例#3
0
        internal Task SelectAsync(HubConnection connection, string value)
        {
            if (!Events.TryGetValue("change", out var changeEventDescriptor))
            {
                throw new InvalidOperationException("Element does not have a change event.");
            }

            var sleectEventArgs = new UIChangeEventArgs()
            {
                Type  = changeEventDescriptor.EventName,
                Value = value
            };

            var browserDescriptor = new RendererRegistryEventDispatcher.BrowserEventDescriptor()
            {
                BrowserRendererId = 0,
                EventHandlerId    = changeEventDescriptor.EventId,
                EventArgsType     = "change",
                EventFieldInfo    = new EventFieldInfo
                {
                    ComponentId = 0,
                    FieldValue  = value
                }
            };

            return(DispatchEventCore(connection, Serialize(browserDescriptor), Serialize(sleectEventArgs)));
        }
示例#4
0
 protected void HandleOnInput(UIChangeEventArgs e)
 {
     if (Options.ChangeTextOnKeyPress)
     {
         HandleValue(e?.Value);
     }
 }
示例#5
0
 protected void HandleOnInput(UIChangeEventArgs e)
 {
     if (Options.ChangeTextOnKeyPress)
     {
         HandleText(e?.Value?.ToString());
     }
 }
示例#6
0
        protected async Task HandleOnChanged(UIChangeEventArgs e)
        {
            if (IsMultiple)
            {
                // when multiple selection is enabled we need to use javascript to get the list of selected items
                internalMultiValue = await JSRunner.GetSelectedOptions <TValue>(ElementId);

                // changed event must be called before validation
                await SelectedValuesChanged.InvokeAsync(internalMultiValue);

                ParentValidation?.UpdateInputValue(internalMultiValue);
            }
            else
            {
                if (Converters.TryChangeType <TValue>(e.Value, out var value))
                {
                    internalValue = value;
                }
                else
                {
                    internalValue = default;
                }

                // changed event must be called before validation
                await SelectedValueChanged.InvokeAsync(internalValue);

                ParentValidation?.UpdateInputValue(internalValue);
            }
        }
示例#7
0
 void ToppingSelected(UIChangeEventArgs e)
 {
     if (int.TryParse((string)e.Value, out var index) && index >= 0)
     {
         AddTopping(toppings[index]);
     }
 }
示例#8
0
        public void CanCombineBindAndConditionalAttribute()
        {
            // This test represents https://github.com/aspnet/Blazor/issues/624

            // Arrange: Rendered with textbox enabled
            var renderer    = new TestRenderer();
            var component   = new BindPlusConditionalAttributeComponent();
            var componentId = renderer.AssignComponentId(component);

            component.TriggerRender();
            var checkboxChangeEventHandlerId = renderer.Batches.Single()
                                               .ReferenceFrames
                                               .First(frame => frame.FrameType == RenderTreeFrameType.Attribute && frame.AttributeEventHandlerId != 0)
                                               .AttributeEventHandlerId;

            // Act: Toggle the checkbox
            var eventArgs = new UIChangeEventArgs {
                Value = true
            };

            renderer.DispatchEvent(componentId, checkboxChangeEventHandlerId, eventArgs);
            var latestBatch     = renderer.Batches.Last();
            var latestDiff      = latestBatch.DiffsInOrder.Single();
            var referenceFrames = latestBatch.ReferenceFrames;

            // Assert: Textbox's "disabled" attribute was removed
            Assert.Equal(2, renderer.Batches.Count);
            Assert.Equal(componentId, latestDiff.ComponentId);
            Assert.Contains(latestDiff.Edits, edit =>
                            edit.SiblingIndex == 1 &&
                            edit.RemovedAttributeName == "disabled");
        }
 protected void ValidateDistributorName(UIChangeEventArgs e)
 {
     if (Distributor != null)
     {
         Distributor.Name = e.Value.ToString();
     }
     Validate();
 }
示例#10
0
        internal void HandleSizing(UIChangeEventArgs args)
        {
            State.RecordActivity();

            string value = args.Value.ToString();

            BuildClassString(value);
        }
        protected async Task OnTargetCurrencyChanged(UIChangeEventArgs e)
        {
            SelectedTargetCurrency = e.Value.ToString();
            TargetCurrency         = Currencies.First(c => c.Code == SelectedTargetCurrency);
            await CalculateRate();

            StateHasChanged();
        }
 public void SetWarehouseCode(UIChangeEventArgs e)
 {
     if (Distributor != null)
     {
         Distributor.WarehouseCode = e.Value.ToString();
     }
     Validate();
 }
 public void ComboScrollSelectionChanged(UIChangeEventArgs e)
 {
     if (int.TryParse(e.Value.ToString(), out int index))
     {
         SelectedScrollIndex = index;
         UpdateScrollUI();
     }
 }
示例#14
0
 protected void OnChangeBodyFont(UIChangeEventArgs e)
 {
     BodyFont    = (string)e.Value;
     BoldWeights = GetWeightForDropdown(BodyFont);
     BoldWeight  = GetBoldStyle(BodyFont);
     BodyWeights = GetWeightForDropdown(BodyFont);
     BodyWeight  = "400";
 }
示例#15
0
        internal void HandleSizing(UIChangeEventArgs args)
        {
            State.RecordActivity();

            string value = args.Value.ToString();
            var    lines = Math.Max(value.Split('\n').Length, value.Split('\r').Length);

            NewMessageStyle = lines > 1 ? $"--box-height: {2 + ((lines - 1) * 1.48)}rem;" : "";
        }
示例#16
0
        protected void OnSiteGuidChange(UIChangeEventArgs e)
        {
            var selectedValue = e.Value.ToString();

            if (int.TryParse(selectedValue, out int siteGuid))
            {
                AppStateProvider.SiteGuid = siteGuid;
            }
        }
示例#17
0
        protected Task HandleOnInput(UIChangeEventArgs e)
        {
            if (Options.ChangeTextOnKeyPress)
            {
                return(HandleValue(e?.Value));
            }

            return(Task.CompletedTask);
        }
示例#18
0
        protected async Task ChangeHandler(UIChangeEventArgs args)
        {
            await OnChange.InvokeAsync((string)args.Value);

            //await ChangeChanged.InvokeAsync((string)args.Value);
            //if (this.OnChange != null)
            //{
            //    await this.OnChange.Invoke(args);
            //}
        }
示例#19
0
        internal async Task EditOnChange(UIChangeEventArgs args)
        {
            if (!string.IsNullOrWhiteSpace(args.Value.ToString()))
            {
                EditMode = false;
                var message = await GitterApi.EditChatMessage(RoomId, MessageData.Id, args.Value.ToString());

                State.UpdateMessage(message);
            }
        }
示例#20
0
 protected void InputChanged(UIChangeEventArgs args)
 {
     if (!debounceTimer.Enabled)
     {
         StartDebounceTimer();
     }
     else
     {
         ExtendDebounceTimer(args);
     }
 }
示例#21
0
        protected async void ServerTypesClicked(UIChangeEventArgs serverTypeEvent)
        {
            serverList.Clear();
            serverName = string.Empty;

            serverTypesId   = serverTypeEvent.Value.ToString();
            serverTypesName = serverList.FirstOrDefault(s => s.ServerTypeId == Int64.Parse(serverTypesId)).Name;

            serverList = await Http.GetJsonAsync <List <Servers> >("api/ServerTypes/GetServers/" + serverTypesId);

            this.StateHasChanged();
        }
示例#22
0
        string tweetText = string.Empty; //280 characters is maximum length for the tweet text

        async void UpdateScoreAsync(UIChangeEventArgs evt)
        {
            string targetText = (string)evt.Value;

            //Make a real call to Sentiment service
            happiness = await PredictSentimentAsync(targetText);

            string liveSamplesUrl = "https://aka.ms/mlnet-live-samples";

            tweetText = $"I just tried this live ML.NET and Blazor sample for Sentiment Analysis. It was fun! Try it yourself and grab the code!: {liveSamplesUrl} #mlnet #machinelearning #dotnetcore";
            //tweetText = $"I just tested this live ML.NET sample for Sentiment Analysis: Text << {targetText} >> was predicted as {happiness}% positive sentiment. Try it by yourself here!: {liveSamplesUrl}";
        }
示例#23
0
        protected async Task InputHandler(UIChangeEventArgs args)
        {
            await AdjustInputHeightAsync();

            await OnInput.InvokeAsync((string)args.Value);

            //await InputChanged.InvokeAsync((string)args.Value);
            //if (this.OnInput != null)
            //{
            //    await this.OnInput.Invoke(args);
            //}
        }
        protected async void ButtonClicked(UIChangeEventArgs countryEvent)
        {
            cityList.Clear();
            cityName = string.Empty;

            countryId   = countryEvent.Value.ToString();
            countryName = countryList.FirstOrDefault(s => s.CountryId == countryId).CountryName;

            cityList = await Http.GetJsonAsync <List <Cities> >("api/Countries/GetCities/" + countryId);

            this.StateHasChanged();
        }
        public async void UpdateScoreAsync(UIChangeEventArgs evt)
        {
            string targetText = (string)evt.Value;

            //Make a real call to Sentiment service
            CurrentHappiness = await PredictSentimentAsync(targetText);

            AddValue(CurrentHappiness);

            // See issue https://github.com/aspnet/Blazor/issues/519.  This is needed otherwise the binding to happiness isn't updated after the async call for prediction.
            StateHasChanged();
        }
示例#26
0
        protected async void PathChangedHandler(UIChangeEventArgs e)
        {
            if (IsMultiple)
            {
                var files = await JSRunner.GetFilePaths(ElementRef);

                PathChanged?.Invoke(files);
            }
            else
            {
                PathChanged?.Invoke(new string[] { e?.Value?.ToString() });
            }
        }
        protected void OnChangeHandler(UIChangeEventArgs ev)
        {
            if (this.radioGroup != null)
            {
                this.radioGroup.toggleOption(new AntCheckboxOptionType
                {
                    value = this.value,
                    label = this.ChildContent
                });
            }

            OnChange.InvokeAsync(ev);
        }
示例#28
0
        protected async void PathChangedHandler(UIChangeEventArgs e)
        {
            if (IsMultiple)
            {
                InternalValue = await JSRunner.GetFilePaths(ElementRef);
            }
            else
            {
                InternalValue = new string[] { e?.Value?.ToString() }
            };

            PathChanged?.Invoke(InternalValue);
        }
示例#29
0
 protected void OnChangeHandler(UIChangeEventArgs ev)
 {
     if (disabled)
     {
         return;
     }
     if (this.Checked == null)
     {
         bool _checked;
         bool.TryParse(ev.Value.ToString(), out _checked);
         Checked = _checked;
     }
     OnChange.InvokeAsync(ev);
 }
        public async Task TimeChanged(UIChangeEventArgs args)
        {
            // TODO: Simon G - This was pulled in from the Code block in RecurrenceDataEntry.razor but does not appear to be called is it still needed?
            if (EndTime != null)
            {
                return;
            }

            if (this.TimeOfDay > EndTime)
            {
                this.EndTime = this.EndTime.Add(TimeSpan.FromDays(1));
            }
            this.Schedule.Duration = this.EndTime.Subtract(this.TimeOfDay);
        }