using EC.Entity.Video; using EC.UsingEventAggregator; using Prism.Events; using Prism.Regions; using System.Windows.Controls; using System.Windows.Input; namespace ECMonitor.Page.CameraMonitor { /// /// UCMainLeft.xaml 的交互逻辑 /// public partial class CameraTreeView : UserControl { public IRegionManager _regionManager { get; set; } public IEventAggregator _ea { get; set; } public CameraTreeView(IRegionManager regionManager, IEventAggregator ea) { _regionManager = regionManager; _ea = ea; InitializeComponent(); } /// /// TreesView's SelectedItem is read-only. Hence we can't bind it. There is a way to obtain a selected item. /// /// /// private void TreeView_MouseDoubleClick(object sender, MouseButtonEventArgs mouseButtonEventArgs) { var node = (TreeView)sender; var item = node.SelectedItem; var type = item?.GetType(); if (type == null) return; if (type == typeof(MsVideoRecorder)) { var recoder = (MsVideoRecorder)item; } else if (type == typeof(MonitorCamera)) { var camera = (MonitorCamera)item; _ea.GetEvent().Publish(camera.Ip); } } } }