using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Threading; using Tango.Core.DI; using Tango.Integration.ExternalBridge; using Tango.Integration.Operation; using Tango.PPC.Common; using Tango.PPC.Common.Application; using Tango.PPC.Common.Authentication; using Tango.PPC.Common.ExternalBridge; using Tango.PPC.Common.Modules; using Tango.PPC.Common.Navigation; using Tango.PPC.Common.Notifications; using Tango.PPC.Common.WatchDog; using Tango.PPC.UI.Dialogs; using Tango.SharedUI; namespace Tango.PPC.UI.ViewModels { /// /// Represents the PPC main view model. /// /// public class MainViewVM : PPCViewModel { private DispatcherTimer _date_timer; private DateTime _currentDateTime; /// /// Gets or sets the current date time. /// public DateTime CurrentDateTime { get { return _currentDateTime; } set { _currentDateTime = value; RaisePropertyChangedAuto(); } } public MainViewVM() { _date_timer = new DispatcherTimer(); _date_timer.Interval = TimeSpan.FromSeconds(1); _date_timer.Tick += _date_timer_Tick; _date_timer.Start(); } /// /// Called when the application has been started. /// public override void OnApplicationStarted() { } public override void OnApplicationReady() { base.OnApplicationReady(); MachineProvider.MachineOperator.CartridgeValidationRequestReceived += MachineOperator_CartridgeValidationRequestReceived; } #region Event Handlers /// /// Handles the Tick event of the _date_timer. /// /// The source of the event. /// The instance containing the event data. private void _date_timer_Tick(object sender, EventArgs e) { CurrentDateTime = DateTime.Now; } private void MachineOperator_CartridgeValidationRequestReceived(object sender, CartridgeValidationEventArgs e) { InvokeUI(async () => { var vm = await NotificationProvider.ShowDialog(new CartridgeValidationViewVM() { IDSPacks = MachineProvider.Machine.Configuration.NoneEmptyIdsPacks.ToList(), }); if (vm.DialogResult) { e.Approve(vm.SelectedIDSPack.PackIndex); } else { e.Decline(); } }); } #endregion } }