aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-08-12 19:00:36 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-08-12 19:00:36 +0300
commit18fc4053deb06af6643f28a6bb4fd66c6a9a93e0 (patch)
treedb2e3b344e30a95a3a09d662930ce129246a57d9 /Software/Visual_Studio/PPC/Tango.PPC.UI
parentbbbc155a96729050b9aa7d966055726df46696af (diff)
downloadTango-18fc4053deb06af6643f28a6bb4fd66c6a9a93e0.tar.gz
Tango-18fc4053deb06af6643f28a6bb4fd66c6a9a93e0.zip
Implemented temporary DB user login for machine service machine setup.
Implemented Tango updater! Implemented support for software update on machine setup.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml.cs10
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs2
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs41
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs33
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs33
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml2
6 files changed, 45 insertions, 76 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml.cs
index f33ca1c42..4187967dc 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Configuration;
using System.Data;
+using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
@@ -20,6 +21,7 @@ namespace Tango.PPC.UI
/// </summary>
public partial class App : Application
{
+ public static String[] StartupArgs { get; private set; }
private LogManager LogManager = LogManager.Default;
/// <summary>
@@ -28,6 +30,14 @@ namespace Tango.PPC.UI
/// <param name="e">A <see cref="T:System.Windows.StartupEventArgs" /> that contains the event data.</param>
protected override void OnStartup(StartupEventArgs e)
{
+ //If no debugger is attached and the argument --debug was passed launch the debugger
+ if (e.Args.Contains("-debug") && !Debugger.IsAttached)
+ {
+ Debugger.Launch();
+ }
+
+ StartupArgs = e.Args;
+
LogManager.RegisterLogger(new VSOutputLogger());
LogManager.RegisterLogger(new FileLogger());
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs
index 181c05145..ca26b7761 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs
@@ -37,7 +37,7 @@ namespace Tango.PPC.UI
WindowStyle = WindowStyle.None;
ResizeMode = ResizeMode.NoResize;
WindowStartupLocation = WindowStartupLocation.Manual;
- Topmost = false; // sure?
+ Topmost = true; // sure?
var screens = System.Windows.Forms.Screen.AllScreens;
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs
index e75a0616c..f2fba05fe 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs
@@ -53,11 +53,11 @@ namespace Tango.PPC.UI.PPCApplication
/// Gets the application version.
/// </summary>
/// <exception cref="NotImplementedException"></exception>
- public string Version
+ public Version Version
{
get
{
- throw new NotImplementedException();
+ return AssemblyHelper.GetCurrentAssemblyVersion();
}
}
@@ -102,32 +102,26 @@ namespace Tango.PPC.UI.PPCApplication
settings.Save();
}
- if (settings.HasSetup)
+ if (App.StartupArgs.Contains("-update_ok"))
+ {
+ settings.ApplicationState = ApplicationStates.Default;
+ settings.Save();
+ }
+
+ if (settings.ApplicationState == ApplicationStates.Default)
{
ObservablesEntitiesAdapter.Instance.Initialize();
}
});
- if (settings.HasSetup)
+ if (settings.ApplicationState == ApplicationStates.PreSetup || settings.ApplicationState == ApplicationStates.SemiSetup)
{
- PostSetup();
+ SetupRequired?.Invoke(this, new EventArgs());
}
else
{
- SetupRequiredEventArgs args = new SetupRequiredEventArgs(() =>
- {
- Task.Factory.StartNew(() =>
- {
- ObservablesEntitiesAdapter.Instance.Initialize();
-
- InvokeUI(() =>
- {
- PostSetup();
- });
- });
- });
- SetupRequired?.Invoke(this, args);
+ PostSetup();
}
};
}
@@ -198,7 +192,16 @@ namespace Tango.PPC.UI.PPCApplication
}
public event EventHandler Ready;
- public event EventHandler<SetupRequiredEventArgs> SetupRequired;
+ public event EventHandler SetupRequired;
public event EventHandler ContentRendered;
+
+ public String BuildDate
+ {
+ get
+ {
+ return AssemblyHelper.GetCurrentAssemblyBuildDate().ToShortDateString();
+ }
+ }
+
}
}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs
index 2a76ba80f..77767d588 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs
@@ -26,12 +26,8 @@ namespace Tango.PPC.UI.ViewModels
/// Represents the PPC loading splash screen view model.
/// </summary>
/// <seealso cref="Tango.PPC.Common.PPCViewModel" />
- public class LoadingViewVM : PPCViewModel, INavigationObjectReceiver<MachineSetupResult>
+ public class LoadingViewVM : PPCViewModel
{
- private bool _setup;
- private SetupRequiredEventArgs _setupArgs;
- private bool _post_setup;
-
/// <summary>
/// Gets or sets the module loader.
/// </summary>
@@ -55,42 +51,17 @@ namespace Tango.PPC.UI.ViewModels
{
if (!DesignMode)
{
- applicationManager.SetupRequired += ApplicationManager_SetupRequired;
Task.Delay(1000).ContinueWith((x) => { IsLoading = true; });
}
}
- private void ApplicationManager_SetupRequired(object sender, SetupRequiredEventArgs e)
- {
- _setupArgs = e;
- _setup = true;
- NavigationManager.NavigateTo(NavigationView.MachineSetupView);
- }
-
/// <summary>
/// Called when the application has been started.
/// </summary>
public override void OnApplicationStarted()
{
IsLoading = false;
-
- if (!_setup || _post_setup)
- {
- NavigationManager.NavigateTo(NavigationView.LoginView);
- }
- }
-
- public async void OnNavigatedToWithObject(MachineSetupResult machineSetupResult)
- {
- if (machineSetupResult.Completed)
- {
- _post_setup = true;
- _setup = false;
- IsLoading = true;
-
- await Task.Delay(500);
- _setupArgs.Continue();
- }
+ NavigationManager.NavigateTo(NavigationView.LoginView);
}
}
}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs
index 7b4016341..2877d52b3 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs
@@ -1,11 +1,13 @@
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
+using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Core;
using Tango.Core.Commands;
+using Tango.Core.Helpers;
using Tango.PPC.Common;
using Tango.PPC.Common.Application;
using Tango.PPC.Common.MachineSetup;
@@ -27,9 +29,7 @@ namespace Tango.PPC.UI.ViewModels
Failed,
}
- private bool _postSetp;
-
- private SetupRequiredEventArgs _setupRequiredEventArgs;
+ private MachineSetupResult _setup_result;
public IMachineSetupManager MachineSetupManager { get; set; }
@@ -80,24 +80,9 @@ namespace Tango.PPC.UI.ViewModels
applicationManager.SetupRequired += ApplicationManager_SetupRequired;
}
- private void ApplicationManager_SetupRequired(object sender, SetupRequiredEventArgs e)
- {
- _setupRequiredEventArgs = e;
- }
-
- public override void OnApplicationStarted()
- {
- base.OnApplicationStarted();
-
- if (_postSetp)
- {
- NavigationManager.NavigateTo(Common.Navigation.NavigationView.LoginView);
- }
- }
-
- public override void OnNavigatedTo()
+ private void ApplicationManager_SetupRequired(object sender, EventArgs e)
{
- base.OnNavigatedTo();
+ NavigationManager.NavigateTo(NavigationView.MachineSetupView);
}
private void AppendLog(String msg)
@@ -117,9 +102,8 @@ namespace Tango.PPC.UI.ViewModels
try
{
- await MachineSetupManager.Setup(SerialNumber, HostAddress);
- Settings.HasSetup = true;
- _postSetp = true;
+ _setup_result = await MachineSetupManager.Setup(SerialNumber, HostAddress);
+ Settings.ApplicationState = ApplicationStates.SemiSetup;
Settings.Save();
State = MachineSetupStates.Completed;
}
@@ -132,7 +116,8 @@ namespace Tango.PPC.UI.ViewModels
private void CompleteSetup()
{
- NavigationManager.NavigateWithObject(NavigationView.LoadingView, new MachineSetupResult() { Completed = true });
+ Process.Start(AssemblyHelper.GetCurrentAssemblyFolder() + "\\Tango.PPC.Updater.exe", _setup_result.UpdatePackagePath);
+ Environment.Exit(0);
}
}
}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml
index e300d95aa..9ff98ce52 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml
@@ -37,7 +37,7 @@
<TextBlock>SERIAL NUMBER</TextBlock>
<touch:TouchTextBox Foreground="{StaticResource TangoGrayTextBrush}" Margin="0 10 0 0" Text="{Binding SerialNumber}" KeyboardContainer="{Binding ElementName=Container}" />
- <TextBlock Margin="0 40 0 0">HOST ADDRESS</TextBlock>
+ <TextBlock Margin="0 40 0 0">MACHINE SERVICE ADDRESS</TextBlock>
<touch:TouchTextBox Foreground="{StaticResource TangoGrayTextBrush}" Margin="0 10 0 0" Text="{Binding HostAddress}" KeyboardContainer="{Binding ElementName=Container}" />
<touch:TouchButton Margin="0 200 0 0" Padding="20" Width="300" CornerRadius="35" Command="{Binding StartCommand}">INSTALL</touch:TouchButton>