aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectionLostViewVM.cs
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-01-18 17:23:37 +0200
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-01-18 17:23:37 +0200
commit6a64a71a5197897cfa6d904274399bad3fb0b2da (patch)
tree9e123f9607df8add1e19f053fa33a1681105c399 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectionLostViewVM.cs
parentc0a30606a4025c584361c920cd59b6e73a59f011 (diff)
downloadTango-6a64a71a5197897cfa6d904274399bad3fb0b2da.tar.gz
Tango-6a64a71a5197897cfa6d904274399bad3fb0b2da.zip
Implemented Machine Studio => PPC auto reconnection.
Implemented SignalR Adapter reconnection.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectionLostViewVM.cs')
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectionLostViewVM.cs64
1 files changed, 64 insertions, 0 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectionLostViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectionLostViewVM.cs
index f1f4f69c0..e96f0ab62 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectionLostViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectionLostViewVM.cs
@@ -3,12 +3,76 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using System.Timers;
+using System.Windows.Threading;
using Tango.SharedUI;
namespace Tango.MachineStudio.UI.ViewModels
{
public class ConnectionLostViewVM : DialogViewVM
{
+ private Timer _reconnectTimer;
+
public String Exception { get; set; }
+
+ private int _reconnectinSeconds;
+ public int ReconnectinSeconds
+ {
+ get { return _reconnectinSeconds; }
+ set { _reconnectinSeconds = value; RaisePropertyChangedAuto(); }
+ }
+
+ private bool _autoReconnect;
+ public bool AutoReconnect
+ {
+ get { return _autoReconnect; }
+ set { _autoReconnect = value; RaisePropertyChangedAuto(); }
+ }
+
+
+ public ConnectionLostViewVM() : base()
+ {
+ ReconnectinSeconds = 10;
+ _reconnectTimer = new Timer();
+ _reconnectTimer.Interval = TimeSpan.FromSeconds(1).TotalMilliseconds;
+ _reconnectTimer.Elapsed += _reconnectTimer_Elapsed;
+ }
+
+ private void _reconnectTimer_Elapsed(object sender, ElapsedEventArgs e)
+ {
+ ReconnectinSeconds--;
+
+ if (ReconnectinSeconds == -1)
+ {
+ _reconnectTimer.Stop();
+
+ InvokeUI(() =>
+ {
+ Accept();
+ });
+ }
+ }
+
+ public override void OnShow()
+ {
+ base.OnShow();
+
+ if (AutoReconnect)
+ {
+ _reconnectTimer.Start();
+ }
+ }
+
+ protected override void Accept()
+ {
+ _reconnectTimer.Stop();
+ base.Accept();
+ }
+
+ protected override void Cancel()
+ {
+ base.Cancel();
+ _reconnectTimer.Stop();
+ }
}
}