aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Properties/AssemblyInfo.cs
blob: 0736349926ccee9e4ef4b5e601d385ced021bf29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;

[assembly: AssemblyTitle("Tango - Scripting IDE Library")]
[assembly: ComVisible(false)]
[assembly: AssemblyVersion("2.0.36.1608")]


[assembly:ThemeInfo(
    ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
                             //(used if a resource is not found in the page,
                             // or application resource dictionaries)
    ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
                                      //(used if a resource is not found in the page,
                                      // app, or any theme specific resource dictionaries)
)]
9 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
using System;
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();
        }
    }
}