protected void OnChangeHandler(UIChangeEventArgs ev) { if (this.checkboxGroup != null) { this.checkboxGroup.toggleOption(new AntCheckboxOptionType { value = this.value, label = this.ChildContent }); } OnChange.InvokeAsync(ev); }
private async Task ChangeValue() { if (!_compositionInputting) { if (!EqualityComparer <TValue> .Default.Equals(CurrentValue, _inputValue)) { CurrentValue = _inputValue; if (OnChange.HasDelegate) { await OnChange.InvokeAsync(Value); } } } }
internal void OnCheckboxChanged(string value, bool checkedState) { if (checkedState) { _currentValues.Add(value); } else { _currentValues.Remove(value); } OnChange.InvokeAsync(_currentValues); StateHasChanged(); }
protected async Task DeleteConfirm() { var parameters = new ModalParameters(); parameters.Add(nameof(Table), Table); var resultModal = ModalService.Show <TableDeletionConfirm>("Confirm", parameters); var result = await resultModal.Result; if (!result.Cancelled) { await OnChange.InvokeAsync("List was changed"); } }
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); }
protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { await Mediator.InitBPMN(Id, DiagramXML); Mediator.OnDiagramChange += async(caller, args) => { await OnChange.InvokeAsync(null); EditInProgress = true; StateHasChanged(); }; } }
public async Task ConfirmRevertAsync() { if (!EditInProgress) { return; } await Mediator.SetDiagramXML(Id, DiagramXML); EditInProgress = false; StateHasChanged(); await revertDialogWindow.CloseAsync(); await OnChange.InvokeAsync(null); }
public void RemoveSelection(string key) { var option = ItemsSource.FirstOrDefault(x => x.Key == key); if (option == null) { return; } CascadedEditContext?.NotifyFieldChanged(FieldIdentifier); if (MultiSelect) { if (!SelectedOptions.Contains(option)) { throw new Exception("This option was not already selected."); } if (OnChange.HasDelegate) { OnChange.InvokeAsync(new BFUDropdownChangeArgs(option, false)); } SelectedOptions = SelectedOptions.Where(x => x != option).ToList(); if (SelectedOptionsChanged.HasDelegate) { SelectedOptionsChanged.InvokeAsync(SelectedOptions); } } else { if (SelectedOption != null) { SelectedOption = null; if (OnChange.HasDelegate) { OnChange.InvokeAsync(new BFUDropdownChangeArgs(option, false)); } if (SelectedOptionChanged.HasDelegate) { SelectedOptionChanged.InvokeAsync(SelectedOption); } } } StateHasChanged(); }
public async Task UploadChanged(string id, int progress) { var file = FileList.FirstOrDefault(x => x.Id.Equals(id)); if (file == null) { return; } file.Progress = progress; await InvokeAsync(StateHasChanged); if (OnChange.HasDelegate) { await OnChange.InvokeAsync(_uploadInfo); } }
private async Task Clear() { CurrentValue = default; IsFocused = true; await this.FocusAsync(Ref); if (OnChange.HasDelegate) { await OnChange.InvokeAsync(Value); } else { //Without the delay, focus is not enforced. await Task.Delay(1); } }
protected override async void OnInputAsync(ChangeEventArgs args) { // do not call base method to avoid lost focus //base.OnInputAsync(args); CurrentValueAsString = args.Value.ToString(); if (OnChange.HasDelegate) { await OnChange.InvokeAsync(CurrentValueAsString); } if (AutoSize) { await ChangeSizeAsync(); } }
protected async Task OnKeyUpAsync(KeyboardEventArgs args) { if (!EqualityComparer <TValue> .Default.Equals(CurrentValue, _inputValue)) { CurrentValue = _inputValue; if (OnChange.HasDelegate) { await OnChange.InvokeAsync(Value); } } if (OnkeyUp.HasDelegate) { await OnkeyUp.InvokeAsync(args); } }
protected async Task HandleChangeAsync(ChangeEventArgs args) { var value = args.Value?.ToString(); if (!IsControlled) { ValueState = value; DirtyCheck(ValueState); await InvokeAsync(StateHasChanged); } else if (!object.Equals(value, Value)) { await OnChange.InvokeAsync(args); } }
public void Deactivate(params string[] inactiveKeys) { var selectedKeys = new List <string>(); foreach (var item in Items) { if (item.Key.IsIn(inactiveKeys)) { item.SetActiveInt(false); } else if (item.Active) { selectedKeys.Add(item.Key); } } OnChange.InvokeAsync(selectedKeys.ToArray()); }
/// <summary> /// Called when [checkbox change]. /// </summary> /// <param name="checkbox">The checkbox.</param> /// <returns></returns> internal void OnCheckboxChange(Checkbox checkbox) { var index = _checkboxItems.IndexOf(checkbox); int indexOffset; OneOf <CheckboxOption[], string[]> workWith; if (checkbox.IsFromOptions) { indexOffset = _indexSetOptionsOffset; workWith = Options; } else { indexOffset = _indexConstructedOptionsOffset; workWith = _constructedOptions; } workWith.Switch(opts => { if (opts[index] != null) { opts[index].Checked = checkbox.Checked; } }, opts => { if (checkbox.Checked && !opts[index - indexOffset].IsIn(_selectedValues)) { _selectedValues = _selectedValues.Append(opts[index - indexOffset]); } else { _selectedValues = _selectedValues.Except(new[] { opts[index - indexOffset] }).ToArray(); } }); CurrentValue = _currentValue(); if (OnChange.HasDelegate) { OnChange.InvokeAsync(CurrentValue); } StateHasChanged(); }
public void Activate(params string[] activeKeys) { var selectedKeys = new List <string>(activeKeys.Length); foreach (var item in Items) { if (item.Key.IsIn(activeKeys)) { selectedKeys.Add(item.Key); item.SetActiveInt(true); } else if (this.Accordion) { item.SetActiveInt(false); } } OnChange.InvokeAsync(selectedKeys.ToArray()); }
protected async Task ConfirmSaveAsync() { try { Contract.ReplaceSafely(diagramToSave); await successSnackbar.ShowAsync(); EditInProgress = false; StateHasChanged(); } catch (Exception e) { alertController.AddAlert("Diagram confirm unsuccessful: " + e.Message, AlertScheme.Danger); } await saveDialogWindow.CloseAsync(); await OnChange.InvokeAsync(null); }
protected async Task OnMouseUpAsync(MouseEventArgs args) { if (!EqualityComparer <TValue> .Default.Equals(CurrentValue, _inputValue)) { if (!_compositionInputting) { CurrentValue = _inputValue; if (OnChange.HasDelegate) { await OnChange.InvokeAsync(Value); } } } if (OnMouseUp.HasDelegate) { await OnMouseUp.InvokeAsync(args); } }
private async Task HandleSelected() { foreach (var file in await FileReaderService.CreateReference(_input).EnumerateFilesAsync()) { if (file != null) { var fileInfo = await file.ReadFileInfoAsync(); await using var ms = await file.CreateMemoryStreamAsync(); var content = new MultipartFormDataContent(); content.Add(new StreamContent(ms, Convert.ToInt32(ms.Length)), fileInfo.Name, fileInfo.Name); var path = await UserHttpRepository.UploadFile(content); FileDataUrls.Add(path); await OnChange.InvokeAsync(path); } } }
private async Task MoveItem(MouseEventArgs e, string direction) { var moveKeys = direction == TransferDirection.Right ? _sourceSelectedKeys : _targetSelectedKeys; if (direction == TransferDirection.Left) { _targetKeys.RemoveAll(key => moveKeys.Contains(key)); } else { _targetKeys.AddRange(moveKeys); } InitData(); var oppositeDirection = direction == TransferDirection.Right ? TransferDirection.Left : TransferDirection.Right; HandleSelect(oppositeDirection, new List <string>()); if (!string.IsNullOrEmpty(_leftFilterValue)) { await HandleSearch(new ChangeEventArgs() { Value = _leftFilterValue }, TransferDirection.Left, false); } if (!string.IsNullOrEmpty(_rightFilterValue)) { await HandleSearch(new ChangeEventArgs() { Value = _rightFilterValue }, TransferDirection.Right, false); } MathTitleCount(); if (OnChange.HasDelegate) { await OnChange.InvokeAsync(new TransferChangeArgs(_targetKeys.ToArray(), direction, moveKeys.ToArray())); } }
private async Task HandleSelected() { foreach (var file in await FileReaderService.CreateReference(_input).EnumerateFilesAsync()) { if (file != null) { var fileInfo = await file.ReadFileInfoAsync(); using (var ms = await file.CreateMemoryStreamAsync(4 * 1024)) { var content = new MultipartFormDataContent(); content.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data"); content.Add(new StreamContent(ms, Convert.ToInt32(ms.Length)), "image", fileInfo.Name); ImgUrl = await HouseRepository.UploadImage(content); await OnChange.InvokeAsync(ImgUrl); } } } }
internal void Click(Panel panel) { if (panel == null) { return; } if (this.Accordion && !panel.Active) { this.Items.Where(item => item != panel && item.Active) .ForEach(item => item.SetActiveInt(false)); } panel.SetActiveInt(!panel.Active); var selectedKeys = this.Items.Where(x => x.Active).Select(x => x.Key).ToArray(); OnChange.InvokeAsync(selectedKeys); panel.OnActiveChange.InvokeAsync(panel.Active); }
private async Task HandleSelected(InputFileChangeEventArgs e) { //foreach (var file in await FileReaderService.CreateReference(_input).EnumerateFilesAsync()) //{ // if (file != null) // { // var fileInfo = await file.ReadFileInfoAsync(); // using (var ms = await file.CreateMemoryStreamAsync(4 * 1024)) // { // var content = new MultipartFormDataContent(); // content.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data"); // content.Add(new StreamContent(ms, Convert.ToInt32(ms.Length)), "image", fileInfo.Name); // ImgUrl = await Repository.UploadImage(content, Id, Table); // await OnChange.InvokeAsync(ImgUrl); // } // } //} var imageFiles = e.GetMultipleFiles(); foreach (var imageFile in imageFiles) { if (imageFile != null) { //var resizedFile = await imageFile.RequestImageFileAsync("image/png", 300, 500); using (var ms = imageFile.OpenReadStream(imageFile.Size)) { var content = new MultipartFormDataContent(); content.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data"); content.Add(new StreamContent(ms, Convert.ToInt32(imageFile.Size)), "image", imageFile.Name); ImgUrl = await Repository.UploadImage(content, Id, Table); await OnChange.InvokeAsync(ImgUrl); } } } }
private async Task HandleSelected(ChangeEventArgs changeEventArgs) { foreach (var file in await FileReaderService.CreateReference(_input).EnumerateFilesAsync()) { if (file == null) { continue; } var fileInfo = await file.ReadFileInfoAsync(); await using var ms = await file.CreateMemoryStreamAsync(4 * 1024); var content = new MultipartFormDataContent(); content.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data"); content.Add(new StreamContent(ms, Convert.ToInt32(ms.Length)), "image", fileInfo.Name); ImgUrl = await Repository.UploadAdImage(content, HttpClientFactory.CreateClient(Configuration["Service:Api:AnonymousApiName"]), NavigationManager); Console.WriteLine($"Upload Ad Image {ImgUrl}"); await OnChange.InvokeAsync(ImgUrl); } }
public void AddSelection(string key) { if (MultiSelect) { if (SelectedKeys.Contains(key)) { throw new Exception("This key was already selected."); } if (OnChange.HasDelegate) { OnChange.InvokeAsync(new BFUDropdownChangeArgs(key, true)); } SelectedKeys.Add(key); if (SelectedKeysChanged.HasDelegate) { SelectedKeysChanged.InvokeAsync(SelectedKeys); } } else { if (SelectedKey != key) { SelectedKey = key; if (OnChange.HasDelegate) { OnChange.InvokeAsync(new BFUDropdownChangeArgs(key, true)); } if (SelectedKeyChanged.HasDelegate) { SelectedKeyChanged.InvokeAsync(SelectedKey); } } isOpen = false; } StateHasChanged(); }
public void RemoveSelection(string key) { if (MultiSelect) { if (!SelectedKeys.Contains(key)) { throw new Exception("This key was not already selected."); } if (OnChange.HasDelegate) { OnChange.InvokeAsync(new BFUDropdownChangeArgs(key, false)); } SelectedKeys.Remove(key); //this used to be following the next command. A bug? I moved it here... if (SelectedKeysChanged.HasDelegate) { SelectedKeysChanged.InvokeAsync(SelectedKeys); } } else { if (SelectedKey != null) { SelectedKey = null; if (OnChange.HasDelegate) { OnChange.InvokeAsync(new BFUDropdownChangeArgs(key, false)); } if (SelectedKeyChanged.HasDelegate) { SelectedKeyChanged.InvokeAsync(SelectedKey); } } } StateHasChanged(); }
private async Task HandleSelected(InputFileChangeEventArgs e) { var imageFile = e.File; if (imageFile is null) { return; } fileUploadMessage = imageFile.Name; var resizedFile = await imageFile.RequestImageFileAsync("image/png", 300, 500); using var ms = resizedFile.OpenReadStream(resizedFile.Size); var content = new MultipartFormDataContent(); content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data"); content.Add(new StreamContent(ms, Convert.ToInt32(resizedFile.Size)), "image", imageFile.Name); ImgUrl = await Repository.UploadImage(content); await OnChange.InvokeAsync(ImgUrl); }
public void RemoveSelection(string key) { var option = ItemsSource.FirstOrDefault(x => x.Key == key); if (option == null) { return; } if (MultiSelect) { if (!SelectedOptions.Contains(option)) { throw new Exception("This option was not already selected."); } if (OnChange.HasDelegate) { OnChange.InvokeAsync(new BFUDropdownChangeArgs(option, false)); } SelectedOptions = SelectedOptions.Where(x => x != option).ToList(); if (SelectedOptionsChanged.HasDelegate) { SelectedOptionsChanged.InvokeAsync(SelectedOptions); } //if (!SelectedKeys.Contains(key)) // throw new Exception("This key was not already selected."); //if (OnChange.HasDelegate) // OnChange.InvokeAsync(new BFUDropdownChangeArgs(key, false)); //SelectedKeys.Remove(key); //this used to be following the next command. A bug? I moved it here... //if (SelectedKeysChanged.HasDelegate) // SelectedKeysChanged.InvokeAsync(SelectedKeys); } else { if (SelectedOption != null) { SelectedOption = null; if (OnChange.HasDelegate) { OnChange.InvokeAsync(new BFUDropdownChangeArgs(option, false)); } if (SelectedOptionChanged.HasDelegate) { SelectedOptionChanged.InvokeAsync(SelectedOption); } } //if (SelectedKey != null) //{ // SelectedKey = null; // if (OnChange.HasDelegate) // OnChange.InvokeAsync(new BFUDropdownChangeArgs(key, false)); // if (SelectedKeyChanged.HasDelegate) // SelectedKeyChanged.InvokeAsync(SelectedKey); //} } StateHasChanged(); }
public void AddSelection(string key) { var option = ItemsSource.FirstOrDefault(x => x.Key == key); if (option == null) { return; } if (MultiSelect) { if (SelectedOptions.Contains(option)) { throw new Exception("This option was already selected somehow."); } if (OnChange.HasDelegate) { OnChange.InvokeAsync(new BFUDropdownChangeArgs(option, true)); } SelectedOptions = SelectedOptions.Append(option).ToList(); if (SelectedOptionsChanged.HasDelegate) { SelectedOptionsChanged.InvokeAsync(SelectedOptions); } //if (SelectedKeys.Contains(key)) // throw new Exception("This key was already selected."); //if (OnChange.HasDelegate) // OnChange.InvokeAsync(new BFUDropdownChangeArgs(key, true)); //SelectedKeys.Add(key); //if (SelectedKeysChanged.HasDelegate) // SelectedKeysChanged.InvokeAsync(SelectedKeys); } else { if (SelectedOption != option) { SelectedOption = option; if (OnChange.HasDelegate) { OnChange.InvokeAsync(new BFUDropdownChangeArgs(option, true)); } if (SelectedOptionChanged.HasDelegate) { SelectedOptionChanged.InvokeAsync(SelectedOption); } } isOpen = false; //if (SelectedKey!= key) //{ // SelectedKey = key; // if (OnChange.HasDelegate) // OnChange.InvokeAsync(new BFUDropdownChangeArgs(key, true)); // if (SelectedKeyChanged.HasDelegate) // SelectedKeyChanged.InvokeAsync(SelectedKey); //} //isOpen = false; } StateHasChanged(); }
public async void OnChangeEvent(SortableJSEvent e) { await OnChange.InvokeAsync(new SortableEvent <TItem>(this, e)); }