MapViewModel.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using Prism.Commands;
  2. using Prism.Mvvm;
  3. using Prism.Services.Dialogs;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace OHV.Module.Interactivity.PopUp
  10. {
  11. public class MapViewModel : BindableBase, IDialogAware
  12. {
  13. private DelegateCommand<string> _closeDialogCommand;
  14. public DelegateCommand<string> CloseDialogCommand =>
  15. _closeDialogCommand ?? ( _closeDialogCommand = new DelegateCommand<string>( CloseDialog ) );
  16. private string _title = "MapView";
  17. public string Title
  18. {
  19. get { return this._title; }
  20. set
  21. {
  22. this.SetProperty( ref this._title , value );
  23. }
  24. }
  25. public event Action<IDialogResult> RequestClose;
  26. public MapViewModel( )
  27. {
  28. }
  29. public bool CanCloseDialog( )
  30. {
  31. return true;
  32. }
  33. public void OnDialogClosed( )
  34. {
  35. }
  36. public void OnDialogOpened( IDialogParameters parameters )
  37. {
  38. //throw new NotImplementedException();
  39. }
  40. protected virtual void CloseDialog(string parameter )
  41. {
  42. ButtonResult result = ButtonResult.None;
  43. if ( parameter?.ToLower() == "true" )
  44. result = ButtonResult.OK;
  45. else if ( parameter?.ToLower() == "false" )
  46. result = ButtonResult.Cancel;
  47. RaiseRequestClose( new DialogResult( result ) );
  48. }
  49. public virtual void RaiseRequestClose( IDialogResult dialogResult )
  50. {
  51. RequestClose?.Invoke( dialogResult );
  52. }
  53. }
  54. }