71 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			71 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			C#
		
	
	
	
| 
								 | 
							
								using DM_Weight.msg;
							 | 
						|||
| 
								 | 
							
								using DM_Weight.Port;
							 | 
						|||
| 
								 | 
							
								using log4net.Repository.Hierarchy;
							 | 
						|||
| 
								 | 
							
								using Prism.Events;
							 | 
						|||
| 
								 | 
							
								using System;
							 | 
						|||
| 
								 | 
							
								using System.Collections.Generic;
							 | 
						|||
| 
								 | 
							
								using System.Configuration;
							 | 
						|||
| 
								 | 
							
								using System.Linq;
							 | 
						|||
| 
								 | 
							
								using System.Text;
							 | 
						|||
| 
								 | 
							
								using System.Threading;
							 | 
						|||
| 
								 | 
							
								using System.Threading.Tasks;
							 | 
						|||
| 
								 | 
							
								using System.Timers;
							 | 
						|||
| 
								 | 
							
								using System.Windows;
							 | 
						|||
| 
								 | 
							
								using System.Windows.Controls;
							 | 
						|||
| 
								 | 
							
								using System.Windows.Data;
							 | 
						|||
| 
								 | 
							
								using System.Windows.Documents;
							 | 
						|||
| 
								 | 
							
								using System.Windows.Input;
							 | 
						|||
| 
								 | 
							
								using System.Windows.Media;
							 | 
						|||
| 
								 | 
							
								using System.Windows.Media.Imaging;
							 | 
						|||
| 
								 | 
							
								using System.Windows.Navigation;
							 | 
						|||
| 
								 | 
							
								using System.Windows.Shapes;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								namespace DM_Weight.Views
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    /// <summary>
							 | 
						|||
| 
								 | 
							
								    /// Interaction logic for MainWindow.xaml
							 | 
						|||
| 
								 | 
							
								    /// </summary>
							 | 
						|||
| 
								 | 
							
								    public partial class HomeWindow : UserControl
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        //int autoExit = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0");
							 | 
						|||
| 
								 | 
							
								        //System.Timers.Timer idleTimer;//= new System.Timers.Timer(60000);
							 | 
						|||
| 
								 | 
							
								        //IEventAggregator _eventAggregator;
							 | 
						|||
| 
								 | 
							
								        //SocketHelper _socketHelper;
							 | 
						|||
| 
								 | 
							
								        public HomeWindow()
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            InitializeComponent();
							 | 
						|||
| 
								 | 
							
								            //if (autoExit > 0)
							 | 
						|||
| 
								 | 
							
								            //{
							 | 
						|||
| 
								 | 
							
								            //    idleTimer = new System.Timers.Timer(autoExit*1000);
							 | 
						|||
| 
								 | 
							
								            //    idleTimer.Elapsed += OnTimerElapsed;
							 | 
						|||
| 
								 | 
							
								            //    this.MouseDown += OnUserActivity;
							 | 
						|||
| 
								 | 
							
								            //    this.MouseMove += OnUserActivity;
							 | 
						|||
| 
								 | 
							
								            //    this.KeyDown += OnUserActivity;
							 | 
						|||
| 
								 | 
							
								            //    idleTimer.Start();
							 | 
						|||
| 
								 | 
							
								            //    _eventAggregator = eventAggregator;
							 | 
						|||
| 
								 | 
							
								            //}
							 | 
						|||
| 
								 | 
							
								            //_socketHelper= socketHelper;
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        //private void OnUserActivity(object sender, EventArgs e)
							 | 
						|||
| 
								 | 
							
								        //{
							 | 
						|||
| 
								 | 
							
								        //    idleTimer.Stop();
							 | 
						|||
| 
								 | 
							
								        //    idleTimer.Start();
							 | 
						|||
| 
								 | 
							
								        //}
							 | 
						|||
| 
								 | 
							
								        //private void OnTimerElapsed(object sender, ElapsedEventArgs e)
							 | 
						|||
| 
								 | 
							
								        //{
							 | 
						|||
| 
								 | 
							
								        //    // 药箱是否全部关闭
							 | 
						|||
| 
								 | 
							
								        //    //bool[] boolArrs = ModbusHelper.GetInstance().GetAllBoxState();
							 | 
						|||
| 
								 | 
							
								        //    //bool allTrue = Array.TrueForAll(boolArrs, b => b == false);
							 | 
						|||
| 
								 | 
							
								        //    ////logger.Info($"进入自动退出定时方法{allTrue}");
							 | 
						|||
| 
								 | 
							
								        //    //if (allTrue)
							 | 
						|||
| 
								 | 
							
								        //    if(!_socketHelper.OpenStatus)
							 | 
						|||
| 
								 | 
							
								        //    {
							 | 
						|||
| 
								 | 
							
								        //        idleTimer.Stop();
							 | 
						|||
| 
								 | 
							
								        //        //无人操作,自动退出
							 | 
						|||
| 
								 | 
							
								        //        _eventAggregator.GetEvent<LoginOutEvent>().Publish();
							 | 
						|||
| 
								 | 
							
								        //    }
							 | 
						|||
| 
								 | 
							
								        //}
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								}
							 |