protected void OnInput(ChangeEventArgs args, int index = 0) { if (index != 0) { throw new ArgumentOutOfRangeException("DatePicker should have only single picker."); } if (args == null) { return; } if (!_duringManualInput) { _duringManualInput = true; _cacheDuringInput = Value; } if (FormatAnalyzer.TryPickerStringConvert(args.Value.ToString(), out TValue changeValue, IsNullable)) { CurrentValue = changeValue; GetIfNotNull(changeValue, (notNullValue) => { PickerValues[0] = notNullValue; }); StateHasChanged(); } }
protected void OnInput(ChangeEventArgs args, int index = 0) { if (args == null) { return; } var array = Value as Array; if (!_duringManualInput) { _duringManualInput = true; _cacheDuringInput = array.GetValue(index) as DateTime?; _pickerValueCache = PickerValues[index]; } if (FormatAnalyzer.TryPickerStringConvert(args.Value.ToString(), out DateTime changeValue, false)) { array.SetValue(changeValue, index); ChangePickerValue(changeValue, index); if (_isNotifyFieldChanged && (Form?.ValidateOnChange == true)) { EditContext?.NotifyFieldChanged(FieldIdentifier); } StateHasChanged(); } }
protected void OnInput(ChangeEventArgs args, int index = 0) { if (args == null) { return; } var array = Value as Array; if (!_duringManualInput) { _duringManualInput = true; _cacheDuringInput = array.GetValue(index) as DateTime?; _pickerValueCache = PickerValues[index]; } if (FormatAnalyzer.TryPickerStringConvert(args.Value.ToString(), out DateTime changeValue, false)) { array.SetValue(changeValue, index); ChangePickerValue(changeValue, index); StateHasChanged(); } UpdateCurrentValueAsString(); }
private async Task TryApplyInputValue() { if (FormatAnalyzer.TryPickerStringConvert(_inputStart.Value, out TValue changeValue, IsNullable)) { CurrentValue = changeValue; GetIfNotNull(changeValue, (notNullValue) => { PickerValues[0] = notNullValue; }); if (OnChange.HasDelegate) { await OnChange.InvokeAsync(new DateTimeChangedEventArgs { Date = Convert.ToDateTime(changeValue, this.CultureInfo), DateString = GetInputValue(0) }); } } }
private async Task <bool> TryApplyInputValue(int index, string inputValue) { if (FormatAnalyzer.TryPickerStringConvert(inputValue, out DateTime changeValue, false)) { var array = Value as Array; array.SetValue(changeValue, index); var validationSuccess = await ValidateRange(index, changeValue, array); if (OnChange.HasDelegate) { await OnChange.InvokeAsync(new DateRangeChangedEventArgs { Dates = new DateTime?[] { array.GetValue(0) as DateTime?, array.GetValue(1) as DateTime? }, DateStrings = new string[] { GetInputValue(0), GetInputValue(1) } }); } return(validationSuccess); } return(false); }