using System; using System.ComponentModel; using System.Threading.Tasks; using DTS.Common.Base; using DTS.Common.Events; using DTS.Common.Interactivity; using DTS.Common.Interface; using Prism.Events; using Prism.Regions; using Unity; // ReSharper disable CheckNamespace // ReSharper disable NotAccessedField.Local // ReSharper disable UnusedAutoPropertyAccessor.Local // ReSharper disable AutoPropertyCanBeMadeGetOnly.Local namespace DTS.Viewer.Navigation { public class NavigationViewModel : BaseViewModel, INavigationViewModel { public INavigationView NavigationView { get; private set; } private IBaseViewModel Parent { get; set; } private IEventAggregator EventAggregator { get; set; } private IUnityContainer UnityContainer { get; set; } public InteractionRequest NotificationRequest { get; private set; } public new InteractionRequest ConfirmationRequest { get; private set; } /// /// Creates a new instance of the Navigation. /// /// The NavigationView interface. /// The logical placeholder defined within the application's UI (in the shell or within views) into which views are displayed. /// The EventAggregator which allows different components to publish/subscribe to events without being coupled to each other. /// The unityContainer. public NavigationViewModel(INavigationView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer) : base(regionManager, eventAggregator, unityContainer) { NavigationView = view; NavigationView.DataContext = this; NotificationRequest = new InteractionRequest(); ConfirmationRequest = new InteractionRequest(); EventAggregator = eventAggregator; UnityContainer = unityContainer; EventAggregator.GetEvent().Subscribe(OnRaiseNotification); } #region Methods public override void Initialize() { } public override void Initialize(object parameter) { Parent = (IBaseViewModel)parameter; } /// /// Private Event handler for RaiseNotification event. /// private void OnRaiseNotification(NotificationContentEventArgs eventArgsWithTitle) { // Notification object expects a NotificationContentEventArgsWithoutTitle object and a Title string. var eventArgsWithoutTitle = new NotificationContentEventArgs(eventArgsWithTitle.Message, eventArgsWithTitle.MessageDetails, eventArgsWithTitle.Image); NotificationRequest.Raise(new Notification { Content = eventArgsWithoutTitle, Title = eventArgsWithTitle.Title }); } #endregion #region ContextRegion public object ContextNavigationRegion { get => ((NavigationView)NavigationView).NavigationRegion.Content; set { ((NavigationView)NavigationView).NavigationRegion.Content = value; OnPropertyChanged("ContextNavigationRegion"); } } #endregion #region Properties /// ///Occurs when a property value changes. /// public new event PropertyChangedEventHandler PropertyChanged; private new void OnPropertyChanged(string propertyName) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } /// /// Gets the HeaderInfo. /// public string HeaderInfo => "NavigationRegion"; public new bool IsBusy { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } public new bool IsDirty => throw new NotImplementedException(); public new bool IsNavigationIncluded { get; set; } #endregion } }