using EC.Entity.PublicModel; using ECMonitor.Code; using ECMonitor.Code.Models; using ECMonitor.UC; using ECMonitor.UC.Videos; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; 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 ECMonitor.Views { /// /// RtspMonitor.xaml 的交互逻辑 /// public partial class RtspMonitor : UserControl { double _videoWidth = 600; double _videoHeight = 450; ShowVideoManager ShowVideo_Manager = new ShowVideoManager(); public RtspMonitor() { InitializeComponent(); } private void btnStart_Click(object sender, RoutedEventArgs e) { CreateVideo("192.168.1.108"); CreateVideo("192.168.1.65"); } private void CreateVideo(string cameraIp) { VideoShowModel videoShowModel =ShowVideo_Manager.GetVideoShowModel(cameraIp); if(videoShowModel != null) { videoShowModel.UPDateTime(); return; } videoShowModel = ShowVideo_Manager.CreateVideoShowModel(cameraIp); if (videoShowModel == null) { ShowLog("相机Ip:" +cameraIp +"不存在",true); return; } UCRtspVlcVideo rtspVideo = new UCRtspVlcVideo(_videoWidth, _videoHeight,1); rtspVideo.Name = videoShowModel.UCName; rtspVideo.Width = 600; rtspVideo.Height = 450; this.panMain.Children.Add(rtspVideo); rtspVideo.Play(videoShowModel.Camera); this.panMain.RegisterName( rtspVideo.Name, rtspVideo); } private void btnStop_Click(object sender, RoutedEventArgs e) { var videoShow = ShowVideo_Manager.GetVideoShowModel("192.168.1.108"); if (videoShow != null) { UCRtspVlcVideo rtspVideo = (UCRtspVlcVideo)this.panMain.FindName(videoShow.UCName); if (rtspVideo != null) { rtspVideo.Stop(); this.panMain.Children.Remove(rtspVideo); ShowVideo_Manager.Remove(videoShow); } } } public void ShowLog(string msg,bool isErr) { MessageBox.Show(msg); } } }