using System; using System.ComponentModel; using System.Threading.Tasks; using DTS.Common.Events; using DTS.Common.Interface; using Microsoft.Practices.Prism.Events; using Microsoft.Practices.Prism.Interactivity.InteractionRequest; using Microsoft.Practices.Prism.Regions; using Microsoft.Practices.Unity; using DTS.Common.Classes; using DTS.Common; using DTS.Common.Base; namespace DTS.Viewer { public class MenuViewModel : BaseViewModel, IMenuViewModel { public IMenuView View { get; private set; } private IShellViewModel Parent { get; set; } private IEventAggregator EventAggregator { get; set; } private IRegionManager _regionManager; private IUnityContainer UnityContainer { get; set; } public InteractionRequest NotificationRequest { get; private set; } public InteractionRequest ConfirmationRequest { get; private set; } /// /// Creates a new instance of the TechnologyDomainEditViewModel. /// /// The ShellView View. /// 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 MenuViewModel(IMenuView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer) : base(regionManager, eventAggregator, unityContainer) { View = view; View.DataContext = this; NotificationRequest = new InteractionRequest(); ConfirmationRequest = new InteractionRequest(); EventAggregator = eventAggregator; UnityContainer = unityContainer; _regionManager = regionManager; EventAggregator.GetEvent().Subscribe(OnRaiseNotification); } public override void Initialize() { //Load stuff int i = 10; } public override void Initialize(object parameter) { Parent = (IShellViewModel)parameter; } #region Methods private void CreateViews(Boolean initialize) { try { //var viewDefinition = new ViewDefinition(RegionNames.MainRegion, typeof(IMainWindow), typeof(IMainWindowModel)); //regionManager.AddView(viewDefinition, null); //-------------------------------------------------------------------------------- // Create Views per each region //-------------------------------------------------------------------------------- { var viewDefinition = new ViewDefinition(RegionNames.MainRegion, typeof(IBaseView), typeof(IBaseViewModel)); //_regionManager.AddView(viewDefinition, null); } } catch (Exception ex) { //log errors throw; } } /// /// Private Event handler for RaiseNotification event. /// private void OnRaiseNotification(NotificationContentEventArgs eventArgsWithTitle) { // The NotificationRequest.Raise triggers the Invoke() method of the .Infrastructure.PopupWindowAction object // to show the .Infrastructure.NotificationWindow window // 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 PropertyChanged /// ///Occurs when a property value changes. /// public event PropertyChangedEventHandler PropertyChanged; private void OnPropertyChanged(string propertyName) { PropertyChangedEventHandler eventHandler = this.PropertyChanged; if (eventHandler != null) { eventHandler(this, new PropertyChangedEventArgs(propertyName)); } } #endregion PropertyChanged #region Properties /// /// Gets the HeaderInfo. /// public string HeaderInfo { get { return "MainRegion"; } } #endregion public new bool IsBusy { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } } public override void Activated() { throw new NotImplementedException(); } public new bool IsDirty { get { throw new NotImplementedException(); } } public override void Cleanup() { throw new NotImplementedException(); } public new Task CleanupAsync() { throw new NotImplementedException(); } public override Task InitializeAsync() { throw new NotImplementedException(); } public override Task InitializeAsync(object parameter) { throw new NotImplementedException(); } } }