Example #1
0
 protected virtual void OnPropertyChanged(string propertyName)
 {
     if (ChangedProperties.ContainsKey(propertyName))
     {
         ChangedProperties[propertyName] = true;
     }
     else
     {
         ChangedProperties[propertyName] = false;
     }
 }
Example #2
0
 public void PropertyChange(string name, object value)
 {
     if (ChangedProperties.ContainsKey(name) == true)
     {
         ChangedProperties[name] = value;
     }
     else
     {
         ChangedProperties.Add(name, value);
     }
 }
      /// <summary>
      /// Paginates the query results.
      /// It sets the Pagination and Page properties.
      /// </summary>
      private List<MovieRecord> Paginate(IEnumerable<MovieRecord> iQueryResults)
      {
         IEnumerable<MovieRecord> results;

         // ChangedProperties is a base class property that contains a list of changed properties.
         // Here it's used to check whether user has changed the Page property value through clicking a pagination link.
         if (ChangedProperties.ContainsKey("Page"))
            results = iQueryResults.Skip(_recordsPerPage * (Page - 1)).Take(_recordsPerPage);
         else
         {
            var pageCount = (int)Math.Ceiling(iQueryResults.Count() / (double)_recordsPerPage);
            Pagination = Enumerable.Range(1, pageCount).ToArray();
            results = iQueryResults.Take(_recordsPerPage);
         }
         return results.ToList();
      }
Example #4
0
        /// <summary>
        /// Sets a specified property value.
        /// </summary>
        /// <param name="name">The property name. May not be null.</param>
        /// <param name="value">The value.</param>
        /// <param name="setChanged">if set to <c>true</c> set the HasChanged property to true.</param>
        /// <param name="forceRaise">if set to <c>true</c> force the raise, even if RaisePropertyChanged is set to false.</param>
        /// <param name="trackChanged">if set to <c>true</c> the property is tracked in the changed properties.</param>
        /// <returns>
        /// true if the value has changed; otherwise false.
        /// </returns>
        protected virtual bool SetProperty(string name, object value, bool setChanged, bool forceRaise, bool trackChanged)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            object oldValue;
            bool   hasOldValue = Properties.TryGetValue(name, out oldValue);

            if (hasOldValue && ArePropertiesEqual(value, oldValue))
            {
                return(false);
            }

            if (!hasOldValue)
            {
                oldValue = GetDefaultValue(name);
                if (ArePropertiesEqual(value, oldValue))
                {
                    return(false);
                }
            }

            if (!OnPropertyChanging(name))
            {
                return(false);
            }

            if (trackChanged && TrackChangedProperties)
            {
                if (!ChangedProperties.ContainsKey(name))
                {
                    ChangedProperties[name] = oldValue;
                }
            }

            bool oldValid = IsValid;

            Properties[name] = value;
            OnPropertyChanged(name, setChanged, forceRaise);
            if (oldValid != IsValid)
            {
                OnPropertyChanged("IsValid");
            }
            return(true);
        }
Example #5
0
 public bool IsPropertyChanged(Columns column)
 {
     return(ChangedProperties.ContainsKey(column.ToString()));
 }