示例#1
0
        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);
        }
示例#2
0
        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),
                    });
                });
            }
        }
示例#3
0
 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));
 }
示例#4
0
 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);
     }
 }
示例#6
0
 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));
 }
示例#7
0
        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();
                },
            };
        }
示例#8
0
        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);
            });
        }
示例#9
0
 private void Value_OnChangeEvent(object sender, decimal e)
 {
     CurrentValue = SwitchT.FromDecimal(e);
 }
示例#10
0
 protected async Task Decrease()
 {
     CurrentValue = SwitchT.Decrease(CurrentValue, Step, Minimum);
 }
示例#11
0
 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);
 }
示例#14
0
 protected void OnChangedHandler(ChangeEventArgs e)
 {
     CurrentValue = SwitchT.FromBool((bool)e.Value);
 }