12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace vCloud.GeneratePackages.Tool.ViewModels
- {
- public abstract class ViewModel : NotificationObject
- {
- private string _description;
- private bool _isVisible = true;
- private bool _isEnable = true;
- private bool _isDisposed;
- /// <summary>
- /// Description, display on UI
- /// </summary>
- public string Description
- {
- get { return _description; }
- set
- {
- if (_description != value)
- {
- _description = value;
- OnPropertyChanged(() => Description);
- }
- }
- }
- /// <summary>
- /// A Flag indicates this UI is visible
- /// </summary>
- public bool IsVisible
- {
- get { return _isVisible; }
- set
- {
- if (_isVisible != value)
- {
- _isVisible = value;
- OnPropertyChanged(() => IsVisible);
- }
- }
- }
- /// <summary>
- /// A Flag indicates this UI is enabled
- /// </summary>
- public bool IsEnabled
- {
- get { return _isEnable; }
- set
- {
- if (_isEnable != value)
- {
- _isEnable = value;
- OnIsEnabledChanged();
- OnPropertyChanged(() => IsEnabled);
- }
- }
- }
- protected virtual void OnIsEnabledChanged()
- {
- //TODO On IsEnabled changed, child class can override implement it
- }
- public void Dispose()
- {
- if (!_isDisposed)
- {
- DoDispose();
- _isDisposed = true;
- }
- }
- protected virtual void DoDispose()
- {
- //implement it in child class
- }
- }
- }
|