aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/TEMP/Tango.Scripting/TestApp/App.xaml.cs
blob: f70c274287fc91e633d6cab983bc6a4dc3f655e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace TestApp
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
    }
}
color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* 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 Tango.BL.Entities;
using Tango.PPC.Common;
using Tango.Settings;
using Tango.SharedUI;

namespace Tango.PPC.UI.Dialogs
{
    public class PowerUpViewVM : DialogViewVM
    {
        private Timer _timer;

        private List<Rml> _rmls;
        public List<Rml> Rmls
        {
            get { return _rmls; }
            set { _rmls = value; RaisePropertyChangedAuto(); }
        }

        private Rml _selectedRml;
        public Rml SelectedRml
        {
            get { return _selectedRml; }
            set { _selectedRml = value; RaisePropertyChangedAuto(); }
        }

        private bool _isSelectedRml;
        public bool IsSelectedRml
        {
            get { return _isSelectedRml; }
            set
            {
                _isSelectedRml = value;
                RaisePropertyChangedAuto();

                if (_isSelectedRml)
                {
                    IsMinimalTemperature = false;
                }
            }
        }

        private bool _isMinimalTemperature;
        public bool IsMinimalTemperature
        {
            get { return _isMinimalTemperature; }
            set
            {
                _isMinimalTemperature = value;
                RaisePropertyChangedAuto();

                if (_isMinimalTemperature)
                {
                    IsSelectedRml = false;
                }
            }
        }

        private int _remainingSeconds;
        public int RemainingSeconds
        {
            get { return _remainingSeconds; }
            set { _remainingSeconds = value; RaisePropertyChangedAuto(); }
        }

        private bool _isTimeoutEnabled;
        public bool IsTimeoutEnabled
        {
            get { return _isTimeoutEnabled; }
            set
            {
                _isTimeoutEnabled = value; RaisePropertyChangedAuto();

                if (!_isTimeoutEnabled)
                {
                    _timer.Stop();
                }
            }
        }

        public PowerUpViewVM()
        {
            RemainingSeconds = (int)SettingsManager.Default.GetOrCreate<PPCSettings>().PowerUpScreenTimeout.TotalSeconds;
            CanClose = true;
            IsMinimalTemperature = true;
            IsTimeoutEnabled = true;
            _timer = new Timer();
            _timer.Interval = TimeSpan.FromSeconds(1).TotalMilliseconds;
            _timer.Elapsed += _timer_Elapsed;
        }

        private void _timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            RemainingSeconds--;

            if (RemainingSeconds == 0)
            {
                InvokeUI(() =>
                {
                    Accept();
                });
            }
        }

        protected override void Cancel()
        {
            _timer.Stop();
            base.Cancel();
        }

        protected override void Accept()
        {
            _timer.Stop();
            base.Accept();
        }

        public override void OnShow()
        {
            base.OnShow();
            _timer.Start();
        }
    }
}