aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.SharedUI/ViewModel.cs
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-01-08 19:00:50 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-01-08 19:00:50 +0200
commitdd4560b79e305772debf48cc76c9ba67af61f259 (patch)
tree9351aa19b976573c08cfcaafe6b976aaeda94fcf /Software/Visual_Studio/Tango.SharedUI/ViewModel.cs
parentce039a3181858a2b99bf58f43db90720e26089e1 (diff)
downloadTango-dd4560b79e305772debf48cc76c9ba67af61f259.tar.gz
Tango-dd4560b79e305772debf48cc76c9ba67af61f259.zip
Added code comments for:
SharedUI.
Diffstat (limited to 'Software/Visual_Studio/Tango.SharedUI/ViewModel.cs')
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/ViewModel.cs52
1 files changed, 51 insertions, 1 deletions
diff --git a/Software/Visual_Studio/Tango.SharedUI/ViewModel.cs b/Software/Visual_Studio/Tango.SharedUI/ViewModel.cs
index 0dac0ce48..e83cd3e87 100644
--- a/Software/Visual_Studio/Tango.SharedUI/ViewModel.cs
+++ b/Software/Visual_Studio/Tango.SharedUI/ViewModel.cs
@@ -12,29 +12,55 @@ using Tango.Core;
namespace Tango.SharedUI
{
+ /// <summary>
+ /// Represents an abstract view model.
+ /// </summary>
+ /// <seealso cref="Tango.Core.ExtendedObject" />
+ /// <seealso cref="System.ComponentModel.INotifyDataErrorInfo" />
public abstract class ViewModel : ExtendedObject, INotifyDataErrorInfo
{
- private List<KeyValuePair<String, String>> _currentErrors = new List<KeyValuePair<string, string>>();
+ private List<KeyValuePair<String, String>> _currentErrors = new List<KeyValuePair<string, string>>(); //Holds the current validation errors.
private bool _hasErrors;
+ /// <summary>
+ /// Gets a value that indicates whether the entity has validation errors.
+ /// </summary>
public bool HasErrors
{
get { return _hasErrors; }
set { _hasErrors = value; RaisePropertyChangedAuto(); }
}
+ /// <summary>
+ /// Occurs when the validation errors have changed for a property or for the entire entity.
+ /// </summary>
public event EventHandler<DataErrorsChangedEventArgs> ErrorsChanged;
+ /// <summary>
+ /// Gets the validation errors for a specified property or for the entire entity.
+ /// </summary>
+ /// <param name="propertyName">The name of the property to retrieve validation errors for; or null or <see cref="F:System.String.Empty" />, to retrieve entity-level errors.</param>
+ /// <returns>
+ /// The validation errors for the property or entity.
+ /// </returns>
public virtual IEnumerable GetErrors(string propertyName)
{
return _currentErrors.Where(x => x.Key == propertyName).Select(x => x.Value).ToList();
}
+ /// <summary>
+ /// Invoked the <see cref="ErrorsChanged"/> event.
+ /// </summary>
+ /// <param name="propName">Name of the property.</param>
protected void RaiseError(String propName)
{
ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs(propName));
}
+ /// <summary>
+ /// Validates this view model by <see cref="ValidationAttribute">validation attributes</see>.
+ /// </summary>
+ /// <returns></returns>
protected bool Validate()
{
OnValidating();
@@ -58,16 +84,32 @@ namespace Tango.SharedUI
return !HasErrors;
}
+ /// <summary>
+ /// Called before validating.
+ /// </summary>
protected virtual void OnValidating()
{
}
}
+ /// <summary>
+ /// Represents an abstract view model which expects an <see cref="IView"/> of the specified type T.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <seealso cref="Tango.Core.ExtendedObject" />
+ /// <seealso cref="System.ComponentModel.INotifyDataErrorInfo" />
public abstract class ViewModel<T> : ViewModel where T : IView
{
+ /// <summary>
+ /// Gets or sets the view.
+ /// </summary>
public T View { get; set; }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ViewModel{T}"/> class.
+ /// </summary>
+ /// <param name="view">The view.</param>
public ViewModel(T view)
{
View = view;
@@ -78,6 +120,11 @@ namespace Tango.SharedUI
};
}
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ViewModel{T}"/> class.
+ /// </summary>
+ /// <param name="view">The view.</param>
+ /// <param name="delayed">if set to <c>true</c> waits for the view to be valid before registering for the <see cref="IView.ViewAttached"/> event.</param>
public ViewModel(T view, bool delayed)
{
Task.Factory.StartNew(() =>
@@ -97,6 +144,9 @@ namespace Tango.SharedUI
});
}
+ /// <summary>
+ /// Called when the <see cref="IView"/> is loaded and attached.
+ /// </summary>
protected virtual void OnViewAttached()
{