Exemple #1
0
        /// <summary>
        /// Updates the framework element based on the given property change.
        /// Subclasses can override this method, but typically they can override
        /// individual methods for each particular type of property change.
        /// </summary>
        /// <param name="change">The property change.</param>
        protected virtual void UpdateElement(PropertyChange change)
        {
            if (property == null)
            {
                return;
            }

            property.Row = row;

            if (change.IncludesEditable())
            {
                UpdateEditability();
            }
            if (change.IncludesVisible())
            {
                UpdateVisibility();
            }
            if (change.IncludesRequired() || change.IncludesEditable())
            {
                UpdateRequired();
            }
            if (change.IncludesValidation() || change.IncludesEditable() || change.IncludesVisible())
            {
                UpdateValidation();
            }
        }
 /// <summary>
 /// Constructs property change event arguments.
 /// </summary>
 /// <param name="change">The change or combination of changes that took place.</param>
 /// <param name="oldValue">The old value before the change.</param>
 /// <param name="newValue">The new value after the change.</param>
 /// <param name="row">The data row context, if any.</param>
 public PropertyChangeEventArgs(PropertyChange change, object oldValue, object newValue, DataRow row)
 {
     Change   = change;
     OldValue = oldValue;
     NewValue = newValue;
     Row      = row;
 }
 /// <summary>
 /// Stores specified change to the given property to listen to,
 /// or adds the change to the stored property, if one already exists.
 /// </summary>
 /// <param name="prop">The property to listen to.</param>
 /// <param name="change">The property change to listen to.</param>
 protected void AddPropertyChange(BaseProperty prop, PropertyChange change)
 {
     if (properties.ContainsKey(prop))
     {
         properties[prop] = properties[prop] + change;
     }
     else
     {
         properties[prop] = change;
     }
 }
Exemple #4
0
        /// <summary>
        /// Get a list of property states for the given property using current descriptions.
        /// </summary>
        /// <param name="property">The data property to get the states for.</param>
        /// <param name="states">The combination of property states to return.</param>
        /// <param name="row">Specific data row for list objects, or null for regular data objects.</param>
        public virtual IEnumerable <string> GetStates(DataProperty property, PropertyChange states, DataRow row)
        {
            var state = new HashSet <string>();

            if (property.Visible)
            {
                if (property.Editable)
                {
                    if (property.Required && states.IncludesRequired())
                    {
                        state.Add(Required);
                    }
                    if (property.Modified == true && states.IncludesValue())
                    {
                        state.Add(Modified);
                    }
                    if (states.IncludesValidation())
                    {
                        var err = property.GetValidationErrors(row);
                        if (err?.Errors != null)
                        {
                            if (err.HasErrors())
                            {
                                state.Add(Invalid);
                            }
                            else if (err.Errors.Any(e => e.Severity == ErrorSeverity.Warning))
                            {
                                state.Add(Warning);
                            }
                            else if (err.Errors.Any() || // info?
                                                         // don't mark as valid blank or enum and bool properties, since it's not helpful
                                     !property.IsNull(row) && !(property is EnumProperty) && !(property is BooleanProperty))
                            {
                                state.Add(Valid);
                            }
                        }
                    }
                }
                else if (states.IncludesEditable())
                {
                    state.Add(Readonly);
                }
            }
            else if (states.IncludesVisible())
            {
                state.Add(Hidden);
            }

            return(state);
        }
 /// <summary>
 /// Asynchronously updates the framework element based on the given property change.
 /// Invokes the synchronous version by default, but subclasses can override this method.
 /// </summary>
 /// <param name="change">The property change.</param>
 protected virtual async Task UpdateElementAsync(PropertyChange change)
 {
     UpdateElement(change);
     await Task.CompletedTask;
 }
        /// <summary>
        /// Updates the framework element based on the given property change.
        /// Subclasses can override this method, but typically they can override
        /// individual methods for each particular type of property change.
        /// </summary>
        /// <param name="change">The property change.</param>
        protected virtual void UpdateElement(PropertyChange change)
        {
            if (property == null) return;

            property.Row = row;

            if (change.IncludesEditable()) UpdateEditability();
            if (change.IncludesVisible()) UpdateVisibility();
            if (change.IncludesRequired() || change.IncludesEditable()) UpdateRequired();
            if (change.IncludesValidation() || change.IncludesEditable() || change.IncludesVisible())
                UpdateValidation();
        }
Exemple #7
0
 /// <summary>
 /// Constructs property change event arguments.
 /// </summary>
 /// <param name="change">The change or combination of changes that took place.</param>
 /// <param name="oldValue">The old value before the change.</param>
 /// <param name="newValue">The new value after the change.</param>
 public PropertyChangeEventArgs(PropertyChange change, object oldValue, object newValue)
 {
     this.change   = change;
     this.oldValue = oldValue;
     this.newValue = newValue;
 }
Exemple #8
0
        /// <summary>
        /// Get space-delimited string with the property states using current descriptions.
        /// </summary>
        /// <param name="property">The data property to get the states for.</param>
        /// <param name="states">The combination of property states to return.</param>
        /// <param name="row">Specific data row for list objects, or null for regular data objects.</param>
        public virtual string GetStateDescription(DataProperty property, PropertyChange states, DataRow row)
        {
            var propertyStates = GetStates(property, states, row);

            return(string.Join(" ", propertyStates));
        }
 /// <summary>
 /// Constructs property change event arguments.
 /// </summary>
 /// <param name="change">The change or combination of changes that took place.</param>
 /// <param name="oldValue">The old value before the change.</param>
 /// <param name="newValue">The new value after the change.</param>
 public PropertyChangeEventArgs(PropertyChange change, object oldValue, object newValue)
 {
     this.change = change;
     this.oldValue = oldValue;
     this.newValue = newValue;
 }