/// <summary> /// Function to set a property as disabled. /// </summary> /// <param name="propertyName">Name of the property.</param> /// <param name="disabled">TRUE if disabled, FALSE if not.</param> /// <exception cref="System.ArgumentNullException">Thrown when the <paramref name="propertyName"/> is NULL (Nothing in VB.Net).</exception> /// <exception cref="System.ArgumentException">Thrown when the <paramref name="propertyName"/> is empty.</exception> /// <exception cref="System.Collections.Generic.KeyNotFoundException">Thrown when the <paramref name="propertyName"/> does not exist as a property for this content.</exception> public void DisableProperty(string propertyName, bool disabled) { if (propertyName == null) { throw new ArgumentNullException("propertyName"); } if (string.IsNullOrWhiteSpace("propertyName")) { throw new ArgumentException(APIResources.GOREDIT_ERR_PARAMETER_MUST_NOT_BE_EMPTY); } if (!TypeDescriptor.Contains(propertyName)) { throw new KeyNotFoundException(string.Format(APIResources.GOREDIT_ERR_PROPERTY_NOT_FOUND, propertyName)); } if (!HasProperties) { return; } TypeDescriptor[propertyName].IsReadOnly = disabled; RefreshProperty(propertyName); }
/// <summary> /// Function to refresh a property in the property grid. /// </summary> /// <param name="propertyName">Name of the property to refresh.</param> /// <exception cref="System.ArgumentNullException">Thrown when the <paramref name="propertyName"/> is NULL (Nothing in VB.Net).</exception> /// <exception cref="System.ArgumentException">Thrown when the <paramref name="propertyName"/> is empty.</exception> /// <exception cref="System.Collections.Generic.KeyNotFoundException">Thrown when the <paramref name="propertyName"/> does not exist as a property for this content.</exception> public void RefreshProperty(string propertyName) { if (propertyName == null) { throw new ArgumentNullException("propertyName"); } if (string.IsNullOrWhiteSpace("propertyName")) { throw new ArgumentException(APIResources.GOREDIT_ERR_PARAMETER_MUST_NOT_BE_EMPTY); } if (!TypeDescriptor.Contains(propertyName)) { throw new KeyNotFoundException(string.Format(APIResources.GOREDIT_ERR_PROPERTY_NOT_FOUND, propertyName)); } if ((!HasProperties) || (OnPropertyRefreshed == null)) { return; } OnPropertyRefreshed(this); }
/// <summary> /// Function to let the interface know that a property has been changed. /// </summary> /// <param name="propertyName">Name of the property that was updated. This value is passed automatically.</param> protected void NotifyPropertyChanged([CallerMemberName] string propertyName = "") { object value = null; if (TypeDescriptor.Contains(propertyName)) { value = TypeDescriptor[propertyName].GetValue <object>(); } NotifyPropertyChanged(propertyName, value); }
/// <summary> /// Function to determine if a content property is available to the UI. /// </summary> /// <param name="propertyName">The name of the property to look up.</param> /// <returns>TRUE if found, FALSE if not.</returns> /// <exception cref="System.ArgumentNullException">Thrown when the <paramref name="propertyName"/> is NULL (Nothing in VB.Net).</exception> /// <exception cref="System.ArgumentException">Thrown when the <paramref name="propertyName"/> is empty.</exception> public bool HasProperty(string propertyName) { if (propertyName == null) { throw new ArgumentNullException("propertyName"); } if (string.IsNullOrWhiteSpace("propertyName")) { throw new ArgumentException(APIResources.GOREDIT_ERR_PARAMETER_MUST_NOT_BE_EMPTY); } return(TypeDescriptor.Contains(propertyName)); }