VMBase.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. namespace GDNXFD.Alert.Config.ViewModel.Base
  2. {
  3. using GalaSoft.MvvmLight;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Runtime.CompilerServices;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. /// <summary>
  11. /// Custom viewmodel base.
  12. /// </summary>
  13. public class VMBase : ViewModelBase, IDisposable
  14. {
  15. private bool isBusy;
  16. /// <summary>
  17. /// Set or get if the viewmodel is in busy mode (performing server petitions...)
  18. /// </summary>
  19. public bool IsBusy
  20. {
  21. get { return this.isBusy; }
  22. set
  23. {
  24. this.isBusy = value;
  25. RaisePropertyChanged(() => IsBusy);
  26. }
  27. }
  28. /// <summary>
  29. /// Internal dispose called if not overrided
  30. /// </summary>
  31. public void Dispose()
  32. {
  33. this.Dispose(true);
  34. GC.SuppressFinalize(this);
  35. }
  36. /// <summary>
  37. /// RaisePropertyChanged override to implement CallerMemberName
  38. /// </summary>
  39. /// <param name="propertyName"></param>
  40. protected override void RaisePropertyChanged([CallerMemberName]string propertyName = "")
  41. {
  42. base.RaisePropertyChanged(propertyName);
  43. }
  44. /// <summary>
  45. /// Dispose override
  46. /// </summary>
  47. /// <param name="dispose"></param>
  48. protected virtual void Dispose(bool dispose)
  49. {
  50. }
  51. }
  52. }