init
This commit is contained in:
@@ -0,0 +1,161 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Threading.Tasks;
|
||||
using DTS.Common.Base;
|
||||
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;
|
||||
|
||||
namespace DTS.Viewer
|
||||
{
|
||||
public class NavigationViewModel : BaseViewModel<INavigationViewModel>, INavigationViewModel
|
||||
{
|
||||
public INavigationView NavigationView { 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 TechnologyDoFrontEditViewModel.
|
||||
/// </summary>
|
||||
/// <param name="view">The NavigationView 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 NavigationViewModel(INavigationView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer)
|
||||
: base(regionManager, eventAggregator, unityContainer)
|
||||
{
|
||||
NavigationView = view;
|
||||
NavigationView.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()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Initialize(object parameter)
|
||||
{
|
||||
Parent = (IShellViewModel)parameter;
|
||||
|
||||
}
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Private Event handler for RaiseNotification event.
|
||||
/// </summary>
|
||||
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
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all regions in the view
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
//public List<FrameworkElement> GetRegions()
|
||||
//{
|
||||
|
||||
// var items = new List<FrameworkElement>();
|
||||
// Utils.GetChildrenByName(((NavigationView)NavigationView).FrontShell, "Region", ref items);
|
||||
// return items;
|
||||
//}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region ContextRegion
|
||||
|
||||
public object ContextNavigationRegion
|
||||
{
|
||||
get { return ((NavigationView)NavigationView).NavigationRegion.Content; }
|
||||
set { ((NavigationView)NavigationView).NavigationRegion.Content = value; OnPropertyChanged("ContextNavigationRegion"); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
///<summary>
|
||||
///Occurs when a property value changes.
|
||||
///</summary>
|
||||
public new event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
private new void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
var eventHandler = PropertyChanged;
|
||||
if (eventHandler != null)
|
||||
{
|
||||
eventHandler(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
#region Properties
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the HeaderInfo.
|
||||
/// </summary>
|
||||
public string HeaderInfo
|
||||
{
|
||||
get { return "NavigationRegion"; }
|
||||
}
|
||||
|
||||
#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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user