init
This commit is contained in:
210
DTS Viewer/DTS.Viewer/ViewModel/MainViewModel.cs
Normal file
210
DTS Viewer/DTS.Viewer/ViewModel/MainViewModel.cs
Normal file
@@ -0,0 +1,210 @@
|
||||
using System.ComponentModel;
|
||||
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 MainViewModel : BaseViewModel<IMainViewModel>, IMainViewModel
|
||||
{
|
||||
public IMainView View { get; private set; }
|
||||
private IViewerShellViewModel 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 MainViewModel.
|
||||
/// </summary>
|
||||
/// <param name="view">The MainView 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 Unity container.</param>
|
||||
public MainViewModel(IMainView 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);
|
||||
|
||||
|
||||
_unityContainer.RegisterType<IMenuView, MenuView>();
|
||||
_unityContainer.RegisterType<IMenuViewModel, MenuViewModel>();
|
||||
|
||||
_unityContainer.RegisterType<INavigationView, NavigationView>();
|
||||
_unityContainer.RegisterType<INavigationViewModel, NavigationViewModel>();
|
||||
}
|
||||
|
||||
#region Methods
|
||||
/// <summary>
|
||||
/// Initialize without parameter
|
||||
/// </summary>
|
||||
public override void Initialize()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize with parameter - Parent
|
||||
/// </summary>
|
||||
public override void Initialize(object parameter)
|
||||
{
|
||||
Parent = (IViewerShellViewModel)parameter;
|
||||
Parent.IsMenuIncluded = _isMenuIncluded;
|
||||
Parent.IsNavigationIncluded = _isNavigationIncluded;
|
||||
_eventAggregator.GetEvent<AssemblyListNotification>().Subscribe(OnAssemblyListChange, ThreadOption.PublisherThread, true);
|
||||
View.DataContext = this;
|
||||
}
|
||||
|
||||
public override void Activated()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Display loaded assemblies
|
||||
/// </summary>
|
||||
/// <param name="e">List of loaded assemblies</param>
|
||||
private void OnAssemblyListChange(AssemblyListInfo e)
|
||||
{
|
||||
//var groupListView = _unityContainer.Resolve<IGroupListView>();
|
||||
//var groupListViewModel = _unityContainer.Resolve<IGroupListViewModel>();
|
||||
|
||||
//var asmImage = new List<AssemblyNameImage>();
|
||||
//foreach (var assembly in e.AssemblyList)
|
||||
//{
|
||||
// asmImage.AddRange(from attribute in assembly.GetCustomAttributes()
|
||||
// where attribute.GetType().Name.EndsWith("ImageAttribute")
|
||||
// select new AssemblyNameImage
|
||||
// {
|
||||
// AssemblyGroup = ((ImageAttribute)attribute).GeAssemblyGroup(),
|
||||
// AssemblyName = Regex.Replace(((ImageAttribute)attribute).GeAssemblyName(), "(\\B[A-Z])", " $1"),
|
||||
// AssemblyImage = ((ImageAttribute)attribute).GeAssemblyImage(),
|
||||
|
||||
// });
|
||||
//}
|
||||
//var asmGroups = new List<AssemblyGroups>();
|
||||
//asmGroups.AddRange(from a in asmImage orderby a.SortOrder group a by a.AssemblyGroup into g select new AssemblyGroups { AssemblyGroupName = g.Key, AssemblyList = new List<AssemblyNameImage>(g.ToList()) });
|
||||
|
||||
//foreach (var group in asmGroups)
|
||||
//{
|
||||
// var groupView = new GroupView();
|
||||
// var groupViewModel = new GroupViewModel(groupView, _regionManager, _eventAggregator, _unityContainer)
|
||||
// {
|
||||
// GroupName = @group.AssemblyGroupName,
|
||||
// AssemblyList = @group.AssemblyList
|
||||
// };
|
||||
// groupViewModel.Initialize(groupListViewModel);
|
||||
// groupView.DataContext = groupViewModel;
|
||||
|
||||
// groupListViewModel.GroupList.Add(groupView);
|
||||
//}
|
||||
|
||||
//groupListViewModel.View = groupListView;
|
||||
//groupListViewModel.Initialize(this);
|
||||
//groupListView.DataContext = groupListViewModel;
|
||||
//ContextMainRegion = groupListView;
|
||||
}
|
||||
|
||||
/// <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
|
||||
});
|
||||
}
|
||||
|
||||
///<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
|
||||
|
||||
#region ContextRegion
|
||||
public object ContextMainRegion
|
||||
{
|
||||
get
|
||||
{
|
||||
return null; /* ((MainView)View).MainRegion.Content; */ }
|
||||
set
|
||||
{
|
||||
//((MainView)View).MainRegion.Content = value;
|
||||
//var viewModel = (IBaseViewModel)((IBaseView)value).DataContext;
|
||||
//Parent.IsMenuIncluded = viewModel.IsMenuIncluded;
|
||||
//Parent.IsNavigationIncluded = viewModel.IsNavigationIncluded;
|
||||
OnPropertyChanged("ContextMainRegion");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
//List<IGroupView> _assemblyGroupList = new List<IGroupView>();
|
||||
//public List<IGroupView> AssemblyGroupList
|
||||
//{
|
||||
// get { return _assemblyGroupList; }
|
||||
// set { _assemblyGroupList = value; OnPropertyChanged("AssemblyGroupList"); }
|
||||
//}
|
||||
|
||||
|
||||
|
||||
private bool _isMenuIncluded = false;
|
||||
public new bool IsMenuIncluded
|
||||
{
|
||||
get { return _isMenuIncluded; }
|
||||
set
|
||||
{
|
||||
_isMenuIncluded = value;
|
||||
OnPropertyChanged("IsMenuIncluded");
|
||||
}
|
||||
}
|
||||
private bool _isNavigationIncluded = false;
|
||||
public new bool IsNavigationIncluded
|
||||
{
|
||||
get { return _isNavigationIncluded; }
|
||||
set
|
||||
{
|
||||
_isNavigationIncluded = value;
|
||||
OnPropertyChanged("IsNavigationIncluded");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the HeaderInfo.
|
||||
/// </summary>
|
||||
public string HeaderInfo { get { return "MainRegion"; } }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
166
DTS Viewer/DTS.Viewer/ViewModel/MenuViewModel.cs
Normal file
166
DTS Viewer/DTS.Viewer/ViewModel/MenuViewModel.cs
Normal file
@@ -0,0 +1,166 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
161
DTS Viewer/DTS.Viewer/ViewModel/NavigationViewModel.cs
Normal file
161
DTS Viewer/DTS.Viewer/ViewModel/NavigationViewModel.cs
Normal file
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
188
DTS Viewer/DTS.Viewer/ViewModel/ShellViewModel.cs
Normal file
188
DTS Viewer/DTS.Viewer/ViewModel/ShellViewModel.cs
Normal file
@@ -0,0 +1,188 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using DTS.Common.Base;
|
||||
using DTS.Viewer.View;
|
||||
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;
|
||||
|
||||
namespace DTS.Viewer
|
||||
{
|
||||
[Export(typeof(IShellView))]
|
||||
[PartCreationPolicy(CreationPolicy.Shared)]
|
||||
public class ShellViewModel : NotificationObject, IViewerShellViewModel
|
||||
{
|
||||
//BaseViewModel<ShellViewModel>,
|
||||
public IViewerShellView 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(IViewerShellView 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);
|
||||
|
||||
_unityContainer .RegisterType<IMainView, MainView>();
|
||||
_unityContainer .RegisterType<IMainViewModel, MainViewModel>(new ContainerControlledLifetimeManager());
|
||||
|
||||
}
|
||||
#region Methods
|
||||
public void Initialize()
|
||||
{
|
||||
int i = 10;
|
||||
}
|
||||
|
||||
public void Initialize(object parameter)
|
||||
{
|
||||
int i = 22;
|
||||
}
|
||||
|
||||
public void Initialize(object parameter, object model)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool IBaseViewModel.IsBusy { get; set; }
|
||||
|
||||
public void Activated()
|
||||
{
|
||||
var s = String.Empty;
|
||||
}
|
||||
|
||||
|
||||
/// <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 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 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"; } }
|
||||
#endregion Properties
|
||||
|
||||
///<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));
|
||||
}
|
||||
}
|
||||
public bool IsBusy
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
|
||||
|
||||
public bool IsDirty
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
191
DTS Viewer/DTS.Viewer/ViewModel/ViewerShellViewModel.cs
Normal file
191
DTS Viewer/DTS.Viewer/ViewModel/ViewerShellViewModel.cs
Normal file
@@ -0,0 +1,191 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
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.Unity;
|
||||
using DTS.Common.Utils;
|
||||
using Microsoft.Practices.Prism.Regions;
|
||||
using Microsoft.Practices.Prism.ViewModel;
|
||||
|
||||
namespace DTS.Viewer
|
||||
{
|
||||
[Export(typeof(IShellView))]
|
||||
[PartCreationPolicy(CreationPolicy.Shared)]
|
||||
public class ViewerShellViewModel : NotificationObject, IViewerShellViewModel
|
||||
{
|
||||
//BaseViewModel<ShellViewModel>,
|
||||
public IViewerShellView 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 ViewerShellViewModel(IViewerShellView 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);
|
||||
|
||||
_unityContainer.RegisterType<IViewerMainView, ViewerMainView>();
|
||||
_unityContainer.RegisterType<IViewerMainViewModel, ViewerMainViewModel>(new ContainerControlledLifetimeManager());
|
||||
|
||||
}
|
||||
#region Methods
|
||||
public void Initialize()
|
||||
{
|
||||
|
||||
int i = 10;
|
||||
}
|
||||
|
||||
public void Initialize(object parameter)
|
||||
{
|
||||
int i = 22;
|
||||
}
|
||||
|
||||
public void Initialize(object parameter, object model)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Activated()
|
||||
{
|
||||
var s = String.Empty;
|
||||
}
|
||||
|
||||
|
||||
/// <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 ContextRegion
|
||||
/// <summary>
|
||||
/// Returns all regions in the main grid
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<FrameworkElement> GetRegions()
|
||||
{
|
||||
var items = new List<FrameworkElement>();
|
||||
Utils.GetChildrenByName(((ViewerShellView)View).MainShell, "Region", ref items);
|
||||
return items;
|
||||
}
|
||||
|
||||
public Object ContextMainRegion
|
||||
{
|
||||
get => ((ViewerShellView)View).MainRegion.Content;
|
||||
set { ((ViewerShellView)View).MainRegion.Content = value; OnPropertyChanged("ContextMainRegion"); }
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
private bool _isMenuIncluded = false;
|
||||
public bool IsMenuIncluded
|
||||
{
|
||||
get => _isMenuIncluded;
|
||||
set
|
||||
{
|
||||
_isMenuIncluded = value;
|
||||
OnPropertyChanged("IsMenuIncluded");
|
||||
}
|
||||
}
|
||||
private bool _isNavigationIncluded = false;
|
||||
public bool IsNavigationIncluded
|
||||
{
|
||||
get => _isNavigationIncluded;
|
||||
set
|
||||
{
|
||||
_isNavigationIncluded = value;
|
||||
OnPropertyChanged("IsNavigationIncluded");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isBusy;
|
||||
public bool IsBusy
|
||||
{
|
||||
get => _isBusy;
|
||||
set { _isBusy = value; OnPropertyChanged("IsBusy"); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the HeaderInfo.
|
||||
/// </summary>
|
||||
public string HeaderInfo { get { return "MainRegion"; } }
|
||||
#endregion Properties
|
||||
|
||||
///<summary>
|
||||
///Occurs when a property value changes.
|
||||
///</summary>
|
||||
public new event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
private void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public bool IsDirty
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
void IBasePropertyChanged.OnPropertyChanged(string propertyName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user