diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2020-01-19 10:18:40 +0200 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2020-01-19 10:18:40 +0200 |
| commit | 1cb784093175d3d1aa73a8361156e9a5eaaf487c (patch) | |
| tree | bfc038bcdc44ba5448bd6a102686bc32a42990d3 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectionLostViewVM.cs | |
| parent | b746156be8be4c31303dad1b7fa8e7f18022c539 (diff) | |
| parent | b9c104e259ca24d2ae7ca82387209779fefddd34 (diff) | |
| download | Tango-1cb784093175d3d1aa73a8361156e9a5eaaf487c.tar.gz Tango-1cb784093175d3d1aa73a8361156e9a5eaaf487c.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
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.cs | 64 |
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(); + } } } |
