aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI
diff options
context:
space:
mode:
authorVictoria Plitt <Victoria.Plitt@twine-s.com>2023-05-10 14:58:28 +0300
committerVictoria Plitt <Victoria.Plitt@twine-s.com>2023-05-10 14:58:28 +0300
commite4f6cc1ebcd74f858518bf74df4df82c4f975935 (patch)
treeaea93948fae81408b9dd306777f28a4a8858d0b0 /Software/Visual_Studio/PPC/Tango.PPC.UI
parentedd7e8af06fe0e70e78ce2de9423ec49a799b78a (diff)
parent5c378ccb814defda8e73dae4296b82117869cec4 (diff)
downloadTango-e4f6cc1ebcd74f858518bf74df4df82c4f975935.tar.gz
Tango-e4f6cc1ebcd74f858518bf74df4df82c4f975935.zip
Merge branch 'eureka' of https://twinetfs.visualstudio.com/Tango/_git/Tango into eureka
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Intro.wmvbin0 -> 6369158 bytes
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/EurekaNavigationManager.cs606
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs2
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj16
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs9
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs9
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml43
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml.cs16
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest2
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/packages.config1
10 files changed, 662 insertions, 42 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Intro.wmv b/Software/Visual_Studio/PPC/Tango.PPC.UI/Intro.wmv
new file mode 100644
index 000000000..7f4a8dd66
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Intro.wmv
Binary files differ
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/EurekaNavigationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/EurekaNavigationManager.cs
new file mode 100644
index 000000000..63332e889
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/EurekaNavigationManager.cs
@@ -0,0 +1,606 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Media;
+using Tango.Core;
+using Tango.Core.Commands;
+using Tango.Core.DI;
+using Tango.PPC.Common;
+using Tango.PPC.Common.Modules;
+using Tango.PPC.Common.Navigation;
+using Tango.PPC.Common.Notifications;
+using Tango.PPC.Common.Threading;
+using Tango.PPC.UI.Views;
+using Tango.PPC.UI.ViewsContracts;
+using Tango.SharedUI.Controls;
+
+namespace Tango.PPC.UI.Navigation
+{
+ /// <summary>
+ /// Represents the default PPC navigation manager.
+ /// </summary>
+ /// <seealso cref="Tango.PPC.Common.Navigation.INavigationManager" />
+ public class EurekaNavigationManager : ExtendedObject, INavigationManager
+ {
+ //private event Action<Object, Object> NavigationCycleCompleted;
+ //private event Action<Object, Object> BeforeNavigationCycleCompleted;
+ private class AwaitingVMResult
+ {
+ public PPCViewModel FromVM { get; set; }
+ public PPCViewModel ToVM { get; set; }
+ public Action Action { get; set; }
+ }
+
+ private List<AwaitingVMResult> _awaitingVMResults;
+ private IDispatcherProvider _dispatcherProvider;
+ private IPPCModuleLoader _moduleLoader;
+ private INotificationProvider _notificationProvider;
+ private String _lastFullPath;
+ private bool _preventHistory;
+ private bool _navigating_back;
+
+ public event EventHandler<PPCViewModel> CurrentVMChanged;
+
+ private Stack<String> _navigationHistory;
+
+ private Object _currentVM;
+ /// <summary>
+ /// Gets the current view model.
+ /// </summary>
+ public PPCViewModel CurrentVM
+ {
+ set
+ {
+ var previous = _currentVM;
+ _currentVM = value;
+
+ var vm = _currentVM as PPCViewModel;
+
+ if (_currentVM != previous && vm != null)
+ {
+ CurrentVMChanged?.Invoke(this, vm);
+ }
+ }
+ get
+ {
+ return _currentVM as PPCViewModel;
+ }
+ }
+
+ private IPPCModule _currentModule;
+ /// <summary>
+ /// Gets or sets the current module.
+ /// </summary>
+ public IPPCModule CurrentModule
+ {
+ get { return _currentModule; }
+ private set { _currentModule = value; RaisePropertyChangedAuto(); }
+ }
+
+ /// <summary>
+ /// Navigates to the previous view.
+ /// </summary>
+ public RelayCommand NavigateBackCommand { get; private set; }
+
+ /// <summary>
+ /// Navigates to the specified full path in command parameter.
+ /// </summary>
+ public RelayCommand<String> NavigateToCommand { get; private set; }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="DefaultNavigationManager"/> class.
+ /// </summary>
+ /// <param name="moduleLoader">The module loader.</param>
+ public EurekaNavigationManager(IPPCModuleLoader moduleLoader, IDispatcherProvider dispatcherProvider, INotificationProvider notificationProvider)
+ {
+ IsBackEnabled = true;
+ _awaitingVMResults = new List<AwaitingVMResult>();
+ _navigationHistory = new Stack<String>();
+ _moduleLoader = moduleLoader;
+ _notificationProvider = notificationProvider;
+
+ NavigateToCommand = new RelayCommand<string>(async (x) => await NavigateTo(x));
+ NavigateBackCommand = new RelayCommand(async () => await NavigateBack());
+
+ _dispatcherProvider = dispatcherProvider;
+ }
+
+ /// <summary>
+ /// Navigates to the specified PPC view.
+ /// </summary>
+ /// <param name="view">The view.</param>
+ public Task<bool> NavigateTo(NavigationView view, bool pushToHistory = true)
+ {
+ pushToHistory = false;
+ if (view == NavigationView.HomeModule)
+ {
+ _navigationHistory.Clear();
+ _lastFullPath = null;
+
+ var firstModule = _moduleLoader.UserModules.FirstOrDefault();
+
+ if (firstModule != null)
+ {
+ var moduleAtt = firstModule.GetType().GetCustomAttribute<PPCModuleAttribute>();
+
+ if (moduleAtt != null)
+ {
+ return NavigateTo(firstModule.GetType(), pushToHistory, moduleAtt.HomeViewName);
+ }
+ else
+ {
+ return NavigateTo(firstModule.GetType(), pushToHistory);
+ }
+ }
+ else
+ {
+ return NavigateTo(NavigationView.NoPermissionsView);
+ }
+ }
+ else
+ {
+
+ LogManager.Log($"Navigating to: {view.ToString()}...");
+
+ var fromView = GetMainNavigationControl().SelectedElement;
+ FrameworkElement toView = null;
+
+ toView = GetMainNavigationControl().NavigateTo(view.ToString(), (Action)(() =>
+ {
+ CurrentVM = toView.DataContext as PPCViewModel;
+ NotifyOnNavigated(fromView.DataContext, toView.DataContext);
+
+ }));
+
+ NotifyOnBeforeNavigated(fromView.DataContext, toView.DataContext);
+
+ return Task.FromResult(true);
+ }
+ }
+
+ /// <summary>
+ /// Navigates to the specified PPC view with the specified receive object.
+ /// </summary>
+ /// <param name="view">The view.</param>
+ /// <param name="obj"></param>
+ /// <param name="pushToHistory"></param>
+ /// <returns></returns>
+ public Task<bool> NavigateWithObject<TPass>(NavigationView view, TPass obj, bool pushToHistory = true)
+ {
+ LogManager.Log($"Navigating to: {view.ToString()}, with object {typeof(TPass).Name}...");
+ GetMainNavigationControl().NavigateTo(view.ToString());
+ INavigationObjectReceiver<TPass> receiver = GetMainNavigationControl().Elements.FirstOrDefault(x => (x.GetType().Name == view.ToString() || NavigationControl.GetNavigationName(x) == view.ToString()) && x.DataContext is INavigationObjectReceiver<TPass>).DataContext as INavigationObjectReceiver<TPass>;
+
+ if (receiver != null)
+ {
+ receiver.OnNavigatedToWithObject(obj);
+ }
+
+ return Task.FromResult(true);
+ }
+
+ /// <summary>
+ /// Navigates to the specified module.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ public Task<bool> NavigateTo<T>(bool pushToHistory = true) where T : IPPCModule
+ {
+ return NavigateTo(typeof(T));
+ }
+
+ /// <summary>
+ /// Navigates to the specified module using the view path (e.g MainView.JobsView).
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="viewPath">The view path.</param>
+ public Task<bool> NavigateTo<T>(string viewPath, bool pushToHistory = true) where T : IPPCModule
+ {
+ return NavigateTo<T>(pushToHistory, viewPath.Split('.'));
+ }
+
+ /// <summary>
+ /// Navigates to the specified module using the view path (e.g MainView,JobsView).
+ /// This method makes it easy to do stuff like NavigateTo(nameof(MainView),nameof(JobsView));
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="viewPath">The view path.</param>
+ public Task<bool> NavigateTo<T>(bool pushToHistory = true, params String[] viewPath) where T : IPPCModule
+ {
+ return NavigateTo(typeof(T), pushToHistory, viewPath);
+ }
+
+ /// <summary>
+ /// Navigates to the specified module and view by full path (e.g Jobs.JobsView).
+ /// </summary>
+ /// <param name="fullPath">The full path.</param>
+ public async Task<bool> NavigateTo(String fullPath, bool pushToHistory = true, Action<PPCViewModel, PPCViewModel> onNavigating = null, Action<PPCViewModel, PPCViewModel> onNavigated = null)
+ {
+ if (_lastFullPath != null && !_lastFullPath.Contains("JobsV2Module"))
+ {
+ pushToHistory = false;
+ }
+
+ try
+ {
+ IsNavigating = true;
+
+ String[] path = fullPath.Split('.');
+ var module = _moduleLoader.UserModules.SingleOrDefault(x => x.GetType().Name == path[0] || x.Name == path[0]);
+
+ if (module == null)
+ {
+ await _notificationProvider.ShowError("The specified module was not loaded.");
+ IsNavigating = false;
+ return false;
+ }
+
+ if (path.Length == 1 && path[0] == CurrentModule.Name)
+ {
+ IsNavigating = false;
+ return true;
+ }
+
+ LogManager.Log($"Navigating to: {fullPath}...");
+
+ var fromVM = CurrentVM;
+
+ if (CurrentVM != null && CurrentVM is INavigationBlocker)
+ {
+ if (_navigating_back)
+ {
+ if (!await (CurrentVM as INavigationBlocker).OnNavigateBackRequest())
+ {
+ IsNavigating = false;
+ return false;
+ }
+ }
+ else
+ {
+ if (!await (CurrentVM as INavigationBlocker).OnNavigateOutRequest())
+ {
+ IsNavigating = false;
+ return false;
+ }
+ }
+ }
+
+
+
+ if (pushToHistory && _lastFullPath != null && !_preventHistory)
+ {
+ _navigationHistory.Push(_lastFullPath);
+ RaisePropertyChanged(nameof(CanNavigateBack));
+ }
+
+ _lastFullPath = fullPath;
+
+ GetMainNavigationControl().NavigateTo(NavigationView.LayoutView.ToString());
+ var navigationControl = GetLayoutNavigationControl();
+ CurrentModule = module;
+ var moduleView = navigationControl.NavigateTo(module.Name);
+
+ CurrentVM = moduleView.DataContext as PPCViewModel;
+
+ if (path.Length > 1)
+ {
+ var moduleNavigation = moduleView.FindChildOffline<NavigationControl>();
+
+ if (moduleNavigation != null)
+ {
+ moduleNavigation.RegisterForLoadedOrNow(async (x, e) =>
+ {
+ var lastView = moduleNavigation.GetElement(path.Last());
+
+ if (lastView != null)
+ {
+ onNavigating?.Invoke(fromVM as PPCViewModel, lastView.DataContext as PPCViewModel);
+ }
+
+ foreach (var view in path.Skip(1))
+ {
+ await Task.Delay(100);
+
+ FrameworkElement v = null;
+
+ v = moduleNavigation.NavigateTo(view, () =>
+ {
+ if (v != null)
+ {
+ NotifyOnNavigated(fromVM, v.DataContext);
+ onNavigated?.Invoke(fromVM as PPCViewModel, v.DataContext as PPCViewModel);
+ NotifyAwaitingVMResults(fromVM as PPCViewModel, v.DataContext as PPCViewModel);
+ }
+ });
+
+ NotifyOnBeforeNavigated(fromVM, v.DataContext);
+
+ if (v != null)
+ {
+ CurrentVM = v.DataContext as PPCViewModel;
+
+ if (view != path.Last())
+ {
+ moduleNavigation = v.FindChildOffline<NavigationControl>();
+ }
+ }
+ else
+ {
+ throw LogManager.Log(new ArgumentNullException("Could not navigate to " + fullPath));
+ }
+ }
+ });
+ }
+ else
+ {
+ onNavigating?.Invoke(fromVM as PPCViewModel, CurrentVM as PPCViewModel);
+
+ NotifyOnBeforeNavigated(fromVM, CurrentVM);
+
+ await Task.Delay(navigationControl.TransitionDuration.TimeSpan);
+
+ NotifyOnNavigated(fromVM, CurrentVM);
+
+ onNavigated?.Invoke(fromVM as PPCViewModel, CurrentVM as PPCViewModel);
+ NotifyAwaitingVMResults(fromVM as PPCViewModel, CurrentVM as PPCViewModel);
+ }
+ }
+ else
+ {
+ NotifyOnBeforeNavigated(fromVM, CurrentVM);
+
+ onNavigating?.Invoke(fromVM as PPCViewModel, CurrentVM as PPCViewModel);
+
+ await Task.Delay(navigationControl.TransitionDuration.TimeSpan);
+
+ NotifyOnNavigated(fromVM, CurrentVM);
+
+ onNavigated?.Invoke(fromVM as PPCViewModel, CurrentVM as PPCViewModel);
+ NotifyAwaitingVMResults(fromVM as PPCViewModel, CurrentVM as PPCViewModel);
+ }
+
+ return true;
+ }
+ catch (Exception ex)
+ {
+ IsNavigating = false;
+ LogManager.Log(ex, $"Error navigating to '{fullPath}'.");
+ await _notificationProvider.ShowError($"Error navigating to '{fullPath}'.");
+ return false;
+ }
+ }
+
+ /// <summary>
+ /// Navigates for result.
+ /// </summary>
+ /// <typeparam name="TModule">The type of the module.</typeparam>
+ /// <typeparam name="TView">The type of the view.</typeparam>
+ /// <typeparam name="TResult">The type of the result.</typeparam>
+ /// <typeparam name="TObject">The type of the object.</typeparam>
+ /// <param name="obj">The object.</param>
+ /// <param name="pushToHistory">if set to <c>true</c> [push to history].</param>
+ /// <returns></returns>
+ public async Task<TResult> NavigateForResult<TModule, TView, TResult, TObject>(TObject obj, bool pushToHistory = true)
+ where TModule : IPPCModule
+ {
+ TaskCompletionSource<TResult> source = new TaskCompletionSource<TResult>();
+
+ var fromVM = CurrentVM;
+
+ await NavigateTo(typeof(TModule).Name + "." + typeof(TView).Name, pushToHistory, (from, to) =>
+ {
+ _awaitingVMResults.Add(new AwaitingVMResult()
+ {
+ FromVM = fromVM as PPCViewModel,
+ ToVM = to as PPCViewModel,
+ Action = () =>
+ {
+ if (to is INavigationResultProvider<TResult, TObject>)
+ {
+ source.SetResult((to as INavigationResultProvider<TResult, TObject>).GetNavigationResult());
+ }
+ }
+ });
+
+ if (to is INavigationResultProvider<TResult, TObject>)
+ {
+ (to as INavigationResultProvider<TResult, TObject>).OnNavigationObjectReceived(obj);
+ }
+ });
+
+ return await source.Task;
+ }
+
+ /// <summary>
+ /// Navigates to the specified module and view with the specified object.
+ /// </summary>
+ /// <typeparam name="TModule">The type of the module.</typeparam>
+ /// <typeparam name="TView">The type of the view.</typeparam>
+ /// <typeparam name="TPass">The type of the pass.</typeparam>
+ /// <param name="obj">The object.</param>
+ /// <param name="pushToHistory">if set to <c>true</c> [push to history].</param>
+ /// <returns></returns>
+ public Task<bool> NavigateWithObject<TModule, TView, TPass>(TPass obj, bool pushToHistory = true) where TModule : IPPCModule
+ {
+ return NavigateTo(typeof(TModule).Name + "." + typeof(TView).Name, pushToHistory, (fromVM, toVM) =>
+ {
+ if (toVM is INavigationObjectReceiver<TPass>)
+ {
+ (toVM as INavigationObjectReceiver<TPass>).OnNavigatedToWithObject(obj);
+ }
+ });
+ }
+
+ private Task<bool> NavigateTo(Type moduleType, bool pushToHistory = true, params String[] viewPath)
+ {
+ if (viewPath != null && viewPath.Length > 0)
+ {
+ return NavigateTo(moduleType.Name + "." + String.Join(".", viewPath), pushToHistory);
+ }
+ else
+ {
+ return NavigateTo(moduleType.Name, pushToHistory);
+ }
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether the navigation system is able to navigate to the previous view.
+ /// </summary>
+ public bool CanNavigateBack
+ {
+ get { return _navigationHistory.Count > 0; }
+ }
+
+ private bool _isBackEnabled;
+ /// <summary>
+ /// Gets a value indicating whether the back should be enabled.
+ /// </summary>
+ public bool IsBackEnabled
+ {
+ get { return _isBackEnabled; }
+ set { _isBackEnabled = value; RaisePropertyChangedAuto(); }
+ }
+
+ private bool _isNavigating;
+ /// <summary>
+ /// Gets or sets a value indicating whether the navigation system is currently navigating.
+ /// </summary>
+ public bool IsNavigating
+ {
+ get { return _isNavigating; }
+ set
+ {
+ _isNavigating = value;
+ RaisePropertyChangedAuto();
+ }
+ }
+
+ /// <summary>
+ /// Navigates to the previous view if <see cref="P:Tango.PPC.Common.Navigation.INavigationManager.CanNavigateBack" /> is true.
+ /// </summary>
+ public async Task<bool> NavigateBack()
+ {
+ LogManager.Log("Navigating back...");
+
+ _navigating_back = true;
+
+ if (_navigationHistory.Count > 0)
+ {
+ String first = _navigationHistory.Pop();
+ _preventHistory = true;
+
+ if (await NavigateTo(first))
+ {
+ RaisePropertyChanged(nameof(CanNavigateBack));
+ _preventHistory = false;
+ _navigating_back = false;
+ return true;
+ }
+ else
+ {
+ _navigationHistory.Push(first);
+ _preventHistory = false;
+ _navigating_back = false;
+ RaisePropertyChanged(nameof(CanNavigateBack));
+ return false;
+ }
+ }
+ else
+ {
+ await NavigateTo(NavigationView.HomeModule);
+ RaisePropertyChanged(nameof(CanNavigateBack));
+ _preventHistory = false;
+ _navigating_back = false;
+ return true;
+ }
+ }
+
+ /// <summary>
+ /// Clears the navigation back history.
+ /// </summary>
+ public void ClearHistory()
+ {
+ LogManager.Log("Navigation history cleared.");
+ _navigationHistory.Clear();
+ RaisePropertyChanged(nameof(CanNavigateBack));
+ }
+
+ /// <summary>
+ /// Clears the navigation back history except the specified view type.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ public void ClearHistoryExcept<T>()
+ {
+ LogManager.Log($"Navigation history cleared except for {typeof(T).Name}.");
+
+ var history_list = _navigationHistory.ToList();
+ history_list = history_list.Where(x => x.Contains(typeof(T).Name)).Distinct().ToList();
+ _navigationHistory.Clear();
+
+ foreach (var item in history_list)
+ {
+ _navigationHistory.Push(item);
+ }
+
+ RaisePropertyChanged(nameof(CanNavigateBack));
+ }
+
+ private void NotifyOnBeforeNavigated(object fromVM, object toVM)
+ {
+ if (fromVM == toVM) return;
+
+ if (fromVM is PPCViewModel)
+ {
+ (fromVM as PPCViewModel)?.OnBeforeNavigatedFrom();
+ }
+
+ if (toVM is PPCViewModel)
+ {
+ (toVM as PPCViewModel)?.OnBeforeNavigatedTo();
+ }
+ }
+
+ private void NotifyOnNavigated(object fromVM, object toVM)
+ {
+ IsNavigating = false;
+
+ if (fromVM == toVM) return;
+
+ if (fromVM is PPCViewModel)
+ {
+ (fromVM as PPCViewModel)?.OnNavigatedFrom();
+ }
+
+ if (toVM is PPCViewModel)
+ {
+ (toVM as PPCViewModel)?.OnNavigatedTo();
+ (toVM as PPCViewModel)?.OnNavigatedTo(fromVM as PPCViewModel);
+ }
+ }
+
+ private void NotifyAwaitingVMResults(PPCViewModel fromVM, PPCViewModel toVM)
+ {
+ var awaiter = _awaitingVMResults.SingleOrDefault(x => x.FromVM == toVM && x.ToVM == fromVM);
+ if (awaiter != null)
+ {
+ _awaitingVMResults.Remove(awaiter);
+ awaiter.Action();
+ }
+ }
+
+ private NavigationControl GetLayoutNavigationControl()
+ {
+ return TangoIOC.Default.GetInstance<ILayoutView>().GetNavigationControl();
+ }
+
+ private NavigationControl GetMainNavigationControl()
+ {
+ return TangoIOC.Default.GetInstance<IMainView>().GetNavigationControl();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs
index 1a7c11764..642a5b02f 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs
@@ -8,4 +8,4 @@ using System.Windows;
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Tango PPC Application")]
-[assembly: AssemblyVersion("2.0.1.0")]
+[assembly: AssemblyVersion("2.0.2.0")]
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj
index b3dffea5d..ce7b9746b 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj
@@ -130,6 +130,9 @@
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="WindowsFormsIntegration" />
+ <Reference Include="WPFMediaKit, Version=2.2.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <HintPath>..\..\packages\WPFMediaKit.2.2.0\lib\WPFMediaKit.dll</HintPath>
+ </Reference>
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
@@ -232,6 +235,7 @@
<Compile Include="Models\MachineOverviewItem.cs" />
<Compile Include="Models\MachineOverviewModel.cs" />
<Compile Include="Modules\DefaultPPCModuleLoader.cs" />
+ <Compile Include="Navigation\EurekaNavigationManager.cs" />
<Compile Include="Navigation\DefaultNavigationManager.cs" />
<Compile Include="Notifications\DefaultNotificationProvider.cs" />
<Compile Include="Notifications\DialogAndView.cs" />
@@ -609,6 +613,7 @@
<Resource Include="Images\Overview Icons\Waste.png" />
<Resource Include="Images\Overview Icons\Feeder4.png" />
<Resource Include="Manifests\eureka_debug.xml" />
+ <Content Include="Intro.wmv" />
<Content Include="Manifests\release.xml" />
<Content Include="Manifests\debug.xml" />
<None Include="firmware_package.tfp">
@@ -617,7 +622,9 @@
<None Include="GetVersionTag.bat">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
- <None Include="packages.config" />
+ <None Include="packages.config">
+ <SubType>Designer</SubType>
+ </None>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
@@ -854,6 +861,7 @@
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\System.Data.SQLite.Core.1.0.108.0\build\net46\System.Data.SQLite.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\System.Data.SQLite.Core.1.0.108.0\build\net46\System.Data.SQLite.Core.targets'))" />
+ <Error Condition="!Exists('..\..\packages\WPFMediaKit.2.2.0\build\WPFMediaKit.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WPFMediaKit.2.2.0\build\WPFMediaKit.targets'))" />
</Target>
<PropertyGroup>
<PostBuildEvent>RD /S /Q "$(TargetDir)cs\"
@@ -931,7 +939,10 @@ if $(ConfigurationName) == Eureka del WebRtc.NET.pdb
if $(ConfigurationName) == Debug copy /Y "$(TargetDir)Packages" "$(TargetDir)"
-if $(ConfigurationName) == Debug "rc.exe" "$(TargetPath)" --set-version-string "Comments" "Debug Tag"</PostBuildEvent>
+if $(ConfigurationName) == Debug "rc.exe" "$(TargetPath)" --set-version-string "Comments" "Debug Tag"
+
+if $(ConfigurationName) == Eureka_Debug copy /Y "$(ProjectDir)Intro.wmv" "$(TargetDir)"
+if $(ConfigurationName) == Eureka copy /Y "$(ProjectDir)Intro.wmv" "$(TargetDir)"</PostBuildEvent>
</PropertyGroup>
<PropertyGroup>
<PreBuildEvent>copy /Y "$(ProjectDir)Manifests\$(ConfigurationName).xml" "$(ProjectDir)app.manifest"
@@ -942,4 +953,5 @@ if $(ConfigurationName) == Debug "rc.exe" "$(TargetPath)" --set-version-string "
<UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" />
</VisualStudio>
</ProjectExtensions>
+ <Import Project="..\..\packages\WPFMediaKit.2.2.0\build\WPFMediaKit.targets" Condition="Exists('..\..\packages\WPFMediaKit.2.2.0\build\WPFMediaKit.targets')" />
</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs
index c7dd0b67c..251eeb1ec 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs
@@ -128,7 +128,14 @@ namespace Tango.PPC.UI
TangoIOC.Default.Register<INotificationProvider, DefaultNotificationProvider>();
TangoIOC.Default.Register<IAuthenticationProvider, DefaultAuthenticationProvider>();
TangoIOC.Default.Register<IPPCModuleLoader, DefaultPPCModuleLoader>();
- TangoIOC.Default.Register<INavigationManager, DefaultNavigationManager>();
+ if (buildProvider.IsEureka)
+ {
+ TangoIOC.Default.Register<INavigationManager, EurekaNavigationManager>();
+ }
+ else
+ {
+ TangoIOC.Default.Register<INavigationManager, DefaultNavigationManager>();
+ }
TangoIOC.Default.Register<IMachineProvider, DefaultMachineProvider>();
TangoIOC.Default.Register<IEventLogger, DefaultEventLogger>();
TangoIOC.Default.Register<IMachineDataSynchronizer, DefaultMachineDataSynchronizer>();
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs
index ec316989f..07b58e55f 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs
@@ -13,6 +13,7 @@ using Tango.PPC.Common.Authentication;
using Tango.BL.Entities;
using Tango.BL.Enumerations;
using Tango.Logging;
+using Tango.PPC.UI.Views;
namespace Tango.PPC.UI.ViewModels
{
@@ -95,6 +96,14 @@ namespace Tango.PPC.UI.ViewModels
if (!AuthenticationProvider.AuthenticationRequired)
{
LogManager.Log("Application is ready! Navigating to home module...");
+
+ if (BuildProvider.IsEureka)
+ {
+ var secondsPassed = (DateTime.Now - LoadingView.VideoStartTime).TotalSeconds;
+ var secondsToHold = Math.Max(10 - secondsPassed, 0);
+ await Task.Delay(TimeSpan.FromSeconds(secondsToHold));
+ }
+
await NavigationManager.NavigateTo(NavigationView.HomeModule);
IsLoading = false;
}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml
index 146d4b50d..3ed91e5db 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml
@@ -9,47 +9,16 @@
xmlns:global="clr-namespace:Tango.PPC.UI"
xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch"
xmlns:local="clr-namespace:Tango.PPC.UI.Views"
+ xmlns:mediaKit="clr-namespace:WPFMediaKit.DirectShow.Controls;assembly=WPFMediaKit"
mc:Ignorable="d"
d:DesignHeight="1280" d:DesignWidth="800" Background="{StaticResource TangoPrimaryBackgroundBrush}" d:DataContext="{d:DesignInstance Type=vm:LoadingViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.LoadingView}">
<Grid>
- <StackPanel HorizontalAlignment="Center">
- <!--<Image gif:ImageBehavior.EnableAnimation="{Binding IsLoading}" gif:ImageBehavior.AnimatedSource="/Images/Twine_Loading_GIF.gif" Margin="100 100 100 0" RenderTransformOrigin="0.5,0.5" RenderOptions.BitmapScalingMode="Fant" Height="382">
- <Image.Style>
- <Style TargetType="Image">
- <Setter Property="RenderTransform">
- <Setter.Value>
- <ScaleTransform ScaleX="1" ScaleY="1" />
- </Setter.Value>
- </Setter>
- <Setter Property="Effect">
- <Setter.Value>
- <fx:DisplaySettingEffect SaturationLevel="0" />
- </Setter.Value>
- </Setter>
- <Style.Triggers>
- <DataTrigger Binding="{Binding IsLoading}" Value="True">
- <DataTrigger.EnterActions>
- <BeginStoryboard>
- <Storyboard>
- <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleY" Duration="00:00:1" To="1.010" AutoReverse="True" RepeatBehavior="10x" />
- <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleX" Duration="00:00:1" To="1.010" AutoReverse="True" RepeatBehavior="10x" />
- <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Effect.SaturationLevel" Duration="00:00:3" AutoReverse="True" RepeatBehavior="3x">
- <LinearDoubleKeyFrame KeyTime="00:00:00" Value="0" />
- <LinearDoubleKeyFrame KeyTime="00:00:2" Value="1" />
- <LinearDoubleKeyFrame KeyTime="00:00:3" Value="6" />
- </DoubleAnimationUsingKeyFrames>
- </Storyboard>
- </BeginStoryboard>
- </DataTrigger.EnterActions>
- </DataTrigger>
- </Style.Triggers>
- </Style>
- </Image.Style>
- </Image>-->
-
+ <Grid x:Name="videoPlayerGrid" Visibility="{Binding BuildProvider.BuildType,Converter={StaticResource BuildTypeToVisibilityConverter},ConverterParameter='Eureka'}">
+ <mediaKit:MediaUriElement x:Name="videoPlayer" Stretch="Uniform" LoadedBehavior="Manual" />
+ </Grid>
+ <StackPanel HorizontalAlignment="Center" Visibility="{Binding BuildProvider.BuildType,Converter={StaticResource BuildTypeToVisibilityConverter},ConverterParameter='TS1800'}">
+
<Grid Margin="0 0 0 0">
- <!--<Image Source="/Images/machine.png" Stretch="Uniform" Width="250" RenderOptions.BitmapScalingMode="Fant"></Image>
- <touch:TouchBusyIndicator Width="350" Height="350" IsIndeterminate="{Binding IsLoading}" />-->
<touch:TouchGifAnimation Source="/Images/loading_anim2.gif" EnableAnimation="{Binding IsLoading}" Margin="0 200 0 0" />
</Grid>
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml.cs
index a1214a0df..4616ea438 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml.cs
@@ -12,6 +12,9 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
+using Tango.Core.DI;
+using Tango.PPC.Common.Application;
+using Tango.PPC.Common.Build;
namespace Tango.PPC.UI.Views
{
@@ -20,9 +23,22 @@ namespace Tango.PPC.UI.Views
/// </summary>
public partial class LoadingView : UserControl
{
+ public static DateTime VideoStartTime { get; set; }
+
public LoadingView()
{
InitializeComponent();
+
+ var buildProvider = TangoIOC.Default.GetInstance<IBuildProvider>();
+ var appManager = TangoIOC.Default.GetInstance<IPPCApplicationManager>();
+
+ if (buildProvider.IsEureka)
+ {
+ VideoStartTime = DateTime.Now;
+ videoPlayer.Source = new Uri(appManager.StartPath + "\\Intro.wmv", UriKind.Absolute);
+ videoPlayer.MediaOpened += (_, __) => VideoStartTime = DateTime.Now;
+ videoPlayer.Play();
+ }
}
}
}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest
index efc5f8179..d72e75011 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest
@@ -16,7 +16,7 @@
Remove this element if your application requires this virtualization for backwards
compatibility.
-->
- <!--<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />-->
+ <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/packages.config b/Software/Visual_Studio/PPC/Tango.PPC.UI/packages.config
index ec7ec1e3a..9e3e48198 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/packages.config
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/packages.config
@@ -11,4 +11,5 @@
<package id="System.Data.SQLite.Core" version="1.0.108.0" targetFramework="net46" />
<package id="System.Data.SQLite.EF6" version="1.0.108.0" targetFramework="net46" />
<package id="System.Data.SQLite.Linq" version="1.0.108.0" targetFramework="net46" />
+ <package id="WPFMediaKit" version="2.2.0" targetFramework="net461" />
</packages> \ No newline at end of file