aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.SharedUI/ViewModel.cs
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-08-22 18:33:29 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-08-22 18:33:29 +0300
commit439ee2d80eab039c2dee00f697d2d814ec67247e (patch)
treedccddef098f5960b42bd60ab817e5cf5678f4c07 /Software/Visual_Studio/Tango.SharedUI/ViewModel.cs
parentf3ed76912f8dc895023b2afb92d605ddde1f0c42 (diff)
downloadTango-439ee2d80eab039c2dee00f697d2d814ec67247e.tar.gz
Tango-439ee2d80eab039c2dee00f697d2d814ec67247e.zip
Added IsFree to base ViewModel.
Implemented IsFree on HardwareVersions & ColorLab modules.
Diffstat (limited to 'Software/Visual_Studio/Tango.SharedUI/ViewModel.cs')
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/ViewModel.cs52
1 files changed, 22 insertions, 30 deletions
diff --git a/Software/Visual_Studio/Tango.SharedUI/ViewModel.cs b/Software/Visual_Studio/Tango.SharedUI/ViewModel.cs
index 7d215cd06..d4f26c79d 100644
--- a/Software/Visual_Studio/Tango.SharedUI/ViewModel.cs
+++ b/Software/Visual_Studio/Tango.SharedUI/ViewModel.cs
@@ -23,6 +23,7 @@ namespace Tango.SharedUI
public abstract class ViewModel : ExtendedObject, INotifyDataErrorInfo
{
private List<KeyValuePair<String, String>> _currentErrors = new List<KeyValuePair<string, string>>(); //Holds the current validation errors.
+ private bool _isFreeSet;
private bool _hasErrors;
/// <summary>
@@ -34,6 +35,16 @@ namespace Tango.SharedUI
set { _hasErrors = value; RaisePropertyChangedAuto(); }
}
+ private bool _isFree;
+ /// <summary>
+ /// Gets or sets a value indicating whether this view model is free to perform actions.
+ /// </summary>
+ public bool IsFree
+ {
+ get { return _isFree; }
+ set { _isFree = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); }
+ }
+
private ObservableCollection<String> _validationErrors;
/// <summary>
/// Gets or sets the validation errors.
@@ -50,6 +61,14 @@ namespace Tango.SharedUI
public event EventHandler<DataErrorsChangedEventArgs> ErrorsChanged;
/// <summary>
+ /// Initializes a new instance of the <see cref="ViewModel"/> class.
+ /// </summary>
+ public ViewModel()
+ {
+ IsFree = true;
+ }
+
+ /// <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>
@@ -160,42 +179,15 @@ namespace Tango.SharedUI
/// </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;
- View.ViewAttached += (x, e) =>
- {
- View = (T)e;
- OnViewAttached();
- };
- }
-
/// <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)
+ public ViewModel() : base()
{
- Task.Factory.StartNew(() =>
- {
- while (view == null)
- {
- Thread.Sleep(10);
- }
- }).ContinueWith((c) =>
+ TangoIOC.Default.GetInstanceWhenAvailable<T>((view) =>
{
View = view;
- View.ViewAttached += (x, e) =>
- {
- View = (T)e;
- OnViewAttached();
- };
+ OnViewAttached();
});
}