Files
DP44/DTS Viewer/DTS.Viewer/ViewModel/MenuViewModel.cs

167 lines
5.9 KiB
C#
Raw Normal View History

2026-04-17 14:55:32 -04:00
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>, 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<Notification> NotificationRequest { get; private set; }
public InteractionRequest<Confirmation> ConfirmationRequest { get; private set; }
/// <summary>
/// Creates a new instance of the TechnologyDomainEditViewModel.
/// </summary>
/// <param name="view">The ShellView View.</param>
/// <param name="regionManager">The logical placeholder defined within the application's UI (in the shell or within views) into which views are displayed.</param>
/// <param name="eventAggregator">The EventAggregator which allows different components to publish/subscribe to events without being coupled to each other.</param>
/// <param name="unityContainer">The unityContainer.</param>
public MenuViewModel(IMenuView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer)
: base(regionManager, eventAggregator, unityContainer)
{
View = view;
View.DataContext = this;
NotificationRequest = new InteractionRequest<Notification>();
ConfirmationRequest = new InteractionRequest<Confirmation>();
EventAggregator = eventAggregator;
UnityContainer = unityContainer;
_regionManager = regionManager;
EventAggregator.GetEvent<RaiseNotification>().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;
}
}
/// <summary>
/// Private Event handler for RaiseNotification event.
/// </summary>
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
///<summary>
///Occurs when a property value changes.
///</summary>
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
/// <summary>
/// Gets the HeaderInfo.
/// </summary>
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();
}
}
}