| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using Prism.Commands;
- using Prism.Mvvm;
- using Prism.Services.Dialogs;
- namespace OHV.Module.Interactivity
- {
- public class NotificationViewModel : BindableBase, IDialogAware
- {
- private Visibility errorVisibillity;
- public Visibility ErrorVisibillity
- {
- get { return errorVisibillity; }
- set { if (SetProperty(ref this.errorVisibillity, value)){ } }
- }
- private Visibility okVisibillity;
- public Visibility OKVisibillity
- {
- get { return okVisibillity; }
- set { if (SetProperty(ref this.okVisibillity, value)) { } }
- }
- private DelegateCommand<string> _closeDialogCommand;
- public DelegateCommand<string> CloseDialogCommand =>
- _closeDialogCommand ?? (_closeDialogCommand = new DelegateCommand<string>(CloseDialog));
- private string _message;
- public string Message
- {
- get { return _message; }
- set { SetProperty(ref _message, value); }
- }
- private string _title = "Notification";
- public string Title
- {
- get { return _title; }
- set { SetProperty(ref _title, value); }
- }
- public event Action<IDialogResult> RequestClose;
- public NotificationViewModel()
- {
- }
- protected virtual void CloseDialog(string parameter)
- {
- ButtonResult result = ButtonResult.None;
- if (parameter?.ToLower() == "true")
- result = ButtonResult.OK;
- else if (parameter?.ToLower() == "false")
- result = ButtonResult.Cancel;
- RaiseRequestClose(new DialogResult(result));
- }
- public virtual void RaiseRequestClose(IDialogResult dialogResult)
- {
- RequestClose?.Invoke(dialogResult);
- }
- public bool CanCloseDialog()
- {
- return true;
- }
- public void OnDialogClosed()
- {
- }
- public void OnDialogOpened(IDialogParameters parameters)
- {
- Message = parameters.GetValue<string>("message");
- var isOK = parameters.GetValue<bool>("Type");
- if (isOK)
- {
- this.ErrorVisibillity = Visibility.Hidden;
- this.OKVisibillity = Visibility.Visible;
- }
- else
- {
- this.ErrorVisibillity = Visibility.Visible;
- this.OKVisibillity = Visibility.Hidden;
- }
- }
- }
- }
|