init
This commit is contained in:
@@ -0,0 +1,526 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using DTS.Common.Base;
|
||||
using DTS.Common.Classes.Viewer.Commands;
|
||||
using DTS.Common.Enums;
|
||||
using DTS.Common.Enums.Sensors;
|
||||
using DTS.Common.Events;
|
||||
using DTS.Common.Interface;
|
||||
using DTS.Common.Utils;
|
||||
using DTS.Viewer.Resources;
|
||||
using Xceed.Wpf.AvalonDock.Layout.Serialization;
|
||||
using System.Globalization;
|
||||
using DTS.Common.Interactivity;
|
||||
using Prism.Regions;
|
||||
using Prism.Events;
|
||||
using Unity;
|
||||
|
||||
// ReSharper disable CheckNamespace
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable NotAccessedField.Local
|
||||
// ReSharper disable UnusedMember.Local
|
||||
// ReSharper disable RedundantDefaultMemberInitializer
|
||||
|
||||
namespace DTS.Viewer
|
||||
{
|
||||
public class ExportMainViewModel : BaseViewModel<IExportMainViewModel>, IExportMainViewModel
|
||||
{
|
||||
public IBaseView View { get; set; }
|
||||
public bool Standalone { get; set; }
|
||||
public string SelectedTest { get; set; }
|
||||
public string SelectedDTSFile { get; set; }
|
||||
|
||||
private List<ITestEvent> _selectedEventList = new List<ITestEvent>();
|
||||
|
||||
public List<ITestEvent> SelectedEventList
|
||||
{
|
||||
get => _selectedEventList;
|
||||
set { _selectedEventList = value; OnPropertyChanged("SelectedEventList"); }
|
||||
}
|
||||
public List<string> AvailableTestIds { get; set; }
|
||||
|
||||
private IBaseWindowModel Parent { get; set; }
|
||||
private IEventAggregator _eventAggregator { get; set; }
|
||||
private IUnityContainer _unityContainer { get; set; }
|
||||
|
||||
public InteractionRequest<Notification> NotificationRequest { get; private set; }
|
||||
public new InteractionRequest<Confirmation> ConfirmationRequest { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the ExportMainViewModel.
|
||||
/// </summary>
|
||||
|
||||
/// <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 ExportMainViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer)
|
||||
: base(regionManager, eventAggregator, unityContainer)
|
||||
{
|
||||
NotificationRequest = new InteractionRequest<Notification>();
|
||||
ConfirmationRequest = new InteractionRequest<Confirmation>();
|
||||
|
||||
_eventAggregator = eventAggregator;
|
||||
_unityContainer = unityContainer;
|
||||
View = _unityContainer.Resolve<IExportMainViewGrid>();
|
||||
View.DataContext = this;
|
||||
View.DataContext = this;
|
||||
|
||||
}
|
||||
|
||||
|
||||
#region Methods
|
||||
public void AddSelectedEvents(string groupName, List<ITestEvent> events)
|
||||
{
|
||||
_eventAggregator.GetEvent<BusyIndicatorChangeNotification>().Publish(true);
|
||||
|
||||
foreach (var e in events)
|
||||
{
|
||||
SelectedEventList.Add(e);
|
||||
}
|
||||
|
||||
_eventAggregator.GetEvent<BusyIndicatorChangeNotification>().Publish(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// sets SelectedDataFile and marks it as selected in viewer/model
|
||||
/// 16158 Browse button on View Data tab not functiona
|
||||
/// </summary>
|
||||
public void SelectAndIncludeDataFile(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value)) return;
|
||||
_selectedDataFile = value;
|
||||
_eventAggregator.GetEvent<DataFolderChangedEvent>().Publish(new DataFolderSelectionArg
|
||||
{ Path = string.Empty, File = _selectedDataFile, SetSelected = true, SelectAll = true, ParentVM = this });
|
||||
OnPropertyChanged("SelectedDataFile");
|
||||
}
|
||||
private void OnDataFileSelected(DataFileSelectionArg arg)
|
||||
{
|
||||
if (this != arg.ParentVM) return;
|
||||
SelectAndIncludeDataFile(arg?.File);
|
||||
}
|
||||
private void Subscribe()
|
||||
{
|
||||
|
||||
_eventAggregator.GetEvent<LoadExportModuleEvent>().Subscribe(OnLoadExportModule, ThreadOption.PublisherThread, true);
|
||||
|
||||
_eventAggregator.GetEvent<TestLoadedCountNotification>().Subscribe(OnTestLoadedChanged);
|
||||
_eventAggregator.GetEvent<TestSummaryCountNotification>().Subscribe(OnTestSelectedCountChanged);
|
||||
|
||||
_eventAggregator.GetEvent<GraphLoadedCountNotification>().Subscribe(OnGraphLoadedCountChanged);
|
||||
_eventAggregator.GetEvent<ShiftT0Event>().Subscribe(OnShiftT0Event);
|
||||
_eventAggregator.GetEvent<GraphSelectedEventCountNotification>().Subscribe(OnGraphSelectedCountChanged);
|
||||
_eventAggregator.GetEvent<GraphChannelsReadCompletedNotification>().Subscribe(OnGraphChannelsReadCompleted, ThreadOption.UIThread);
|
||||
_eventAggregator.GetEvent<ViewerSettingsVisibilityChangedEvent>().Subscribe(OnViewerSettingsVisibilityChanged);
|
||||
_eventAggregator.GetEvent<DataFileSelectedEvent>().Subscribe(OnDataFileSelected);
|
||||
_eventAggregator.GetEvent<SaveToPDFRequestedEvent>().Subscribe(OnSaveToPDFRequested);
|
||||
}
|
||||
|
||||
private void OnViewerSettingsVisibilityChanged(Visibility settingsVisibility)
|
||||
{
|
||||
SettingsVisibility = settingsVisibility;
|
||||
}
|
||||
private Visibility _settingsVisibility = Visibility.Visible;
|
||||
public Visibility SettingsVisibility
|
||||
{
|
||||
get => _settingsVisibility;
|
||||
private set
|
||||
{
|
||||
_settingsVisibility = value;
|
||||
OnPropertyChanged("SettingsVisibility");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Initialize without parameter
|
||||
/// </summary>
|
||||
public override void Initialize()
|
||||
{
|
||||
Subscribe();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize with parameter - Parent
|
||||
/// </summary>
|
||||
public override void Initialize(object parameter)
|
||||
{
|
||||
Parent = (IBaseWindowModel)parameter;
|
||||
Parent.IsMenuIncluded = _isMenuIncluded;
|
||||
Parent.IsNavigationIncluded = _isNavigationIncluded;
|
||||
Subscribe();
|
||||
View.DataContext = this;
|
||||
}
|
||||
public override void Activated()
|
||||
{
|
||||
}
|
||||
|
||||
private void OnGraphLoadedCountChanged(GraphLoadedCountNotificationArg arg)
|
||||
{
|
||||
if (this != arg?.ParentVM) return;
|
||||
TotalLoadedGraphs = arg.LoadedCount;
|
||||
}
|
||||
|
||||
private void OnGraphSelectedCountChanged(GraphSelectedEventCountNotificationArg arg)
|
||||
{
|
||||
if (this != arg?.ParentVM) return;
|
||||
TotalSelectedGraphs = arg.SelectedEventCount;
|
||||
}
|
||||
|
||||
private void OnGraphChannelsReadCompleted(GraphChannelsReadCompletedNotificationArgs arg)
|
||||
{
|
||||
if (null == arg) { return; }
|
||||
if ((IGraphView)ContextGraphRegion == null) { return; }
|
||||
if (((IGraphView)ContextGraphRegion).DataContext != arg?.GraphVM) return;
|
||||
|
||||
_eventAggregator.GetEvent<BusyIndicatorChangeNotification>().Publish(!arg.IsReadCompleted);
|
||||
}
|
||||
|
||||
private void OnTestLoadedChanged(TestLoadedCountNotificationArg arg)
|
||||
{
|
||||
if (this != arg?.ParentVM) return;
|
||||
TotalLoadedTests = arg.LoadedCount;
|
||||
}
|
||||
|
||||
private void OnTestSelectedCountChanged(TestSummaryCountNotificationArg arg)
|
||||
{
|
||||
if (this != arg?.ParentVM) return;
|
||||
TotalSelectedTests = arg.SummaryCount;
|
||||
}
|
||||
|
||||
private void OnLoadExportModule(LoadExportModuleArg arg)
|
||||
{
|
||||
IsBusy = true;
|
||||
IsBusyMessage = "Loading export list";
|
||||
|
||||
if (null == ContextGraphRegion) ContextGraphRegion = GetGraphView(this);
|
||||
if (null == ContextTestsRegion) ContextTestsRegion = GetTestDefinitionView(this);
|
||||
if (null == ContextGraphListRegion) ContextGraphListRegion = GetGraphListView(this);
|
||||
|
||||
IsBusy = false;
|
||||
IsBusyMessage = string.Empty;
|
||||
}
|
||||
public void ZoomReset()
|
||||
{
|
||||
_eventAggregator.GetEvent<ResetZoomChangedEvent>().Publish(true);
|
||||
}
|
||||
public void LeftKeyPress()
|
||||
{
|
||||
//inform any other modules and models of a T0 shift
|
||||
_eventAggregator.GetEvent<ShiftT0Event>().Publish(new ShiftT0EventArguments(-1, false, true));
|
||||
}
|
||||
public void RightKeyPress()
|
||||
{
|
||||
//inform any other modules and models of a T0 shift
|
||||
_eventAggregator.GetEvent<ShiftT0Event>().Publish(new ShiftT0EventArguments(1, false, true));
|
||||
}
|
||||
|
||||
|
||||
private void OnShiftT0Event(ShiftT0EventArguments args)
|
||||
{
|
||||
if (args.IsInitialization) { return; }
|
||||
|
||||
if (args.T0Time != 0) { ShowModifications = true; }
|
||||
if (args.T0Steps != 0) { ShowModifications = true; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Views
|
||||
private IGraphView GetGraphView(IBaseViewModel parent)
|
||||
{
|
||||
var view = _unityContainer.Resolve<IGraphView>();
|
||||
var viewModel = _unityContainer.Resolve<IGraphViewModel>();
|
||||
view.DataContext = viewModel;
|
||||
viewModel.Initialize(parent);
|
||||
return view;
|
||||
}
|
||||
private IExportGraphMainView GetGraphListView(IBaseViewModel parent)
|
||||
{
|
||||
var view = _unityContainer.Resolve<IExportGraphMainView>();
|
||||
var viewModel = _unityContainer.Resolve<IExportGraphMainViewModel>();
|
||||
view.DataContext = viewModel;
|
||||
viewModel.Initialize(parent);
|
||||
return view;
|
||||
}
|
||||
private ITestSummaryListView GetTestDefinitionView(IBaseViewModel parent)
|
||||
{
|
||||
var view = _unityContainer.Resolve<ITestSummaryListView>();
|
||||
var viewModel = _unityContainer.Resolve<ITestSummaryListViewModel>();
|
||||
view.DataContext = viewModel;
|
||||
viewModel.Initialize(parent);
|
||||
return view;
|
||||
}
|
||||
#endregion Views
|
||||
|
||||
#region ContextRegion
|
||||
|
||||
private IBaseViewModel _activeContent;
|
||||
public IBaseViewModel ActiveContent { get => _activeContent; set { _activeContent = value; OnPropertyChanged("ActiveContent"); } }
|
||||
|
||||
public object ContextNavigationRegion
|
||||
{
|
||||
get => Standalone ? ((ExportMainView)View).NavigationRegion.Content : ((ExportMainViewGrid)View).NavigationRegion.Content;
|
||||
set { if (Standalone) ((ExportMainView)View).NavigationRegion.Content = value; else ((ExportMainViewGrid)View).NavigationRegion.Content = value; OnPropertyChanged("ContextNavigationRegion"); }
|
||||
}
|
||||
|
||||
#region Graph
|
||||
public object ContextGraphRegion
|
||||
{
|
||||
get => Standalone ? ((ExportMainView)View).GraphRegion.Content : ((ExportMainViewGrid)View).GraphRegion.Content;
|
||||
set { if (Standalone) ((ExportMainView)View).GraphRegion.Content = value; else ((ExportMainViewGrid)View).GraphRegion.Content = value; OnPropertyChanged("ContextGraphRegion"); }
|
||||
}
|
||||
public object ContextGraphListRegion
|
||||
{
|
||||
get => Standalone ? ((ExportMainView)View).GraphListRegion.Content : ((ExportMainViewGrid)View).GraphListRegion.Content;
|
||||
set { if (Standalone) ((ExportMainView)View).GraphListRegion.Content = value; else ((ExportMainViewGrid)View).GraphListRegion.Content = value; OnPropertyChanged("ContextGraphListRegion"); }
|
||||
}
|
||||
#endregion Graph
|
||||
public object ContextTestsRegion
|
||||
{
|
||||
get => Standalone ? ((ExportMainView)View).TestsRegion.Content : ((ExportMainViewGrid)View).TestsRegion.Content;
|
||||
set { if (Standalone) ((ExportMainView)View).TestsRegion.Content = value; else ((ExportMainViewGrid)View).TestsRegion.Content = value; OnPropertyChanged("ContextTestsRegion"); }
|
||||
}
|
||||
public object ContextGraphsRegion
|
||||
{
|
||||
get => Standalone ? ((ExportMainView)View).GraphListRegion.Content : ((ExportMainViewGrid)View).GraphListRegion.Content;
|
||||
set { if (Standalone) ((ExportMainView)View).GraphListRegion.Content = value; else ((ExportMainViewGrid)View).GraphListRegion.Content = value; OnPropertyChanged("ContextGraphsRegion"); }
|
||||
|
||||
}
|
||||
public object ContextPropertyRegion { get; set; }
|
||||
public List<FrameworkElement> GetRegions()
|
||||
{
|
||||
var items = new List<FrameworkElement>();
|
||||
if (Standalone) Utils.GetChildrenByName(((ExportMainView)View).MainShell, "Region", ref items);
|
||||
else Utils.GetChildrenByName(((ExportMainViewGrid)View).MainShell, "Region", ref items);
|
||||
return items;
|
||||
}
|
||||
private readonly object saveLock = new object();
|
||||
private void OnSaveToPDFRequested(string directory)
|
||||
{
|
||||
if (null == (ExportMainViewGrid)View) return;
|
||||
lock (saveLock)
|
||||
{
|
||||
var pdfFileName = DateTime.Now.ToString("M'/'d'/'yyyy", CultureInfo.InvariantCulture).Replace("/", "_") + "_" +
|
||||
DateTime.Now.ToString("h':'mm' 'tt", CultureInfo.InvariantCulture).Replace(":", "_") + "_" + DateTime.Now.Second + "_" +
|
||||
DateTime.Now.Millisecond + ".pdf";
|
||||
var intResult = ((ExportMainViewGrid)View).SaveToPDF(directory, pdfFileName);
|
||||
var output = string.Empty;
|
||||
if (intResult > 0)
|
||||
{
|
||||
//Success
|
||||
output = string.Format(StringResources.SavePDFSuccess, Environment.NewLine,
|
||||
Path.Combine(directory, pdfFileName), Environment.NewLine,
|
||||
Path.Combine(directory, pdfFileName.Replace(".pdf", ".png")));
|
||||
_eventAggregator.GetEvent<PageErrorEvent>().Publish(new PageErrorArg(new string[] { output }, null));
|
||||
}
|
||||
else if (intResult < 0)
|
||||
{
|
||||
//Failure
|
||||
output = StringResources.SavePDFError;
|
||||
_eventAggregator.GetEvent<PageErrorEvent>().Publish(new PageErrorArg(new string[] { output }, null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string ConfigPath { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
#region Test Title
|
||||
|
||||
private string _titleTests = StringResources.TestsDefaultTitle;
|
||||
public string TitleTests
|
||||
{
|
||||
get => _titleTests;
|
||||
set
|
||||
{
|
||||
_titleTests = value;
|
||||
if (Standalone) ((ExportMainView)View).TestRegionPanel.Title = _titleTests;
|
||||
OnPropertyChanged("TitleTests");
|
||||
}
|
||||
}
|
||||
private int _totalSelectedTests = 0;
|
||||
public int TotalSelectedTests
|
||||
{
|
||||
get => _totalSelectedTests;
|
||||
set
|
||||
{
|
||||
_totalSelectedTests = value;
|
||||
TitleTests = StringResources.TestsDefaultTitle + TotalSelectedTests + "/" + TotalLoadedTests;
|
||||
if (_totalSelectedTests == 0) { TitleTestIDs = StringResources.TestIDsDefaultTitle; }
|
||||
OnPropertyChanged("TotalSelectedTests");
|
||||
}
|
||||
}
|
||||
private int _totalLoadedTests = 0;
|
||||
public int TotalLoadedTests
|
||||
{
|
||||
get => _totalLoadedTests;
|
||||
set { _totalLoadedTests = value; TitleTests = StringResources.TestsDefaultTitle + TotalSelectedTests + "/" + TotalLoadedTests; OnPropertyChanged("TotalLoadedTests"); }
|
||||
}
|
||||
#endregion Test Title
|
||||
|
||||
#region Test ID Title
|
||||
private string _titleTestIDs = StringResources.GraphsDefaultTitle;
|
||||
|
||||
public string TitleTestIDs
|
||||
{
|
||||
get => _titleTestIDs;
|
||||
set
|
||||
{
|
||||
_titleTestIDs = value;
|
||||
if (Standalone) ((ExportMainView)View).GraphListPanel.Title = _titleTestIDs;
|
||||
OnPropertyChanged("TitleTestIDs");
|
||||
}
|
||||
}
|
||||
private int _totalSelectedGraphs = 0;
|
||||
public int TotalSelectedGraphs
|
||||
{
|
||||
get => _totalSelectedGraphs;
|
||||
set { _totalSelectedGraphs = value; TitleTestIDs = StringResources.GraphsDefaultTitle + TotalSelectedGraphs + "/" + TotalLoadedGraphs; OnPropertyChanged("TotalSelectedGraphs"); }
|
||||
}
|
||||
private int _totalLoadedGraphs = 0;
|
||||
public int TotalLoadedGraphs
|
||||
{
|
||||
get => _totalLoadedGraphs;
|
||||
set { _totalLoadedGraphs = value; TitleTestIDs = StringResources.GraphsDefaultTitle + TotalSelectedGraphs + "/" + TotalLoadedGraphs; OnPropertyChanged("TotalLoadedGraphs"); }
|
||||
}
|
||||
#endregion Graph Title
|
||||
|
||||
private string _selectedDataFolder = string.Empty;
|
||||
public string SelectedDataFolder
|
||||
{
|
||||
get => _selectedDataFolder;
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(value)) return;
|
||||
|
||||
_selectedDataFolder = value; _eventAggregator.GetEvent<DataFolderChangedEvent>().Publish(new DataFolderSelectionArg { Path = _selectedDataFolder, File = string.Empty, SelectAll = true, ParentVM = this }); OnPropertyChanged("SelectedDataFolder");
|
||||
}
|
||||
}
|
||||
|
||||
public bool DoesUserHaveEditPermission { get; set; } = false;
|
||||
|
||||
private string _selectedDataFile = string.Empty;
|
||||
public string SelectedDataFile
|
||||
{
|
||||
get => _selectedDataFile;
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(value)) return;
|
||||
_selectedDataFile = value; _eventAggregator.GetEvent<DataFolderChangedEvent>().Publish(new DataFolderSelectionArg { Path = string.Empty, File = _selectedDataFile, SelectAll = true, ParentVM = this }); OnPropertyChanged("SelectedDataFile");
|
||||
}
|
||||
}
|
||||
|
||||
public bool _showModifications = false;
|
||||
public bool ShowModifications
|
||||
{
|
||||
get => _showModifications;
|
||||
set { _showModifications = value; OnPropertyChanged("ShowModifications"); }
|
||||
}
|
||||
|
||||
private IsoViewMode _channelCodeViewMode = IsoViewMode.ISOAndUserCode;
|
||||
public IsoViewMode ChannelCodeViewMode
|
||||
{
|
||||
get => _channelCodeViewMode;
|
||||
set { _channelCodeViewMode = value; _eventAggregator.GetEvent<ChannelCodesViewChangedEvent>().Publish(value); OnPropertyChanged("ChannelCodeViewMode"); }
|
||||
}
|
||||
|
||||
private CalibrationBehaviors _calibrationBehaviorSetting = CalibrationBehaviors.NonLinearIfAvailable;
|
||||
public CalibrationBehaviors CalibrationBehaviorSetting
|
||||
{
|
||||
get => _calibrationBehaviorSetting;
|
||||
set { _calibrationBehaviorSetting = value; _eventAggregator.GetEvent<ExportCalibrationBehaviorSettingChangedEvent>().Publish(value); OnPropertyChanged("CalibrationBehaviorSetting"); }
|
||||
}
|
||||
|
||||
private bool _calibrationBehaviorSettableInViewer = true;
|
||||
public bool CalibrationBehaviorSettableInViewer
|
||||
{
|
||||
get => _calibrationBehaviorSettableInViewer;
|
||||
set
|
||||
{
|
||||
_calibrationBehaviorSettableInViewer = value;
|
||||
_eventAggregator.GetEvent<CalibrationBehaviorSettableInViewerChangedEvent>().Publish(value);
|
||||
OnPropertyChanged("CalibrationBehaviorSettableInViewer");
|
||||
((ExportMainViewGrid)View).graphsTab.IsSelected = true;// !value;
|
||||
}
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Occurs when a property value changes.
|
||||
///</summary>
|
||||
public new event PropertyChangedEventHandler PropertyChanged;
|
||||
private new void OnPropertyChanged(string propertyName) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); }
|
||||
|
||||
private bool _isBusy = false;
|
||||
/// <summary>
|
||||
/// Display or hide Busy Indicator
|
||||
/// </summary>
|
||||
public new bool IsBusy { get => _isBusy; set { _isBusy = value; OnPropertyChanged("IsBusy"); } }
|
||||
|
||||
private string _isBusyMessage = string.Empty;
|
||||
/// <summary>
|
||||
/// Busy Message text
|
||||
/// </summary>
|
||||
public new string IsBusyMessage { get => _isBusyMessage; set { _isBusyMessage = value; OnPropertyChanged("IsBusyMessage"); } }
|
||||
|
||||
private bool _isMenuIncluded = false;
|
||||
public new bool IsMenuIncluded { get => _isMenuIncluded; set { _isMenuIncluded = value; OnPropertyChanged("IsMenuIncluded"); } }
|
||||
private bool _isNavigationIncluded = false;
|
||||
public new bool IsNavigationIncluded { get => _isNavigationIncluded; set { _isNavigationIncluded = value; OnPropertyChanged("IsNavigationIncluded"); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the HeaderInfo.
|
||||
/// </summary>
|
||||
public string HeaderInfo => "MainRegion";
|
||||
|
||||
#endregion
|
||||
|
||||
#region Commands
|
||||
|
||||
#region LoadLayoutCommand
|
||||
RelayCommand _loadLayoutCommand = null;
|
||||
public ICommand LoadLayoutCommand => _loadLayoutCommand ?? (_loadLayoutCommand = new RelayCommand(OnLoadLayout, CanLoadLayout));
|
||||
|
||||
private bool CanLoadLayout(object parameter)
|
||||
{
|
||||
return File.Exists(@".\DataProViewerAvalonDock.config");
|
||||
}
|
||||
|
||||
private void OnLoadLayout(object parameter)
|
||||
{
|
||||
var layoutSerializer = new XmlLayoutSerializer(((ExportMainView)View).DockManager);
|
||||
//Here I've implemented the LayoutSerializationCallback just to show
|
||||
// a way to feed layout desarialization with content loaded at runtime
|
||||
//Actually I could in this case let AvalonDock to attach the contents
|
||||
//from current layout using the content ids
|
||||
//LayoutSerializationCallback should anyway be handled to attach contents
|
||||
//not currently loaded
|
||||
layoutSerializer.LayoutSerializationCallback += (s, e) =>
|
||||
{
|
||||
};
|
||||
layoutSerializer.Deserialize(@".\DataProViewerAvalonDock.config");
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region SaveLayoutCommand
|
||||
RelayCommand _saveLayoutCommand = null;
|
||||
public ICommand SaveLayoutCommand => _saveLayoutCommand ?? (_saveLayoutCommand = new RelayCommand(OnSaveLayout, CanSaveLayout));
|
||||
|
||||
private bool CanSaveLayout(object parameter)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private void OnSaveLayout(object parameter)
|
||||
{
|
||||
var layoutSerializer = new XmlLayoutSerializer(((ExportMainView)View).DockManager);
|
||||
layoutSerializer.Serialize(@".\AvalonDock.config");
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
311
DTS Viewer/DTS.Viewer/Modules/Main/ViewModel/MainViewModel.cs
Normal file
311
DTS Viewer/DTS.Viewer/Modules/Main/ViewModel/MainViewModel.cs
Normal file
@@ -0,0 +1,311 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows;
|
||||
using DTS.Common;
|
||||
using DTS.Common.Base;
|
||||
using DTS.Common.Events;
|
||||
using DTS.Common.Interface;
|
||||
using DTS.Common.Utils;
|
||||
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 IBaseView View { get; private set; }
|
||||
|
||||
private IBaseWindowModel Parent { get; set; }
|
||||
private IEventAggregator _eventAggregator { get; set; }
|
||||
private new IRegionManager _regionManager;
|
||||
private IUnityContainer _unityContainer { get; set; }
|
||||
|
||||
public InteractionRequest<Notification> NotificationRequest { get; private set; }
|
||||
public new 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);
|
||||
}
|
||||
|
||||
#region Methods
|
||||
/// <summary>
|
||||
/// Initialize without parameter
|
||||
/// </summary>
|
||||
public override void Initialize()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize with parameter - Parent
|
||||
/// </summary>
|
||||
public override void Initialize(object parameter)
|
||||
{
|
||||
Parent = (IBaseWindowModel)parameter;
|
||||
Parent.IsMenuIncluded = _isMenuIncluded;
|
||||
Parent.IsNavigationIncluded = _isNavigationIncluded;
|
||||
|
||||
_eventAggregator.GetEvent<AssemblyListNotification>().Subscribe(OnAssemblyListChange, ThreadOption.PublisherThread, true);
|
||||
_eventAggregator.GetEvent<BusyIndicatorChangeNotification>().Subscribe(OnBusyIndicatorNotification, 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 assemblyList = new List<AssemblyNameImage>();
|
||||
foreach (var assembly in e.AssemblyList)
|
||||
{
|
||||
assemblyList.AddRange(from attribute in assembly.GetCustomAttributes()
|
||||
where attribute.GetType().Name.EndsWith("ImageAttribute")
|
||||
select new AssemblyNameImage
|
||||
{
|
||||
AssemblyGroup = ((ImageAttribute)attribute).GetAssemblyGroup(),
|
||||
AssemblyName = Regex.Replace(((ImageAttribute)attribute).GetAssemblyName(), "(\\B[A-Z])", " $1"),
|
||||
AssemblyImage = ((ImageAttribute)attribute).GetAssemblyImage(),
|
||||
AssemblyRegion = ((ImageAttribute)attribute).GetAssemblyRegion()
|
||||
});
|
||||
}
|
||||
foreach (var assembly in assemblyList)
|
||||
{
|
||||
switch (assembly.AssemblyRegion)
|
||||
{
|
||||
case eAssemblyRegion.NavigationRegion:
|
||||
break;
|
||||
|
||||
case eAssemblyRegion.GraphRegion:
|
||||
ContextGraphRegion = GetGraphView(Parent);
|
||||
break;
|
||||
case eAssemblyRegion.StatsRegion:
|
||||
|
||||
break;
|
||||
case eAssemblyRegion.CursorRegion:
|
||||
|
||||
break;
|
||||
case eAssemblyRegion.DiagRegion:
|
||||
|
||||
break;
|
||||
case eAssemblyRegion.TestsRegion:
|
||||
break;
|
||||
case eAssemblyRegion.GraphsRegion:
|
||||
|
||||
break;
|
||||
case eAssemblyRegion.LegendRegion:
|
||||
|
||||
break;
|
||||
case eAssemblyRegion.PropertyRegion:
|
||||
ContextPropertyRegion = GetPropertyView(Parent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <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>
|
||||
/// Private Event handler for RaiseNotification event.
|
||||
/// </summary>
|
||||
private void OnBusyIndicatorNotification(bool eventArg)
|
||||
{
|
||||
IsBusy = eventArg;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Views
|
||||
private INavigationView GetNavigationView(IBaseViewModel parent)
|
||||
{
|
||||
var view = _unityContainer.Resolve<INavigationView>();
|
||||
var viewModel = _unityContainer.Resolve<INavigationViewModel>();
|
||||
view.DataContext = viewModel;
|
||||
viewModel.Initialize(parent);
|
||||
return view;
|
||||
}
|
||||
private IPropertyView GetPropertyView(IBaseWindowModel parent)
|
||||
{
|
||||
var view = _unityContainer.Resolve<IPropertyView>();
|
||||
var viewModel = _unityContainer.Resolve<IPropertyViewModel>();
|
||||
view.DataContext = viewModel;
|
||||
viewModel.Initialize(parent);
|
||||
return view;
|
||||
}
|
||||
private IGraphView GetGraphView(IBaseWindowModel parent)
|
||||
{
|
||||
var view = _unityContainer.Resolve<IGraphView>();
|
||||
var viewModel = _unityContainer.Resolve<IGraphViewModel>();
|
||||
view.DataContext = viewModel;
|
||||
viewModel.Initialize(parent);
|
||||
return view;
|
||||
}
|
||||
#endregion Views
|
||||
|
||||
#region ContextRegion
|
||||
public object ContextNavigationRegion
|
||||
{
|
||||
get { return ((MainView)View).NavigationRegion.Content; }
|
||||
set { ((MainView)View).NavigationRegion.Content = value; OnPropertyChanged("ContextNavigationRegion"); }
|
||||
}
|
||||
|
||||
#region Graph
|
||||
public object ContextGraphRegion
|
||||
{
|
||||
get { return ((MainView)View).GraphRegion.Content; }
|
||||
set { ((MainView)View).GraphRegion.Content = value; OnPropertyChanged("ContextGraphsRegion"); }
|
||||
}
|
||||
#endregion Graph
|
||||
public object ContextTestsRegion
|
||||
{
|
||||
get { return ((MainView)View).TestsRegion.Content; }
|
||||
set { ((MainView)View).TestsRegion.Content = value; OnPropertyChanged("ContextTestsRegion"); }
|
||||
}
|
||||
|
||||
public object ContextGraphsRegion
|
||||
{
|
||||
get { return ((MainView)View).GraphsRegion.Content; }
|
||||
set { ((MainView)View).GraphsRegion.Content = value; OnPropertyChanged("ContextGraphsRegion"); }
|
||||
}
|
||||
|
||||
public object ContextLegendRegion
|
||||
{
|
||||
get { return ((MainView)View).LegendRegion.Content; }
|
||||
set { ((MainView)View).LegendRegion.Content = value; OnPropertyChanged("ContextLegendRegion"); }
|
||||
}
|
||||
|
||||
public object ContextDiagRegion
|
||||
{
|
||||
get { return ((MainView)View).DiagRegion.Content; }
|
||||
set { ((MainView)View).DiagRegion.Content = value; OnPropertyChanged("ContextDiagRegion"); }
|
||||
}
|
||||
|
||||
public object ContextStatsRegion
|
||||
{
|
||||
get { return ((MainView)View).StatsRegion.Content; }
|
||||
set { ((MainView)View).StatsRegion.Content = value; OnPropertyChanged("ContextStatsRegion"); }
|
||||
}
|
||||
|
||||
public object ContextCursorRegion
|
||||
{
|
||||
get { return ((MainView)View).CursorRegion.Content; }
|
||||
set { ((MainView)View).CursorRegion.Content = value; OnPropertyChanged("ContextCursorRegion"); }
|
||||
}
|
||||
|
||||
public object ContextPropertyRegion
|
||||
{
|
||||
get { return ((MainView)View).PropertyRegion.Content; }
|
||||
set { ((MainView)View).PropertyRegion.Content = value; OnPropertyChanged("ContextPropertyRegion"); }
|
||||
}
|
||||
|
||||
public List<FrameworkElement> GetRegions()
|
||||
{
|
||||
var items = new List<FrameworkElement>();
|
||||
Utils.GetChildrenByName(((MainView)View).MainShell, "Region", ref items);
|
||||
return items;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
//List<IGroupView> _assemblyGroupList = new List<IGroupView>();
|
||||
//public List<IGroupView> AssemblyGroupList
|
||||
//{
|
||||
// get { return _assemblyGroupList; }
|
||||
// set { _assemblyGroupList = value; OnPropertyChanged("AssemblyGroupList"); }
|
||||
//}
|
||||
|
||||
///<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));
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isBusy = false;
|
||||
public new bool IsBusy
|
||||
{
|
||||
get { return _isBusy; }
|
||||
set { _isBusy = value; OnPropertyChanged("IsBusy"); }
|
||||
}
|
||||
private string _isBusyMessage = string.Empty;
|
||||
public new string IsBusyMessage { get { return _isBusyMessage; } set { _isBusyMessage = value; OnPropertyChanged("IsBusyMessage"); } }
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,626 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Threading;
|
||||
using DTS.Common;
|
||||
using DTS.Common.Base;
|
||||
using DTS.Common.Classes.Viewer.Commands;
|
||||
using DTS.Common.Enums;
|
||||
using DTS.Common.Enums.Sensors;
|
||||
using DTS.Common.Events;
|
||||
using DTS.Common.Interface;
|
||||
using DTS.Common.Utils;
|
||||
using DTS.Common.Settings;
|
||||
using DTS.Viewer.Resources;
|
||||
|
||||
using Xceed.Wpf.AvalonDock.Layout;
|
||||
using Xceed.Wpf.AvalonDock.Layout.Serialization;
|
||||
using System.Globalization;
|
||||
using DTS.Common.Interactivity;
|
||||
using Prism.Regions;
|
||||
using Prism.Events;
|
||||
using Unity;
|
||||
|
||||
// ReSharper disable CheckNamespace
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable NotAccessedField.Local
|
||||
// ReSharper disable UnusedMember.Local
|
||||
// ReSharper disable RedundantDefaultMemberInitializer
|
||||
|
||||
namespace DTS.Viewer
|
||||
{
|
||||
public class ViewerMainViewModel : BaseViewModel<IViewerMainViewModel>, IViewerMainViewModel
|
||||
{
|
||||
public IBaseView View { get; set; }
|
||||
|
||||
private IBaseWindowModel Parent { get; set; }
|
||||
private IEventAggregator _eventAggregator { get; set; }
|
||||
private IUnityContainer _unityContainer { get; set; }
|
||||
|
||||
public InteractionRequest<Notification> NotificationRequest { get; private set; }
|
||||
public new InteractionRequest<Confirmation> ConfirmationRequest { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the MainViewModel.
|
||||
/// </summary>
|
||||
|
||||
/// <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 ViewerMainViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer)
|
||||
: base(regionManager, eventAggregator, unityContainer)
|
||||
{
|
||||
NotificationRequest = new InteractionRequest<Notification>();
|
||||
ConfirmationRequest = new InteractionRequest<Confirmation>();
|
||||
|
||||
_eventAggregator = eventAggregator;
|
||||
_unityContainer = unityContainer;
|
||||
View = _unityContainer.Resolve<IViewerMainViewGrid>();
|
||||
View.DataContext = this;
|
||||
}
|
||||
|
||||
|
||||
#region Methods
|
||||
/// <summary>
|
||||
/// sets SelectedDataFile and marks it as selected in viewer/model
|
||||
/// 16158 Browse button on View Data tab not functiona
|
||||
/// </summary>
|
||||
public void SelectAndIncludeDataFile(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value)) return;
|
||||
_selectedDataFile = value;
|
||||
_eventAggregator.GetEvent<DataFolderChangedEvent>().Publish(new DataFolderSelectionArg
|
||||
{ Path = string.Empty, File = _selectedDataFile, SetSelected = true, ParentVM = this });
|
||||
OnPropertyChanged("SelectedDataFile");
|
||||
}
|
||||
private void OnDataFileSelected(DataFileSelectionArg arg)
|
||||
{
|
||||
if (this != arg.ParentVM) return;
|
||||
SelectAndIncludeDataFile(arg?.File);
|
||||
}
|
||||
private void Subscribe()
|
||||
{
|
||||
_eventAggregator.GetEvent<LoadViewModulEvent>().Subscribe(OnLoadViewModul, ThreadOption.PublisherThread, true);
|
||||
|
||||
_eventAggregator.GetEvent<TestLoadedCountNotification>().Subscribe(OnTestLoadedChanged);
|
||||
_eventAggregator.GetEvent<TestSummaryCountNotification>().Subscribe(OnTestSelectedCountChanged);
|
||||
|
||||
_eventAggregator.GetEvent<GraphLoadedCountNotification>().Subscribe(OnGraphLoadedCountChanged);
|
||||
_eventAggregator.GetEvent<ShiftT0Event>().Subscribe(OnShiftT0Event);
|
||||
_eventAggregator.GetEvent<GraphSelectedChannelCountNotification>().Subscribe(OnGraphSelectedCountChanged);
|
||||
_eventAggregator.GetEvent<GraphChannelsReadCompletedNotification>().Subscribe(OnGraphChannelsReadCompleted, ThreadOption.UIThread);
|
||||
_eventAggregator.GetEvent<ViewerSettingsVisibilityChangedEvent>().Subscribe(OnViewerSettingsVisibilityChanged);
|
||||
_eventAggregator.GetEvent<DataFileSelectedEvent>().Subscribe(OnDataFileSelected);
|
||||
_eventAggregator.GetEvent<SaveToPDFRequestedEvent>().Subscribe(OnSaveToPDFRequested);
|
||||
}
|
||||
|
||||
private void OnViewerSettingsVisibilityChanged(Visibility settingsVisibility)
|
||||
{
|
||||
SettingsVisibility = settingsVisibility;
|
||||
}
|
||||
private Visibility _settingsVisibility = Visibility.Visible;
|
||||
public Visibility SettingsVisibility
|
||||
{
|
||||
get => _settingsVisibility;
|
||||
private set
|
||||
{
|
||||
_settingsVisibility = value;
|
||||
OnPropertyChanged("SettingsVisibility");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Initialize without parameter
|
||||
/// </summary>
|
||||
public override void Initialize()
|
||||
{
|
||||
Subscribe();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize with parameter - Parent
|
||||
/// </summary>
|
||||
public override void Initialize(object parameter)
|
||||
{
|
||||
Parent = (IBaseWindowModel)parameter;
|
||||
Parent.IsMenuIncluded = _isMenuIncluded;
|
||||
Parent.IsNavigationIncluded = _isNavigationIncluded;
|
||||
Subscribe();
|
||||
View.DataContext = this;
|
||||
}
|
||||
public override void Activated()
|
||||
{
|
||||
}
|
||||
|
||||
private void OnGraphLoadedCountChanged(GraphLoadedCountNotificationArg arg)
|
||||
{
|
||||
if (this != arg?.ParentVM) return;
|
||||
TotalLoadedGraphs = arg.LoadedCount;
|
||||
}
|
||||
|
||||
private void OnGraphSelectedCountChanged(GraphSelectedChannelCountNotificationArg arg)
|
||||
{
|
||||
if (this != arg?.ParentVM) return;
|
||||
TotalSelectedGraphs = arg.SelectedChannelCount;
|
||||
}
|
||||
|
||||
private void OnGraphChannelsReadCompleted(GraphChannelsReadCompletedNotificationArgs arg)
|
||||
{
|
||||
if (null == arg) { return; }
|
||||
if (((IGraphView)ContextGraphRegion).DataContext != arg?.GraphVM) return;
|
||||
|
||||
_eventAggregator.GetEvent<BusyIndicatorChangeNotification>().Publish(!arg.IsReadCompleted);
|
||||
}
|
||||
|
||||
private void OnTestLoadedChanged(TestLoadedCountNotificationArg arg)
|
||||
{
|
||||
if (this != arg?.ParentVM) return;
|
||||
TotalLoadedTests = arg.LoadedCount;
|
||||
}
|
||||
|
||||
private void OnTestSelectedCountChanged(TestSummaryCountNotificationArg arg)
|
||||
{
|
||||
if (this != arg?.ParentVM) return;
|
||||
TotalSelectedTests = arg.SummaryCount;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Private Event handler for Status change event.
|
||||
/// </summary>
|
||||
private void OnStatusChange(StatusInfo content)
|
||||
{
|
||||
Dispatcher.CurrentDispatcher.InvokeAsync(() =>
|
||||
{
|
||||
IsBusy = content.IsBusy;
|
||||
IsBusyMessage = content.Text;
|
||||
}, DispatcherPriority.Normal);
|
||||
}
|
||||
|
||||
private void OnLoadViewModul(LoadViewModulArg arg)
|
||||
{
|
||||
IsBusy = true;
|
||||
IsBusyMessage = "Loading view list";
|
||||
|
||||
if (null == ContextGraphRegion) ContextGraphRegion = GetGraphView(this);
|
||||
if (null == ContextTestsRegion) ContextTestsRegion = GetTestDefinitionView(this);
|
||||
if (null == ContextGraphListRegion) ContextGraphListRegion = GetGraphListView(this);
|
||||
if (null == ContextChartOptionsRegion) ContextChartOptionsRegion = GetChartOptionsView(this);
|
||||
if (null == ContextTestModificationRegion) ContextTestModificationRegion = GetTestModificationView(this);
|
||||
if (null == ContextViewerSettingsRegion) ContextViewerSettingsRegion = GetViewerSettingsView(this);
|
||||
|
||||
IsBusy = false;
|
||||
IsBusyMessage = string.Empty;
|
||||
}
|
||||
|
||||
public void ZoomReset()
|
||||
{
|
||||
_eventAggregator.GetEvent<ResetZoomChangedEvent>().Publish(true);
|
||||
}
|
||||
public void LeftKeyPress()
|
||||
{
|
||||
//inform any other modules and models of a T0 shift
|
||||
_eventAggregator.GetEvent<ShiftT0Event>().Publish(new ShiftT0EventArguments(-1, false, true));
|
||||
}
|
||||
public void RightKeyPress()
|
||||
{
|
||||
//inform any other modules and models of a T0 shift
|
||||
_eventAggregator.GetEvent<ShiftT0Event>().Publish(new ShiftT0EventArguments(1, false, true));
|
||||
}
|
||||
|
||||
|
||||
private void OnShiftT0Event(ShiftT0EventArguments args)
|
||||
{
|
||||
if (args.IsInitialization) { return; }
|
||||
|
||||
if (args.T0Time != 0) { ShowModifications = true; }
|
||||
if (args.T0Steps != 0) { ShowModifications = true; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Views
|
||||
|
||||
private INavigationView GetNavigationView(IBaseViewModel parent)
|
||||
{
|
||||
var view = _unityContainer.Resolve<INavigationView>();
|
||||
var viewModel = _unityContainer.Resolve<INavigationViewModel>();
|
||||
view.DataContext = viewModel;
|
||||
viewModel.Initialize(parent);
|
||||
return view;
|
||||
}
|
||||
private INavigationViewModel GetNavigationViewModel(IBaseViewModel parent)
|
||||
{
|
||||
var view = _unityContainer.Resolve<INavigationView>();
|
||||
var viewModel = _unityContainer.Resolve<INavigationViewModel>();
|
||||
view.DataContext = viewModel;
|
||||
viewModel.Initialize(parent);
|
||||
return viewModel;
|
||||
}
|
||||
private IChartOptionsView GetChartOptionsView(IBaseViewModel parent)
|
||||
{
|
||||
var view = _unityContainer.Resolve<IChartOptionsView>();
|
||||
var viewModel = _unityContainer.Resolve<IChartOptionsViewModel>();
|
||||
view.DataContext = viewModel;
|
||||
viewModel.Initialize(parent);
|
||||
return view;
|
||||
}
|
||||
private IGraphView GetGraphView(IBaseViewModel parent)
|
||||
{
|
||||
var view = _unityContainer.Resolve<IGraphView>();
|
||||
var viewModel = _unityContainer.Resolve<IGraphViewModel>();
|
||||
view.DataContext = viewModel;
|
||||
viewModel.Initialize(parent);
|
||||
return view;
|
||||
}
|
||||
private IGraphMainView GetGraphListView(IBaseViewModel parent)
|
||||
{
|
||||
var view = _unityContainer.Resolve<IGraphMainView>();
|
||||
var viewModel = _unityContainer.Resolve<IGraphMainViewModel>();
|
||||
view.DataContext = viewModel;
|
||||
viewModel.Initialize(parent);
|
||||
return view;
|
||||
}
|
||||
private IViewerSettingsView GetViewerSettingsView(IBaseViewModel parent)
|
||||
{
|
||||
var view = _unityContainer.Resolve<IViewerSettingsView>();
|
||||
var viewModel = _unityContainer.Resolve<IViewerSettingsViewModel>();
|
||||
view.DataContext = viewModel;
|
||||
viewModel.Initialize(parent);
|
||||
return view;
|
||||
}
|
||||
private ITestModificationView GetTestModificationView(IBaseViewModel parent)
|
||||
{
|
||||
var view = _unityContainer.Resolve<ITestModificationView>();
|
||||
var viewModel = _unityContainer.Resolve<ITestModificationViewModel>();
|
||||
view.DataContext = viewModel;
|
||||
try
|
||||
{
|
||||
viewModel.UseISOCodeFilterMapping = SettingsDB.GetGlobalValueBool("UseISOCodeFilterMapping", true);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
viewModel.Initialize(parent);
|
||||
return view;
|
||||
}
|
||||
|
||||
private ITestSummaryListView GetTestDefinitionView(IBaseViewModel parent)
|
||||
{
|
||||
var view = _unityContainer.Resolve<ITestSummaryListView>();
|
||||
var viewModel = _unityContainer.Resolve<ITestSummaryListViewModel>();
|
||||
view.DataContext = viewModel;
|
||||
viewModel.Initialize(parent);
|
||||
return view;
|
||||
}
|
||||
#endregion Views
|
||||
|
||||
#region ContextRegion
|
||||
|
||||
private IBaseViewModel _activeContent;
|
||||
public IBaseViewModel ActiveContent { get => _activeContent; set { _activeContent = value; OnPropertyChanged("ActiveContent"); } }
|
||||
|
||||
|
||||
#region Graph
|
||||
public object ContextGraphRegion
|
||||
{
|
||||
get => ((ViewerMainViewGrid)View).GraphRegion.Content;
|
||||
set { ((ViewerMainViewGrid)View).GraphRegion.Content = value; OnPropertyChanged("ContextGraphRegion"); }
|
||||
}
|
||||
public object ContextGraphListRegion
|
||||
{
|
||||
get => ((ViewerMainViewGrid)View).GraphListRegion.Content;
|
||||
set { ((ViewerMainViewGrid)View).GraphListRegion.Content = value; OnPropertyChanged("ContextGraphListRegion"); }
|
||||
}
|
||||
#endregion Graph
|
||||
public object ContextTestsRegion
|
||||
{
|
||||
get => ((ViewerMainViewGrid)View).TestsRegion.Content;
|
||||
set { ((ViewerMainViewGrid)View).TestsRegion.Content = value; OnPropertyChanged("ContextTestsRegion"); }
|
||||
}
|
||||
|
||||
public object ContextGraphsRegion
|
||||
{
|
||||
get => ((ViewerMainViewGrid)View).GraphListRegion.Content;
|
||||
set { ((ViewerMainViewGrid)View).GraphListRegion.Content = value; OnPropertyChanged("ContextGraphsRegion"); }
|
||||
|
||||
}
|
||||
|
||||
public object ContextLegendRegion
|
||||
{
|
||||
get => ((ViewerMainViewGrid)View).LegendRegion.Content;
|
||||
set { ((ViewerMainViewGrid)View).LegendRegion.Content = value; OnPropertyChanged("ContextLegendRegion"); }
|
||||
}
|
||||
|
||||
public object ContextDiagRegion
|
||||
{
|
||||
get => ((ViewerMainViewGrid)View).DiagRegion.Content;
|
||||
set { ((ViewerMainViewGrid)View).DiagRegion.Content = value; OnPropertyChanged("ContextDiagRegion"); }
|
||||
}
|
||||
|
||||
public object ContextStatsRegion
|
||||
{
|
||||
get => ((ViewerMainViewGrid)View).StatsRegion.Content;
|
||||
set { ((ViewerMainViewGrid)View).StatsRegion.Content = value; OnPropertyChanged("ContextStatsRegion"); }
|
||||
}
|
||||
|
||||
public object ContextCursorRegion
|
||||
{
|
||||
get =>((ViewerMainViewGrid)View).CursorRegion.Content;
|
||||
set { ((ViewerMainViewGrid)View).CursorRegion.Content = value; OnPropertyChanged("ContextCursorRegion"); }
|
||||
}
|
||||
|
||||
public object ContextPropertyRegion { get; set; }
|
||||
|
||||
public object ContextChartOptionsRegion
|
||||
{
|
||||
get => ((ViewerMainViewGrid)View).ChartOptionsRegion.Content;
|
||||
set { ((ViewerMainViewGrid)View).ChartOptionsRegion.Content = value; OnPropertyChanged("ContextChartOptionsRegion"); }
|
||||
}
|
||||
public object ContextTestModificationRegion
|
||||
{
|
||||
get => ((ViewerMainViewGrid)View).TestModificationRegion.Content;
|
||||
set { ((ViewerMainViewGrid)View).TestModificationRegion.Content = value; OnPropertyChanged("ContextTestModificationRegion"); }
|
||||
}
|
||||
public object ContextViewerSettingsRegion
|
||||
{
|
||||
get => ((ViewerMainViewGrid)View).SettingsRegion.Content;
|
||||
set { ((ViewerMainViewGrid)View).SettingsRegion.Content = value; OnPropertyChanged("ContextViewerSettingsRegion"); }
|
||||
}
|
||||
public List<FrameworkElement> GetRegions()
|
||||
{
|
||||
var items = new List<FrameworkElement>();
|
||||
Utils.GetChildrenByName(((ViewerMainViewGrid)View).MainShell, "Region", ref items);
|
||||
return items;
|
||||
}
|
||||
private readonly object saveLock = new object();
|
||||
private void OnSaveToPDFRequested(string directory)
|
||||
{
|
||||
if (null == (ViewerMainViewGrid)View) return;
|
||||
lock (saveLock)
|
||||
{
|
||||
var pdfFileName = DateTime.Now.ToString("M'/'d'/'yyyy", CultureInfo.InvariantCulture).Replace("/", "_") + "_" +
|
||||
DateTime.Now.ToString("h':'mm' 'tt", CultureInfo.InvariantCulture).Replace(":", "_") + "_" + DateTime.Now.Second + "_" +
|
||||
DateTime.Now.Millisecond + ".pdf";
|
||||
var intResult = ((ViewerMainViewGrid)View).SaveToPDF(directory, pdfFileName);
|
||||
var output = string.Empty;
|
||||
if (intResult > 0)
|
||||
{
|
||||
//Success
|
||||
output = string.Format(StringResources.SavePDFSuccess, Environment.NewLine,
|
||||
Path.Combine(directory, pdfFileName), Environment.NewLine,
|
||||
Path.Combine(directory, pdfFileName.Replace(".pdf", ".png")));
|
||||
_eventAggregator.GetEvent<PageErrorEvent>().Publish(new PageErrorArg(new string[] { output }, null));
|
||||
}
|
||||
else if (intResult < 0)
|
||||
{
|
||||
//Failure
|
||||
output = StringResources.SavePDFError;
|
||||
_eventAggregator.GetEvent<PageErrorEvent>().Publish(new PageErrorArg(new string[] { output }, null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string ConfigPath { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
#region Test Title
|
||||
|
||||
private string _titleTests = StringResources.TestsDefaultTitle;
|
||||
public string TitleTests
|
||||
{
|
||||
get => _titleTests;
|
||||
set
|
||||
{
|
||||
_titleTests = value;
|
||||
OnPropertyChanged("TitleTests");
|
||||
}
|
||||
}
|
||||
private int _totalSelectedTests = 0;
|
||||
public int TotalSelectedTests
|
||||
{
|
||||
get => _totalSelectedTests;
|
||||
set
|
||||
{
|
||||
_totalSelectedTests = value;
|
||||
TitleTests = StringResources.TestsDefaultTitle + TotalSelectedTests + "/" + TotalLoadedTests;
|
||||
if (_totalSelectedTests == 0) { TitleGraphs = StringResources.GraphsDefaultTitle; }
|
||||
OnPropertyChanged("TotalSelectedTests");
|
||||
}
|
||||
}
|
||||
private int _totalLoadedTests = 0;
|
||||
public int TotalLoadedTests
|
||||
{
|
||||
get => _totalLoadedTests;
|
||||
set { _totalLoadedTests = value; TitleTests = StringResources.TestsDefaultTitle + TotalSelectedTests + "/" + TotalLoadedTests; OnPropertyChanged("TotalLoadedTests"); }
|
||||
}
|
||||
#endregion Test Title
|
||||
|
||||
#region Graph Title
|
||||
private string _titleGraphs = StringResources.GraphsDefaultTitle;
|
||||
|
||||
public string TitleGraphs
|
||||
{
|
||||
get => _titleGraphs;
|
||||
set
|
||||
{
|
||||
_titleGraphs = value;
|
||||
OnPropertyChanged("TitleGraphs");
|
||||
}
|
||||
}
|
||||
private int _totalSelectedGraphs = 0;
|
||||
public int TotalSelectedGraphs
|
||||
{
|
||||
get => _totalSelectedGraphs;
|
||||
set { _totalSelectedGraphs = value; TitleGraphs = StringResources.GraphsDefaultTitle + TotalSelectedGraphs + "/" + TotalLoadedGraphs; OnPropertyChanged("TotalSelectedGraphs"); }
|
||||
}
|
||||
private int _totalLoadedGraphs = 0;
|
||||
public int TotalLoadedGraphs
|
||||
{
|
||||
get => _totalLoadedGraphs;
|
||||
set { _totalLoadedGraphs = value; TitleGraphs = StringResources.GraphsDefaultTitle + TotalSelectedGraphs + "/" + TotalLoadedGraphs; OnPropertyChanged("TotalLoadedGraphs"); }
|
||||
}
|
||||
#endregion Graph Title
|
||||
|
||||
private string _selectedDataFolder = string.Empty;
|
||||
public string SelectedDataFolder
|
||||
{
|
||||
get => _selectedDataFolder;
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(value)) return;
|
||||
|
||||
_selectedDataFolder = value; _eventAggregator.GetEvent<DataFolderChangedEvent>().Publish(new DataFolderSelectionArg { Path = _selectedDataFolder, File = string.Empty, ParentVM = this }); OnPropertyChanged("SelectedDataFolder");
|
||||
}
|
||||
}
|
||||
|
||||
public bool DoesUserHaveEditPermission { get; set; } = false;
|
||||
|
||||
private string _selectedDataFile = string.Empty;
|
||||
public string SelectedDataFile
|
||||
{
|
||||
get => _selectedDataFile;
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(value)) return;
|
||||
_selectedDataFile = value; _eventAggregator.GetEvent<DataFolderChangedEvent>().Publish(new DataFolderSelectionArg { Path = string.Empty, File = _selectedDataFile, ParentVM = this }); OnPropertyChanged("SelectedDataFile");
|
||||
}
|
||||
}
|
||||
|
||||
public bool _showModifications = false;
|
||||
public bool ShowModifications
|
||||
{
|
||||
get => _showModifications;
|
||||
set { _showModifications = value; OnPropertyChanged("ShowModifications"); }
|
||||
}
|
||||
|
||||
private IsoViewMode _channelCodeViewMode = IsoViewMode.ISOAndUserCode;
|
||||
public IsoViewMode ChannelCodeViewMode
|
||||
{
|
||||
get => _channelCodeViewMode;
|
||||
set { _channelCodeViewMode = value; _eventAggregator.GetEvent<ChannelCodesViewChangedEvent>().Publish(value); OnPropertyChanged("ChannelCodeViewMode"); }
|
||||
}
|
||||
|
||||
private CalibrationBehaviors _calibrationBehaviorSetting = CalibrationBehaviors.NonLinearIfAvailable;
|
||||
public CalibrationBehaviors CalibrationBehaviorSetting
|
||||
{
|
||||
get => _calibrationBehaviorSetting;
|
||||
set { _calibrationBehaviorSetting = value; _eventAggregator.GetEvent<CalibrationBehaviorSettingChangedEvent>().Publish(value); OnPropertyChanged("CalibrationBehaviorSetting"); }
|
||||
}
|
||||
|
||||
private bool _calibrationBehaviorSettableInViewer = true;
|
||||
public bool CalibrationBehaviorSettableInViewer
|
||||
{
|
||||
get => _calibrationBehaviorSettableInViewer;
|
||||
set
|
||||
{
|
||||
_calibrationBehaviorSettableInViewer = value;
|
||||
_eventAggregator.GetEvent<CalibrationBehaviorSettableInViewerChangedEvent>().Publish(value);
|
||||
OnPropertyChanged("CalibrationBehaviorSettableInViewer");
|
||||
//FB13946: Test tab should be the first if in Viewer Tile, graphs tab if in Run Test/Download
|
||||
//CalibrationSettableInViewer is a proxy here for which tile we're in
|
||||
((ViewerMainViewGrid)View).graphsTab.IsSelected = !value;
|
||||
((ViewerMainViewGrid)View).testsTab.IsSelected = value;
|
||||
//FB 14797 select first tab always to not switch when the graph is loading.
|
||||
((ViewerMainViewGrid)View).chartOptTab.IsSelected = true;
|
||||
((ViewerMainViewGrid)View).chartOptTab.Focusable = true;
|
||||
((ViewerMainViewGrid)View).chartOptTab.Focus();
|
||||
}
|
||||
}
|
||||
|
||||
//List<IGroupView> _assemblyGroupList = new List<IGroupView>();
|
||||
//public List<IGroupView> AssemblyGroupList
|
||||
//{
|
||||
// get { return _assemblyGroupList; }
|
||||
// set { _assemblyGroupList = value; OnPropertyChanged("AssemblyGroupList"); }
|
||||
//}
|
||||
|
||||
///<summary>
|
||||
///Occurs when a property value changes.
|
||||
///</summary>
|
||||
public new event PropertyChangedEventHandler PropertyChanged;
|
||||
private new void OnPropertyChanged(string propertyName) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); }
|
||||
|
||||
private bool _isBusy = false;
|
||||
/// <summary>
|
||||
/// Display or hide Busy Indicator
|
||||
/// </summary>
|
||||
public new bool IsBusy { get => _isBusy; set { _isBusy = value; OnPropertyChanged("IsBusy"); } }
|
||||
|
||||
private string _isBusyMessage = string.Empty;
|
||||
/// <summary>
|
||||
/// Busy Message text
|
||||
/// </summary>
|
||||
public new string IsBusyMessage { get => _isBusyMessage; set { _isBusyMessage = value; OnPropertyChanged("IsBusyMessage"); } }
|
||||
|
||||
private bool _isMenuIncluded = false;
|
||||
public new bool IsMenuIncluded { get => _isMenuIncluded; set { _isMenuIncluded = value; OnPropertyChanged("IsMenuIncluded"); } }
|
||||
private bool _isNavigationIncluded = false;
|
||||
public new bool IsNavigationIncluded { get => _isNavigationIncluded; set { _isNavigationIncluded = value; OnPropertyChanged("IsNavigationIncluded"); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the HeaderInfo.
|
||||
/// </summary>
|
||||
public string HeaderInfo => "MainRegion";
|
||||
|
||||
#endregion
|
||||
|
||||
#region Commands
|
||||
|
||||
#region LoadLayoutCommand
|
||||
RelayCommand _loadLayoutCommand = null;
|
||||
public ICommand LoadLayoutCommand => _loadLayoutCommand ?? (_loadLayoutCommand = new RelayCommand(OnLoadLayout, CanLoadLayout));
|
||||
|
||||
private bool CanLoadLayout(object parameter)
|
||||
{
|
||||
return File.Exists(@".\DataProViewerAvalonDock.config");
|
||||
}
|
||||
|
||||
private void OnLoadLayout(object parameter)
|
||||
{
|
||||
var layoutSerializer = new XmlLayoutSerializer(((ViewerMainView)View).DockManager);
|
||||
//Here I've implemented the LayoutSerializationCallback just to show
|
||||
// a way to feed layout desarialization with content loaded at runtime
|
||||
//Actually I could in this case let AvalonDock to attach the contents
|
||||
//from current layout using the content ids
|
||||
//LayoutSerializationCallback should anyway be handled to attach contents
|
||||
//not currently loaded
|
||||
layoutSerializer.LayoutSerializationCallback += (s, e) =>
|
||||
{
|
||||
//if (e.Model.ContentId == FileStatsViewModel.ToolContentId)
|
||||
// e.Content = Workspace.This.FileStats;
|
||||
//else if (!string.IsNullOrWhiteSpace(e.Model.ContentId) &&
|
||||
// File.Exists(e.Model.ContentId))
|
||||
// e.Content = Workspace.This.Open(e.Model.ContentId);
|
||||
};
|
||||
layoutSerializer.Deserialize(@".\DataProViewerAvalonDock.config");
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region SaveLayoutCommand
|
||||
RelayCommand _saveLayoutCommand = null;
|
||||
public ICommand SaveLayoutCommand => _saveLayoutCommand ?? (_saveLayoutCommand = new RelayCommand(OnSaveLayout, CanSaveLayout));
|
||||
|
||||
public object ContextNavigationRegion { get; set; }
|
||||
|
||||
private bool CanSaveLayout(object parameter)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private void OnSaveLayout(object parameter)
|
||||
{
|
||||
var layoutSerializer = new XmlLayoutSerializer(((ViewerMainView)View).DockManager);
|
||||
layoutSerializer.Serialize(@".\AvalonDock.config");
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
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<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(((ViewerShellView)View).MainShell, "Region", ref items);
|
||||
return items;
|
||||
}
|
||||
|
||||
public Object ContextMainRegion
|
||||
{
|
||||
get { return ((ViewerShellView)View).MainRegion.Content; }
|
||||
set { ((ViewerShellView)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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user