189 lines
6.4 KiB
Plaintext
189 lines
6.4 KiB
Plaintext
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.ComponentModel.Composition;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using DTS.Common.Events;
|
|
using DTS.Common.Interface;
|
|
using Microsoft.Practices.Prism.Events;
|
|
using Microsoft.Practices.Prism.Interactivity.InteractionRequest;
|
|
using Microsoft.Practices.Unity;
|
|
using DTS.Common.Utils;
|
|
using Microsoft.Practices.Prism.Regions;
|
|
using Microsoft.Practices.Prism.ViewModel;
|
|
using DTS.Common.Base;
|
|
|
|
namespace DTS.Viewer.Loader
|
|
{
|
|
[Export(typeof(IShellView))]
|
|
[PartCreationPolicy(CreationPolicy.Shared)]
|
|
public class ShellViewModel : IShellViewModel
|
|
{
|
|
//BaseViewModel<ShellViewModel>,
|
|
public IShellView View { get; private 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 ShellViewModel(IShellView 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);
|
|
//LoadViewer();
|
|
}
|
|
#region Methods
|
|
public void Initialize()
|
|
{
|
|
}
|
|
|
|
public void Initialize(object parameter)
|
|
{
|
|
}
|
|
|
|
public void Activated()
|
|
{
|
|
}
|
|
|
|
|
|
/// <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 });
|
|
}
|
|
private void LoadViewer()
|
|
{
|
|
|
|
var viewerView = _unityContainer.Resolve<IViewerShellView>();
|
|
var viewerViewModel = _unityContainer.Resolve<IViewerShellViewModel>();
|
|
|
|
viewerView.DataContext = viewerViewModel;
|
|
((ShellView)viewerView).Visibility = Visibility.Visible;
|
|
}
|
|
|
|
public void Cleanup()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public Task CleanupAsync()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public Task InitializeAsync()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public Task InitializeAsync(object parameter)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
#endregion
|
|
|
|
#region ContextRegion
|
|
/// <summary>
|
|
/// Returns all regions in the main grid
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<FrameworkElement> GetRegions()
|
|
{
|
|
var items = new List<FrameworkElement>();
|
|
Utils.GetChildrenByName(((ShellView)View).MainShell, "Region", ref items);
|
|
return items;
|
|
}
|
|
|
|
public Object ContextMainRegion
|
|
{
|
|
get { return ((ShellView)View).MainRegion.Content; }
|
|
set { ((ShellView)View).MainRegion.Content = value; OnPropertyChanged("ContextMainRegion"); }
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
private double _width;
|
|
public double Width { get { return _width; } set { _width = value; }}
|
|
|
|
private double _height;
|
|
public double Height { get { return _height; } set { _height = value; } }
|
|
|
|
private bool _isMenuIncluded = false;
|
|
public bool IsMenuIncluded
|
|
{
|
|
get { return _isMenuIncluded; }
|
|
set
|
|
{
|
|
_isMenuIncluded = value;
|
|
OnPropertyChanged("IsMenuIncluded");
|
|
}
|
|
}
|
|
private bool _isNavigationIncluded = false;
|
|
public bool IsNavigationIncluded
|
|
{
|
|
get { return _isNavigationIncluded; }
|
|
set
|
|
{
|
|
_isNavigationIncluded = value;
|
|
OnPropertyChanged("IsNavigationIncluded");
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Gets the HeaderInfo.
|
|
/// </summary>
|
|
public string HeaderInfo { get { return "MainRegion"; } }
|
|
|
|
public bool IsBusy { get; set; }
|
|
|
|
|
|
|
|
public bool IsDirty { get; }
|
|
|
|
///<summary>
|
|
///Occurs when a property value changes.
|
|
///</summary>
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
private void OnPropertyChanged(string propertyName)
|
|
{
|
|
var eventHandler = PropertyChanged;
|
|
if (eventHandler != null)
|
|
{
|
|
eventHandler(this, new PropertyChangedEventArgs(propertyName));
|
|
}
|
|
}
|
|
#endregion Properties
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|