protected override bool ValidateCurrentValue(TValue value) { if (!base.ValidateCurrentValue(value)) { return(false); } var dateValue = SwitchT.ToDateTimeNull(value); if (dateValue.HasValue) { if (Minimum.HasValue && (EnableTime == true ? (Minimum.Value > dateValue.Value) : (Minimum.Value.Date > dateValue.Value.Date))) { return(false); } if (Maximum.HasValue && (EnableTime == true ? (Maximum.Value < dateValue.Value) : (Maximum.Value.Date < dateValue.Value.Date))) { return(false); } } return(true); }
protected void OnClickIconHandler() { this.InvokeStateHasChanged(); if (!DisableCalendar && !Disabled && !ReadOnly) { CallAfterRender(async() => { dotNetObjectRef ??= CreateDotNetObjectRef(dotNetObject); await JsInvokeAsync <object>("matBlazor.matDatePicker.open", Ref, flatpickrInputRef, dotNetObjectRef, new FlatpickrOptions { EnableTime = this.EnableTime, Enable24hours = this.Enable24hours, EnableSeconds = this.EnableSeconds, EnableWeekNumbers = this.EnableWeekNumbers, DisableMobile = this.DisableMobile, Mode = this.Mode, Position = Position.ToString().ToLower(), DefaultDate = SwitchT.ToDateTimeNull(Value), Minimum = this.EnableTime ? Minimum : Minimum?.Date, Maximum = this.EnableTime ? Maximum : Maximum?.Date, Value = SwitchT.ToDateTimeNull(CurrentValue), }); }); } }
protected override string FormatValueAsString(TValue value) { if (Format == null && EnableTime == false) { return(SwitchT.FormatValueAsString(value, System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern)); } return(SwitchT.FormatValueAsString(value, Format)); }
private TValue ComputeItemValue(TItem obj) { if (ItemValueSelector != null) { return(ItemValueSelector.Invoke(obj)); } return(SwitchT.ParseFromString(obj?.ToString(), Format)); }
protected void ChangeHandler(ChangeEventArgs e) { CurrentValue = SwitchT.FromBoolNull((bool)e.Value, Indeterminate); if (OnValueChanged != null) { OnValueChanged(e); } }
protected IEnumerable <MatAutocompleteItem <TValue, TItem> > GetFilteredCollection(string searchText) { return(Items.Select(x => new MatAutocompleteItem <TValue, TItem>() { Value = ComputeItemValue(x), Item = x }) .Where(x => string.IsNullOrEmpty(searchText) || (SwitchT.FormatValueAsString(x.Value, Format)?.ToLowerInvariant().Contains(searchText?.ToLowerInvariant()) == true)) .Take(NumberOfElementsInPopup ?? DefaultsElementsInPopup)); }
public BaseMatDatePickerInternal() { ClassMapper.Add("mat-date-picker"); ClassMapper.Add("mat-text-field-with-actions-container"); dotNetObject = new MatDatePickerJsHelper() { OnChangeAction = (value) => { var v = value.FirstOrDefault(); CurrentValue = SwitchT.FromDateTimeNull(v); InvokeStateHasChanged(); }, }; }
public BaseMatSlider() { jsHelper = new MatDotNetObjectReference <MatSliderJsHelper>(new MatSliderJsHelper()); jsHelper.Value.OnChangeEvent += Value_OnChangeEvent; ValueMin = SwitchT.GetMinimum(); ValueMax = SwitchT.GetMaximum(); Step = SwitchT.GetStep(); ClassMapper .Add("mat-slider") .Add("mdc-slider") .If("mdc-slider--discrete", () => Discrete) .If("mdc-slider--display-markers", () => Discrete && Markers); CallAfterRender(async() => { await JsInvokeAsync <object>("matBlazor.matSlider.init", Ref, jsHelper.Reference, Immediate); }); }
private void Value_OnChangeEvent(object sender, decimal e) { CurrentValue = SwitchT.FromDecimal(e); }
protected async Task Decrease() { CurrentValue = SwitchT.Decrease(CurrentValue, Step, Minimum); }
protected async Task Increase() { CurrentValue = SwitchT.Increase(CurrentValue, Step, Maximum); }
protected void Decrease() { CurrentValue = SwitchT.Decrease(CurrentValue, Step, Minimum); }
protected void Increase() { CurrentValue = SwitchT.Increase(CurrentValue, Step, Maximum); }
protected void OnChangedHandler(ChangeEventArgs e) { CurrentValue = SwitchT.FromBool((bool)e.Value); }