You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.3 KiB
55 lines
1.3 KiB
using JiLinApp.Biz.TransmitAlarm;
|
|
using JiLinApp.Core;
|
|
using JiLinApp.Docking.FenceAlarm;
|
|
using JiLinApp.Docking.VibrateAlarm;
|
|
using JiLinApp.Mvvm;
|
|
using JiLinApp.Pages.Main;
|
|
using Prism.Events;
|
|
using Prism.Regions;
|
|
|
|
namespace JiLinApp.Pages.PtzManage;
|
|
|
|
public class MainViewModel : ViewModelBase
|
|
{
|
|
#region Fields
|
|
|
|
private Main View { get; set; }
|
|
|
|
private AppConfig AppConfig { get; }
|
|
|
|
private IAlarmService AlarmService { get; }
|
|
|
|
#endregion Fields
|
|
|
|
public MainViewModel(IRegionManager region, IEventAggregator ea) : base(region, ea)
|
|
{
|
|
// Bind global fields
|
|
AppConfig = Global.AppConfig;
|
|
AlarmService = Global.AlarmService;
|
|
|
|
// Bind invoke event
|
|
ea.GetEvent<ShakeTcpAlarmSendEvent>().Subscribe(ShakeTcpAlarmReact);
|
|
ea.GetEvent<FenceUdpAlarmSendEvent>().Subscribe(FenceUdpAlarmReact);
|
|
}
|
|
|
|
public override void SetView(object view)
|
|
{
|
|
View = (Main)view;
|
|
}
|
|
|
|
#region InvokeEvent
|
|
|
|
internal void ShakeTcpAlarmReact(TcpAlarmHostMessage msg)
|
|
{
|
|
AlarmService.SendAlarmMessage(msg.ToAlarmMessage());
|
|
View.GotoPreset();
|
|
}
|
|
|
|
internal void FenceUdpAlarmReact(UdpAlarmHostMessage msg)
|
|
{
|
|
AlarmService.SendAlarmMessage(msg.ToAlarmMessage());
|
|
View.GotoPreset();
|
|
}
|
|
|
|
#endregion InvokeEvent
|
|
}
|