Пример #1
0
        private void OnProgress <T>(RowInput <T> rowInput)
            where T : UIElement, new()
        {
            if (Mode == ValidationMode.Explicit)
            {
                return;
            }

            if (HasError(CurrentRow, rowInput.Target))
            {
                return;
            }

            var asyncValidators = Template.RowAsyncValidators;

            for (int i = 0; i < asyncValidators.Count; i++)
            {
                var asyncValidator = asyncValidators[i];
                var sourceColumns  = asyncValidator.SourceColumns;
                if (sourceColumns.Overlaps(rowInput.Target) && IsVisible(CurrentRow, sourceColumns))
                {
                    asyncValidator.Run();
                }
            }
        }
Пример #2
0
            /// <summary>
            /// Adds async validator.
            /// </summary>
            /// <param name="input">The row input.</param>
            /// <param name="validator">The delegate to perform validation.</param>
            /// <param name="displayName">The display name of the validator.</param>
            /// <returns>This template builder for fluent coding.</returns>
            public TemplateBuilder AddAsyncValidator <T>(RowInput <T> input, Func <DataRow, Task <IEnumerable <string> > > validator, string displayName = null)
                where T : UIElement, new()
            {
                if (input == null)
                {
                    throw new ArgumentNullException(nameof(input));
                }

                return(AddAsyncValidator(input.Target, validator, displayName));
            }
Пример #3
0
        /// <summary>
        /// Begins input implementation.
        /// </summary>
        /// <param name="flushingTrigger">The flushing trigger.</param>
        /// <param name="progressiveFlushingTrigger">The progressive flushing trigger.</param>
        /// <returns>The row input.</returns>
        public RowInput <T> BeginInput(Trigger <T> flushingTrigger, Trigger <T> progressiveFlushingTrigger = null)
        {
            VerifyNotSealed();
            if (Input != null)
            {
                throw new InvalidOperationException(DiagnosticMessages.TwoWayBinding_InputAlreadyExists);
            }

            return(Input = new RowInput <T>(this, flushingTrigger, progressiveFlushingTrigger));
        }
Пример #4
0
        void IRowValidation.OnFlushed <T>(RowInput <T> rowInput, bool makeProgress, bool valueChanged)
        {
            if (!makeProgress && !valueChanged)
            {
                return;
            }

            if (valueChanged)
            {
                UpdateAsyncErrors(rowInput.Target);
                if (Mode != ValidationMode.Explicit)
                {
                    Validate(CurrentRow, false);
                }
            }
            if (UpdateProgress(rowInput, valueChanged, makeProgress))
            {
                OnProgress(rowInput);
            }
            InvalidateView();
        }
Пример #5
0
        internal bool UpdateProgress <T>(RowInput <T> rowInput, bool valueChanged, bool makeProgress)
            where T : UIElement, new()
        {
            Debug.Assert(valueChanged || makeProgress);

            if (_progress == null)
            {
                return(valueChanged);
            }

            var currentRow = _inputManager.CurrentRow;

            Debug.Assert(currentRow != null);
            var sourceColumns = rowInput.Target;

            if (sourceColumns == null || sourceColumns.Count == 0)
            {
                return(false);
            }

            if (makeProgress)
            {
                var columns = GetProgress(_progress, currentRow);
                if (columns == null || columns.IsSupersetOf(sourceColumns))
                {
                    return(valueChanged);
                }
                if (valueChanged || Exists(_valueChanged, currentRow, sourceColumns))
                {
                    _progress[currentRow] = columns.Union(sourceColumns);
                    return(true);
                }
            }
            else
            {
                _valueChanged[currentRow] = GetProgress(_valueChanged, currentRow).Union(sourceColumns);
            }

            return(false);
        }
        /// <summary>
        /// Binds row input validation errors to <see cref="ValidationErrorsControl"/>.
        /// </summary>
        /// <typeparam name="T">The element type of row input.</typeparam>
        /// <param name="source">The source row input.</param>
        /// <returns>The row binding object.</returns>
        public static RowBinding <ValidationErrorsControl> BindToValidationErrorsControl <T>(this RowInput <T> source)
            where T : UIElement, new()
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            return(new RowBinding <ValidationErrorsControl>(
                       onRefresh: (v, p) =>
            {
                var errors = source.GetValidationInfo(p).Errors;
                if (ShouldUpdateItemsSource(v, errors))
                {
                    v.ItemsSource = errors;
                }
            },
                       onSetup: null, onCleanup: null));
        }
 private static RowBinding <InPlaceEditor> MergeIntoInPlaceEditor <TEditing, TInert>(this RowInput <TEditing> rowInput, RowBinding <TInert> inertRowBinding)
     where TEditing : UIElement, new()
     where TInert : UIElement, new()
 {
     Debug.Assert(rowInput != null);
     Debug.Assert(inertRowBinding != null);
     return(InPlaceEditor.AddToInPlaceEditor(rowInput, inertRowBinding));
 }